cumulativeQueryPart.vue 12 KB

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