From 20ee6d90aff15ab1d10ae88d0d7542af48144375 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Sun, 1 Mar 2026 22:30:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][yp0?= =?UTF-8?q?03]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/HandleFormItem.vue | 98 ++++++++++++++++++---- .../Template/mixins/formPackageMixins.js | 87 ++++++++++++------- 2 files changed, 142 insertions(+), 43 deletions(-) diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index d682873..8ded2d0 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -110,12 +110,13 @@
- -
+ +
-
- - +
+ +
是否在规定时间完成
+ @@ -253,7 +254,7 @@ export default { }, data() { let initialValue = this.value; - let initialOtherValues = {}, checkboxTagList = []; + let initialOtherValues = {}, checkboxTagList = [], fqyqValue = {}; // 如果是checkboxList类型且value是对象格式 if (this.type === 'checkboxList' && this.value && typeof this.value === 'object') { @@ -267,7 +268,9 @@ export default { checked: tag.checked, tagValue: tag.tagValue || '' })); - } + } else if (this.type === 'fqyq' && !this.value) { + initialValue = {mainRadio: '', subRadio: '',inputValue:""}; + } return { inputValue: initialValue, oldValue: initialValue, // 记录上一次的值 @@ -284,6 +287,8 @@ export default { checkboxValue: this.getChecked(),//是否选中 checkboxTagList: checkboxTagList, // checkboxTag类型的列表数据 oldCheckboxTagList: JSON.parse(JSON.stringify(checkboxTagList)), // 记录上一次的checkboxTagList + fqyqValue: initialValue, // fqyq类型的值 + oldFqyqValue: {...initialValue}, // 记录上一次的fqyq值 uuid: getuuid(), // 唯一标识符,用于EventBus事件匹配 regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], //试剂/仪器/供试品等类型 selectRegentInfo: {},//选择的试剂/仪器/供试品等信息 @@ -295,6 +300,7 @@ export default { pendingUploadFile: null, // 用于存储待上传的文件 pendingRemoveFile: null, // 用于存储待删除的文件 currentTagIndex:-1,//当前选中的checkboxTag索引 + currentFqyqType:'',//当前选中的fqyq操作的类型 } }, watch: { @@ -309,7 +315,14 @@ export default { checked: tag.checked, tagValue: tag.tagValue || '' })); - } else { + } else if (this.type === 'fqyq' && newVal && typeof newVal === 'object') { + // fqyq类型 + this.fqyqValue = { + mainRadio: newVal.mainRadio || '', + inputValue: newVal.inputValue || '', + subRadio: newVal.subRadio || '' + }; + } else { this.inputValue = this.type === 'checkboxList' && !Array.isArray(newVal) ? [] : newVal; } } @@ -346,7 +359,7 @@ export default { }, methods: { getFlexClass() { - const noFlexArr = ["radio", "checkboxTag"] + const noFlexArr = ["radio", "checkboxTag","fqyq"] return noFlexArr.includes(this.type) ? '' : 'flex1' }, getDecimalDigits() { @@ -665,13 +678,14 @@ export default { }, getFillTypeStyle(type) { const { fillType } = this.item; + const filterType = ["attachment","checkboxTag","fqyq"] const typeObj = { actFill: "orange-border",//实际填写的边框颜色 green: "green-border", preFill: "blue-border",//预填写的边框颜色 } // 如果有错误状态,返回红色边框样式,覆盖原有的边框颜色 - if (this.error && this.type !== "attachment" && this.type !== "checkboxTag") { + if (this.error && !filterType.includes(this.type)) { return "error-border"; } return typeObj[fillType] || "" @@ -857,6 +871,21 @@ export default { this.$emit('input', [...this.checkboxTagList]); this.$emit('change', [...this.checkboxTagList]); }, + + // fqyq 主radio变化处理 + onFqyqRadioChange(val, radioType) { + this.fqyqValue[radioType] = val; + this.currentFqyqType = radioType; + this.onCommonHandleSaveRecord(); + }, + + // fqyq 输入框失去焦点 + onFqyqInputBlur(e) { + this.fqyqValue.inputValue = e.target.value; + this.currentFqyqType = 'inputValue'; + this.onCommonHandleSaveRecord(this.fqyqValue.inputValue); + }, + // 统一处理失去焦点事件 onBlur(e) { this.onCommonHandleSaveRecord(e.target.value); @@ -889,6 +918,16 @@ export default { this.visible = true; } }, + getFqyqInfo(){ + const { mainRadio,inputValue,subRadio } = this.fqyqValue; + const { mainRadio: oldMainRadio,inputValue: oldInputValue,subRadio: oldSubRadio } = this.oldFqyqValue; + const o ={ + "mainRadio":{oldValue:oldMainRadio,newValue:mainRadio,des:""}, + "inputValue":{oldValue:oldInputValue,newValue:inputValue,des:""}, + "subRadio":{oldValue:oldSubRadio,newValue:subRadio,des:"是否在规定时间完成:"} + } + return o[this.currentFqyqType]; + }, async onCommonHandleSaveRecord(val) { const isEmpty = this.isValueEmpty(this.inputValue); if (this.error && !isEmpty) { @@ -945,11 +984,15 @@ export default { const oldTag = this.oldCheckboxTagList[this.currentTagIndex] || {}; isSame = this.isEqual(oldTag.checked, currentTag.checked); isOldValueEmpty = this.isValueEmpty(oldTag.checked); - - }else{ + } else if (this.type === "fqyq") { + const current = this.getFqyqInfo(); + isSame = this.isEqual(current.oldValue,current.newValue); + isOldValueEmpty = this.isValueEmpty(current.oldValue); + } else { isSame = this.isEqual(this.oldValue, this.inputValue) isOldValueEmpty = this.isValueEmpty(this.oldValue); } + console.log(isSame,isOldValueEmpty,this.fqyqValue,this.oldFqyqValue,"isSame") if (isSame) { return; } @@ -981,6 +1024,10 @@ export default { this.checkboxTagList = JSON.parse(JSON.stringify(this.oldCheckboxTagList)); oldValue = [...this.checkboxTagList]; } + } else if (this.type === "fqyq") { + // 如果没有指定字段,回退整个对象 + this.fqyqValue = JSON.parse(JSON.stringify(this.oldFqyqValue)); + oldValue = { ...this.fqyqValue }; } this.inputValue = this.oldValue; this.$emit('input', oldValue); // 触发 v-model 更新 @@ -1008,8 +1055,12 @@ export default { const currentTag = this.checkboxTagList[this.currentTagIndex] || {}; recordOldVlaue = `${oldTag.tagValue || ''}:${oldTag.checked ? '勾选' : '未勾选'}`; recordValue = `${currentTag.tagValue || ''}:${currentTag.checked ? '勾选' : '未勾选'}`; - isModify = oldTag.checked !== undefined - + isModify = oldTag.checked !== undefined; + } else if (this.type === "fqyq") { + const current = this.getFqyqInfo(); + recordOldVlaue = `${current.des+current.oldValue}`; + recordValue = `${current.des+current.newValue}`; + isModify = !!this.oldFqyqValue.mainRadio } const record = { ...baseInfo, @@ -1040,6 +1091,9 @@ export default { // 如果没有指定tagIndex,更新整个数组 this.oldCheckboxTagList = JSON.parse(JSON.stringify(this.checkboxTagList)); } + } else if (this.type === "fqyq") { + // 如果没有指定字段,更新整个对象 + this.oldFqyqValue = JSON.parse(JSON.stringify(this.fqyqValue)); } let value = this.inputValue; if (this.type === 'checkboxList') { @@ -1049,6 +1103,8 @@ export default { }; } else if (this.type === "checkboxTag") { value = [...this.checkboxTagList]; + } else if (this.type === "fqyq") { + value = { ...this.fqyqValue }; } if (this.type === "button") { this.$emit('clickButton', this.item, this.inputValue, data); @@ -1692,6 +1748,9 @@ export default { border-color: #f9c588; } } + .el-radio__inner { + border-color: #f9c588; + } } } @@ -1748,6 +1807,15 @@ export default { } .fqyq-input{ width: 500px; - margin-left: 10px; + margin-right:10px; +} +.mb-10{ + margin-bottom: 10px; +} +.fs-14{ + font-size: 14px; +} +.mr-10{ + margin-right: 10px; } \ No newline at end of file diff --git a/src/components/Template/mixins/formPackageMixins.js b/src/components/Template/mixins/formPackageMixins.js index 4af3cb3..ed74c6d 100644 --- a/src/components/Template/mixins/formPackageMixins.js +++ b/src/components/Template/mixins/formPackageMixins.js @@ -54,7 +54,7 @@ export default { } this.onValueChangeCompareTo(key, val); this.formFields[key] = val; - this.$emit("select", { key, value: val, type,...this.formFields }); + this.$emit("select", { key, value: val, type, ...this.formFields }); // 清除该表单项的错误状态 if (this.errors[key]) { this.$set(this.errors, key, false); @@ -62,22 +62,22 @@ export default { }, //试剂/仪器等弹窗提交 - onRegentSubmit(data,inputValue,key,item){ - this.updateFormData(key,inputValue); - this.$emit("onRegentSubmit", {selectInfo:data,inputValue,key,config:item}); + onRegentSubmit(data, inputValue, key, item) { + this.updateFormData(key, inputValue); + this.$emit("onRegentSubmit", { selectInfo: data, inputValue, key, config: item }); }, - getRegentItem(item,fieldCode="type"){ - const type = item[fieldCode] ; - console.log(item,"type") + getRegentItem(item, fieldCode = "type") { + const type = item[fieldCode]; + console.log(item, "type") return { label: "", type, fillType: item.subFillType || item.fillType, parentLabel: item.label, - filledCodes:item.filledCodes, + filledCodes: item.filledCodes, } }, - + handleClickButton(key) { this.$emit("clickButton", key) }, @@ -96,7 +96,7 @@ export default { this.$set(this.errors, key, false); } }, - //批量更新表单数据 + //批量更新表单数据 batchUpdateFormData(data) { const cloneFormFields = JSON.parse(JSON.stringify(this.formFields)); Object.keys(data).forEach(key => { @@ -107,29 +107,29 @@ export default { this.$set(this.errors, key, false); } }) - + }, //更新表单数据 - updateFormData(key, value,data) { - const {isUpdateRecord,signData} = data || {}; + updateFormData(key, value, data) { + const { isUpdateRecord, signData } = data || {}; // 深拷贝当前表单数据,避免直接修改原数据 const cloneFormFields = JSON.parse(JSON.stringify(this.formFields)); - + this.oldFormFields[key] = cloneFormFields[key]; this.formFields[key] = value; // 清除该表单项的错误状态 if (this.errors[key]) { this.$set(this.errors, key, false); } - - if(isUpdateRecord){ + + if (isUpdateRecord) { setTimeout(() => { - this.$refs[key][0].handleUpdateRecord(signData,{oldValue:this.oldFormFields[key],inputValue:value}); + this.$refs[key][0].handleUpdateRecord(signData, { oldValue: this.oldFormFields[key], inputValue: value }); }, 10); } }, - - + + handleClickable(sItem, key) { if (this.templateFillType !== 'actFill') { return @@ -177,7 +177,7 @@ export default { fillType: sItem.subFillType || sItem.fillType, parentLabel: sItem.label, } - if(sItem.subDisabled){ + if (sItem.subDisabled) { config.disabled = sItem.subDisabled; } return config; @@ -215,14 +215,14 @@ export default { // 处理特殊字段 - "其他"字段 if (currentConfig.otherCode) { - const { otherCode,type } = currentConfig; + const { otherCode, type } = currentConfig; //如果是更新的话,优先使用formFields中的值 if (update) { result[otherCode] = formFields[otherCode] || formData[otherCode] || ''; } else { result[otherCode] = formData[otherCode] || formFields[otherCode] || ''; } - config[otherCode] = { label: "template.common.other",parentType:type, parentKey: key, type: "input", fillType: currentConfig.fillType } + config[otherCode] = { label: "template.common.other", parentType: type, parentKey: key, type: "input", fillType: currentConfig.fillType } } if (currentConfig.subKey) { const { subKey } = currentConfig; @@ -311,17 +311,17 @@ export default { if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段 formFields[o.otherCode] = ""; } - }else if(o.type === "radioAndOther"){ - const isSelectedOther = this.isShowOtherByRadioAndOther(formFields[key]); + } else if (o.type === "radioAndOther") { + const isSelectedOther = this.isShowOtherByRadioAndOther(formFields[key]); if (!isSelectedOther) {//如果其他选项没有被选择,清空其他字段 formFields[o.otherCode] = ""; } } } - if(o.type === "attachment"){ + if (o.type === "attachment") { const attValue = formFields[key]; - if(!attValue || attValue == "[]"){ + if (!attValue || attValue == "[]") { errors.push({ field: key, label: o.label, @@ -329,13 +329,44 @@ export default { }); this.$set(this.errors, key, true); } + } else if (o.type === "fqyq") { + const fqyqValue = formFields[key]; + const {mainRadio, subRadio,inputValue} = fqyqValue; + if (!mainRadio) { + errors.push({ + field: key, + label: o.label, + error: "请选择是否在规定时间完成" + }); + this.$set(this.errors, key, true); + } else { + if (mainRadio==="是") { + if (!subRadio) { + errors.push({ + field: key, + label: o.label, + error: "请选择是否在规定时间完成" + }); + this.$set(this.errors, key, true); + }else if(!inputValue){ + errors.push({ + field: key, + label: o.label, + error: "请输入信息" + }); + this.$set(this.errors, key, true); + } + } + } + + continue } if (this.isValueEmpty(formFields[key])) { // 其他字段需要判断是否显示再校验 if (o.label === "template.common.other" && !this.isShowOther(formFields[o.parentKey]) && o.parentType !== "radioAndOther") { continue } - if (o.type === "radioAndOther" &&o.label === "template.common.other" && !this.isShowOtherByRadioAndOther(formFields[o.parentKey])) { + if (o.type === "radioAndOther" && o.label === "template.common.other" && !this.isShowOtherByRadioAndOther(formFields[o.parentKey])) { continue } //span的字段不校验 @@ -432,7 +463,7 @@ export default { if (this.errors[key]) { this.$set(this.errors, key, false); } - + // 如果是checkboxList类型,需要处理otherValues if (val && typeof val === 'object' && val.otherValues) { // 将otherValues中的每个值也保存到formFields中