lilei 7 ay önce
ebeveyn
işleme
6d833b163f

+ 3 - 1
src/views/salesManagement/salesQueryNew/comps/chooseProduct.vue

@@ -69,7 +69,7 @@ export default {
   methods: {
     // 关闭弹框
     onClose () {
-      this.$emit('close', this.hasRefash)
+      this.$emit('close', this.hasRefash, this.cptype)
     },
     // 添加产品,
     // row 产品信息, promoProductClz 促销产品类型, 0 正常产品
@@ -99,6 +99,8 @@ export default {
       if (!newValue) {
         this.onClose()
         this.cptype = 3
+      } else {
+        this.hasRefash = false
       }
     }
   }

+ 1 - 1
src/views/salesManagement/salesQueryNew/comps/productActiveList.vue

@@ -746,7 +746,7 @@ export default {
             salesBillSn: _this.salesBillSn
           }
           // 更换活动
-          _this.$emit('upActive', '0', params)
+          _this.$emit('upActive', params, 1)
         }
       })
     },

+ 67 - 60
src/views/salesManagement/salesQueryNew/comps/productNormalList.vue

@@ -70,19 +70,7 @@
               size="small"
             > 批量操作 <a-icon type="down" /> </a-button>
           </a-dropdown>
-          <span v-if="selectTotal" style="margin-left:10px;">已选 {{ selectTotal }} 项</span>
-        </a-col>
-        <a-col :md="16" :sm="24" style="text-align:right;">
-          <a-button
-            type="link"
-            class="button-info"
-            id="salesEdit-import-product"
-            @click="openGuideModal=true"><a-icon type="login" /> 导入产品</a-button>
-          <a-button
-            id="salesEdit-new-product"
-            type="link"
-            class="button-info"
-            @click="openCpModal"><a-icon type="plus" /> 添加产品</a-button>
+          <span v-if="selectTotal" style="margin:0 10px;">已选 {{ selectTotal }} 项</span>
           <a-button
             :id="'salesEdit-allSetWare'"
             type="link"
@@ -98,6 +86,18 @@
             @click="handleMenuClick({key:2})"
           ><a-icon type="delete"/> 全部删除</a-button>
         </a-col>
+        <a-col :md="16" :sm="24" style="text-align:right;">
+          <a-button
+            type="link"
+            class="button-info"
+            id="salesEdit-import-product"
+            @click="openGuideModal=true"><a-icon type="login" /> 导入产品</a-button>
+          <a-button
+            id="salesEdit-new-product"
+            type="link"
+            class="button-info"
+            @click="openCpModal"><a-icon type="plus" /> 添加产品</a-button>
+        </a-col>
       </a-row>
     </div>
 
@@ -365,6 +365,12 @@ export default {
     warehouseLoad (sn, list) {
       this.warehouseDataList = list
     },
+    //  产品分类  change
+    changeProductType (val, opt) {
+      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+    },
     // 表格选中项
     rowSelectionFun (obj) {
       this.rowSelectionInfo = obj || null
@@ -390,11 +396,34 @@ export default {
         }
       })
     },
+    // 删除产品
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '确认要删除吗?',
+        centered: true,
+        closable: true,
+        onOk () {
+          _this.delLoading = true
+          _this.spinning = true
+          salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh(false)
+              _this.$emit('refash', 'normal', 'del')
+            }
+            _this.delLoading = false
+            _this.spinning = false
+          })
+        }
+      })
+    },
     // 删除全部已选产品
     handleBatchDelAll () {
       const _this = this
       if (_this.dataSource.length == 0) {
-        _this.$message.warning('暂无可删除的已选产品!')
+        _this.$message.warning('暂无可删除的产品!')
         return
       }
       this.$confirm({
@@ -405,7 +434,7 @@ export default {
           _this.spinning = true
           deleteAll({ salesBillSn: _this.salesBillSn }).then(res => {
             if (res.status == 200) {
-              _this.$refs.table.refresh(false)
+              _this.resetSearchForm()
               // 触发事件给父级组件
               _this.$emit('refash', 'normal', 'batchDel')
               _this.$message.success(res.message)
@@ -418,14 +447,11 @@ export default {
     // 批量删除已选产品
     handleBatchDel () {
       const _this = this
-      if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
+      if (!_this.selectTotal) {
         _this.$message.warning('请先选择要批量删除的产品!')
         return
       }
-      const obj = []
-      _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
-        obj.push(item.salesBillDetailSn)
-      })
+      const obj = _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => item.salesBillDetailSn) || []
       this.$confirm({
         title: '提示',
         content: '已选产品' + obj.length + '项,确认要批量删除吗?',
@@ -437,7 +463,7 @@ export default {
             salesBillDetailSnList: obj
           }).then(res => {
             if (res.status == 200) {
-              _this.$refs.table.refresh(false)
+              _this.clearTable()
               // 触发事件给父级组件
               _this.$emit('refash', 'normal', 'batchDel')
               _this.$message.success(res.message)
@@ -457,7 +483,7 @@ export default {
       }
       this.setWarehouseInfo(ajax_data)
     },
-    // 选择仓库确认
+    // 全部或批量仓库设置确认
     chooseWarehouseOk (sn) {
       const _this = this
       const snArr = []
@@ -468,7 +494,7 @@ export default {
         warehouseSn: sn,
         salesBillDetailSnList: snArr,
         salesBillSn: _this.salesBillSn,
-        allFlag: _this.warehouseTit ? true : undefined
+        allFlag: snArr.length == 0 ? true : undefined
       }
       _this.setWarehouseInfo(ajax_data)
     },
@@ -480,23 +506,21 @@ export default {
         if (res.status == 200) {
           _this.$message.success(res.message)
           _this.$emit('refash', 'promo', 'update')
+          if (data.allFlag) {
+            _this.resetSearchForm()
+          } else {
+            _this.clearTable()
+          }
         }
-        _this.$refs.table.refresh(false)
         _this.openWarehouseModal = false
         _this.spinning = false
       })
     },
-    //  产品分类  change
-    changeProductType (val, opt) {
-      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
-      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
-      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
-    },
     // 操作下拉菜单
     handleMenuClick (e) {
       const _this = this
       if (e.key == 0) { // 仓库设置
-        if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
+        if (!this.selectTotal) {
           _this.$message.warning('请先选择要设置的产品!')
         } else {
           _this.openWarehouseModal = true
@@ -505,7 +529,6 @@ export default {
       } else if (e.key == 1) { // 删除已选项
         this.handleBatchDel()
       } else if (e.key == 3) {
-        _this.$refs.table.clearSelected()
         _this.warehouseTit = '全部仓库设置'
         _this.openWarehouseModal = true
       } else {
@@ -535,7 +558,7 @@ export default {
       }
     },
     // 重置查询
-    resetSearchForm (flag) {
+    resetSearchForm () {
       this.queryParam.productCode = ''
       this.queryParam.productName = ''
       this.queryParam.warehouseSn = undefined
@@ -545,9 +568,16 @@ export default {
       this.queryParam.productTypeSn3 = ''
       this.productType = []
       this.$refs.table.clearSelected()
-      this.$refs.table.refresh(!!flag)
+      this.rowSelectionInfo = null
+      this.$refs.table.refresh(true)
     },
-    // 参与促销
+    // 清空选项并查询当前页
+    clearTable () {
+      this.$refs.table.clearSelected()
+      this.rowSelectionInfo = null
+      this.$refs.table.refresh(false)
+    },
+    // 参与促销选择弹框
     handleAddPromo (record) {
       this.$refs.updateActive.getActiveList({
         productSn: record.productSn,
@@ -575,29 +605,6 @@ export default {
       this.openUpActiveModal = false
       this.$refs.table.refresh(false)
     },
-    // 删除产品
-    handleDel (row) {
-      const _this = this
-      this.$confirm({
-        title: '提示',
-        content: '确认要删除吗?',
-        centered: true,
-        closable: true,
-        onOk () {
-          _this.delLoading = true
-          _this.spinning = true
-          salesDetailDel({ salesBillDetailSn: row.salesBillDetailSn, salesBillSn: _this.salesBillSn }).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$refs.table.refresh(false)
-              _this.$emit('refash', 'normal', 'del')
-            }
-            _this.delLoading = false
-            _this.spinning = false
-          })
-        }
-      })
-    },
     // 保存添加的产品到销售列表
     saveNewProduct (row, promotionFlag) {
       // 防止多次添加产品
@@ -626,7 +633,7 @@ export default {
       }).then(res => {
         if (res.status == 200) {
           this.$message.success('产品添加成功', 2.5)
-          this.resetSearchForm(true)
+          this.resetSearchForm()
           // 触发事件给父级组件
           this.$emit('refash', 'normal', 'add')
         }
@@ -650,7 +657,7 @@ export default {
       salesBatchInsert(params).then(res => {
         if (res.status == 200) {
           this.$message.success('产品导入成功', 2.5)
-          this.resetSearchForm(true)
+          this.resetSearchForm()
           // 触发事件给父级组件
           this.$emit('refash', 'normal', 'import')
         }

+ 127 - 126
src/views/salesManagement/salesQueryNew/edit.vue

@@ -59,14 +59,14 @@
         <div slot="title">
           <div style="display: flex;justify-content: space-between;">
             <span>活动产品</span>
-            <a-button size="small" @click="getActiveList(true)" type="link" class="button-info"><a-icon type="reload"/> 刷新</a-button>
+            <a-button size="small" @click="getActiveList(false)" type="link" class="button-info"><a-icon type="reload"/> 刷新</a-button>
           </div>
         </div>
         <activeStatisticsList
           ref="activeTjList"
           @openCpModal="openProductModal"
           @refash="refashTableData"
-          @selected="getActiveProduct"
+          @selected="active => salesPromoSnSet = active"
           :activeList="activeList"
           :warehouseSn="warehouseSn"
           :salesBillSn="salesBillSn"
@@ -256,22 +256,6 @@ export default {
     handleBack () {
       this.$router.push({ name: 'salesQueryNewList', query: { closeLastOldTab: true } })
     },
-    //  销售单详情
-    getOrderDetail (flag, callback) {
-      this.spinning = true
-      salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => {
-        this.spinning = false
-        if (res.status == 200) {
-          this.detailData = res.data
-          this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
-          if (callback) { callback() }
-        }
-        if (flag) {
-          // 获取活动列表
-          this.getActiveList()
-        }
-      })
-    },
     // 查看参与规则明细
     showRuleDetail (sn) {
       this.$refs.activeTjList.showDesc({ promoRuleSn: sn })
@@ -297,104 +281,24 @@ export default {
         this.spinning = false
       })
     },
-    // 获取销售单参与的活动列表
-    async getActiveList (flag) {
-      // 已参与活动列表
-      const list = await salesPromoQueryList({ salesBillSn: this.$route.params.sn }).then(res => res.data || [])
-      this.activeList = list.filter(item => item.promotion && item.promotionRule)
-      // 触发活动统计查询变量
-      this.$nextTick(() => {
-        if (this.activeList.length) this.$refs.activeTjList.hasInit = false
-      })
-      if (!flag) {
-        setTimeout(() => {
-          // 刷新正常产品列表
-          this.$refs.productNormalList.resetSearchForm()
-          // 刷新活动产品列表
-          if (this.activeList.length) this.$refs.productActiveList.resetSearchForm()
-        }, 500)
-      }
-    },
-    // 获取是否有新活动,
-    async getNewActive () {
-      const hasNewActive = await salesQueryUnPartPromo({ salesBillSn: this.$route.params.sn, enabledFlag: '1' }).then(res => res.data)
-      if (hasNewActive.length) {
-        this.newActiveList = hasNewActive
-        // 有则弹出弹框确认
-        this.showNewActiveModal = true
-      } else {
-        // 获取销售单详情
-        this.getOrderDetail(true)
-      }
-    },
-    // 新活动弹框确认后
-    showNewActiveOk (type) {
-      this.showNewActiveModal = false
-      // 特价规则排序
-      if (type == 1) {
-        this.getSalesPromoDiscountSort()
-      } else {
-        // 取消加入新活动
-        this.getOrderDetail(true)
-      }
-    },
-    // 特价规则排序列表
-    getSalesPromoDiscountSort () {
-      this.spinning = true
-      salesPromoDiscountSort({ salesBillSn: this.$route.params.sn }).then(res => {
-        if (res.status == 200) {
-          this.discountActiveList = res.data
-          this.showDiscountSortModal = res.data && res.data.length > 1
-          if (res.data && res.data.length <= 1) {
-            this.getOrderDetail(true)
-          }
-        }
-        this.spinning = false
-      })
-    },
-    // 特价规则排序完成或取消排序
-    showDiscountSortOk () {
-      this.showDiscountSortModal = false
-      this.getOrderDetail(true)
-    },
     // 打开选择产品弹框,type:0 正常产品,1活动产品,2累计产品
     openProductModal (type, promo) {
       this.$refs.chooseProduct.pageInit(this.detailData, promo, type)
       this.showCpModal = true
     },
     // 添加产品后,关闭弹框
-    closeProductModal (hasRefash) {
+    closeProductModal (hasRefash, type) {
       this.showCpModal = false
+      // 刷新产品列表和活动统计列表
       if (hasRefash) {
-        this.getActiveList()
-      }
-    },
-    // 获取指定活动的产品列表
-    getActiveProduct (active) {
-      this.salesPromoSnSet = active
-    },
-    // 添加活动产品成功的回调,刷新产品列表
-    // type:normal 正常列表 ,active 活动列表
-    // action:add 添加,del 删除,batchDel 批量删除,update 更新数据
-    refashTableData (type, action) {
-      // 如果是活动产品
-      if (type == 'promo') {
-        // 刷新正常产品列表
-        if (action != 'add') this.$refs.productNormalList.resetSearchForm()
-      } else if (type == 'normal') { // 如果是正常产品
-        // 刷新活动产品列表
-        if (this.activeList.length && action != 'add') this.$refs.productActiveList.resetSearchForm()
-      } else {
-        // 刷新正常产品列表
-        this.$refs.productNormalList.resetSearchForm()
-        // 刷新活动产品列表
-        if (this.activeList.length) this.$refs.productActiveList.resetSearchForm()
-      }
-      // 重新获取详情信息
-      this.getOrderDetail(false)
-      if (action != 'add') {
-        // 重新获取参与活动列表
-        this.getActiveList(true)
+        this.getActiveList(false)
+        if (type == 0) {
+          // 刷新活动产品列表
+          if (this.activeList.length) this.$refs.productActiveList.resetSearchForm()
+        } else {
+          // 刷新正常产品列表
+          this.$refs.productNormalList.resetSearchForm()
+        }
       }
     },
     // 确定新增产品到列表,
@@ -408,29 +312,24 @@ export default {
         if (cptype == 1) {
           if (this.activeList.length) this.$refs.productActiveList.saveNewProduct(row, promo, promoProductClz)
         }
+        // 累计产品
         if (cptype == 2) {
           if (this.activeList.length) this.$refs.productActiveList.accumulateProduct(row, promo, promoProductClz)
         }
       }
     },
-    // 更换活动,type 1 促销活动,0 正常活动
+    // type 1 更换活动,0 参与活动
     upActive (params, type) {
       salesChangePromo(params).then(res => {
         if (res.status == 200) {
+          // 刷新活动统计
+          this.getActiveList(false)
           if (type == 1) {
-            // 刷新活动产品
-            if (this.activeList.length) this.$refs.productActiveList.upAcitveSuccess()
-            // 刷新活动统计
-            if (this.activeList.length) this.$refs.activeTjList.getDataList()
-            // 刷新详情和正常产品列表
-            this.refashTableData('promo')
+            // 刷新正常产品列表
+            this.$refs.productNormalList.resetSearchForm()
           } else {
-            // 刷新正常活动
-            this.$refs.productNormalList.addAcitveSuccess()
-            // 刷新活动统计
-            if (this.activeList.length) this.$refs.activeTjList.getDataList()
-            // 刷新详情和活动产品列表
-            this.refashTableData('normal')
+            // 刷新活动产品列表
+            if (this.activeList.length) this.$refs.productActiveList.resetSearchForm()
           }
         }
       })
@@ -487,11 +386,6 @@ export default {
         }
       }
     },
-    // 校验销售价低于成本价提示成功,关闭弹窗
-    vaildPriceOk () {
-      this.tempData = null
-      this.openVaildPriceModal = false
-    },
     // 提交销售单
     async submitOrder (data) {
       this.spinning = true
@@ -512,6 +406,113 @@ export default {
       }
       this.spinning = false
     },
+    // 校验销售价低于成本价提示成功,关闭弹窗
+    vaildPriceOk () {
+      this.tempData = null
+      this.openVaildPriceModal = false
+    },
+    // 刷新查询列表数据
+    getTableListData () {
+      // 刷新正常产品列表
+      this.$refs.productNormalList.resetSearchForm()
+      // 刷新活动产品列表
+      if (this.activeList.length) this.$refs.productActiveList.resetSearchForm()
+    },
+    // 添加活动产品成功的回调,刷新产品列表
+    // type:normal 正常列表 ,active 活动列表
+    // action:add 添加,del 删除,batchDel 批量删除,update 更新数据
+    // 如果添加操作,不实时刷新列表,关闭后再刷新
+    refashTableData (type, action) {
+      // 重新获取详情信息
+      this.getOrderDetail(false)
+      // 如果是活动产品,刷新正常产品列表
+      if (type == 'promo') {
+        if (action != 'add') this.$refs.productNormalList.resetSearchForm()
+      } else if (type == 'normal') { // 如果是正常产品
+        // 刷新活动产品列表
+        if (this.activeList.length && action != 'add') this.$refs.productActiveList.resetSearchForm()
+      } else {
+        // 正常和活动列表都刷新
+        this.getTableListData()
+      }
+      // 非添加操作,重新获取参与活动列表
+      if (action != 'add') {
+        this.getActiveList(false)
+      }
+    },
+    // 获取销售单参与的活动列表,flag: true 查询产品明细列表,false 不查
+    async getActiveList (flag) {
+      this.spinning = true
+      // 已参与活动列表
+      const list = await salesPromoQueryList({ salesBillSn: this.$route.params.sn }).then(res => res.data || [])
+      this.activeList = list.filter(item => item.promotion && item.promotionRule)
+      // 触发活动统计查询变量
+      this.$nextTick(() => {
+        if (this.activeList.length) this.$refs.activeTjList.hasInit = false
+      })
+      this.spinning = false
+      if (flag) {
+        setTimeout(() => {
+          this.getTableListData()
+        }, 200)
+      }
+    },
+    //  销售单详情 flag: true 查询活动列表,false 不查
+    async getOrderDetail (flag) {
+      this.spinning = true
+      const detail = await salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => res.data)
+      if (detail) {
+        this.detailData = detail
+        this.detailData.totalDiscountAmount = Number(this.detailData.totalOrigAmount || 0) - Number(this.detailData.totalAmount || 0)
+      }
+      this.spinning = false
+      if (flag) {
+        // 获取活动列表
+        this.getActiveList(true)
+      }
+    },
+    // 获取是否有新活动,
+    async getNewActive () {
+      const hasNewActive = await salesQueryUnPartPromo({ salesBillSn: this.$route.params.sn, enabledFlag: '1' }).then(res => res.data)
+      if (hasNewActive.length) {
+        this.newActiveList = hasNewActive
+        // 有则弹出参与新活动弹框
+        this.showNewActiveModal = true
+      } else {
+        // 获取销售单详情
+        this.getOrderDetail(true)
+      }
+    },
+    // 新活动弹框确认后
+    showNewActiveOk (type) {
+      this.showNewActiveModal = false
+      // 特价规则排序
+      if (type == 1) {
+        this.getSalesPromoDiscountSort()
+      } else {
+        // 取消加入新活动
+        this.getOrderDetail(true)
+      }
+    },
+    // 特价规则排序列表
+    getSalesPromoDiscountSort () {
+      this.spinning = true
+      salesPromoDiscountSort({ salesBillSn: this.$route.params.sn }).then(res => {
+        if (res.status == 200) {
+          this.discountActiveList = res.data
+          this.showDiscountSortModal = res.data && res.data.length > 1
+          if (res.data && res.data.length <= 1) {
+            this.getOrderDetail(true)
+          }
+        }
+        this.spinning = false
+      })
+    },
+    // 特价规则排序完成或取消排序
+    showDiscountSortOk () {
+      this.showDiscountSortModal = false
+      this.getOrderDetail(true)
+    },
     // 页面初始化
     pageInit () {
       this.salesBillSn = this.$route.params.sn