Browse Source

合并转费用单

lilei 11 tháng trước cách đây
mục cha
commit
8581bae27c

+ 22 - 1
src/api/salesNew.js

@@ -237,7 +237,28 @@ export const queryBatchCreateBySalesBillSn = (params) => {
     method: 'post'
   })
 }
-
+// 批量查询合并后的报销单
+export const queryBatchCreateBySalesPromoSnListGroupType = (params) => {
+  return axios({
+    url: `/expenseAccount/queryBatchCreateBySalesPromoSnListGroupType`,
+    data: params,
+    method: 'post',
+    headers:{
+      'module': encodeURIComponent('销售单合并后转费用报销单')
+    }
+  })
+}
+// 保存合并选项
+export const expenseAccountSaveGroupType = (params) => {
+  return axios({
+    url: `/expenseAccount/saveCreateGroupType`,
+    data: params,
+    method: 'post',
+    headers:{
+      'module': encodeURIComponent('销售单转费用报销单,确定合并')
+    }
+  })
+}
 // 保存费用报销单
 export const expenseAccountSave = (params) => {
   return axios({

+ 6 - 1
src/views/expenseManagement/expenseReimbursement/baseDataModal.vue

@@ -281,7 +281,12 @@ export default {
           _this.spinning = true
           // 从销售单转的费用
           if (_this.fromPage == 'sales') {
-            _this.$emit('expenseSaveOk', form)
+            _this.$emit('expenseSaveOk', form, this.fromPage)
+            return false
+          }
+          // 从销售单转的费用,并合并提交
+          if (_this.fromPage == 'salesMearge') {
+            _this.$emit('expenseSaveOk', form, this.fromPage)
             return false
           }
           // 手动建的费用单

+ 50 - 43
src/views/salesManagement/waitCostOrder/list.vue

@@ -135,7 +135,7 @@ import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
 import baseDataModal from '@/views/expenseManagement/expenseReimbursement/baseDataModal.vue'
 import viewSelectModal from './viewSelectModal.vue'
 import meargeOptionModal from './meargeOptionModal.vue'
-import { salesConvertExpenseList, expenseAccountSave, queryBatchCreateBySalesBillSn } from '@/api/salesNew'
+import { salesConvertExpenseList, expenseAccountSave, queryBatchCreateBySalesBillSn, expenseAccountSaveGroupType, queryBatchCreateBySalesPromoSnListGroupType } from '@/api/salesNew'
 export default {
   name: 'WaitCostOrder',
   mixins: [commonMixin],
@@ -242,56 +242,57 @@ export default {
     },
     // 合并提交
     handleMerge () {
-      const _this = this
-      const salesPromoSnList = []
-      const slen = _this.rowSelectionInfo.selectedRowKeys.length
-      if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
-        _this.$message.warning('请在列表勾选后再进行合并提交操作!')
+      if (!this.hasSelect) {
+        this.$message.warning('请先勾选再合并提交!')
         return
       }
-      // 批量合并提交
-      this.rowSelectionInfo.selectedRows.map(item => {
-        salesPromoSnList.push(item.salesPromoSn)
-      })
       // 打开合并选项弹框
       this.showMeargeModal = true
     },
     // 确定合并
-    meargeOk (data) {
-      console.log(data)
-      // 打开已合并的待转费用报销单弹框
-      if (!this.hasSelect) {
-        this.$message.warning('请先勾选再合并提交!')
-        return
-      }
-      this.showViewModal = true
-      this.$refs.viewModal.title = '已合并的待转费用报销单'
-      this.$refs.viewModal.submitType = 'mearge'
-      this.$refs.viewModal.setData(this.rowSelectionInfo && this.rowSelectionInfo.selectedRows)
-    },
-    // 合并提交
-    meargeSubmit (data) {
+    meargeOk (groupType) {
+      // 批量合并
       const salesPromoSnList = []
-      data.map(item => {
+      this.rowSelectionInfo.selectedRows.map(item => {
         salesPromoSnList.push(item.salesPromoSn)
       })
-      // 打开转费用单弹框
-      this.handleExpense(salesPromoSnList)
+      const params = {
+        salesPromoSnList: salesPromoSnList,
+        groupType: groupType
+      }
+      // 开始合并
+      queryBatchCreateBySalesPromoSnListGroupType(params).then(res => {
+        // 打开已合并的待转费用报销单弹框
+        if (res.status == 200) {
+          const list = res.data && res.data.detailList || []
+          if (list.length) {
+            // 打开查看弹框
+            this.showViewModal = true
+            this.$refs.viewModal.title = '已合并的待转费用报销单'
+            this.$refs.viewModal.submitType = 'mearge'
+            this.$refs.viewModal.setData(list, res.data)
+          } else {
+            this.$message.warning('没有可合并的待转费用报销单!')
+          }
+        }
+      })
     },
-    // 直接不合并提交
+    // 确定合并提交转费用单弹框
+    meargeSubmit (data) {
+      this.expenseSave(data, 'salesMearge')
+    },
+    // 直接提交(不合并)
     handleSave (row) {
-      const _this = this
       const salesPromoSnList = []
       // 单个转
       if (row) {
         salesPromoSnList.push(row.salesPromoSn)
       } else {
-        const slen = _this.rowSelectionInfo.selectedRowKeys.length
-        if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && slen < 1)) {
-          _this.$message.warning('请在列表勾选后再进行提交操作!')
+        // 批量转
+        if (!this.hasSelect) {
+          this.$message.warning('请在列表勾选后再进行提交操作!')
           return
         }
-        // 批量转
         this.rowSelectionInfo.selectedRows.map(item => {
           salesPromoSnList.push(item.salesPromoSn)
         })
@@ -304,28 +305,34 @@ export default {
       const _this = this
       this.spinning = true
       const hasExpense = await queryBatchCreateBySalesBillSn({ salesPromoSnList: snList }).then(res => res.data || [])
-
       let result = null
       for (const key in hasExpense) {
         result = hasExpense[key]
       }
-      // 关闭查看弹框
-      this.$refs.viewModal.spinning = false
-      this.showViewModal = false
       // 转费用单弹框
-      _this.expenseSave(result)
+      _this.expenseSave(result, 'sales')
     },
-    // 打开新建转费用单弹框
-    expenseSave (data) {
+    // 新建转费用单
+    expenseSave (data, type) {
       if (data) {
+        // 关闭查看弹框
+        this.$refs.viewModal.spinning = false
+        this.showViewModal = false
+        // 打开新建转费用单弹框
         this.openBaseModal = true
-        this.$refs.expenseModal.setDetail(data, 'sales')
+        this.$refs.expenseModal.setDetail(data, type)
+        this.spinning = false
+      } else {
         this.spinning = false
       }
     },
     // 转费用单成功
-    expenseSaveOk (params) {
-      expenseAccountSave(params).then(res => {
+    expenseSaveOk (params, type) {
+      // type:
+      // sales:不合并
+      // salesMearge:合并转
+      const fun = type == 'sales' ? expenseAccountSave : expenseAccountSaveGroupType
+      fun(params).then(res => {
         if (res.status == 200) {
           this.$message.info(res.message)
           this.openBaseModal = false

+ 16 - 3
src/views/salesManagement/waitCostOrder/meargeOptionModal.vue

@@ -42,13 +42,23 @@ export default {
       isShow: this.openModal,
       sameCustomeName: true, // 是否勾选相同客户名称
       sameRules1: undefined, // 相同促销活动
-      sameRules2: undefined // 相同活动规则(同一促销活动)
+      sameRules2: undefined, // 相同活动规则(同一促销活动)
+      groupType: 'CUSTOMER'
     }
   },
   methods: {
     // 确定提交
     submit () {
-      this.$emit('meargeOk', { sameRules1: this.sameRules1, sameRules2: this.sameRules2 })
+      if (!this.sameRules1 && !this.sameRules2) {
+        this.groupType = 'CUSTOMER' // 相同客户名称
+      } else {
+        if (this.sameRules1) {
+          this.groupType = 'CUSTOMER_PROMO' // 相同促销活动
+        } else if (this.sameRules2) {
+          this.groupType = 'CUSTOMER_PROMO_RULE' // 相同活动规则(同一促销活动)
+        }
+      }
+      this.$emit('meargeOk', this.groupType)
       this.isShow = false
     }
   },
@@ -59,7 +69,10 @@ export default {
     isShow (nVal, oVal) {
       if (!nVal) {
         this.$emit('close')
-        this.sameRules = undefined
+      } else {
+        this.sameRules1 = undefined
+        this.sameRules2 = undefined
+        this.groupType = 'CUSTOMER'
       }
     }
   }

+ 10 - 3
src/views/salesManagement/waitCostOrder/viewSelectModal.vue

@@ -62,7 +62,8 @@ export default {
       tableHeight: 450, // 表格高度
       dataSource: [], // 列表数据
       title: '已选待转费用报销单',
-      submitType: 'noMearge' // 默认是,直接勾选的数据,不是合并后的数据
+      submitType: 'noMearge', // 默认是,直接勾选的数据,不是合并后的数据
+      otherData: null // 其它参数
     }
   },
   computed: {
@@ -83,16 +84,22 @@ export default {
   },
   methods: {
     // 设置列表数据
-    setData (list) {
+    setData (list, data) {
+      this.otherData = data
       this.dataSource = JSON.parse(JSON.stringify(list))
       this.dataSource.map((item, index) => {
         item.no = index + 1
+        // 合并列表字段不一样
+        if (this.submitType == 'mearge') {
+          item.convertExpenseAccountTypeDictValue = item.expenseTypeName
+          item.promotionRuleTypeDictValue = item.promotionRuleTypeName
+        }
       })
     },
     // 继续提交
     submit () {
       this.spinning = true
-      this.$emit('submit', this.dataSource)
+      this.$emit('submit', this.submitType == 'noMearge' ? this.dataSource : this.otherData)
     },
     // 关闭弹框
     cancel () {

+ 2 - 2
vue.config.js

@@ -108,9 +108,9 @@ const vueConfig = {
     // If you want to turn on the proxy, please remosve the mockjs /src/main.jsL11
     proxy: {
       '/api': {
-        // target: 'http://192.168.2.113:8660/ocs-admin',
+        target: 'http://192.168.2.124:8602/ocs-admin',
         // target: 'https://t.ocs.360arrow.com/ocs-admin', //  练习
-        target: 'https://p.ocs.360arrow.com/ocs-admin', //  预发布
+        // target: 'https://p.ocs.360arrow.com/ocs-admin', //  预发布
         ws: false,
         changeOrigin: true,
         pathRewrite: {