queryPart.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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" style="margin-bottom: 10px;">
  35. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  36. <a-button style="margin-left: 5px" @click="resetSearchForm" id="productInfoList-reset">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin: 0 5px">
  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="{ y: 149 }"
  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. style="width: 100%;"
  71. placeholder="请输入" />
  72. </div>
  73. </template>
  74. <!-- 产品名称 -->
  75. <template slot="productName" slot-scope="text, record">
  76. <div class="ellipsisCon">
  77. <a-tooltip placement="rightBottom">
  78. <template slot="title">
  79. <span>{{ text }}</span>
  80. </template>
  81. <span class="ellipsisText">{{ text }}</span>
  82. </a-tooltip>
  83. <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.isJoinActivityProduct == 1"></a-badge>
  84. </div>
  85. </template>
  86. <!-- 操作 -->
  87. <template slot="action" slot-scope="text, record">
  88. <a-button
  89. size="small"
  90. type="link"
  91. class="button-info"
  92. :loading="newLoading"
  93. @click="handleAdd(record)"
  94. :disabled="!record.productPrice || record.productPrice<=0"
  95. id="productInfoList-edit-btn">添加</a-button>
  96. </template>
  97. </s-table>
  98. </div>
  99. </template>
  100. <script>
  101. import { queryStockProductPage } from '@/api/stock'
  102. import ProductType from '@/views/common/productType.js'
  103. import ProductBrand from '@/views/common/productBrand.js'
  104. import { STable, VSelect } from '@/components'
  105. export default {
  106. name: 'QueryPart',
  107. components: { STable, VSelect, ProductBrand, ProductType },
  108. props: {
  109. newLoading: Boolean
  110. },
  111. data () {
  112. return {
  113. advanced: false, // 高级搜索 展开/关闭
  114. showSetting: false, // 设置弹框
  115. productType: [],
  116. buyerSn: '',
  117. queryParam: { // 查询条件
  118. productCode: '', // 产品编码
  119. productName: '', // 产品名称
  120. productOrigCode: '', // 原厂编码
  121. productBrandSn: undefined, // 产品品牌
  122. productTypeSn1: '', // 产品一级分类
  123. productTypeSn2: '', // 产品二级分类
  124. productTypeSn3: '' // 产品三级分类
  125. },
  126. disabled: false, // 查询、重置按钮是否可操作
  127. // 加载数据方法 必须为 Promise 对象
  128. loadData: parameter => {
  129. this.disabled = true
  130. this.queryParam.dealerSn = this.buyerSn
  131. return queryStockProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: '1' })).then(res => {
  132. const data = res.data
  133. data.list = data.list.filter(item => item != null)
  134. const no = (data.pageNo - 1) * data.pageSize
  135. for (var i = 0; i < data.list.length; i++) {
  136. data.list[i].no = no + i + 1
  137. data.list[i].salesNums = 1
  138. data.list[i].currentStockQty = data.list[i].currentStockQty || 0
  139. const productPackQty = (data.list[i].productPackQty || data.list[i].productPackQty == 0) ? data.list[i].productPackQty : '--'
  140. const productUnit = data.list[i].productUnit || '--'
  141. const productPackQtyUnit = data.list[i].productPackQtyUnit || '--'
  142. data.list[i].packQtyV = productPackQty + productUnit + '/' + productPackQtyUnit
  143. }
  144. this.disabled = false
  145. return data
  146. })
  147. }
  148. }
  149. },
  150. computed: {
  151. columns () {
  152. const arr = [
  153. { title: '产品编码', dataIndex: 'productCode', width: '14%', align: 'center', customRender: function (text) { return text || '--' } },
  154. { title: '产品名称', dataIndex: 'productName', scopedSlots: { customRender: 'productName' }, width: '18%', align: 'left' },
  155. { title: '原厂编码', dataIndex: 'productOrigCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  156. { title: '品牌', dataIndex: 'productBrandName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  157. { title: '库存数量', dataIndex: 'currentStockQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  158. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  159. // { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  160. { title: '包装数', dataIndex: 'packQtyV', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  161. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '8%', align: 'center' },
  162. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  163. ]
  164. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  165. arr.splice(6, 0, { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  166. }
  167. return arr
  168. }
  169. },
  170. methods: {
  171. // 双击列表
  172. handleClickRow (record) {
  173. const _this = this
  174. return {
  175. on: {
  176. dblclick: (event) => {
  177. if (!record.productPrice || record.productPrice <= 0) {
  178. _this.$message.info('该产品暂时不能添加')
  179. } else {
  180. event.stopPropagation()
  181. _this.$emit('add', record, 0)
  182. }
  183. }
  184. }
  185. }
  186. },
  187. // 重置
  188. resetSearchForm () {
  189. this.queryParam.productCode = ''
  190. this.queryParam.productName = ''
  191. this.queryParam.productOrigCode = ''
  192. this.queryParam.productBrandSn = undefined
  193. this.queryParam.productTypeSn1 = ''
  194. this.queryParam.productTypeSn2 = ''
  195. this.queryParam.productTypeSn3 = ''
  196. this.productType = []
  197. this.$refs.table.refresh(true)
  198. },
  199. pageInit (buyerSn) {
  200. this.buyerSn = buyerSn
  201. this.resetSearchForm()
  202. },
  203. // 刷新当前页面
  204. resetCurForm () {
  205. this.$refs.table.refresh()
  206. },
  207. // 选择配件
  208. handleAdd (row) {
  209. this.$emit('add', row, 0)
  210. },
  211. // 产品分类 change
  212. changeProductType (val, opt) {
  213. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  214. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  215. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="less" scoped>
  221. .productInfoList-wrap{
  222. .ellipsisCon{
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. .ellipsisText{
  227. width: 100%;
  228. overflow: hidden;
  229. text-overflow: ellipsis;
  230. display: box;
  231. display: -webkit-box;
  232. -webkit-line-clamp: 1;
  233. -webkit-box-orient: vertical;
  234. }
  235. }
  236. }
  237. </style>