lilei 6 tháng trước cách đây
mục cha
commit
8c66a0bf69

+ 5 - 6
src/api/salesDetailNew.js

@@ -133,17 +133,16 @@ export const salesDetailAllList = (params) => {
     }
   })
 }
-// 销售  下推销售单列表
-export const waitDispatchDetailList = (params) => {
-  const url = `/dispatch/detail/queryPage/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
+
+// 销售 - 待下推列表 - 新
+export const queryAwaitDispatch = (params) => {
+  const url = `/sales/detail/queryAwaitDispatch`
   return axios({
     url: url,
     data: params,
     method: 'post',
     headers: {
-      'module': encodeURIComponent('累计产品列表')
+      'module': encodeURIComponent('销售单待下推列表')
     }
   })
 }

+ 41 - 5
src/views/salesManagement/salesQueryNew/comps/detailProductList.vue

@@ -92,6 +92,10 @@ export default {
     showHeader: {
       type: Boolean,
       default: true
+    },
+    activeList: { // 参与的活动列表
+      type: Array,
+      default: () => []
     }
   },
   data () {
@@ -161,6 +165,33 @@ export default {
         { title: '序号', field: 'no', key: 'a', width: 50, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
         { title: '产品编码', field: 'productCode', key: 'b', width: 150, align: 'left', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row, row[column.field], h) } },
         { title: '产品名称', field: 'productName', key: 'c', width: 250, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
+        {
+          title: '规则数量',
+          field: 'rulesNums',
+          key: '4',
+          width: 60,
+          align: 'center',
+          operationColumn: false,
+          renderBodyCell: ({ row, column, rowIndex }, h) => {
+            return (
+              <a-popover placement="right">
+                <template slot="content">
+                  {row.promoRuleSnList.map(item => {
+                    return (
+                      <div
+                        id={'dispacth-ruleDetail-' + row.productSn}
+                        title="点击查看详情"
+                        style="padding:5px 0;cursor: pointer;"
+                        onClick={() => _this.showRuleDetail(item)}
+                      >{ _this.activeRuleFilter(item) }</div>
+                    )
+                  })}
+                </template>
+                <a-button type="link" id={'dispacth-ruleSn-' + row.productSn} size="small" class="button-info">{row.promoRuleNum}<span style="zoom:0.6;color: #666;">个∨</span></a-button>
+              </a-popover>
+            )
+          }
+        },
         { title: '原厂编码', field: 'productOrigCode', key: 'd', width: 150, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
         { title: '出库仓库', field: 'warehouseName', key: 'e', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } }
       ]
@@ -218,16 +249,21 @@ export default {
     }
   },
   methods: {
+    // 参与规则名称
+    activeRuleFilter (val) {
+      const row = this.activeList.length && this.activeList.find(item => item.promoRuleSn == val)
+      return row ? row.promotion.description + '-' + row.promotionRule.description : ''
+    },
+    // 查看参与规则详情
+    showRuleDetail (promoRuleSn) {
+      this.detailSn = promoRuleSn
+      this.openDetailModal = true
+    },
     // 关闭详情弹窗
     closeDetailModal () {
       this.detailSn = null
       this.openDetailModal = false
     },
-    // 查看活动详情
-    showDesc (row) {
-      this.detailSn = row.promoRuleSn
-      this.openDetailModal = true
-    },
     // 获取销售单参与的活动列表
     pageInit () {
       this.searchTable()

+ 17 - 2
src/views/salesManagement/waitDispatchNew/edit.vue

@@ -14,6 +14,7 @@
         <queryPart
           ref="partQuery"
           :newLoading="isInster"
+          :activeList="activeList"
           @cancelProduct="cancelProduct"
           @cancelAll="cancelAll"
           @convertPromoGifts="convertPromoGifts"
@@ -59,7 +60,7 @@ import queryPart from './queryPart.vue'
 import detailProductList from './detailProductList.vue'
 import dsModal from './dsModal.vue'
 // 接口
-import { salesDetailBySn } from '@/api/salesNew'
+import { salesDetailBySn, salesPromoQueryList } from '@/api/salesNew'
 import { insertBatchOfWaitDispatch, salesDetailUpdateCancelQty, salesDetailCancleOfAll, batchTransferOfPurchaseAmount } from '@/api/salesDetailNew'
 import { pushDown } from '@/api/waitDispatchDetail'
 import { findBySalesBillSn } from '@/api/dispatch'
@@ -81,7 +82,8 @@ export default {
       productForm: {
         dispatchBillSn: '' // 下推单sn
       },
-      totalData: null // 统计数据
+      totalData: null, // 统计数据
+      activeList: [] // 参与活动列表
     }
   },
   methods: {
@@ -89,6 +91,18 @@ export default {
     handleBack () {
       this.$router.push({ name: 'salesQueryNewList', query: { closeLastOldTab: true } })
     },
+    // 获取销售单参与的活动列表
+    async getActiveList () {
+      // 已参与活动列表
+      const list = await salesPromoQueryList({ salesBillSn: this.$route.params.sn || this.bizSn }).then(res => res.data || [])
+      this.activeList = list.filter(item => item.promotion && item.promotionRule)
+      // 触发活动统计查询变量
+      this.$nextTick(() => {
+        if (this.activeList.length) {
+          this.$refs.activeTjList.hasInit = false
+        }
+      })
+    },
     // 统计查询
     getTotalData (flag) {
       findBySalesBillSn({ salesBillSn: this.$route.params.salesBillSn }).then(res => {
@@ -240,6 +254,7 @@ export default {
     pageInit () {
       this.$refs.partQuery.clearSelectTable()
       this.salesBillSn = this.$route.params.salesBillSn
+      this.getActiveList()
       this.getOrderDetail(true)
       this.getTotalData(true)
     }

+ 67 - 111
src/views/salesManagement/waitDispatchNew/queryPart.vue

@@ -162,7 +162,7 @@ import detailModal from '@/views/promotionRulesManagement/dealerPromotions/detai
 import toPurchaseModal from './toPurchaseModal'
 import chooseWarehouse from '@/views/common/chooseWarehouse'
 // 接口
-import { salesDetailAllList, waitDispatchDetailList, salesPromoDetailCount, salesDetaiCount } from '@/api/salesDetailNew'
+import { queryAwaitDispatch, salesPromoDetailCount, salesDetaiCount } from '@/api/salesDetailNew'
 import { salesPromoQueryList, getCreatePurchaseFlag } from '@/api/salesNew'
 
 export default {
@@ -181,6 +181,10 @@ export default {
     showHeader: { // 是否显示表格头部
       type: Boolean,
       default: true
+    },
+    activeList: { // 参与的活动列表
+      type: Array,
+      default: () => []
     }
   },
   data () {
@@ -208,7 +212,6 @@ export default {
         convertPromoGiftsFlag: undefined // 转采购额
       },
       disabled: false, //  查询、重置按钮是否可操作
-      activeList: [], // 活动列表
       spinning: false,
       dataSource: [], // 原始数据
       tableData: [], // 表格数据
@@ -293,23 +296,15 @@ export default {
       }
       // 单号
       const codeFormat = function (record, data, h) {
-        let ftext = ''
-        let fcolor = ''
-        if (record.promotionFlag == 'GIFT') {
-          ftext = '促'
-          fcolor = '#52c41a'
-        }
-        if (record.promotionFlag == 'GATE') {
-          ftext = '槛'
-          fcolor = '#108ee9'
-        }
-
         return (
           <div>
-            <span style="padding-right: 15px;">{data}</span>
-            {ftext ? (<a-badge count={ftext} number-style={{ backgroundColor: fcolor, zoom: '80%' }}></a-badge>) : ''}
-            {record.bakConvertPromoGiftsQty ? (<a-badge count="转" number-style={{ backgroundColor: '#ffaa00', zoom: '80%' }}></a-badge>) : ''}
-            { Number((_this.showLockStockQty ? record.lockStockQty : record.stockQty) || 0) < Number(record.unpushedQty || 0) ? (<a-badge count="缺" number-style={{ zoom: '80%' }}></a-badge>) : ''}
+            <span style="padding-right: 10px;">{data}</span>
+            {record.promotionFlag.indexOf('GIFT') >= 0 ? <a-badge count="促" numberStyle={{ backgroundColor: '#52c41a', zoom: '0.7' }}/> : ''}
+            {record.promotionFlag.indexOf('DISCOUNT') >= 0 ? <a-badge count="特" numberStyle={{ backgroundColor: '#faad14', zoom: '0.7' }}/> : ''}
+            {record.promotionFlag.indexOf('GATE') >= 0 ? <a-badge count="槛" numberStyle={{ backgroundColor: '#108ee9', zoom: '0.7' }}/> : ''}
+            {record.promotionFlag.indexOf('REGULAR') >= 0 ? <a-badge count="正" numberStyle={{ backgroundColor: '#ff5500', zoom: '0.7' }}/> : ''}
+            {record.bakConvertPromoGiftsQty ? (<a-badge count="转" numberStyle={{ backgroundColor: '#ffaa00', zoom: '80%' }}></a-badge>) : ''}
+            {Number((_this.showLockStockQty ? record.lockStockQty : record.stockQty) || 0) < Number(record.unpushedQty || 0) ? (<a-badge count="缺" numberStyle={{ zoom: '0.7' }}></a-badge>) : ''}
           </div>
         )
       }
@@ -377,31 +372,10 @@ export default {
       }
       // 编号,并且格式化活动分类行
       const noFormat = function (record, data, h) {
-        const isBuyPSendP = record.promo && record.promo.promotionRule.convertExpenseFlag == 1 && record.promo.promotionRule.promotionRuleType == 'BUY_PROD_GIVE_PROD'
         return (
           <div>
-            {record.id.indexOf('promo-') >= 0 ? (
-              <div class="active-title">
-                {record.promo ? (
-                  <div>
-                    <strong style="font-size:14px;">{record.promo.promotion.description} </strong>
-                    <span>({record.promo.promotionRule.description})</span>
-                    <span id={'dispacth-desc-' + record.promo.promoRuleSn} style="margin-left:20px;color:#00aaff;cursor: pointer;" onClick={() => _this.showDesc(record.promo)}>
-                      <a-icon title="查看活动详情" type="eye"/> 活动详情
-                    </span>
-                  </div>
-                ) : (<div></div>)}
-                <div>
-                  款数:<strong>{record.total && record.total.totalCategory || '--'}</strong>;
-                  数量:<strong>{record.total && record.total.totalQty || '--'}</strong>;
-                  {_this.$hasPermissions('B_salesEdit_salesPrice') ? (<span>总金额:<strong>{record.total && record.total.totalAmount || '--'}</strong>;</span>) : ('')}
-                  {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.lossAmount ? (<span>优惠金额:<strong>{record.total.lossAmount}</strong>;</span>) : ('')}
-                  {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.cgejyAmount > 0 && !isBuyPSendP ? (<span>采购额结余:<strong>{_this.toThousands(record.total.cgejyAmount)}</strong>;</span>) : ('')}
-                  {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.cgejyAmount < 0 && !isBuyPSendP ? (<span>采购额超出:<strong>{_this.toThousands(record.total.cgeccAmount)}</strong>;</span>) : ('')}
-                  {_this.$hasPermissions('B_salesEdit_salesPrice') && record.promo && record.total && record.total.totalPromoGiftsAmount && isBuyPSendP ? (<span>促销产品转采购额金额:<strong>{_this.toThousands(record.total && record.total.totalPromoGiftsAmount) || '--'}</strong>;</span>) : ('')}
-                  {record.expenseAccountFlag != 'WAIT' ? record.expenseAccountFlagDictValue : ''}
-                </div>
-              </div>
+            {record.id.indexOf('promo-active') >= 0 ? (
+              <div class="active-title">参与促销的产品</div>
             ) : (<span>{data}</span>)}
           </div>
         )
@@ -412,9 +386,37 @@ export default {
         { title: '序号', field: 'no', key: 'a', width: 50, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return noFormat(row, row[column.field], h) } },
         { title: '产品编码', field: 'productCode', key: 'b', width: 150, align: 'left', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return codeFormat(row, row[column.field], h) } },
         { title: '产品名称', field: 'productName', key: 'c', width: 220, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
+        {
+          title: '规则数量',
+          field: 'rulesNums',
+          key: '4',
+          width: 60,
+          align: 'center',
+          operationColumn: false,
+          renderBodyCell: ({ row, column, rowIndex }, h) => {
+            return (
+              <a-popover placement="right">
+                <template slot="content">
+                  {row.promoRuleSnList.map(item => {
+                    return (
+                      <div
+                        id={'dispacth-ruleDetail-' + row.productSn}
+                        title="点击查看详情"
+                        style="padding:5px 0;cursor: pointer;"
+                        onClick={() => _this.showRuleDetail(item)}
+                      >{ _this.activeRuleFilter(item) }</div>
+                    )
+                  })}
+                </template>
+                <a-button type="link" id={'dispacth-ruleSn-' + row.productSn} size="small" class="button-info">{row.promoRuleNum}<span style="zoom:0.6;color: #666;">个∨</span></a-button>
+              </a-popover>
+            )
+          }
+        },
         { title: '原厂编码', field: 'productOrigCode', key: 'd', width: 150, align: 'left', operationColumn: false, ellipsis: { showTitle: true }, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
         { title: '出库仓库', field: 'warehouseName', key: 'e', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } }
       ]
+      // 单元格合并数量
       this.colspanNums = this.showConvertPromoGifts ? 7 : 6
       if (this.$hasPermissions('B_salesDispatch_salesPrice')) { //  售价权限
         this.colspanNums = this.colspanNums + 1
@@ -459,16 +461,21 @@ export default {
     }
   },
   methods: {
-    // 查看活动详情
-    showDesc (row) {
-      this.detailSn = row.promoRuleSn
-      this.openDetailModal = true
-    },
     // 关闭详情弹窗
     closeDetailModal () {
       this.detailSn = null
       this.openDetailModal = false
     },
+    // 参与规则名称
+    activeRuleFilter (val) {
+      const row = this.activeList.length && this.activeList.find(item => item.promoRuleSn == val)
+      return row ? row.promotion.description + '-' + row.promotionRule.description : ''
+    },
+    // 查看参与规则详情
+    showRuleDetail (promoRuleSn) {
+      this.detailSn = promoRuleSn
+      this.openDetailModal = true
+    },
     // 合并活动分类单元格
     bodyCellSpan ({ row, column, rowIndex }) {
       if (row.id.indexOf('promo-') >= 0) {
@@ -513,17 +520,6 @@ export default {
         })
       }
     },
-    // 获取销售单参与的活动列表
-    getActiveList () {
-      salesPromoQueryList({ salesBillSn: this.salesBillSn }).then(res => {
-        if (res.status == 200) {
-          this.activeList = res.data.filter(item => item.enabledFlag == 1) || []
-        }
-        this.$nextTick(() => {
-          this.searchTable()
-        })
-      })
-    },
     // 查询列表
     async searchTable () {
       this.selectedRowKeys = []
@@ -534,63 +530,24 @@ export default {
       this.queryParam.salesBillSn = this.salesBillSn
       this.queryParam.showStock = true
       const params = this.queryParam
-      // 获取活动列表
+      // 所有活动接口
       const active = this.activeList
-      // 正常产品
+      // 是否查询正常产品
       const hasSearchNormal = !params.promotionFlag || params.promotionFlag == 0
-      // 所有活动接口
-      const proList = hasSearchNormal ? await salesDetailAllList(params).then(res => res.data) : []
-      // 正常产品统计信息
-      const norTotal = hasSearchNormal ? await salesDetaiCount(params).then(res => res.data) : null
-      // 是否有正常产品
-      this.hasNormalProduct = proList.length > 0
-      // 没有活动时不显示统计
-      let listData = active.length ? (proList.length ? [{
-        id: 'promo-normal',
-        total: norTotal
-      }, ...proList] : []) : proList
+      const proList = hasSearchNormal ? await queryAwaitDispatch({ ...params, detailPromoFlag: 0 }).then(res => res.data) : []
+      this.hasNormalProduct = proList.length > 0 // 是否有正常产品
+      // 没有活动时不显示正常产品标题行
+      let listData = proList
 
+      // 获取活动产品列表,查询条件未选正常产品
       if (params.promotionFlag != 0) {
-        // 循环获取活动产品
-        for (let i = 0; i < active.length; i++) {
-          const promo = active[i]
-          const activeParams = {
-            promoRuleSn: promo.promoRuleSn,
-            promoSn: promo.promoSn,
-            salesPromoSn: promo.salesPromoSn,
-            ...params
-          }
-
-          // 获取活动产品统计
-          const acTotal = await salesPromoDetailCount(activeParams).then(res => res.data)
-          if (acTotal) {
-            // 采购额结余
-            acTotal.cgejyAmount = (Number(acTotal.totalPromoGiftsAmount || 0) - Number(acTotal.totalUsePromoGiftsAmount || 0)).toFixed(2)
-            // 采购额超出
-            acTotal.cgeccAmount = (Number(acTotal.totalUsePromoGiftsAmount || 0) - Number(acTotal.totalPromoGiftsAmount || 0)).toFixed(2)
-          }
-
-          // 有数据时才调用接口,避免做无用的调用
-          if (acTotal && acTotal.totalQty) {
-            // 获取活动产品列表
-            const aclist = await salesDetailAllList(activeParams).then(res => res.data)
-            const retList = aclist.length ? [{
-              id: 'promo-' + i,
-              promo: promo,
-              total: acTotal
-            }, ...aclist] : []
-            // 将活动产品数据拼接
-            listData = aclist && aclist.length ? listData.concat(retList) : listData
-          }
-        }
-
-        // 如果活动没有任何产品
-        if (active.length) {
-          const hasAcp = listData.filter(item => item.id != 'promo-normal').filter(item => item.id.indexOf('promo-') >= 0)
-          if (hasAcp && hasAcp.length == 0) {
-            listData = listData.filter(item => item.id.indexOf('promo-') < 0) || []
-          }
-        }
+        const aclist = await queryAwaitDispatch({ ...params, detailPromoFlag: 1 }).then(res => res.data)
+        // 没用活动产品,不显示
+        const retList = aclist.length ? [{
+          id: 'promo-active'
+        }, ...aclist] : []
+        // 将活动产品数据拼接
+        listData = aclist && aclist.length ? listData.concat(retList) : listData
       }
       this.dataSource = listData
 
@@ -652,10 +609,9 @@ export default {
     pageInit (salesBillSn, detailData) {
       this.salesBillSn = salesBillSn
       this.detailData = detailData
-      // 获取活动列表
-      this.getActiveList()
       // 是否转过采购单
       this.hasCreatePurchaseFlag()
+      this.searchTable()
     },
     // 清空选项
     clearSelectTable () {