diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index 83026c2..d5044ec 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -325,9 +325,10 @@ export default { this.justUpdateFilledFormData(); }, onCheckboxTagChange(rowIndex, colIndex, col, tagIndex, value) { + console.log(value,"vvv") this.localDataSource[rowIndex][col.prop][tagIndex] = value; this.onErrorUpdate(rowIndex, colIndex, col.prop, value?false:true); - this.$emit("onCheckboxTagChange", rowIndex, col, tagIndex, value) + this.$emit("onCheckboxTagChange", rowIndex, col, this.localDataSource[rowIndex][col.prop]) }, handleClickButton(e, data, key, rowIndex, colIndex) { this.$emit("clickButton", key, rowIndex, colIndex, e, data,) diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index a42a2f4..5bec01e 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -24,12 +24,11 @@ :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" v-model="inputValue" :disabled="getDisabled()" :placeholder="getPlaceholder()" @change="onItemCheckboxChange"> - - + + {{ option.label }} @@ -41,11 +40,10 @@ {{ option.label }}
- +
@@ -63,7 +61,7 @@ {{ $t(item.buttonName) }} - +
- +
- - - {{ tagValue}} + + + {{ tagValue }} - - + +
@@ -248,23 +237,23 @@ export default { }, data() { let initialValue = this.value; - let initialOtherValues = {},checkboxTagChecked = false,tagValue = ''; - + let initialOtherValues = {}, checkboxTagChecked = false, tagValue = ''; + // 如果是checkboxList类型且value是对象格式 if (this.type === 'checkboxList' && this.value && typeof this.value === 'object') { initialValue = this.value.checkboxValues || []; initialOtherValues = this.value.otherValues || {}; } else if (this.type === 'checkboxList' && !Array.isArray(this.value)) { initialValue = []; - }else if (this.type === 'checkboxTag' && this.value && typeof this.value === 'object') { - checkboxTagChecked = this.value.checked || false; + } else if (this.type === 'checkboxTag' && this.value && typeof this.value === 'object') { + checkboxTagChecked = this.value.checked; tagValue = this.value.tagValue || ''; } return { inputValue: initialValue, oldValue: initialValue, // 记录上一次的值 otherValues: initialOtherValues, // 存储checkboxList中otherCode对应的输入值 - oldOtherValues: {...initialOtherValues}, // 记录上一次的otherValues + oldOtherValues: { ...initialOtherValues }, // 记录上一次的otherValues showModal: false, // 控制模态框显示 modificationRecords: [], // 存储修改记录 modalTimer: null, // 用于延迟隐藏模态框 @@ -275,6 +264,7 @@ export default { visible: false,//是否显示弹窗 checkboxValue: this.getChecked(),//是否选中 checkboxTagChecked: checkboxTagChecked, // checkboxTag类型的checkbox选中状态 + oldCheckboxTagChecked: checkboxTagChecked, // checkboxTag类型的checkbox选中状态 tagValue: tagValue, // checkboxTag类型的tag值 uuid: getuuid(), // 唯一标识符,用于EventBus事件匹配 regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq', 'jcb', 'qxbd'], //试剂/仪器/供试品等类型 @@ -290,7 +280,7 @@ export default { }, watch: { value(newVal) { - console.log(newVal,"newVal") + console.log(newVal, "newVal") if (this.type === 'checkboxList' && newVal && typeof newVal === 'object') { this.inputValue = newVal.checkboxValues || []; this.otherValues = newVal.otherValues || {}; @@ -333,13 +323,13 @@ export default { EventBus.$off("onMixReagentSubmit", this.onMixReagentSubmit) }, methods: { - getFlexClass(){ - const noFlexArr = ["radio","checkboxTag"] + getFlexClass() { + const noFlexArr = ["radio", "checkboxTag"] return noFlexArr.includes(this.type) ? '' : 'flex1' }, - getDecimalDigits(){ - const {precision} = this.item; - if(!isNaN(precision)){ + getDecimalDigits() { + const { precision } = this.item; + if (!isNaN(precision)) { return precision } return 6 @@ -531,11 +521,11 @@ export default { // 执行试剂提交的共同逻辑 executeReagentSubmit(data) { this.inputValue = data.selectedId; - const {filledCodes=[]} = this.item; - console.log(filledCodes,"filledCodes") - const {selectInfo,row} = data; - if(filledCodes.length>0){ - this.inputValue = row[filledCodes[0]]+"("+row[filledCodes[1]]+")"; + const { filledCodes = [] } = this.item; + console.log(filledCodes, "filledCodes") + const { selectInfo, row } = data; + if (filledCodes.length > 0) { + this.inputValue = row[filledCodes[0]] + "(" + row[filledCodes[1]] + ")"; } this.selectRegentInfo = data; EventBus.$emit("hideSelectMixReagentDialog"); @@ -779,7 +769,7 @@ export default { // 检查是否有被取消选中的checkbox if (this.oldValue && Array.isArray(this.oldValue)) { const uncheckedValues = this.oldValue.filter(oldVal => !this.inputValue.includes(oldVal)); - + // 清除被取消选中的checkbox对应的otherValues if (uncheckedValues.length > 0) { this.item.options.forEach(option => { @@ -790,19 +780,19 @@ export default { } } value = { - checkboxValues: this.inputValue, - otherValues: this.otherValues - }; - if(val){ - + checkboxValues: this.inputValue, + otherValues: this.otherValues + }; + if (val) { + this.onCommonHandleSaveRecord(); } } - + this.$emit('input', value); this.$emit('change', value); - + // 根据输入值判断是否显示错误状态 const isEmpty = this.isValueEmpty(value); @@ -818,7 +808,8 @@ export default { this.onInputChange(); }, // checkboxTag的checkbox变化处理 - onCheckboxTagChange() { + onCheckboxTagChange(e) { + this.checkboxTagChecked = e; this.emitCheckboxTagValue(); this.onCommonHandleSaveRecord(); }, @@ -917,19 +908,24 @@ export default { this.$emit("change", this.inputValue); return; } - + // 值发生了变化,需要弹出密码输入框 - const isSame = this.isEqual(this.oldValue, this.inputValue); - let isOtherValuesSame = true; + let isSame = true, isOldValueEmpty = true; // 如果是checkboxList类型,需要同时比较otherValues if (this.type === 'checkboxList' && this.otherValues) { - isOtherValuesSame = this.isEqual(this.oldOtherValues, this.otherValues); - } - console.log(this.oldValue, this.inputValue, isSame, isOtherValuesSame,this.otherValues,this.oldOtherValues,"是否需要记录修改记录") - if (isSame && isOtherValuesSame) { + isSame = this.isEqual(this.oldOtherValues, this.otherValues); + isOldValueEmpty = this.isValueEmpty(this.oldOtherValues); + } else if (this.type === "checkboxTag") { + isSame = this.isEqual(this.oldCheckboxTagChecked, this.checkboxTagChecked); + isOldValueEmpty = this.isValueEmpty(this.oldCheckboxTagChecked); + }else{ + isSame = this.isEqual(this.oldValue, this.inputValue) + isOldValueEmpty = this.isValueEmpty(this.oldValue); + } + if (isSame) { return; } - if (!this.isValueEmpty(this.oldValue) && !(isSame && isOtherValuesSame) && this.templateFillType === "actFill") { + if (!isOldValueEmpty && !(isSame) && this.templateFillType === "actFill") { // 通过EventBus触发电子签名弹窗 EventBus.$emit('showEditSignDialog', { uuid: this.uuid }); } else {//如果是第一次填写,不需要密码验证 @@ -942,11 +938,16 @@ export default { // 用户点击取消,还原数据 let oldValue = this.oldValue; if (this.type === 'checkboxList') { - oldValue = { + oldValue = { checkboxValues: oldValue.checkboxValues || oldValue, otherValues: this.oldOtherValues }; - } + }else if(this.type === "checkboxTag"){ + oldValue = { + checked: this.oldCheckboxTagChecked, + tagValue: this.tagValue, + }; + } this.inputValue = this.oldValue; this.$emit('input', oldValue); // 触发 v-model 更新 // this.$emit("blur", this.oldValue); @@ -957,20 +958,26 @@ export default { }, //处理更新记录 - handleUpdateRecord(data,recordData) { + handleUpdateRecord(data, recordData) { const baseInfo = this.getCommonRecordInfo(); - if (!this.oldValue && !this.inputValue){ + if (!this.oldValue && !this.inputValue) { return } - if(recordData){ + if (recordData) { this.oldValue = recordData.oldValue; this.inputValue = recordData.inputValue; } + let recordOldVlaue = this.oldValue,recordValue = this.inputValue,isModify = !!this.oldValue; + if(this.type === "checkboxTag"){ + recordOldVlaue =this.oldValue? `${this.oldValue.tagValue}:${this.oldValue.checked?'勾选':'未勾选'}`:''; + recordValue = `${this.inputValue?.tagValue}:${this.inputValue?.checked?'勾选':'未勾选'}`; + isModify = this.oldValue.checked !== undefined; + } const record = { ...baseInfo, - oldValue: this.oldValue, - value: this.inputValue, - title: this.oldValue ? "修改" : "提交", + oldValue: recordOldVlaue, + value: recordValue, + title: isModify ? "修改" : "提交", time: moment().format("YYYY-MM-DD HH:mm:ss"), } if (data) { @@ -982,11 +989,13 @@ export default { newRecord: [record], resourceList: this.getZdxgjl(), } - - // 更新oldValue和oldOtherValues + + // 更新oldValue和oldOtherValues if (this.type === 'checkboxList') { this.oldValue = [...this.inputValue]; this.oldOtherValues = { ...this.otherValues }; + }else if(this.type === "checkboxTag"){ + this.oldCheckboxTagChecked = this.checkboxTagChecked; } let value = this.inputValue; if (this.type === 'checkboxList') { @@ -994,10 +1003,15 @@ export default { checkboxValues: this.inputValue, otherValues: this.otherValues }; + }else if(this.type === "checkboxTag"){ + value = { + checked: this.checkboxTagChecked, + tagValue: this.tagValue, + }; } - if(this.type === "button"){ - this.$emit('clickButton', this.item,this.inputValue,data); - if(this.templateFillType === "preFill"){ + if (this.type === "button") { + this.$emit('clickButton', this.item, this.inputValue, data); + if (this.templateFillType === "preFill") { return; } } @@ -1015,7 +1029,7 @@ export default { } this.$nextTick(() => { EventBus.$emit('onModifyRecord', params,) - console.log(params,"onModifyRecord") + console.log(params, "onModifyRecord") if (this.regentType.includes(this.item.type)) { this.$emit("onRegentSubmit", this.selectRegentInfo, this.inputValue); } @@ -1104,7 +1118,7 @@ export default { isShowHandle() { const { fillType } = this.item; //只有当模板状态不是预填时,才显示操作按钮 - return this.templateFillType !== "preFill" && fillType === "actFill"&&this.type!=="button" + return this.templateFillType !== "preFill" && fillType === "actFill" && this.type !== "button" }, //判断是否禁用 getDisabled() { @@ -1580,15 +1594,17 @@ export default { margin-right: 16px; display: flex; align-items: center; + &:not(:last-child) { margin-bottom: 10px; } + // display: inline-block; - + .el-input { width: 200px; margin-left: 10px; - + &.error-border { .el-input__inner { border-color: #ff5d5d !important; @@ -1598,7 +1614,7 @@ export default { } } - + } .orange-border { @@ -1610,6 +1626,7 @@ export default { } } + .el-checkbox { &.is-checked { .el-checkbox__label { @@ -1622,6 +1639,7 @@ export default { } } } + .el-radio { &.is-checked { .el-radio__label { @@ -1663,6 +1681,7 @@ export default { .tag-content { cursor: pointer; position: relative; + .tag-input { width: 100px; } @@ -1680,13 +1699,13 @@ export default { padding: 2px; border-radius: 50%; position: absolute; - top:6px; - right:5px; + top: 6px; + right: 5px; // transition: all 0.3s; // &:hover { - color: red; - background-color: #f5f5f5; + color: red; + background-color: #f5f5f5; // } } } diff --git a/src/components/Template/mixins/formPackageMixins.js b/src/components/Template/mixins/formPackageMixins.js index 1c6ab3a..4af3cb3 100644 --- a/src/components/Template/mixins/formPackageMixins.js +++ b/src/components/Template/mixins/formPackageMixins.js @@ -261,7 +261,6 @@ export default { selectInfoKeys.forEach(key => { result[key] = formData[key]; }) - console.log(config,"allConfig") // 更新表单字段 this.formFields = result; this.allFieldsConfig = config; diff --git a/src/views/business/comps/template/comps/yp/YP003.vue b/src/views/business/comps/template/comps/yp/YP003.vue index 41c0aca..87a7963 100644 --- a/src/views/business/comps/template/comps/yp/YP003.vue +++ b/src/views/business/comps/template/comps/yp/YP003.vue @@ -19,8 +19,9 @@ :formData="formData" operationWidth = "80px" :prefixKey = "`table`" - fieldItemLabel = "template.common.operationSteps" + fieldItemLabel = "template.yp.yp003.ybxx" @clickButton="handleClickButton" + @onCheckboxTagChange="onCheckboxTagChange" :showOperation="fillType === 'preFill'" >