queryPart.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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-col>
  47. </a-row>
  48. </a-form>
  49. </div>
  50. <!-- 列表 -->
  51. <s-table
  52. class="sTable"
  53. ref="table"
  54. size="small"
  55. :rowKey="(record) => record.id"
  56. :columns="columns"
  57. :data="loadData"
  58. :customRow="handleClickRow"
  59. :scroll="{ y: tableHeight, x: 1050 }"
  60. :pageSize="50"
  61. :defaultLoadData="false"
  62. bordered>
  63. <!-- 销售数量 -->
  64. <template slot="nums" slot-scope="text, record">
  65. <div @dblclick.stop>
  66. <a-input-number
  67. size="small"
  68. v-model="record.salesNums"
  69. :precision="0"
  70. :min="1"
  71. :max="99999999"
  72. style="width: 100%;"
  73. placeholder="请输入" />
  74. </div>
  75. </template>
  76. <!-- 产品名称 -->
  77. <template slot="productName" slot-scope="text, record">
  78. <div class="ellipsisCon">
  79. <a-tooltip placement="rightBottom">
  80. <template slot="title">
  81. <span>{{ text }}</span>
  82. </template>
  83. <span class="ellipsisText">{{ text }}</span>
  84. </a-tooltip>
  85. <a-badge :number-style="{ backgroundColor: '#52c41a' }" count="活动" v-if="record.isJoinActivityProduct == 1"></a-badge>
  86. </div>
  87. </template>
  88. <!-- 操作 -->
  89. <template slot="action" slot-scope="text, record">
  90. <a-button
  91. size="small"
  92. type="link"
  93. class="button-info"
  94. :loading="newLoading"
  95. @click="handleAdd(record)"
  96. :disabled="!record.productPrice || record.productPrice<=0"
  97. id="productInfoList-edit-btn">添加</a-button>
  98. </template>
  99. </s-table>
  100. </div>
  101. </template>
  102. <script>
  103. import { commonMixin } from '@/utils/mixin'
  104. import { queryStockProductPage } from '@/api/stock'
  105. import ProductType from '@/views/common/productType.js'
  106. import ProductBrand from '@/views/common/productBrand.js'
  107. import chooseWarehouse from '@/views/common/chooseWarehouse'
  108. import { STable, VSelect } from '@/components'
  109. export default {
  110. name: 'QueryPart',
  111. mixins: [commonMixin],
  112. components: { STable, VSelect, ProductBrand, ProductType, chooseWarehouse },
  113. props: {
  114. newLoading: Boolean
  115. },
  116. data () {
  117. return {
  118. advanced: false, // 高级搜索 展开/关闭
  119. showSetting: false, // 设置弹框
  120. productType: [],
  121. buyerSn: '',
  122. queryParam: { // 查询条件
  123. productCode: '', // 产品编码
  124. productName: '', // 产品名称
  125. productOrigCode: '', // 原厂编码
  126. productBrandSn: undefined, // 产品品牌
  127. productTypeSn1: '', // 产品一级分类
  128. productTypeSn2: '', // 产品二级分类
  129. productTypeSn3: '', // 产品三级分类
  130. warehouseSn: undefined
  131. },
  132. defaultWarehouseSn: undefined, // 默认仓库sn
  133. disabled: false, // 查询、重置按钮是否可操作
  134. tableHeight: 300,
  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. let data
  141. if (res.status == 200) {
  142. data = res.data
  143. data.list = data.list.filter(item => item != null)
  144. const no = (data.pageNo - 1) * data.pageSize
  145. for (var i = 0; i < data.list.length; i++) {
  146. data.list[i].no = no + i + 1
  147. data.list[i].salesNums = 1
  148. data.list[i].currentStockQty = data.list[i].currentStockQty || 0
  149. const productPackQty = (data.list[i].productPackQty || data.list[i].productPackQty == 0) ? data.list[i].productPackQty : '--'
  150. const productUnit = data.list[i].productUnit || '--'
  151. const productPackQtyUnit = data.list[i].productPackQtyUnit || '--'
  152. data.list[i].packQtyV = productPackQty + productUnit + '/' + productPackQtyUnit
  153. }
  154. this.disabled = false
  155. }
  156. return data
  157. })
  158. }
  159. }
  160. },
  161. computed: {
  162. columns () {
  163. const arr = [
  164. { title: '产品编码', dataIndex: 'productCode', width: '150px', align: 'left', customRender: function (text) { return text || '--' } },
  165. { title: '产品名称', dataIndex: 'productName', scopedSlots: { customRender: 'productName' }, align: 'left' },
  166. { title: '原厂编码', dataIndex: 'productOrigCode', width: '100px', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  167. { title: '品牌', dataIndex: 'productBrandName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  168. { title: '出库仓库', dataIndex: 'warehouseName', width: '80px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  169. { title: '库存数量', dataIndex: 'currentStockQty', width: '80px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  170. { title: '单位', dataIndex: 'productUnit', width: '60px', align: 'center', customRender: function (text) { return text || '--' } },
  171. // { title: '售价', dataIndex: 'productPrice', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  172. { title: '包装数', dataIndex: 'packQtyV', width: '60px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  173. { title: '销售数量', dataIndex: 'salesNums', scopedSlots: { customRender: 'nums' }, width: '80px', align: 'center', fixed: 'right' },
  174. { title: '操作', dataIndex: 'action', scopedSlots: { customRender: 'action' }, width: '60px', align: 'center', fixed: 'right' }
  175. ]
  176. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  177. arr.splice(6, 0, { title: '售价', dataIndex: 'productPrice', width: '80px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  178. arr.splice(7, 0, { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '80px', align: 'center', customRender: function (text) { return text || '--' } })
  179. }
  180. return arr
  181. }
  182. },
  183. watch: {
  184. advanced (a, b) {
  185. this.tableHeight = window.innerHeight - (a ? 325 : 280)
  186. }
  187. },
  188. methods: {
  189. loadWarehouse (sn) {
  190. this.defaultWarehouseSn = sn
  191. this.queryParam.warehouseSn = sn
  192. if (this.buyerSn) {
  193. this.resetSearchForm()
  194. }
  195. },
  196. // 双击列表
  197. handleClickRow (record) {
  198. const _this = this
  199. return {
  200. on: {
  201. dblclick: (event) => {
  202. event.stopPropagation()
  203. this.$emit('add', record, 0, 0)
  204. }
  205. }
  206. }
  207. },
  208. // 查询
  209. searchForm () {
  210. if (this.queryParam.warehouseSn) {
  211. this.$refs.table.refresh(true)
  212. } else {
  213. this.$message.info('请选择仓库')
  214. }
  215. },
  216. // 重置
  217. resetSearchForm () {
  218. this.queryParam.productCode = ''
  219. this.queryParam.productName = ''
  220. this.queryParam.productOrigCode = ''
  221. this.queryParam.productBrandSn = undefined
  222. this.queryParam.productTypeSn1 = ''
  223. this.queryParam.productTypeSn2 = ''
  224. this.queryParam.productTypeSn3 = ''
  225. this.productType = []
  226. this.queryParam.warehouseSn = this.defaultWarehouseSn
  227. this.$refs.table.refresh(true)
  228. },
  229. pageInit (data, promo) {
  230. this.buyerSn = data.buyerSn
  231. this.tableHeight = window.innerHeight - 280
  232. this.resetSearchForm()
  233. },
  234. // 刷新当前页面
  235. resetCurForm () {
  236. const _this = this
  237. _this.$nextTick(() => {
  238. _this.$refs.table.refresh()
  239. })
  240. },
  241. // 选择配件
  242. handleAdd (row) {
  243. this.$emit('add', row, 0, 0)
  244. },
  245. // 产品分类 change
  246. changeProductType (val, opt) {
  247. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  248. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  249. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  250. }
  251. }
  252. }
  253. </script>
  254. <style lang="less" scoped>
  255. .productInfoList-wrap{
  256. .ellipsisCon{
  257. display: flex;
  258. justify-content: space-between;
  259. align-items: center;
  260. .ellipsisText{
  261. width: 100%;
  262. overflow: hidden;
  263. text-overflow: ellipsis;
  264. display: box;
  265. display: -webkit-box;
  266. -webkit-line-clamp: 1;
  267. -webkit-box-orient: vertical;
  268. }
  269. }
  270. }
  271. </style>