Răsfoiți Sursa

lizhuo merges Goal Management into dev at 2023-8-1 9:00

002637 1 an în urmă
părinte
comite
87f04b122f

+ 22 - 13
src/views/business/spd/goal_management/AnnualSaleGoalMerge.vue

@@ -1047,6 +1047,18 @@ export default {
         ...this.queryParams
       }, `annualSaleMergeDetails_${new Date().getTime()}.xlsx`)
     },
+    // 导出区域目标汇总
+    handleExportZoneSum() {
+      this.download('goal_management/annualSaleMergeDetails/exportZoneSum', {
+        ...this.queryParams
+      }, `zoneSum_${new Date().getTime()}.xlsx`)
+    },
+    // 导出客户目标汇总
+    handleExportCustomSum() {
+      this.download('goal_management/annualSaleMergeDetails/exportCustomSum', {
+        ...this.queryParams
+      }, `customSum_${new Date().getTime()}.xlsx`)
+    },
     // 树形参照
     chooseTreeReferForQuery(type, isPage, title) {
       this.referCondition.type = type
@@ -1226,27 +1238,22 @@ export default {
       if (this.activeName !== 'annualSaleGoalMergeDetails') {
         return this.$message.error('当前标签不是年销售目标合并明细')
       }
-      let classify = this.form.goalCategory
-      let classifyValue;
-      if (classify === null || classify === '') {
+      let query = JSON.parse(JSON.stringify(this.form))
+      if (query.goalCategory === null || query.goalCategory === '') {
         return this.$message.error('请输入目标分类')
-      } else if (classify === '销售区域') {
-        classifyValue = this.form.saleZone
-        if (classifyValue === null) {
+      } else if (query.goalCategory === '销售区域') {
+        if (query.saleZone === null) {
           return this.$message.error('请输入销售区域')
         }
-      } else if (classify === '一级分类') {
-        classifyValue = this.form.oneLevelClassify
-        if (classifyValue === null) {
+      } else if (query.goalCategory === '一级分类') {
+        if (query.oneLevelClassify === null) {
           return this.$message.error('请输入一级分类')
         }
-      } else if (classify === '二级分类') {
-        classifyValue = this.form.twoLevelClassify
-        if (classifyValue === null) {
+      } else if (query.goalCategory === '二级分类') {
+        if (query.twoLevelClassify === null) {
           return this.$message.error('请输入二级分类')
         }
       }
-      let query = { classify: classify, classifyValue: classifyValue }
       mergeAnnualSaleMergeDetails(query).then(response => {
         console.log(response);
         this.annualSaleGoalMergeDetailsList = response.data.consolidatedDetail
@@ -1315,8 +1322,10 @@ export default {
         this.handleExportDetails()
       } else if (command === 'exportZoneSum') {
         console.log('导出区域目标汇总')
+        this.handleExportZoneSum()
       } else if (command === 'exportCustomSum') {
         console.log('导出客户目标汇总')
+        this.handleExportCustomSum()
       }
     }
   }

+ 129 - 21
src/views/business/spd/goal_management/MonthGoalMerge.vue

@@ -325,14 +325,11 @@
       </el-form>
 
       <el-row :gutter="10" class="mb8">
-<!--        <el-col :span="1.5">
-          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddDetails">增 行</el-button>
-        </el-col>-->
         <el-col :span="1.5">
           <el-button type="primary" plain icon="el-icon-folder-opened" size="mini" @click="clickMerge">合 并</el-button>
         </el-col>
       </el-row>
-      <el-tabs v-model="activeName">
+      <el-tabs v-model="activeName" @tab-click="getNewTwoArray">
         <el-tab-pane label="月销售目标合并明细" name="monthGoalMergeDetails">
           <el-table v-loading="loading" :data="monthGoalMergeDetailsList" @selection-change="handleSelectionChange">
             <el-table-column type="selection" width="55" align="center" fixed />
@@ -442,6 +439,83 @@
             </el-table-column>-->
           </el-table>
         </el-tab-pane>
+        <el-tab-pane label="区域目标汇总(月)" name="zoneGoalSum">
+          <el-table :data="zoneGoalSumList">
+            <el-table-column label="序号" type="index" width="55" align="center" fixed />
+            <el-table-column label="销售组织" align="center" prop="saleOrg" width="180">
+              <template slot-scope="scope">
+                <el-popover-select-v2 v-model="zoneGoalSumList[scope.$index].saleOrg" title="销售组织" valueKey="name"
+                                      referName="CUSTOMER_PARAM" disabled
+                                      :dataMapping="{ saleOrgCode: 'code', saleOrg: 'name'}"
+                                      :source.sync="zoneGoalSumList[scope.$index]" placeholder="请输入销售组织">
+                </el-popover-select-v2>
+              </template>
+            </el-table-column>
+            <el-table-column label="销售区域" align="center" prop="saleZone" width="180">
+              <template slot-scope="scope">
+                <el-popover-select-v2 v-model="zoneGoalSumList[scope.$index].saleZone" title="销售区域" valueKey="name"
+                                      referName="CUSTOMER_PARAM" disabled
+                                      :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
+                                      :source.sync="zoneGoalSumList[scope.$index]" placeholder="请输入销售区域">
+                </el-popover-select-v2>
+              </template>
+            </el-table-column>
+            <el-table-column label="月份" align="center" prop="monthly" width="250">
+              <template slot-scope="scope">
+                <el-date-picker disabled v-model="zoneGoalSumList[scope.$index].monthly" value-format="yyyy-MM" type="month" placeholder="选择月份">
+                </el-date-picker>
+              </template>
+            </el-table-column>
+            <el-table-column label="目标值" align="center" prop="totalGoal" width="220">
+              <template slot-scope="scope">
+                <el-input-number @change="computeTotal" v-model="zoneGoalSumList[scope.$index].goalValue" :precision="2" :step="1" :min="0" disabled></el-input-number>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-tab-pane>
+        <el-tab-pane label="客户目标汇总(月)" name="customGoalSum">
+          <el-table :data="customGoalSumList">
+            <el-table-column label="序号" type="index" width="55" align="center" fixed />
+            <el-table-column label="销售组织" align="center" prop="saleOrg" width="180">
+              <template slot-scope="scope">
+                <el-popover-select-v2 v-model="customGoalSumList[scope.$index].saleOrg" title="销售组织" valueKey="name"
+                                      referName="CUSTOMER_PARAM" disabled
+                                      :dataMapping="{ saleOrgCode: 'code', saleOrg: 'name'}"
+                                      :source.sync="customGoalSumList[scope.$index]" placeholder="请输入销售组织">
+                </el-popover-select-v2>
+              </template>
+            </el-table-column>
+            <el-table-column label="销售区域" align="center" prop="saleZone" width="180">
+              <template slot-scope="scope">
+                <el-popover-select-v2 v-model="customGoalSumList[scope.$index].saleZone" title="销售区域" valueKey="name"
+                                      referName="CUSTOMER_PARAM" disabled
+                                      :dataMapping="{ saleZoneCode: 'code', saleZone: 'name'}"
+                                      :source.sync="customGoalSumList[scope.$index]" placeholder="请输入销售区域">
+                </el-popover-select-v2>
+              </template>
+            </el-table-column>
+            <el-table-column label="客户" align="center" prop="custom" width="180">
+              <template slot-scope="scope">
+                <el-popover-select-v2 v-model="customGoalSumList[scope.$index].custom" title="客户" valueKey="name"
+                                      referName="CUSTOMER_PARAM" disabled
+                                      :dataMapping="{ customCode: 'code', custom: 'name'}"
+                                      :source.sync="customGoalSumList[scope.$index]" placeholder="请输入客户">
+                </el-popover-select-v2>
+              </template>
+            </el-table-column>
+            <el-table-column label="月份" align="center" prop="monthly" width="250">
+              <template slot-scope="scope">
+                <el-date-picker disabled v-model="customGoalSumList[scope.$index].monthly" value-format="yyyy-MM" type="month" placeholder="选择月份">
+                </el-date-picker>
+              </template>
+            </el-table-column>
+            <el-table-column label="目标值" align="center" prop="totalGoal" width="220">
+              <template slot-scope="scope">
+                <el-input-number @change="computeTotal" v-model="customGoalSumList[scope.$index].goalValue" :precision="2" :step="1" :min="0" disabled></el-input-number>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-tab-pane>
       </el-tabs>
     </el-drawer>
 
@@ -491,6 +565,8 @@ export default {
       // 月销售目标合并表格数据
       monthGoalMergeList: [],
       monthGoalMergeDetailsList: [],
+      zoneGoalSumList: [],
+      customGoalSumList: [],
       // 弹出层标题
       title: "",
       // 是否显示弹出层
@@ -1042,32 +1118,29 @@ export default {
     },
     // 合并数据
     clickMerge() {
-      let classify = this.form.goalCategory
-      let classifyValue;
-      if (classify === null || classify === '') {
+      if (this.activeName !== 'monthGoalMergeDetails') {
+        return this.$message.error('当前标签不是月销售目标合并明细')
+      }
+      let query = JSON.parse(JSON.stringify(this.form))
+      if (query.goalCategory === null || query.goalCategory === '') {
         return this.$message.error('请输入目标分类')
-      } else if (classify === '销售区域') {
-        classifyValue = this.form.saleZone
-        if (classifyValue === null) {
+      } else if (query.goalCategory === '销售区域') {
+        if (query.saleZone === null) {
           return this.$message.error('请输入销售区域')
         }
-      } else if (classify === '一级分类') {
-        classifyValue = this.form.oneLevelClassify
-        if (classifyValue === null) {
+      } else if (query.goalCategory === '一级分类') {
+        if (query.oneLevelClassify === null) {
           return this.$message.error('请输入一级分类')
         }
-      } else if (classify === '二级分类') {
-        classifyValue = this.form.twoLevelClassify
-        if (classifyValue === null) {
+      } else if (query.goalCategory === '二级分类') {
+        if (query.twoLevelClassify === null) {
           return this.$message.error('请输入二级分类')
         }
-      } else if (classify === '客户维度') {
-        classifyValue = this.form.custom
-        if (classifyValue === null) {
+      } else if (query.goalCategory === '客户维度') {
+        if (query.custom === null) {
           return this.$message.error('请输入客户')
         }
       }
-      let query = { classify: classify, classifyValue: classifyValue }
       mergeMonthSaleMergeDetails(query).then(response => {
         console.log(response);
         this.monthGoalMergeDetailsList = response.data.monthGoalMergeDetails
@@ -1099,7 +1172,42 @@ export default {
         console.log('导出明细');
         this.handleExportDetails()
       }
-    }
+    },
+    // 获得区域目标汇总or客户目标汇总
+    getNewTwoArray() {
+      let arr = JSON.parse(JSON.stringify(this.monthGoalMergeDetailsList))
+      // 如果子表标签是annualSaleGoalMergeDetails 或者 主表的目标分类是“销售区域”
+      if (this.activeName === 'monthGoalMergeDetails' || this.form.goalCategory !== '销售区域') {
+        this.zoneGoalSumList = null
+        this.customGoalSumList = null
+        return
+      }
+      // 根据某三个属性进行合并并相加totalGoal的函数
+      const mergeAndSumTotalGoal = (array) => {
+        return Array.from(array.reduce((map, obj) => {
+          let key = null
+          if (this.activeName === 'zoneGoalSum') {
+            key = `${obj.saleOrg}-${obj.saleZone}-${obj.monthly}`
+          } else if (this.activeName === 'customerGoalSum') {
+            key = `${obj.saleOrg}-${obj.saleZone}-${obj.custom}-${obj.monthly}`
+          }
+          if (map.has(key)) {
+            const existingObj = map.get(key)
+            existingObj.goalValue += obj.goalValue
+          } else {
+            map.set(key, { ...obj })
+          }
+          return map
+        }, new Map()).values())
+      }
+      // 调用合并函数
+      const mergedArray = mergeAndSumTotalGoal(arr)
+      if (this.activeName === 'zoneGoalSum') {
+        this.zoneGoalSumList = mergedArray
+      } else if (this.activeName === 'customGoalSum') {
+        this.customGoalSumList = mergedArray
+      }
+    },
   }
 };
 </script>

+ 10 - 4
src/views/business/spd/goal_management/MonthReturnMerge.vue

@@ -126,6 +126,7 @@
         <el-dropdown-menu slot="dropdown">
           <el-dropdown-item command="export">导出</el-dropdown-item>
           <el-dropdown-item command="exportDetails">导出明细</el-dropdown-item>
+          <el-dropdown-item command="exportZoneSum">导出区域目标汇总</el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
     </el-col>
@@ -699,6 +700,11 @@ export default {
         ...this.queryParams
       }, `monthReturnMergeDetails_${new Date().getTime()}.xlsx`)
     },
+    handleExportZoneSum() {
+      this.download('mk/monthReturnMergeDetails/exportZoneSum', {
+        ...this.queryParams
+      }, `zoneSum_${new Date().getTime()}.xlsx`)
+    },
     // 关闭抽屉
     handleClose(done) {
       this.$confirm('确认关闭?')
@@ -716,10 +722,7 @@ export default {
       if (this.form.custom === null) {
         return this.$message.error('请输入客户')
       }
-      let classify = this.form.goalCategory
-      let classifyValue = this.form.custom
-      let query = { classify: classify, classifyValue: classifyValue }
-      mergeMonthReturnMergeDetails(query).then(response => {
+      mergeMonthReturnMergeDetails(this.form).then(response => {
         console.log(response)
         this.monthReturnMergeDetailsList = response.data.monthReturnMergeDetails
         this.computeTotal()
@@ -796,6 +799,9 @@ export default {
       } else if (command === 'exportDetails') {
         console.log('导出明细');
         this.handleExportDetails()
+      } else if (command === 'exportZoneSum') {
+        console.log('导出区域目标汇总');
+        this.handleExportZoneSum()
       }
     }
   }