queryPart.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <div class="productInfoList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品编码">
  9. <a-input id="productInfoList-code" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品名称">
  14. <a-input id="productInfoList-name" v-model.trim="queryParam.productName" 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-origCode" v-model.trim="queryParam.productOrigCode" 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. <ProductBrand id="productInfoList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="产品类别">
  30. <ProductType id="productInfoList-productType" v-model="productType" @change="changeProductType"></ProductType>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="24">
  35. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  36. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin:0 15px 0 8px">
  38. {{ advanced ? '收起' : '展开' }}
  39. <a-icon :type="advanced ? 'up' : 'down'"/>
  40. </a>
  41. <a-popover>
  42. <template slot="content">双击列表配件可快速选中添加</template>
  43. <a-icon type="question-circle" theme="twoTone" />
  44. </a-popover>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. <!-- 列表 -->
  50. <s-table
  51. class="sTable"
  52. ref="table"
  53. size="small"
  54. :rowKey="(record) => record.id"
  55. :columns="columns"
  56. :data="loadData"
  57. :customRow="handleClickRow"
  58. :scroll="{ x: 1710, y: 300 }"
  59. :defaultLoadData="false"
  60. bordered>
  61. <!-- 销售数量 -->
  62. <template slot="nums" slot-scope="text, record">
  63. <div @dblclick.stop>
  64. <a-input-number
  65. size="small"
  66. v-model="record.salesNums"
  67. :precision="0"
  68. :min="1"
  69. :max="999999"
  70. placeholder="请输入" />
  71. </div>
  72. </template>
  73. <!-- 产品名称 -->
  74. <template slot="productName" slot-scope="text, record">
  75. <span style="vertical-align: middle;">{{ text }}</span>
  76. <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.isJoinActivityProduct == 1"></a-badge>
  77. </template>
  78. <!-- 操作 -->
  79. <template slot="action" slot-scope="text, record">
  80. <a-button
  81. size="small"
  82. type="primary"
  83. class="button-info"
  84. :loading="newLoading"
  85. @click="handleAdd(record)"
  86. :disabled="!record.productPrice || record.productPrice<=0"
  87. id="productInfoList-edit-btn">添加</a-button>
  88. </template>
  89. </s-table>
  90. </div>
  91. </template>
  92. <script>
  93. import { queryStockProductPage } from '@/api/stock'
  94. import ProductType from '@/views/common/productType.js'
  95. import ProductBrand from '@/views/common/productBrand.js'
  96. import { STable, VSelect } from '@/components'
  97. export default {
  98. name: 'QueryPart',
  99. components: { STable, VSelect, ProductBrand, ProductType },
  100. props: {
  101. buyerSn: {
  102. type: [Number, String],
  103. default: ''
  104. },
  105. newLoading: Boolean
  106. },
  107. data () {
  108. return {
  109. advanced: false, // 高级搜索 展开/关闭
  110. showSetting: false, // 设置弹框
  111. productType: [],
  112. queryParam: { // 查询条件
  113. productCode: '', // 产品编码
  114. productName: '', // 产品名称
  115. productOrigCode: '', // 原厂编码
  116. productBrandSn: undefined, // 产品品牌
  117. productTypeSn1: '', // 产品一级分类
  118. productTypeSn2: '', // 产品二级分类
  119. productTypeSn3: '' // 产品三级分类
  120. },
  121. disabled: false, // 查询、重置按钮是否可操作
  122. columns: [
  123. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  124. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '产品名称', dataIndex: 'productName', scopedSlots: { customRender: 'productName' }, align: 'center' },
  126. { title: '原厂编码', dataIndex: 'productOrigCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  127. { title: '品牌', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  128. { title: '库存数量', dataIndex: 'currentStockQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  129. { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  130. { title: '售价', dataIndex: 'productPrice', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') } },
  131. { title: '包装数', dataIndex: 'packQtyV', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: 150, align: 'center' },
  133. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: 200, align: 'center', fixed: 'right' }
  134. ],
  135. // 加载数据方法 必须为 Promise 对象
  136. loadData: parameter => {
  137. this.disabled = true
  138. this.queryParam.dealerSn = this.buyerSn
  139. return queryStockProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: '1' })).then(res => {
  140. const data = res.data
  141. data.list = data.list.filter(item => item != null)
  142. const no = (data.pageNo - 1) * data.pageSize
  143. for (var i = 0; i < data.list.length; i++) {
  144. data.list[i].no = no + i + 1
  145. data.list[i].salesNums = 1
  146. data.list[i].currentStockQty = data.list[i].currentStockQty || 0
  147. const productPackQty = (data.list[i].productPackQty || data.list[i].productPackQty == 0) ? data.list[i].productPackQty : '--'
  148. const productUnit = data.list[i].productUnit || '--'
  149. const productPackQtyUnit = data.list[i].productPackQtyUnit || '--'
  150. data.list[i].packQtyV = productPackQty + productUnit + '/' + productPackQtyUnit
  151. }
  152. this.disabled = false
  153. return data
  154. })
  155. }
  156. }
  157. },
  158. methods: {
  159. // 双击列表
  160. handleClickRow (record) {
  161. const _this = this
  162. return {
  163. on: {
  164. dblclick: (event) => {
  165. if (!record.productPrice || record.productPrice <= 0) {
  166. _this.$message.info('该产品暂时不能添加')
  167. } else {
  168. event.stopPropagation()
  169. _this.$emit('add', record, 0)
  170. }
  171. }
  172. }
  173. }
  174. },
  175. // 重置
  176. resetSearchForm () {
  177. this.queryParam.productCode = ''
  178. this.queryParam.productName = ''
  179. this.queryParam.productOrigCode = ''
  180. this.queryParam.productBrandSn = undefined
  181. this.queryParam.productTypeSn1 = ''
  182. this.queryParam.productTypeSn2 = ''
  183. this.queryParam.productTypeSn3 = ''
  184. this.productType = []
  185. this.$refs.table.refresh(true)
  186. },
  187. // 刷新当前页面
  188. resetCurForm () {
  189. this.$refs.table.refresh()
  190. },
  191. // 选择配件
  192. handleAdd (row) {
  193. this.$emit('add', row, 0)
  194. },
  195. // 产品分类 change
  196. changeProductType (val, opt) {
  197. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  198. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  199. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  200. }
  201. }
  202. }
  203. </script>