diff --git a/src/enums/EsEnum.js b/src/enums/EsEnum.js index 033a9318..c24ac0d0 100644 --- a/src/enums/EsEnum.js +++ b/src/enums/EsEnum.js @@ -102,19 +102,22 @@ export default class EsEnum { } /** - * 根据value获取按钮 + * 通过value获取其他属性 + * @param key + * @param value + * @returns {*|null} */ - btnOfValue (value) { + propertyOfValue (key, value) { if (!value && value!== 0) { - return [] + return null } - for (const i in this){ + for (const i in this) { const e = this[i] - if (e.value !== undefined && e.value !== null && e.value.toString() === value.toString()) { - return e.btn || [] + if (e[key] !== undefined && e[key] !== null) { + return e[key] } } - return [] + return null } /** diff --git a/src/enums/commonEnums.js b/src/enums/commonEnums.js index 8c04a588..a7b86b7e 100644 --- a/src/enums/commonEnums.js +++ b/src/enums/commonEnums.js @@ -212,8 +212,8 @@ export const IsReadOnlyEnums = { // 标准法规入库/变更流程 export const FGEntryChangeProcessNode = new EsEnums({ - initiate: { text: '法规工程师发起', value: '1', btn: ['save', 'submit'] }, - approve: { text: '审批', value: '审批', btn: ['return', 'save', 'agree', 'reject'] } + initiate: { text: '填写法规信息', value: '填写法规信息', btn: ['save', 'submit'], disabled: false }, + approve: { text: '审批', value: '审批', btn: ['return', 'save', 'agree', 'reject'], disabled: true } }) // 标准征求意见流程 diff --git a/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue b/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue index 5b345119..faa5ab56 100644 --- a/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue +++ b/src/views/workCenter/standardEntryOrChangeProcess/StandardEntryOrChangeProcess.vue @@ -257,7 +257,7 @@ v-model="formInline[item.dbFieldName]" @nameChange="treeSelectNameChange" :filedName="item.dbFieldName" - type="radio" + type="checkbox" :nameStr="formInline[item.dbFieldName + '_dictText']" :dict-id="item.dictId" :disabled="disabled || disabledFieldList.includes(item.dbFieldName)" /> @@ -278,7 +278,7 @@ @change="event => event.target.value = event.target.value.trim()" :maxLength="500" type="textarea" - v-decorator="['handleText']" /> + v-decorator="['handleText', validatorRules.handleText]" /> @@ -426,7 +426,14 @@ export default { switchValue: 'base', excludeStandardNumbers: null, currentNode: null, - btnList: [] // 拥有的按钮 + btnList: [], // 拥有的按钮 + validatorRules: { + // 备注 + handleText: { + rules: [{ required: false, message: this.$t('pleaseEnter') + this.$t('remarks') }], + validateTrigger: 'blur' + }, + } } }, computed: { @@ -458,7 +465,6 @@ export default { }, created () { if (this.$route.query.processInstanceId || this.$route.query.draftId) { - this.disabled = true this.initProcessData() } else { this.currentNode = FGEntryChangeProcessNode.initiate.value @@ -477,26 +483,54 @@ export default { initProcessData () { this.loading = true const { processInstanceId, draftId } = this.$route.query - queryStandardECProcessData({ processInstanceId, draftId }).then(res => { + queryStandardECProcessData({ processInstanceId, draftId }).then(async res => { if (res.success) { const businessData = Object.assign({}, { ...res.result.businessInfoDTO.businessMap }) this.formInline.source = businessData.source this.loading = false // 获取对应类型的表单 - this.handleSourceChange() + await this.handleSourceChange() // 处理流程信息回显 this.processInfo = Object.assign({}, res.result.basicProcessInfoDTO || {}) // 处理流程审批信息 this.approvalInfo = Object.assign({}, res.result.basicTaskInfoDTO || {}) this.$nextTick(() => { // 处理表单数据回显 - this.formInline = Object.assign({ ...this.formInline }, { ...businessData }) - this.formInline.standard_number_temp = this.formInline.standard_number this.processInfoForm.setFieldsValue(this.processInfo) this.approvalInfoForm.setFieldsValue(this.approvalInfo) + + // 处理业务基本信息部分的数据 + const formList = Object.values(this.formList).reduce((acc, cur) => acc.concat(cur), []) + this.formInline = Object.assign({ ...this.formInline }, { ...businessData }) + this.formInline.standard_number_temp = this.formInline.standard_number + const treeMultipleField = formList.filter(tt => tt.fieldShowType === FieldType.TREE.value) + treeMultipleField.forEach(field => { + const valueArr = [] + if (this.formInline[field.dbFieldName]) { + const values = this.formInline[field.dbFieldName].split(',') + for (let i = 0; i < values.length; i++) { + valueArr[i] = { + value: values[i] + } + } + this.formInline[field.dbFieldName] = valueArr + } else { + this.formInline[field.dbFieldName] = undefined + } + }) + const dictField = formList.filter(tt => tt.fieldShowType === FieldType.OPTION_SINGLE.value) + dictField.forEach(field => { + this.formInline[field.dbFieldName] = this.formInline[field.dbFieldName] || null + }) }) // 获取按钮清单 - this.btnList = FGEntryChangeProcessNode.btnOfValue(this.$route.query.taskName) + const btnList = FGEntryChangeProcessNode.propertyOfValue('btn', this.$route.query.taskName) + if (btnList && btnList.length > 0) { + this.btnList = btnList + } else { + this.btnList = FGEntryChangeProcessNode.approve.btn + } + this.disabled = FGEntryChangeProcessNode.propertyOfValue('disabled', this.$route.query.taskName) || false } else { this.$message.warning(res.message) this.loading = false @@ -517,52 +551,57 @@ export default { * 获取国内标准的表单 */ initDomesticStandardForm () { - const params = { - module: StandardSource.DOMESTIC.value, - type: 2 // 2是新增;1是详情 - } - this.formInline = {} - this.loading = true - getDomesticStandardFormModal(params).then(res => { - if (res.success) { - this.formList = res.result || {} - this.formListArr = Object.values(this.formList).reduce((acc, cur) => acc.concat(cur), []) - this.formPartList = Object.keys(this.formList) - this.formInline.source = StandardSource.DOMESTIC.value - this.$forceUpdate() - this.getOptionsData() // 处理通过接口获取的下拉数据 - this.integrateData() // 处理表单验证 - this.initRetractableFlag() // 处理面板展开 - if (this.formInline.standard_property) { - this.handleDomesticSpecialCheck() - } + return new Promise(resolve => { + const params = { + module: StandardSource.DOMESTIC.value, + type: 2 // 2是新增;1是详情 } - }).finally(() => { - this.loading = false + this.formInline = {} + this.loading = true + getDomesticStandardFormModal(params).then(res => { + if (res.success) { + this.formList = res.result || {} + this.formListArr = Object.values(this.formList).reduce((acc, cur) => acc.concat(cur), []) + this.formPartList = Object.keys(this.formList) + this.formInline.source = StandardSource.DOMESTIC.value + this.$forceUpdate() + this.getOptionsData() // 处理通过接口获取的下拉数据 + this.integrateData() // 处理表单验证 + this.initRetractableFlag() // 处理面板展开 + if (this.formInline.standard_property) { + this.handleDomesticSpecialCheck() + } + } + }).finally(() => { + this.loading = false + resolve() + }) }) }, /** * 获取海外标准的表单 */ initOverseasStandardForm () { - this.loading = true - const params = { - module: StandardSource.OVERSEAS.value, - type: 2 // 2是新增;1是详情 - } - this.formInline = {} - getOverseasStandardForm(params).then(res => { - if (res.success) { - this.formList = res.result || {} - this.formListArr = Object.values(this.formList).reduce((acc, cur) => acc.concat(cur), []) - this.formPartList = Object.keys(this.formList) - this.formInline.source = StandardSource.OVERSEAS.value - this.getOptionsData() // 处理通过接口获取的下拉数据 - this.integrateData() // 处理表单验证 - this.initRetractableFlag() // 处理面板展开 + return new Promise(resolve => { + this.loading = true + const params = { + module: StandardSource.OVERSEAS.value, + type: 2 // 2是新增;1是详情 } - }).finally(() => { - this.loading = false + this.formInline = {} + getOverseasStandardForm(params).then(res => { + if (res.success) { + this.formList = res.result || {} + this.formListArr = Object.values(this.formList).reduce((acc, cur) => acc.concat(cur), []) + this.formPartList = Object.keys(this.formList) + this.formInline.source = StandardSource.OVERSEAS.value + this.getOptionsData() // 处理通过接口获取的下拉数据 + this.integrateData() // 处理表单验证 + this.initRetractableFlag() // 处理面板展开 + } + }).finally(() => { + this.loading = false + }) }) }, /** @@ -678,18 +717,21 @@ export default { * 来源变更,重新获取表单 */ handleSourceChange () { - switch (this.formInline.source) { - case StandardSource.DOMESTIC.value: - this.initDomesticStandardForm() - break - case StandardSource.OVERSEAS.value: - this.initOverseasStandardForm() - break - default: - this.formInline.source = StandardSource.DOMESTIC.value - this.initDomesticStandardForm() - break - } + return new Promise(async resolve => { + switch (this.formInline.source) { + case StandardSource.DOMESTIC.value: + await this.initDomesticStandardForm() + break + case StandardSource.OVERSEAS.value: + await this.initOverseasStandardForm() + break + default: + this.formInline.source = StandardSource.DOMESTIC.value + await this.initDomesticStandardForm() + break + } + resolve() + }) }, /** * 操作类型变化 @@ -826,6 +868,8 @@ export default { * 同意 */ handleAgree () { + this.validatorRules.handleText.rules[0].required = false + this.approvalInfoForm.setFieldsValue({ handleText: '同意' }) const formData = this.dealFormData() if (!formData) { return @@ -846,6 +890,7 @@ export default { * 驳回 */ handleReject () { + this.validatorRules.handleText.rules[0].required = true const formData = this.dealFormData() if (!formData) { return