修改所有判断权重之和的逻辑
This commit is contained in:
parent
da7050e297
commit
bbb713c3c2
@ -411,7 +411,27 @@ export default {
|
|||||||
async handleGetNext () {
|
async handleGetNext () {
|
||||||
// 提交绩效详情
|
// 提交绩效详情
|
||||||
const arr = this.handleFilter(this.obj.recortModelDtos)
|
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 weight = 0
|
||||||
let maxWeight = 0
|
let maxWeight = 0
|
||||||
const nullArray = arr.map(i => {
|
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)
|
return this.$message.error(arr[i].name + '维度内的权重和必须为' + Math.round((arr[i].weight * 100) * 1000) / 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
this.obj.recortModelDtos.map(i => {
|
this.obj.recortModelDtos.map(i => {
|
||||||
i.detailDtos.map(j => {
|
i.detailDtos.map(j => {
|
||||||
@ -489,7 +509,27 @@ export default {
|
|||||||
if (type === 1) {
|
if (type === 1) {
|
||||||
// 保存绩效详情
|
// 保存绩效详情
|
||||||
const arr = this.handleFilter(this.obj.recortModelDtos)
|
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 weight = 0
|
||||||
let maxWeight = 0
|
let maxWeight = 0
|
||||||
const nullArray = arr.map(i => {
|
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)
|
return this.$message.error(arr[i].name + '维度内的权重和必须为' + Math.round((arr[i].weight * 100) * 1000) / 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
// 保存和暂存绩效详情直接走下面
|
// 保存和暂存绩效详情直接走下面
|
||||||
params.recortModelDtos.map(i => {
|
params.recortModelDtos.map(i => {
|
||||||
|
|||||||
@ -386,7 +386,27 @@ export default {
|
|||||||
async handleGetNext () {
|
async handleGetNext () {
|
||||||
const arr = this.handleFilter(this.obj.recortModelDtos)
|
const arr = this.handleFilter(this.obj.recortModelDtos)
|
||||||
arr.pop()
|
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 weight = 0
|
||||||
let maxWeight = 0
|
let maxWeight = 0
|
||||||
const nullArray = arr.map(i => {
|
const nullArray = arr.map(i => {
|
||||||
@ -416,7 +436,7 @@ export default {
|
|||||||
if (!_boolean) {
|
if (!_boolean) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
} */
|
||||||
|
|
||||||
let res1 = await apiSaveDetail(this.obj)
|
let res1 = await apiSaveDetail(this.obj)
|
||||||
if (res1.code !== 200) {
|
if (res1.code !== 200) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user