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