|
@@ -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>
|