This commit is contained in:
xiongchengqiang 2020-12-08 10:33:44 +08:00
parent ed6bbaba45
commit 79fd1696ef
3 changed files with 86 additions and 12 deletions

View File

@ -207,6 +207,9 @@ export default {
handleNumber (item) { handleNumber (item) {
return item.detailDtos ? item.detailDtos.filter(i => !i.isDelete).length : 0 return item.detailDtos ? item.detailDtos.filter(i => !i.isDelete).length : 0
}, },
handleFilter (item) {
return item ? item.filter(i => !i.isDelete) : []
},
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)) { if (arr.some(i => i.weight === null)) {
@ -235,7 +238,6 @@ export default {
const obj = { status: 1, menuName: '制定了' } const obj = { status: 1, menuName: '制定了' }
const params = Object.assign({}, { resultRecordId: this.$route.query.id || '' }, obj) const params = Object.assign({}, { resultRecordId: this.$route.query.id || '' }, obj)
let res = await apiSaveapproval(params) let res = await apiSaveapproval(params)
console.log("🚀 ~ file: index.vue ~ line 238 ~ handleGetNext ~ res", res)
if (res.code !== 200) { if (res.code !== 200) {
this.$message.error(res.msg || '出错了 ') this.$message.error(res.msg || '出错了 ')
return return
@ -299,16 +301,30 @@ export default {
this.showIndicators = false this.showIndicators = false
}, },
handleSubmitZhibiao () { handleSubmitZhibiao () {
console.log(this.formIndicators)
const arr = this.obj.recortModelDtos[this.formIndicators.dazhibiaoIndex].detailDtos
this.$refs.formIndicators.validate((v) => { this.$refs.formIndicators.validate((v) => {
if (v) { if (v) {
if (this.formIndicators.index === -1) { if (this.formIndicators.index === -1) {
this.obj.recortModelDtos[this.formIndicators.dazhibiaoIndex].detailDtos.push(Object.assign({}, this.formIndicators, { checkWeight: this.formIndicators.checkWeight / 100 })) arr.push(Object.assign({}, this.formIndicators, { checkWeight: this.formIndicators.checkWeight / 100 }))
} else { } else {
this.obj.recortModelDtos[this.formIndicators.dazhibiaoIndex].detailDtos[this.formIndicators.index] = Object.assign({}, this.formIndicators, { checkWeight: this.formIndicators.checkWeight / 100 }) let _index = 0
this.obj.recortModelDtos[this.formIndicators.dazhibiaoIndex].detailDtos = arr.map(i => {
if (i.isDelete !== 1) {
if (_index === this.formIndicators.index) {
i = Object.assign({}, this.formIndicators, { checkWeight: this.formIndicators.checkWeight / 100 })
}
_index++
}
return i
})
} }
this.$forceUpdate()
this.showIndicators = false this.showIndicators = false
} }
}) })
console.log(" this.obj", this.obj)
}, },
// //
hanidleEdit (item, index, type) { hanidleEdit (item, index, type) {
@ -319,6 +335,7 @@ export default {
return return
} }
} }
this.zhibiaoTitle = index === -1 ? "添加指标" : "编辑指标"
if (index === -1) { if (index === -1) {
this.formIndicators = { this.formIndicators = {
checkWeight: 0 checkWeight: 0
@ -341,9 +358,7 @@ export default {
this.obj.recortModelDtos[type].detailDtos = this.obj.recortModelDtos[type].detailDtos.filter(i => i !== item) this.obj.recortModelDtos[type].detailDtos = this.obj.recortModelDtos[type].detailDtos.filter(i => i !== item)
this.$forceUpdate() this.$forceUpdate()
}, },
handleFilter (item) {
return item ? item.filter(i => !i.isDelete) : []
},
async handleGetTbale (id = this.$route.query.id) { async handleGetTbale (id = this.$route.query.id) {
let res = await apiResultGetDetail({ id }) let res = await apiResultGetDetail({ id })
if (res.code !== 200) return if (res.code !== 200) return

View File

@ -123,9 +123,9 @@
<script> <script>
import getPersonnel from '@/components/getPersonnel' import getPersonnel from '@/components/getPersonnel'
import PopupRight from '@/components/PopupRight' import PopupRight from '@/components/PopupRight'
import { apiSaveapproval, apiAssessresetdata } from '@/api/assessment' import { apiSaveapproval, apiAssessresetdata, apiSaveDetail } from '@/api/assessment'
export default { export default {
props: ['tableInfo', 'formList', 'info', 'resultRecordId'], props: ['tableInfo', 'formList', 'info', 'resultRecordId', 'obj'],
data () { data () {
return { return {
authList: [ authList: [
@ -241,6 +241,8 @@ export default {
computed: {}, computed: {},
beforeMount () { }, beforeMount () { },
mounted () { mounted () {
console.log(this.resultRecordId)
console.log("🚀 ~ file: index.vue ~ line 308 ~ handleGetNext ~ this.obj", this.obj)
}, },
methods: { methods: {
async handleResetData (resultRecordId) { async handleResetData (resultRecordId) {
@ -294,10 +296,66 @@ export default {
}, },
async handleAgree () { async handleAgree () {
this.$loadingStart() this.$loadingStart()
let res = await this.handlApiSaveapproval({ status: 1, menuName: '同意了' }) await this.handleGetNext()
this.$loadingEnd() this.$loadingEnd()
this.dialogFormVisible = !!res
},
handleFilter (item) {
return item ? item.filter(i => !i.isDelete) : []
},
async handleGetNext () {
const arr = this.handleFilter(this.obj.recortModelDtos)
arr.pop()
if (arr.some(i => i.weight === null)) {
let weight = 0
let maxWeight = 0
const nullArray = arr.map(i => {
i.detailDtos.map(j => {
if (i.weight === null) maxWeight += j.checkWeight
weight += j.checkWeight
})
})
if (weight !== 1) {
const noWeightArr = arr.filter(i => i.weight === null)
let str = noWeightArr.map(i => i.name).join(',')
this.$message.error(str + '维度内的权重和必须为100%')
return
}
} else {
let _boolean = true
arr.map(i => {
if (i.weight !== i.detailDtos.reduce((result, item) => {
return result += item.checkWeight
}, 0)) {
this.$message.error(i.name + '维度内的权重和必须为100%')
_boolean = false
}
})
if (!_boolean) {
return
}
}
const obj = { status: 1, menuName: '同意了' }
const params = Object.assign({}, { resultRecordId: this.$route.query.id || '' }, obj)
let res = await apiSaveapproval(params)
if (res.code !== 200) {
this.$message.error(res.msg || '出错了 ')
return
}
this.obj.commentId = res.commentId
let res1 = await apiSaveDetail(this.obj)
if (res1.code !== 200) {
this.$message.error(res1.msg)
return
}
this.$message({
message: res.msg,
type: 'success'
})
this.dialogFormVisible = false
history.go(0)
}, },
// //
handleBohui () { handleBohui () {

View File

@ -26,8 +26,9 @@
departmentName:obj.departmentName departmentName:obj.departmentName
}" /> }" />
<div class="performance-content-title-right"> <div class="performance-content-title-right">
<UseButton :resultRecordId='resultRecordId' <UseButton :obj='obj'
v-if="isShow && !tableInfo.result && !tableInfo.score" :resultRecordId='resultRecordId'
v-if="isShow && !tableInfo.result && !tableInfo.score && obj.recortModelDtos.length !==0"
:formList='formList' :formList='formList'
:tableInfo.sync='tableInfo' /> :tableInfo.sync='tableInfo' />
</div> </div>