cumulativeProduct.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div class="cumulativeProductList-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="客户名称">
  9. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="cumulativeProductList-buyerName" @change="custChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="cumulativeProductList-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="cumulativeProductList-salesBillNo" v-model.trim="queryParam.salesBillNo" 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="cumulativeProductList-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="原厂编码">
  30. <a-input id="cumulativeProductList-origCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="产品品牌">
  35. <ProductBrand id="cumulativeProductList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="产品分类">
  40. <ProductType id="cumulativeProductList-productType" v-model="productType" @change="changeProductType"></ProductType>
  41. </a-form-item>
  42. </a-col>
  43. </template>
  44. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  45. <a-button type="primary" @click="searchForm" :disabled="disabled" id="cumulativeProductList-refresh">查询</a-button>
  46. <a-button style="margin-left: 5px" @click="resetSearchForm" id="cumulativeProductList-reset">重置</a-button>
  47. <a @click="advanced=!advanced" style="margin: 0 5px">
  48. {{ advanced ? '收起' : '展开' }}
  49. <a-icon :type="advanced ? 'up' : 'down'"/>
  50. </a>
  51. </a-col>
  52. </a-row>
  53. </a-form>
  54. </div>
  55. <!-- tab选项卡 -->
  56. <a-tabs type="card" @change="changeTab" size="small">
  57. <a-tab-pane v-for="item in tabList" :key="item.val" :tab="item.text"></a-tab-pane>
  58. </a-tabs>
  59. <div class="table-operator">
  60. <a-button type="primary" @click="handleAdd">批量添加</a-button>
  61. <span v-if="selectTotal" style="margin-left:10px;">已选{{ selectTotal }}项</span>
  62. </div>
  63. <!-- 列表 -->
  64. <s-table
  65. class="sTable"
  66. ref="table"
  67. size="small"
  68. :rowKey="(record) => record.productSn"
  69. rowKeyName="productSn"
  70. :columns="columns"
  71. :data="loadData"
  72. :row-selection="{ columnWidth: 40 }"
  73. @rowSelection="rowSelectionFun"
  74. :scroll="{ y: tableHeight, x: 1040 }"
  75. :defaultLoadData="false"
  76. :pageSize="50"
  77. bordered>
  78. </s-table>
  79. </div>
  80. </template>
  81. <script>
  82. import { commonMixin } from '@/utils/mixin'
  83. import { salesDetailQueryBorrowPageList } from '@/api/salesNew'
  84. import ProductType from '@/views/common/productType.js'
  85. import ProductBrand from '@/views/common/productBrand.js'
  86. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  87. import { STable, VSelect } from '@/components'
  88. export default {
  89. name: 'ActiveQueryPart',
  90. mixins: [commonMixin],
  91. components: { STable, VSelect, ProductBrand, ProductType, dealerSubareaScopeList },
  92. props: {
  93. newLoading: Boolean
  94. },
  95. data () {
  96. return {
  97. advanced: false, // 高级搜索 展开/关闭
  98. showSetting: false, // 设置弹框
  99. productType: [], // 产品类型
  100. buyerSn: '', // 客户sn
  101. queryParam: { // 查询条件
  102. buyerSn: undefined, // 客户名称
  103. productCode: '', // 产品编码
  104. salesBillNo: '', // 销售单号
  105. productName: '', // 产品名称
  106. productOrigCode: '', // 原厂编码
  107. productBrandSn: undefined, // 产品品牌
  108. productTypeSn1: '', // 产品一级分类
  109. productTypeSn2: '', // 产品二级分类
  110. productTypeSn3: '' // 产品三级分类
  111. },
  112. tableHeight: 300, // 表格高度
  113. disabled: false, // 查询、重置按钮是否可操作
  114. promoProductClz: 'GATE', // 促销产品类型
  115. promoRuleData: null, // 促销规则数据
  116. tabList: [], // 促销产品选项卡
  117. rowSelectionInfo: null, // 已选择
  118. // 加载数据方法 必须为 Promise 对象
  119. loadData: parameter => {
  120. this.disabled = true
  121. return salesDetailQueryBorrowPageList(Object.assign(parameter, this.queryParam, { onlineFalg: '1' })).then(res => {
  122. let data
  123. if (res.status == 200) {
  124. data = res.data
  125. data.list = data.list.filter(item => item != null)
  126. const no = (data.pageNo - 1) * data.pageSize
  127. for (var i = 0; i < data.list.length; i++) {
  128. data.list[i].no = no + i + 1
  129. // 产品包装数
  130. const productPackQty = (data.list[i].packQty || data.list[i].packQty == 0) ? data.list[i].packQty : '--'
  131. const productUnit = data.list[i].productEntity.unit || '--'
  132. const productPackQtyUnit = data.list[i].packQtyUnit || '--'
  133. data.list[i].packQtyV = productPackQty + productUnit + '/' + productPackQtyUnit
  134. }
  135. this.disabled = false
  136. }
  137. return data
  138. })
  139. }
  140. }
  141. },
  142. computed: {
  143. // 已选产品数量
  144. selectTotal () {
  145. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  146. },
  147. columns () {
  148. const arr = [
  149. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '销售单号', dataIndex: 'borrowBillNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '客户名称', dataIndex: 'buyerName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  152. { title: '产品编码', dataIndex: 'productCode', width: '150px', align: 'left', customRender: function (text) { return text || '--' } },
  153. { title: '产品名称', dataIndex: 'productEntity.name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  154. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '150px', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  155. { title: '品牌', dataIndex: 'productEntity.productBrandName', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  156. { title: '单位', dataIndex: 'productEntity.unit', width: '60px', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '包装数', dataIndex: 'packQtyV', width: '60px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  158. { title: '销售数量', dataIndex: 'qty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  159. ]
  160. const idx = 7
  161. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  162. arr.splice(idx, 0, { title: '售价', dataIndex: 'price', width: '100px', align: 'right', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  163. arr.splice(idx + 1, 0, { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } })
  164. arr.push({ title: '售价小计', dataIndex: 'totalAmount', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  165. }
  166. return arr
  167. }
  168. },
  169. watch: {
  170. advanced (a, b) {
  171. this.tableHeight = window.innerHeight - (a ? 413 : 368)
  172. }
  173. },
  174. methods: {
  175. // 选择客户
  176. custChange (val) {
  177. this.queryParam.buyerSn = val.key
  178. },
  179. // 表格选中项
  180. rowSelectionFun (obj) {
  181. this.rowSelectionInfo = obj || null
  182. },
  183. // 切换tab
  184. changeTab (e) {
  185. this.promoProductClz = e
  186. this.resetSearchForm()
  187. // 清空表格选中项
  188. this.$refs.table.clearSelected()
  189. // this.rowSelectionInfo = null
  190. },
  191. // 查询
  192. searchForm () {
  193. this.$refs.table.refresh(true)
  194. },
  195. // 重置
  196. resetSearchForm () {
  197. this.queryParam.productCode = ''
  198. this.queryParam.productName = ''
  199. this.queryParam.salesBillNo = ''
  200. this.queryParam.productOrigCode = ''
  201. this.queryParam.productBrandSn = undefined
  202. this.queryParam.productTypeSn1 = ''
  203. this.queryParam.productTypeSn2 = ''
  204. this.queryParam.productTypeSn3 = ''
  205. this.productType = []
  206. this.queryParam.buyerSn = undefined
  207. this.$refs.dealerSubareaScopeList.resetForm()
  208. this.$refs.table.refresh(true)
  209. },
  210. // 页面初始化
  211. pageInit (data, promo) {
  212. this.promoRuleData = promo.promotionRule
  213. this.queryParam.salesBillSn = data.salesBillSn
  214. this.queryParam.salesPromoSn = promo.salesPromoSn
  215. // 选项卡数据
  216. const tabList = []
  217. if (this.promoRuleData) {
  218. if (this.promoRuleData.gateFlag === '1') {
  219. tabList.push({ text: '门槛产品', val: 'GATE' })
  220. }
  221. if (this.promoRuleData.promotionRuleType != 'PROMO_PROD') {
  222. tabList.push({ text: '正价产品', val: 'REGULAR' })
  223. }
  224. }
  225. this.tabList = tabList
  226. this.promoProductClz = tabList[0].val
  227. this.tableHeight = window.innerHeight - 368
  228. this.resetSearchForm()
  229. },
  230. // 刷新当前页面
  231. resetCurForm () {
  232. const _this = this
  233. _this.$nextTick(() => {
  234. _this.$refs.table.refresh()
  235. })
  236. },
  237. // 添加产品
  238. handleAdd () {
  239. if (this.selectTotal == 0) {
  240. this.$message.warning('请先选择产品后再进行批量操作!')
  241. return
  242. }
  243. const chooseDataList = this.rowSelectionInfo.selectedRows = this.rowSelectionInfo.selectedRows.map(item => {
  244. item.borrowFlag = 1
  245. item.salesBillSn = this.queryParam.salesBillSn
  246. item.promotionFlag = this.promoProductClz
  247. return item
  248. })
  249. this.$emit('add', chooseDataList, this.promoProductClz)
  250. },
  251. // 选择产品分类 change
  252. changeProductType (val, opt) {
  253. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  254. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  255. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="less" scoped>
  261. .cumulativeProductList-wrap{
  262. /deep/ .ant-tabs-bar{
  263. margin-bottom: 5px!important;
  264. }
  265. }
  266. </style>