queryPart.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <div class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchForm">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="出库仓库" prop="warehouseSn" required>
  9. <chooseWarehouse ref="warehouse" :allowClear="false" v-model="queryParam.warehouseSn" :isDefault="true" @load="loadWarehouse"></chooseWarehouse>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="productInfoList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="产品名称">
  19. <a-input id="productInfoList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="原厂编码">
  25. <a-input id="productInfoList-origCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="产品品牌">
  30. <ProductBrand id="productInfoList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="产品分类">
  35. <ProductType id="productInfoList-productType" v-model="productType" @change="changeProductType"></ProductType>
  36. </a-form-item>
  37. </a-col>
  38. </template>
  39. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  40. <a-button type="primary" @click="searchForm" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  41. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  42. <a @click="advanced=!advanced" style="margin: 0 5px">
  43. {{ advanced ? '收起' : '展开' }}
  44. <a-icon :type="advanced ? 'up' : 'down'"/>
  45. </a>
  46. <a-popover>
  47. <template slot="content">双击列表配件可快速选中添加</template>
  48. <a-icon type="question-circle" theme="twoTone" />
  49. </a-popover>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  53. </div>
  54. <!-- 列表 -->
  55. <s-table
  56. class="sTable"
  57. ref="table"
  58. size="small"
  59. :rowKey="(record) => record.id"
  60. :columns="columns"
  61. :data="loadData"
  62. :customRow="handleClickRow"
  63. :scroll="{ y: 149 }"
  64. :defaultLoadData="false"
  65. bordered>
  66. <!-- 销售数量 -->
  67. <template slot="nums" slot-scope="text, record">
  68. <div @dblclick.stop>
  69. <a-input-number
  70. size="small"
  71. v-model="record.salesNums"
  72. :precision="0"
  73. :min="1"
  74. :max="999999"
  75. style="width: 100%;"
  76. placeholder="请输入" />
  77. </div>
  78. </template>
  79. <!-- 产品名称 -->
  80. <template slot="productName" slot-scope="text, record">
  81. <div class="ellipsisCon">
  82. <a-tooltip placement="rightBottom">
  83. <template slot="title">
  84. <span>{{ text }}</span>
  85. </template>
  86. <span class="ellipsisText">{{ text }}</span>
  87. </a-tooltip>
  88. <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.isJoinActivityProduct == 1"></a-badge>
  89. </div>
  90. </template>
  91. <!-- 操作 -->
  92. <template slot="action" slot-scope="text, record">
  93. <a-button
  94. size="small"
  95. type="link"
  96. class="button-info"
  97. :loading="newLoading"
  98. @click="handleAdd(record)"
  99. :disabled="!record.productPrice || record.productPrice<=0"
  100. id="productInfoList-edit-btn">添加</a-button>
  101. </template>
  102. </s-table>
  103. </div>
  104. </template>
  105. <script>
  106. import { commonMixin } from '@/utils/mixin'
  107. import { queryStockProductPage } from '@/api/stock'
  108. import ProductType from '@/views/common/productType.js'
  109. import ProductBrand from '@/views/common/productBrand.js'
  110. import chooseWarehouse from '@/views/common/chooseWarehouse'
  111. import { STable, VSelect } from '@/components'
  112. export default {
  113. name: 'QueryPart',
  114. mixins: [commonMixin],
  115. components: { STable, VSelect, ProductBrand, ProductType, chooseWarehouse },
  116. props: {
  117. newLoading: Boolean
  118. },
  119. data () {
  120. return {
  121. advanced: false, // 高级搜索 展开/关闭
  122. showSetting: false, // 设置弹框
  123. productType: [],
  124. buyerSn: '',
  125. queryParam: { // 查询条件
  126. productCode: '', // 产品编码
  127. productName: '', // 产品名称
  128. productOrigCode: '', // 原厂编码
  129. productBrandSn: undefined, // 产品品牌
  130. productTypeSn1: '', // 产品一级分类
  131. productTypeSn2: '', // 产品二级分类
  132. productTypeSn3: '', // 产品三级分类
  133. warehouseSn: undefined
  134. },
  135. defaultWarehouseSn: undefined, // 默认仓库sn
  136. disabled: false, // 查询、重置按钮是否可操作
  137. // 加载数据方法 必须为 Promise 对象
  138. loadData: parameter => {
  139. this.disabled = true
  140. this.queryParam.dealerSn = this.buyerSn
  141. return queryStockProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: '1', pricingState: 'PRICED' })).then(res => {
  142. let data
  143. if (res.status == 200) {
  144. data = res.data
  145. data.list = data.list.filter(item => item != null)
  146. const no = (data.pageNo - 1) * data.pageSize
  147. for (var i = 0; i < data.list.length; i++) {
  148. data.list[i].no = no + i + 1
  149. data.list[i].salesNums = 1
  150. data.list[i].currentStockQty = data.list[i].currentStockQty || 0
  151. const productPackQty = (data.list[i].productPackQty || data.list[i].productPackQty == 0) ? data.list[i].productPackQty : '--'
  152. const productUnit = data.list[i].productUnit || '--'
  153. const productPackQtyUnit = data.list[i].productPackQtyUnit || '--'
  154. data.list[i].packQtyV = productPackQty + productUnit + '/' + productPackQtyUnit
  155. }
  156. this.disabled = false
  157. }
  158. return data
  159. })
  160. }
  161. }
  162. },
  163. computed: {
  164. columns () {
  165. const arr = [
  166. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '产品名称', dataIndex: 'productName', scopedSlots: { customRender: 'productName' }, width: '18%', align: 'left' },
  168. { title: '出库仓库', dataIndex: 'warehouseName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  169. { title: '原厂编码', dataIndex: 'productOrigCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  170. { title: '品牌', dataIndex: 'productBrandName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  171. { title: '库存数量', dataIndex: 'currentStockQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  172. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  173. // { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  174. { title: '包装数', dataIndex: 'packQtyV', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  175. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '8%', align: 'center' },
  176. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  177. ]
  178. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  179. arr.splice(6, 0, { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  180. }
  181. return arr
  182. }
  183. },
  184. methods: {
  185. loadWarehouse (sn) {
  186. this.defaultWarehouseSn = sn
  187. this.queryParam.warehouseSn = sn
  188. },
  189. // 双击列表
  190. handleClickRow (record) {
  191. const _this = this
  192. return {
  193. on: {
  194. dblclick: (event) => {
  195. if (!record.productPrice || record.productPrice <= 0) {
  196. _this.$message.info('该产品暂时不能添加')
  197. } else {
  198. event.stopPropagation()
  199. _this.$emit('add', record, 0)
  200. }
  201. }
  202. }
  203. }
  204. },
  205. // 查询
  206. searchForm () {
  207. if (this.queryParam.warehouseSn) {
  208. this.$refs.table.refresh(true)
  209. } else {
  210. this.$message.info('请选择仓库')
  211. }
  212. },
  213. // 重置
  214. resetSearchForm () {
  215. this.queryParam.productCode = ''
  216. this.queryParam.productName = ''
  217. this.queryParam.productOrigCode = ''
  218. this.queryParam.productBrandSn = undefined
  219. this.queryParam.productTypeSn1 = ''
  220. this.queryParam.productTypeSn2 = ''
  221. this.queryParam.productTypeSn3 = ''
  222. this.productType = []
  223. this.queryParam.warehouseSn = this.defaultWarehouseSn
  224. this.$refs.table.refresh(true)
  225. },
  226. pageInit (buyerSn, warehouseSn) {
  227. this.buyerSn = buyerSn
  228. this.resetSearchForm()
  229. },
  230. // 刷新当前页面
  231. resetCurForm () {
  232. const _this = this
  233. _this.$nextTick(() => {
  234. _this.$refs.table.refresh()
  235. })
  236. },
  237. // 选择配件
  238. handleAdd (row) {
  239. this.$emit('add', row, 0)
  240. },
  241. // 产品分类 change
  242. changeProductType (val, opt) {
  243. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  244. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  245. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="less" scoped>
  251. .productInfoList-wrap{
  252. .ellipsisCon{
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. .ellipsisText{
  257. width: 100%;
  258. overflow: hidden;
  259. text-overflow: ellipsis;
  260. display: box;
  261. display: -webkit-box;
  262. -webkit-line-clamp: 1;
  263. -webkit-box-orient: vertical;
  264. }
  265. }
  266. }
  267. </style>