cumulativeQueryPart.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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" v-if="tabList&&tabList.length">
  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 }}项,数量合计{{ selectCount.totalNum }}个,售价小计合计{{ toThousands(selectCount.totalPrice) }}元</span>
  62. </div>
  63. <!-- 列表 -->
  64. <s-table
  65. class="sTable"
  66. ref="table"
  67. size="small"
  68. :rowKey="(record) => record.borrowDetailSn"
  69. rowKeyName="borrowDetailSn"
  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: 'CumulativeQueryPart',
  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. promoProductClz: 'GATE' // 促销产品类型
  112. },
  113. tableHeight: 300, // 表格高度
  114. disabled: false, // 查询、重置按钮是否可操作
  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. // 数量合计、售价小计
  148. selectCount () {
  149. let totalNum = 0
  150. let totalPrice = 0
  151. if (this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length) {
  152. this.rowSelectionInfo.selectedRows.forEach(item => {
  153. totalNum += item.qty
  154. totalPrice += item.totalAmount
  155. })
  156. }
  157. return { totalNum, totalPrice }
  158. },
  159. columns () {
  160. const _this = this
  161. const arr = [
  162. { title: '序号', dataIndex: 'no', width: '4%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '销售单号', dataIndex: 'borrowBillNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  164. { title: '客户名称', dataIndex: 'buyerName', width: '11%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  165. { title: '产品编码', dataIndex: 'productCode', width: '150px', align: 'left', customRender: function (text) { return text || '--' } },
  166. { title: '产品名称', dataIndex: 'productEntity.name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  167. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '150px', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  168. { title: '品牌', dataIndex: 'productEntity.productBrandName', width: '70px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  169. { title: '单位', dataIndex: 'productEntity.unit', width: '50px', align: 'center', customRender: function (text) { return text || '--' } },
  170. { title: '包装数', dataIndex: 'packQtyV', width: '50px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  171. { title: '销售数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  172. ]
  173. const idx = 7
  174. if (this.$hasPermissions('B_salesEdit_salesPrice')) { // 售价权限
  175. arr.splice(idx, 0, { title: '售价', dataIndex: 'price', width: '70px', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  176. arr.splice(idx + 1, 0, { title: '价格级别', dataIndex: 'priceLevelDictValue', width: '5%', align: 'center', customRender: function (text) { return text || '--' } })
  177. arr.push({ title: '售价小计', dataIndex: 'totalAmount', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  178. }
  179. return arr
  180. }
  181. },
  182. watch: {
  183. advanced (a, b) {
  184. this.tableHeight = window.innerHeight - (a ? 413 : 368)
  185. }
  186. },
  187. methods: {
  188. // 选择客户
  189. custChange (val) {
  190. this.queryParam.buyerSn = val.key
  191. },
  192. // 表格选中项
  193. rowSelectionFun (obj) {
  194. this.rowSelectionInfo = obj || null
  195. },
  196. // 切换tab
  197. changeTab (e) {
  198. this.queryParam.promoProductClz = e
  199. this.resetSearchForm()
  200. // 清空表格选中项
  201. this.$refs.table.clearSelected()
  202. // this.rowSelectionInfo = null
  203. },
  204. // 查询
  205. searchForm () {
  206. this.$refs.table.refresh(true)
  207. },
  208. // 重置
  209. resetSearchForm () {
  210. this.queryParam.productCode = ''
  211. this.queryParam.productName = ''
  212. this.queryParam.salesBillNo = ''
  213. this.queryParam.productOrigCode = ''
  214. this.queryParam.productBrandSn = undefined
  215. this.queryParam.productTypeSn1 = ''
  216. this.queryParam.productTypeSn2 = ''
  217. this.queryParam.productTypeSn3 = ''
  218. this.productType = []
  219. this.queryParam.buyerSn = undefined
  220. this.$refs.dealerSubareaScopeList.resetForm()
  221. this.$refs.table.refresh(true)
  222. },
  223. // 页面初始化
  224. pageInit (data, promo) {
  225. this.promoRuleData = promo.promotionRule
  226. this.queryParam.salesBillSn = data.salesBillSn
  227. this.queryParam.salesPromoSn = promo.salesPromoSn
  228. this.queryParam.promoRuleSn = promo.salesPromoSn
  229. // 选项卡数据
  230. const tabList = []
  231. if (this.promoRuleData) {
  232. if (this.promoRuleData.gateFlag === '1') {
  233. tabList.push({ text: '门槛产品', val: 'GATE' })
  234. }
  235. if (this.promoRuleData.promotionRuleType != 'PROMO_PROD') {
  236. tabList.push({ text: '正价产品', val: 'REGULAR' })
  237. }
  238. }
  239. this.tabList = tabList
  240. this.queryParam.promoProductClz = tabList && tabList.length ? tabList[0].val : ''
  241. this.tableHeight = window.innerHeight - 368
  242. this.resetSearchForm()
  243. },
  244. // 刷新当前页面
  245. resetCurForm () {
  246. const _this = this
  247. _this.$nextTick(() => {
  248. _this.$refs.table.refresh()
  249. })
  250. },
  251. // 添加产品
  252. handleAdd () {
  253. if (this.selectTotal == 0) {
  254. this.$message.warning('请先选择产品后再进行批量操作!')
  255. return
  256. }
  257. const chooseDataList = this.rowSelectionInfo.selectedRows = this.rowSelectionInfo.selectedRows.map(item => {
  258. item.borrowFlag = 1
  259. item.salesBillSn = this.queryParam.salesBillSn
  260. item.promotionFlag = this.queryParam.promoProductClz
  261. return item
  262. })
  263. this.$emit('add', chooseDataList, this.queryParam.promoProductClz)
  264. },
  265. // 选择产品分类 change
  266. changeProductType (val, opt) {
  267. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  268. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  269. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="less" scoped>
  275. .cumulativeProductList-wrap{
  276. /deep/ .ant-tabs-bar{
  277. margin-bottom: 5px!important;
  278. }
  279. }
  280. </style>