perf: 优化代码

This commit is contained in:
zyn
2024-01-04 14:49:46 +08:00
parent 4c45e18c6c
commit c0d2789b53
@@ -73,7 +73,7 @@
<div v-show="active === '2'" class="block" style="padding-top: 20px;">
<PersonInfo ref="roleForm" :roleForm="roleForm" :roleRules="roleRules" :disabled="disabled" />
</div>
<ApprovalHistory v-if="type !== '1' && type !== 'C1'" v-show="active === '3'" />
<ApprovalHistory v-if="type !== '1'" v-show="active === '3'" />
<div v-show="active === '4'">
<ProcessTitle>
<template slot="title">条款信息</template>
@@ -176,6 +176,9 @@ export default {
data () {
const verify = {
validateFBGBUSS: (rule, value, callback) => {
if(this.$route.params.type === '1' || this.$route.params.type === '2') {
return callback()
}
if(!this.form.FBGBUSS || this.form.FBGBUSS === '') {
return callback(new Error('请上传发布稿文件!'))
}
@@ -279,7 +282,7 @@ export default {
{ required: true, message: '请选择制修订类型', trigger: [ 'change', 'blur' ] }
],
standCode: [
{ required: false, message: '请输入企业标准号', trigger: [ 'change', 'blur' ] },
{ required: true, message: '请输入企业标准号', trigger: [ 'change', 'blur' ] },
{ min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: [ 'change', 'blur' ] },
],
expirationDate: [
@@ -507,14 +510,13 @@ export default {
},
addRules () {
const type = this.$route.params.type
if (type !== '1' && type !== 'C1') {
if (type !== '1' && type !== '2') {
this.rules.FBGBUSSName[0].required = true
}
if (type === '13') {
this.rules.issueTime[0].required = true
this.rules.standYear[0].required = true
this.rules.standNum[0].required = true
this.rules.standCode[0].required = true
}
},
handleTabs (val) {
@@ -572,13 +574,22 @@ export default {
this.form.FBGBUSS = ''
this.form.FBGBUSSName = ''
if (this.form.standStatus === '2') {
if (this.type === '13' && this.form.standStatus === '2') {
this.getStandByRevision('1')
}
this.refreshPage()
},
standStatusChange (e) {
if(this.$route.params.type === '1') {
this.form = { ...this.initForm }
this.form.standStatus = e
return
}
this.form.standStatus = e
if (this.type !== '13') return;
this.form.standYear = this.init.standYear
this.form.standNum = this.init.standNum
this.form.standCode = this.init.standCode
@@ -601,12 +612,6 @@ export default {
})
this.setInitValue('old', this.form.standSort, this.form.standNum, this.form.standYear, this.form.standCode)
// this.old = {
// standYear: this.form.standYear,
// standNum: this.form.standNum,
// standCode: this.form.standCode,
// standSort: this.form.standSort
// }
}
if (this.form.standStatus === '2') {
this.form.standYear = year.toString()
@@ -616,33 +621,13 @@ export default {
const oldStandYear = oldYear.slice(0, 4)
const oldStandNum = this.form.standCode.slice(0, this.form.standCode.lastIndexOf('-')).replace(this.form.standSort, '')
// this.old = {
// standYear: oldStandYear,
// standNum: oldStandNum,
// standCode: this.form.standCode,
// standSort: this.form.standSort
// }
this.setInitValue('old', this.form.standSort, oldStandNum, oldStandYear, this.form.standCode)
if (oldStandYear === this.form.standYear) {
if (oldYear.indexOf('X') > -1) {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + 'X'
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + ' X'
}
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + this.form.standYear
}
this.getStandCode(oldStandNum, oldStandYear, oldYear)
} else {
// 制定切修订 -> 顺序号和企标号是空的
if (!this.form.DTQBBHBUSS || this.form.DTQBBHBUSS === '') {
this.setInitValue('old', this.form.standSort, '', this.form.standYear, '')
// this.old = {
// standYear: this.form.standYear,
// standNum: '',
// standCode: '',
// standSort: this.form.standSort
// }
} else {
const standCode = this.form.standCode = this.form.DTQBBHBUSS
this.$http._getData('/lawss/sarBussionessStand/queryBussinessStandByStandCode', { standCode }).then(res => {
@@ -655,15 +640,7 @@ export default {
this.setInitValue('old', this.form.standSort, oldStandNum, oldStandYear, this.form.standCode)
if (oldStandYear === this.form.standYear) {
if (oldYear.indexOf('X') > -1) {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + 'X'
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + ' X'
}
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + this.form.standYear
}
this.getStandCode(oldStandNum, oldStandYear, oldYear)
}
})
}
@@ -672,12 +649,6 @@ export default {
if (this.form.standStatus === '3') {
this.setInitValue('old', this.form.standSort, this.form.standNum, this.form.standYear, this.form.standCode)
// this.old = {
// standYear: this.form.standYear,
// standNum: this.form.standNum,
// standCode: this.form.standCode,
// standSort: this.form.standSort
// }
}
this.refreshPage()
@@ -686,6 +657,8 @@ export default {
this[key] = { standYear, standNum, standCode, standSort }
},
standSortChange () {
if (this.type !== '13') return;
this.getStandByFormulate()
this.getStandByRevision()
},
@@ -696,6 +669,8 @@ export default {
this.form = { ...this.form }
},
DTQBBHBUSSChange (obj) {
if (this.type !== '13') return;
const { standCode, standSort } = obj
this.getStandByRevision('2', standCode, standSort)
},
@@ -735,15 +710,7 @@ export default {
const oldStandYear = oldYear.slice(0, 4)
const oldStandNum = this.old.standCode.slice(0, this.old.standCode.lastIndexOf('-')).replace(this.old.standSort, '')
if (oldStandYear === this.form.standYear) {
if (oldYear.indexOf('X') > -1) {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + 'X'
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + ' X'
}
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + this.form.standYear
}
this.getStandCode(oldStandNum, oldStandYear, oldYear)
}
},
getStandInfoByReviseStatus (type, standCode, standSort) {
@@ -780,6 +747,32 @@ export default {
if (this.form.standStatus === '2') {
this.form.standYear = year.toString()
if (!this.form.standCode || this.form.standCode === '') {
if (this.form.DTQBBHBUSS && this.form.DTQBBHBUSS !== '') {
// 企业标准号空 代替企标编号非空
const standCode = this.form.standCode = this.form.DTQBBHBUSS
this.$http._getData('/lawss/sarBussionessStand/queryBussinessStandByStandCode', { standCode }).then(res => {
if (res.ok) {
this.form.standSort = res.data.standSort || res.data.standSortShow
const oldYear = this.form.standCode.slice(this.form.standCode.lastIndexOf('-') + 1) // 2022 2022 X
const oldStandYear = oldYear.slice(0, 4)
const oldStandNum = this.form.standCode.slice(0, this.form.standCode.lastIndexOf('-')).replace(this.form.standSort, '')
this.setInitValue('init', this.form.standSort, oldStandNum, oldStandYear, this.form.standCode)
this.old = JSON.parse(JSON.stringify(this.init))
this.getStandCode(oldStandNum, oldStandYear, oldYear)
}
})
return
}
// 企业标准号空 代替企标编号空
this.setInitValue('init', this.form.standSort, '', '', '')
this.old = JSON.parse(JSON.stringify(this.init))
return
}
// 企业标准号非空
const oldYear = this.form.standCode.slice(this.form.standCode.lastIndexOf('-') + 1) // 2022 2022 X
const oldStandYear = oldYear.slice(0, 4)
const oldStandNum = this.form.standCode.slice(0, this.form.standCode.lastIndexOf('-')).replace(this.form.standSort, '')
@@ -787,23 +780,31 @@ export default {
this.setInitValue('init', this.form.standSort, oldStandNum, oldStandYear, this.form.standCode)
this.old = JSON.parse(JSON.stringify(this.init))
if (oldStandYear === this.form.standYear) {
if (oldYear.indexOf('X') > -1) {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + 'X'
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + ' X'
}
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + this.form.standYear
}
this.getStandCode(oldStandNum, oldStandYear, oldYear)
}
if (this.form.standStatus === '3') {
if (!this.form.standCode || this.form.standCode === '') {
this.setInitValue('init', this.form.standSort, '', '', '')
this.old = JSON.parse(JSON.stringify(this.init))
return
}
const oldStandNum = this.form.standCode.slice(0, this.form.standCode.lastIndexOf('-')).replace(this.form.standSort, '')
this.setInitValue('init', this.form.standSort, oldStandNum, this.form.standYear, this.form.standCode)
this.old = JSON.parse(JSON.stringify(this.init))
}
},
getStandCode (oldStandNum, oldStandYear, oldYear) {
if (oldStandYear === this.form.standYear) {
if (oldYear.indexOf('X') > -1) {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + 'X'
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + oldYear + ' X'
}
} else {
this.form.standCode = this.form.standSort + oldStandNum + '-' + this.form.standYear
}
},
getData () {
const { bpnId, taskIds, prcId } = this.$route.query
@@ -820,7 +821,9 @@ export default {
this.form = JSON.parse(JSON.stringify(processForm.form))
this.roleForm = JSON.parse(JSON.stringify(processForm.roleForm))
this.afterCompatible(processForm) // 兼容旧数据
this.getInitData()
if (this.type === '13') {
this.getInitData()
}
this.$nextTick(() => {
this.reloadForm = true
})