activeQueryPart.vue 11 KB

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