diff --git a/src/views/kpi/assessment/goals/index.vue b/src/views/kpi/assessment/goals/index.vue index 53e0897..92afe49 100644 --- a/src/views/kpi/assessment/goals/index.vue +++ b/src/views/kpi/assessment/goals/index.vue @@ -411,7 +411,27 @@ export default { async handleGetNext () { // 提交绩效详情 const arr = this.handleFilter(this.obj.recortModelDtos) - if (arr.some(i => i.weight === null)) { + let weight = 0 + for (let i in arr) { + let num = 0 + this.handleFilter(arr[i].detailDtos).map(l => { + num += l.checkWeight + }) + if (arr[i].weight !== null) { + // 维度有设置权重的 + if (num.toFixed(2) !== arr[i].weight.toFixed(2)) { + return this.$message.error(arr[i].name + '维度内的权重和必须为' + Math.round((arr[i].weight * 100) * 1000) / 1000) + } + } + weight += num + } + if (Math.round((weight * 100) * 1000) / 1000 !== 100) { + let str = arr.map(i => i.name).join(',') + this.$message.error(str + '维度内的权重和必须为100%!') + return + } + /* if (arr.some(i => i.weight === null)) { + // 有维度没有限制权重 let weight = 0 let maxWeight = 0 const nullArray = arr.map(i => { @@ -436,7 +456,7 @@ export default { return this.$message.error(arr[i].name + '维度内的权重和必须为' + Math.round((arr[i].weight * 100) * 1000) / 1000) } } - } + } */ this.obj.recortModelDtos.map(i => { i.detailDtos.map(j => { @@ -489,7 +509,27 @@ export default { if (type === 1) { // 保存绩效详情 const arr = this.handleFilter(this.obj.recortModelDtos) - if (arr.some(i => i.weight === null)) { + let weight = 0 + for (let i in arr) { + let num = 0 + this.handleFilter(arr[i].detailDtos).map(l => { + num += l.checkWeight + }) + if (arr[i].weight !== null) { + // 维度有设置权重的 + if (num.toFixed(2) !== arr[i].weight.toFixed(2)) { + return this.$message.error(arr[i].name + '维度内的权重和必须为' + Math.round((arr[i].weight * 100) * 1000) / 1000) + } + } + weight += num + } + if (Math.round((weight * 100) * 1000) / 1000 !== 100) { + let str = arr.map(i => i.name).join(',') + this.$message.error(str + '维度内的权重和必须为100%!') + return + } + /* if (arr.some(i => i.weight === null)) { + // 有维度没有限制权重 let weight = 0 let maxWeight = 0 const nullArray = arr.map(i => { @@ -515,7 +555,7 @@ export default { return this.$message.error(arr[i].name + '维度内的权重和必须为' + Math.round((arr[i].weight * 100) * 1000) / 1000) } } - } + } */ } // 保存和暂存绩效详情直接走下面 params.recortModelDtos.map(i => { diff --git a/src/views/kpi/assessment/performance/components/UseButton/index.vue b/src/views/kpi/assessment/performance/components/UseButton/index.vue index 6b43cdc..ea8c86c 100644 --- a/src/views/kpi/assessment/performance/components/UseButton/index.vue +++ b/src/views/kpi/assessment/performance/components/UseButton/index.vue @@ -386,7 +386,27 @@ export default { async handleGetNext () { const arr = this.handleFilter(this.obj.recortModelDtos) arr.pop() - if (arr.some(i => i.weight === null)) { + let weight = 0 + for (let i in arr) { + let num = 0 + this.handleFilter(arr[i].detailDtos).map(l => { + num += l.checkWeight + }) + if (arr[i].weight !== null) { + // 维度有设置权重的 + if (num.toFixed(2) !== arr[i].weight.toFixed(2)) { + return this.$message.error(arr[i].name + '维度内的权重和必须为' + Math.round((arr[i].weight * 100) * 1000) / 1000) + } + } + weight += num + } + if (Math.round((weight * 100) * 1000) / 1000 !== 100) { + let str = arr.map(i => i.name).join(',') + this.$message.error(str + '维度内的权重和必须为100%!') + return + } + + /* if (arr.some(i => i.weight === null)) { let weight = 0 let maxWeight = 0 const nullArray = arr.map(i => { @@ -416,7 +436,7 @@ export default { if (!_boolean) { return } - } + } */ let res1 = await apiSaveDetail(this.obj) if (res1.code !== 200) {