diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index 41aae02..b22cc2f 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -235,7 +235,7 @@ import { getToken } from "@/utils/auth"; import { isShowOtherByCheckboxTree } from "@/utils/formPackageCommon"; export default { - inject: ['templateData', 'templateFillType', "getZdxgjl", "getFhyjjl", "updateZdxgjl", "replaceFhyjjl", "updateFhyjjl", "getFieldCheckObj", "updateFieldCheckObj"], + inject: ['templateData', 'templateFillType',"getSubmittedCodes","updateSubmittedCodes", "getZdxgjl", "getFhyjjl", "updateZdxgjl", "replaceFhyjjl", "updateFhyjjl", "getFieldCheckObj", "updateFieldCheckObj"], components: { Question, DecimalInput, @@ -1096,9 +1096,10 @@ export default { const { mainRadio: oldMainRadio, inputValue: oldInputValue, subRadio: oldSubRadio } = this.oldFqyqValue; const o = { "mainRadio": { oldValue: oldMainRadio, newValue: mainRadio, des: "" }, - "inputValue": { oldValue: oldInputValue, newValue: inputValue, des: "" }, + "inputValue": { oldValue: oldInputValue, newValue: inputValue, des: "",key: this.fieldKey+"_inputValue" }, "subRadio": { oldValue: oldSubRadio, newValue: subRadio, des: "是否在规定时间完成:" } } + console.log(o, this.currentHandleType, this.fqyqValue,"fqyqValue") return o[this.currentHandleType]; }, getCheckboxTreeInfo() { @@ -1109,7 +1110,7 @@ export default { const oldItem = oldCheckedValues.find(item => item.label === currentCheckboxTreeValue); const o = { "checkboxTreeCheckbox": { oldValue: oldItem, newValue: newItem, des: "" }, - "checkboxTreeOther": { oldValue: oldOtherValues[currentCheckboxTreeValue], newValue: otherValues[currentCheckboxTreeValue], des: `${currentCheckboxTreeValue}:` }, + "checkboxTreeOther": { oldValue: oldOtherValues[currentCheckboxTreeValue], newValue: otherValues[currentCheckboxTreeValue], des: `${currentCheckboxTreeValue}:`,key: this.fieldKey+"_"+currentCheckboxTreeValue }, } return o[currentHandleType]; }, @@ -1168,7 +1169,11 @@ export default { } else if (this.type === "fqyq") { const current = this.getFqyqInfo(); isSame = isEqual(current.oldValue, current.newValue); - isOldValueEmpty = isValueEmpty(current.oldValue); + if(this.currentHandleType === "inputValue"){ + isOldValueEmpty =this.isUnSubmitted(current.key); + }else{ + isOldValueEmpty = isValueEmpty(current.oldValue); + } } else if (this.type === "checkboxTree") { const current = this.getCheckboxTreeInfo() || {}; const { oldValue = {}, newValue = {} } = current; @@ -1177,16 +1182,16 @@ export default { isOldValueEmpty = oldValue.checked === undefined; } else { isSame = isEqual(current.oldValue, current.newValue); - isOldValueEmpty = isValueEmpty(current.oldValue); + isOldValueEmpty = this.isUnSubmitted(current.key); } } else if(this.type === "checkbox"){ isSame = isEqual(this.oldValue, this.inputValue) - isOldValueEmpty = this.oldValue === ''; + isOldValueEmpty =this.isUnSubmitted(); }else { isSame = isEqual(this.oldValue, this.inputValue) - isOldValueEmpty = isValueEmpty(this.oldValue); + isOldValueEmpty = this.isUnSubmitted(); } console.log(isSame, isOldValueEmpty, this.currentCheckboxTreeValue, this.oldValue, this.inputValue, "isSame") if (isSame) { @@ -1200,6 +1205,13 @@ export default { } }, + //是否提交过 + isUnSubmitted(key){ + const finallyKey = key || this.fieldKey; + const has = this.getSubmittedCodes().includes(finallyKey) + return !has; + }, + //如果用户取消,那么回退到上一次的值 resetRecord() { // 用户点击取消,还原数据 @@ -1232,6 +1244,7 @@ export default { if (!this.oldValue && !this.inputValue) { return } + let finallyKey = this.fieldKey; if (recordData) { this.oldValue = recordData.oldValue; this.inputValue = recordData.inputValue; @@ -1248,6 +1261,9 @@ export default { const current = this.getFqyqInfo(); recordOldVlaue = `${current.des + current.oldValue}`; recordValue = `${current.des + current.newValue}`; + if(this.currentHandleType === "inputValue"){ + finallyKey = current.key; + } isModify = !!this.oldFqyqValue.mainRadio } else if (this.type === "checkboxTree") { // checkboxTree类型,记录当前操作的值变化 @@ -1257,6 +1273,7 @@ export default { recordOldVlaue = `${oldValue?.label || ''}:${oldValue?.checked ? '勾选' : '未勾选'}`; recordValue = `${newValue.label || ''}:${newValue.checked ? '勾选' : '未勾选'}`; isModify = newValue.checked !== undefined; + finallyKey = current.key; } else { recordOldVlaue = `${current.des + (current.oldValue || '')}`; recordValue = `${current.des + (current.newValue || '')}`; @@ -1271,7 +1288,7 @@ export default { ...baseInfo, oldValue: recordOldVlaue, value: recordValue, - title: isModify ? "修改" : "提交", + title: !this.isUnSubmitted(finallyKey) ? "修改" : "提交", time: moment().format("YYYY-MM-DD HH:mm:ss"), } if (data) { @@ -1281,6 +1298,7 @@ export default { const params = { type: "fieldChanged", newRecord: [record], + submittedCodes: this.getSubmittedCodes(), resourceList: this.getZdxgjl(), } @@ -1320,6 +1338,7 @@ export default { if (this.templateFillType === "actFill") {//只有实际填报的时候才记录修改记录 this.updateZdxgjl(record); + this.updateSubmittedCodes(finallyKey); } this.$nextTick(() => { EventBus.$emit('onModifyRecord', params,) diff --git a/src/utils/index.js b/src/utils/index.js index f63de38..8202b04 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -419,6 +419,9 @@ export const getExpireDate = ( effectivePeriod, effectivePeriodUnit ) => { + if(startDate === "NA"){ + return "NA"; + } const start = moment(startDate) const unit = effectivePeriodUnit === '天' ? 'days' : 'hours' const end = start diff --git a/src/views/business/comps/template/TemplateTable.vue b/src/views/business/comps/template/TemplateTable.vue index 2517548..07c9d3d 100644 --- a/src/views/business/comps/template/TemplateTable.vue +++ b/src/views/business/comps/template/TemplateTable.vue @@ -358,10 +358,13 @@ export default { if (v.zdxgjl) { this.zdxgjl = JSON.parse(v.zdxgjl) || []; } + if (v.submittedCodes) { + this.submittedCodes = JSON.parse(v.submittedCodes) || []; + } if (v.fhyjjl) { this.fhyjjl = JSON.parse(v.fhyjjl) || []; } - if (v.zdgxjl) { + if (v.zdgxjl) {//qc勾选记录 this.fieldCheckObj = JSON.parse(v.zdgxjl) || {}; } } @@ -374,12 +377,20 @@ export default { templateData: this.templateData, templateFillType: this.fillType, getZdxgjl: () => this.zdxgjl, + getSubmittedCodes: () => this.submittedCodes, getFhyjjl: () => this.fhyjjl, getFieldCheckObj: () => this.fieldCheckObj, //更新提交记录 updateZdxgjl: (data) => { this.zdxgjl.unshift(data); }, + //更新已提交数据的codes + updateSubmittedCodes: (code) => { + if(!this.submittedCodes.includes(code)){ + this.submittedCodes.unshift(code); + return + } + }, //更新复核意见记录 updateFhyjjl: (data) => { this.fhyjjl.unshift(data); @@ -404,6 +415,7 @@ export default { currentEditSignUuid: null, // 当前请求EditSign的HandleFormItem的uuid latestParams: {},//用于存储最新的params hasCustomTable: false,//是否有自定义表格 + submittedCodes: [],//用于记录已提交数据的codes }; }, created() { diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index c05e190..a6ffe10 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -166,11 +166,17 @@ export default { effectivePeriodUnit && !expireDate ) { - const start = moment(startDate) - const unit = effectivePeriodUnit === '天' ? 'days' : 'hours' - const end = start - .add(Number(effectivePeriod), unit) - .format('YYYY-MM-DD HH:mm:ss') + let end; + if (startDate === "NA") { + end = "NA"; + } else { + const start = moment(startDate) + const unit = effectivePeriodUnit === '天' ? 'days' : 'hours' + end = start + .add(Number(effectivePeriod), unit) + .format('YYYY-MM-DD HH:mm:ss') + } + this.formData = { ...this.formData, expireDate: end } } console.log(this.formData, 'formData from templateData')