فهرست منبع

【年销售目标合并】
1.删除、收回、查询接口联调;
2.区域目标汇总(年),客户目标汇总(年)数据赋值,目标合计

002390 1 سال پیش
والد
کامیت
40388c2c81

+ 18 - 4
src/views/business/spd/target/AnnualSaleGoalMerge.vue

@@ -147,7 +147,7 @@
             >提交</el-button
           >
           <el-button
-            v-if="scope.row.status == '1'"
+            v-if="scope.row.status == '1' && scope.row.flowId"
             :size="size"
             type="text"
             @click="handleReback(scope.row)"
@@ -173,8 +173,9 @@ import { dicts } from "./common/dicts";
 import useColumns from "./common/AnnualSaleGoalMerge/columns";
 import { rollBack } from "@/api/business/spd/goal_management/publicInterface";
 import {
-  listAnnualSaleGoalMerge,
   submit,
+  delAnnualSaleGoalMerge,
+  listAnnualSaleGoalMerge,
 } from "@/api/business/spd/goal_management/annualSaleGoalMerge";
 export default {
   name: "AnnualSaleGoalMerge",
@@ -210,9 +211,21 @@ export default {
     async getList(params, page) {
       try {
         this.loading = true;
-        let { code, rows, total } = await listAnnualSaleGoalMerge({
+        let queryParams = {
           ...params,
           ...page,
+          params: {
+            beginTime: params.documentDateRange
+              ? params.documentDateRange[0]
+              : null,
+            endTime: params.documentDateRange
+              ? params.documentDateRange[1]
+              : null,
+          },
+        };
+        delete queryParams.documentDateRange;
+        let { code, rows, total } = await listAnnualSaleGoalMerge({
+          ...queryParams,
         });
         if (code == 200) {
           this.tableData = rows;
@@ -283,12 +296,13 @@ export default {
       setVisible(true);
     },
     // 删除
-    handleDelete() {
+    handleDelete(row) {
       this.$modal
         .confirm("是否确认删除?")
         .then(async () => {
           try {
             this.$modal.loading("处理中,请稍后...");
+            console.log(row.id, "id");
             const { code, msg } = await delAnnualSaleGoalMerge(row.id);
             if (code == 200) {
               this.$modal.notifySuccess(msg);

+ 117 - 26
src/views/business/spd/target/common/AnnualSaleGoalMerge/details/columns.js

@@ -182,56 +182,147 @@ export default function useColumns() {
           attr: {},
         },
         {
-          item: { key: "totalGoal", title: "合计(元)" },
-          attr: {},
+          item: { key: "totalGoal", title: "合计(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            disabled: true,
+            isSummary: true,
+          },
         },
         {
-          item: { key: "januaryGoal", title: "一月(元)" },
-          attr: {},
+          item: { key: "januaryGoal", title: "一月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "februaryGoal", title: "二月(元)" },
-          attr: {},
+          item: { key: "februaryGoal", title: "二月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "marchGoal", title: "三月(元)" },
-          attr: {},
+          item: { key: "marchGoal", title: "三月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "aprilGoal", title: "四月(元)" },
-          attr: {},
+          item: { key: "aprilGoal", title: "四月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "mayGoal", title: "五月(元)" },
-          attr: {},
+          item: { key: "mayGoal", title: "五月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "juneGoal", title: "六月(元)" },
-          attr: {},
+          item: { key: "juneGoal", title: "六月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "julyGoal", title: "七月(元)" },
-          attr: {},
+          item: { key: "julyGoal", title: "七月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "augustGoal", title: "八月(元)" },
-          attr: {},
+          item: { key: "augustGoal", title: "八月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "septemberGoal", title: "九月(元)" },
-          attr: {},
+          item: { key: "septemberGoal", title: "九月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "octoberGoal", title: "十月(元)" },
-          attr: {},
+          item: { key: "octoberGoal", title: "十月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "novemberGoal", title: "十一月(元)" },
-          attr: {},
+          item: { key: "novemberGoal", title: "十一月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
         {
-          item: { key: "decemberGoal", title: "十二月(元)" },
-          attr: {},
+          item: { key: "decemberGoal", title: "十二月(元)", },
+          attr: {
+            is: "el-input-number",
+            min: 0,
+            step: 0.1,
+            precision: 2,
+            isSummary: true,
+            controlsPosition: "right",
+          },
         },
       ],
     },

+ 232 - 1
src/views/business/spd/target/common/AnnualSaleGoalMerge/details/index.vue

@@ -253,6 +253,100 @@ export default {
         return this.$message.warning("请选择二级分类");
       }
     },
+    // 改变一至十二月份(元)
+    changeMonth(prop) {
+      const month = [
+        "januaryGoal",
+        "februaryGoal",
+        "marchGoal",
+        "aprilGoal",
+        "mayGoal",
+        "juneGoal",
+        "julyGoal",
+        "augustGoal",
+        "septemberGoal",
+        "octoberGoal",
+        "novemberGoal",
+        "decemberGoal",
+      ];
+      this.params.goalTotal = this.params["annualGoalMergeDetailsList"].reduce(
+        (sum, item) => {
+          const rowSum = month.reduce((sum, m) => {
+            return (sum += (item[m] ? item[m] : 0) * 1);
+          }, 0);
+          return (sum += rowSum);
+        },
+        0
+      );
+      if (prop) {
+        let { row } = prop;
+        row["totalGoal"] = month.reduce((sum, item) => {
+          return (sum += (row[item] ? row[item] : 0) * 1);
+        }, 0);
+      }
+      // 实时统计
+      this.$refs.annualGoalMergeDetailsList[0].updateFooter();
+    },
+    tabClick({ name }) {
+      const { annualGoalMergeDetailsList, areaDetailList, customerDetailList } =
+        this.params;
+      let arr = _.cloneDeep(annualGoalMergeDetailsList);
+
+      if (name === "annualGoalMergeDetailsList") {
+        this.params.areaDetailList = [];
+        this.params.customerDetailList = [];
+        return;
+      }
+      // 根据某三个属性进行合并并相加totalGoal的函数
+      const mergeAndSumTotalGoal = (array) => {
+        return Array.from(
+          array
+            .reduce((map, obj) => {
+              let key = `${obj.saleOrg}-${obj.saleZone}-${
+                name === "areaDetailList" ? obj.creator : obj.custom
+              }`;
+
+              console.log(key, "key---------------");
+              if (map.has(key)) {
+                const existingObj = map.get(key);
+                existingObj.totalGoal = parseFloat(existingObj.totalGoal);
+                existingObj.totalGoal += parseFloat(obj.totalGoal);
+                existingObj.totalGoal = existingObj.totalGoal.toFixed(2);
+                existingObj.januaryGoal += obj.januaryGoal;
+                existingObj.februaryGoal += obj.februaryGoal;
+                existingObj.marchGoal += obj.marchGoal;
+                existingObj.aprilGoal += obj.aprilGoal;
+                existingObj.mayGoal += obj.mayGoal;
+                existingObj.juneGoal += obj.juneGoal;
+                existingObj.julyGoal += obj.julyGoal;
+                existingObj.augustGoal += obj.augustGoal;
+                existingObj.septemberGoal += obj.septemberGoal;
+                existingObj.octoberGoal += obj.octoberGoal;
+                existingObj.novemberGoal += obj.novemberGoal;
+                existingObj.decemberGoal += obj.decemberGoal;
+              } else {
+                map.set(key, {
+                  ...obj,
+                });
+              }
+              return map;
+            }, new Map())
+            .values()
+        );
+      };
+
+      // 调用合并函数
+      const mergedArray = mergeAndSumTotalGoal(arr);
+      console.log(name, "name", mergedArray, " mergedArray");
+
+      this.params = {
+        ...this.params,
+        areaDetailList:
+          name === "areaDetailList" ? mergedArray : areaDetailList,
+        customerDetailList:
+          name === "customerDetailList" ? mergedArray : customerDetailList,
+      };
+    },
   },
   created() {},
 };
@@ -369,7 +463,11 @@ export default {
       >
     </el-row>
 
-    <el-tabs v-model="tabName" style="margin: 0 20px; position: relative">
+    <el-tabs
+      v-model="tabName"
+      @tab-click="tabClick"
+      style="margin: 0 20px; position: relative"
+    >
       <el-tab-pane
         v-for="({ item, TableColumns: columns }, index) in TabColumns"
         :key="index"
@@ -385,6 +483,139 @@ export default {
           :size="$attrs.size"
           :height="tableHeight"
         >
+          <!-- 一至十二月 -->
+          <template slot="januaryGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="februaryGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="marchGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="aprilGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="mayGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="juneGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="julyGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="augustGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="septemberGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="octoberGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="novemberGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
+          <template slot="decemberGoal" slot-scope="scope">
+            <component
+              v-bind="scope.attr"
+              v-model="scope.row[scope.item.key]"
+              :size="$attrs.size"
+              :source.sync="scope.row"
+              :disabled="addType == 'see'"
+              @change="changeMonth(scope)"
+            >
+            </component>
+          </template>
         </el-super-ux-table>
       </el-tab-pane>
     </el-tabs>