3 Commits

5 changed files with 89 additions and 56 deletions
Unified View
  1. +2
    -2
      src/components/Template/CustomTable.vue
  2. +15
    -10
      src/components/Template/HandleFormItem.vue
  3. +47
    -43
      src/components/Template/mixins/formPackageMixins.js
  4. +24
    -0
      src/utils/conConverter.js
  5. +1
    -1
      src/views/business/comps/template/mixins/templateMixin.js

+ 2
- 2
src/components/Template/CustomTable.vue View File

@ -31,7 +31,7 @@
:value="headerFields[`${colIndex}_${headerIndex}`]" :value="headerFields[`${colIndex}_${headerIndex}`]"
:error="hasHeaderError(colIndex, headerIndex, headerCol.key)" :error="hasHeaderError(colIndex, headerIndex, headerCol.key)"
@update:error="onHeaderColumnErrorUpdate(colIndex, headerIndex, headerCol.key, $event)" @update:error="onHeaderColumnErrorUpdate(colIndex, headerIndex, headerCol.key, $event)"
:orange-bg="regentIsExpired(headerCol.key,rowIndex)"
:orange-bg="regentIsExpired(headerCol.key,colIndex)"
@onRegentSubmit="(data, inputValue) => onHeaderRegentSubmit(data, inputValue, colIndex, headerIndex)" /> @onRegentSubmit="(data, inputValue) => onHeaderRegentSubmit(data, inputValue, colIndex, headerIndex)" />
</template> </template>
<template <template
@ -548,7 +548,7 @@ export default {
}, },
// //
regentIsExpired(key,rowIndex) { regentIsExpired(key,rowIndex) {
const item = this.localDataSource[rowIndex];
const item = this.localDataSource[rowIndex] || {};
const { yxq, sxrq } = item[`selectInfo_${key}`] || {}; const { yxq, sxrq } = item[`selectInfo_${key}`] || {};
const rq = sxrq || yxq; const rq = sxrq || yxq;
if (rq) { if (rq) {

+ 15
- 10
src/components/Template/HandleFormItem.vue View File

@ -1245,7 +1245,10 @@ export default {
return return
} }
let finallyKey = this.fieldKey; let finallyKey = this.fieldKey;
if (recordData) {
this.oldValue = recordData.oldValue;
this.inputValue = recordData.inputValue;
}
let recordOldVlaue = this.oldValue, recordValue = this.inputValue, isModify = !!this.oldValue,oldUrl = "",url=""; let recordOldVlaue = this.oldValue, recordValue = this.inputValue, isModify = !!this.oldValue,oldUrl = "",url="";
if (this.type === "checkboxTag") { if (this.type === "checkboxTag") {
// checkboxTagtagIndex // checkboxTagtagIndex
@ -1288,10 +1291,10 @@ export default {
oldUrl = oldAttList.map(item => item.url).join("|"); oldUrl = oldAttList.map(item => item.url).join("|");
url = attList.map(item => item.url).join("|"); url = attList.map(item => item.url).join("|");
} }
if (recordData) {
recordOldVlaue = recordData.oldValue;
recordValue = recordData.inputValue;
}
// if (recordData) {
// recordOldVlaue = recordData.oldValue;
// recordValue = recordData.inputValue;
// }
const record = { const record = {
...baseInfo, ...baseInfo,
oldValue: recordOldVlaue, oldValue: recordOldVlaue,
@ -1355,12 +1358,14 @@ export default {
this.updateZdxgjl(record); this.updateZdxgjl(record);
this.updateSubmittedCodes(finallyKey); this.updateSubmittedCodes(finallyKey);
} }
if (isRegent(this.item)) {
this.$emit("onRegentSubmit", this.selectRegentInfo, this.inputValue);
}
this.$nextTick(() => { this.$nextTick(() => {
EventBus.$emit('onModifyRecord', params,)
console.log(params, "onModifyRecord")
if (isRegent(this.item)) {
this.$emit("onRegentSubmit", this.selectRegentInfo, this.inputValue);
}
setTimeout(() => {
EventBus.$emit('onModifyRecord', params,)
}, 100);
}) })
}, },

+ 47
- 43
src/components/Template/mixins/formPackageMixins.js View File

@ -1,5 +1,5 @@
import _ from 'lodash' import _ from 'lodash'
import { getuuid, isEqual, isValueEmpty } from '@/utils/index.js'
import { getuuid, isEqual, isValueEmpty,isRegent } from '@/utils/index.js'
import { isShowOtherByCheckboxTree } from '@/utils/formPackageCommon.js' import { isShowOtherByCheckboxTree } from '@/utils/formPackageCommon.js'
import moment from 'moment' import moment from 'moment'
@ -52,8 +52,8 @@ export default {
if (currentConfig?.selectTo) { if (currentConfig?.selectTo) {
this.formFields[currentConfig?.selectTo] = val this.formFields[currentConfig?.selectTo] = val
if (this.errors[currentConfig?.selectTo]) { if (this.errors[currentConfig?.selectTo]) {
this.$set(this.errors, currentConfig?.selectTo, false)
}
this.$set(this.errors, currentConfig?.selectTo, false)
}
} }
this.onValueChangeCompareTo(key, val) this.onValueChangeCompareTo(key, val)
this.formFields[key] = val this.formFields[key] = val
@ -76,10 +76,9 @@ export default {
}, },
//试剂/仪器等弹窗提交 //试剂/仪器等弹窗提交
onRegentSubmit(data, inputValue, key, item) { onRegentSubmit(data, inputValue, key, item) {
this.updateFormData(key, inputValue)
this.formFields[`selectInfo_${key}`] = data.selectInfo;
if(data.type === "yq"){
this.formFields[`yqInfo_${key}`] = data.row;
this.formFields[`selectInfo_${key}`] = JSON.parse(JSON.stringify(data.selectInfo));
if (data.type === "yq") {
this.formFields[`yqInfo_${key}`] = JSON.parse(JSON.stringify(data.row));
} }
this.$emit('onRegentSubmit', { this.$emit('onRegentSubmit', {
selectInfo: data, selectInfo: data,
@ -87,9 +86,10 @@ export default {
key, key,
config: item config: item
}) })
this.updateFormData(key, inputValue)
}, },
onBeforeReagentSubmit(data, callback, key) { onBeforeReagentSubmit(data, callback, key) {
this.$emit('beforeReagentSubmit', { selectData: data, callback, key, formFields: this.formFields })
this.$emit('beforeReagentSubmit', { selectData: data, callback, key, formFields: this.formFields })
}, },
getRegentItem(item, fieldCode = 'type') { getRegentItem(item, fieldCode = 'type') {
const type = item[fieldCode] const type = item[fieldCode]
@ -139,7 +139,7 @@ export default {
}, },
//更新表单数据 //更新表单数据
updateFormData(key, value, data) { updateFormData(key, value, data) {
const { isUpdateRecord, signData,record } = data || {}
const { isUpdateRecord, signData, record } = data || {}
// 深拷贝当前表单数据,避免直接修改原数据 // 深拷贝当前表单数据,避免直接修改原数据
const cloneFormFields = JSON.parse(JSON.stringify(this.formFields)) const cloneFormFields = JSON.parse(JSON.stringify(this.formFields))
@ -149,10 +149,10 @@ export default {
if (this.errors[key]) { if (this.errors[key]) {
this.$set(this.errors, key, false) this.$set(this.errors, key, false)
} }
const re = record||{
oldValue: this.oldFormFields[key],
inputValue: value
}
const re = record || {
oldValue: this.oldFormFields[key],
inputValue: value
}
if (isUpdateRecord) { if (isUpdateRecord) {
setTimeout(() => { setTimeout(() => {
this.$refs[key][0].handleUpdateRecord(signData, re) this.$refs[key][0].handleUpdateRecord(signData, re)
@ -392,36 +392,40 @@ export default {
if (item.config?.thirdOtherCode) { if (item.config?.thirdOtherCode) {
config[item.config?.thirdOtherCode] = item.config?.thirdOtherCode config[item.config?.thirdOtherCode] = item.config?.thirdOtherCode
} }
if (isRegent(item.config) || isRegent(item.config,"subType")) {
// 处理selectInfo_开头的字段,步骤表单需要保留selectInfo_开头的字段
// 优先使用this.formFields中以selectInfo_开头的字段
let selectInfoKeys = [], yqInfoKeys = [];
if (this.formFields) {
selectInfoKeys = Object.keys(this.formFields).filter((key) =>
key.startsWith('selectInfo_')
)
yqInfoKeys = Object.keys(this.formFields).filter((key) =>
key.startsWith('yqInfo_')
)
}
// 如果this.formFields中没有,则使用formData中的
if (selectInfoKeys.length === 0 && formData) {
selectInfoKeys = Object.keys(formData).filter((key) =>
key.startsWith('selectInfo_')
)
}
if (yqInfoKeys.length === 0 && formData) {
yqInfoKeys = Object.keys(formData).filter((key) =>
key.startsWith('yqInfo_')
)
}
selectInfoKeys.forEach((key) => {
result[key] = this.formFields[key] || formData[key] || ''
})
yqInfoKeys.forEach((key) => {
result[key] = this.formFields[key] || formData[key] || ''
})
}
} }
}) })
// 处理selectInfo_开头的字段,步骤表单需要保留selectInfo_开头的字段
// 优先使用this.formFields中以selectInfo_开头的字段
let selectInfoKeys = [],yqInfoKeys = [];
if (this.formFields) {
selectInfoKeys = Object.keys(this.formFields).filter((key) =>
key.startsWith('selectInfo_')
)
yqInfoKeys = Object.keys(this.formFields).filter((key) =>
key.startsWith('yqInfo_')
)
}
// 如果this.formFields中没有,则使用formData中的
if (selectInfoKeys.length === 0 && formData) {
selectInfoKeys = Object.keys(formData).filter((key) =>
key.startsWith('selectInfo_')
)
}
if (yqInfoKeys.length === 0 && formData) {
yqInfoKeys = Object.keys(formData).filter((key) =>
key.startsWith('yqInfo_')
)
}
selectInfoKeys.forEach((key) => {
result[key] = this.formFields[key] || formData[key] || ''
})
yqInfoKeys.forEach((key) => {
result[key] = this.formFields[key] || formData[key] || ''
})
// 更新表单字段 // 更新表单字段
this.formFields = { ...result } this.formFields = { ...result }
this.allFieldsConfig = config this.allFieldsConfig = config
@ -661,8 +665,8 @@ export default {
getFormDataByKey(key) { getFormDataByKey(key) {
return this.formFields[key] return this.formFields[key]
}, },
onBeforeSaveRecord(data, callback, item){
this.$emit('beforeSaveRecord', {data, callback,item})
onBeforeSaveRecord(data, callback, item) {
this.$emit('beforeSaveRecord', { data, callback, item })
}, },
onBlur(key, val) { onBlur(key, val) {
// compareTo 功能:当fillType==="actFill"时,判断当前值是否与compareTo字段的值一样,如果不一样则将当前input框的背景色标记成橙色 // compareTo 功能:当fillType==="actFill"时,判断当前值是否与compareTo字段的值一样,如果不一样则将当前input框的背景色标记成橙色

+ 24
- 0
src/utils/conConverter.js View File

@ -1,8 +1,30 @@
/** /**
* 浓度单位转换 同一类别内转换 * 浓度单位转换 同一类别内转换
*/ */
import { Message } from 'element-ui';
class ConcentrationConverter { class ConcentrationConverter {
// 用于防抖的消息缓存
messageCache = {};
/**
* 防抖显示消息相同消息在指定时间内只显示一次
* @param {string} message - 消息内容
* @param {string} type - 消息类型
* @param {number} delay - 防抖时间毫秒默认2000ms
*/
showDebouncedMessage(message, type = 'warning', delay = 2000) {
const now = Date.now();
const cacheKey = `${message}_${type}`;
if (!this.messageCache[cacheKey] || now - this.messageCache[cacheKey] > delay) {
this.messageCache[cacheKey] = now;
Message({
message: message,
type: type
});
}
}
// 单位换算系数 // 单位换算系数
unitFactors = { unitFactors = {
// 质量单位(以g为基准) // 质量单位(以g为基准)
@ -128,11 +150,13 @@ class ConcentrationConverter {
// 3. 检查是否为%单位 // 3. 检查是否为%单位
if (inputUnit === '%' || normalizedTargetUnit === '%') { if (inputUnit === '%' || normalizedTargetUnit === '%') {
// %单位是单独的系列,不进行转换 // %单位是单独的系列,不进行转换
this.showDebouncedMessage(`单位类别不匹配: ${inputUnit} 不能转换为 ${targetUnit},请重新选择`);
throw new Error(`单位类别不匹配: ${inputUnit} 不能转换为 ${targetUnit}`); throw new Error(`单位类别不匹配: ${inputUnit} 不能转换为 ${targetUnit}`);
} }
// 4. 验证单位类别 // 4. 验证单位类别
if (!this.isSameCategory(inputUnit, normalizedTargetUnit)) { if (!this.isSameCategory(inputUnit, normalizedTargetUnit)) {
this.showDebouncedMessage(`单位类别不匹配: ${inputUnit} 不能转换为 ${targetUnit},请重新选择`);
throw new Error(`单位类别不匹配: ${inputUnit} 不能转换为 ${targetUnit}`); throw new Error(`单位类别不匹配: ${inputUnit} 不能转换为 ${targetUnit}`);
} }

+ 1
- 1
src/views/business/comps/template/mixins/templateMixin.js View File

@ -307,7 +307,7 @@ export default {
} else if (nd === 'NA') { } else if (nd === 'NA') {
callback.prevent('当前实际浓度为NA,请重新选择') callback.prevent('当前实际浓度为NA,请重新选择')
} else if (ytndArr.length !== sjndArr.length) { } else if (ytndArr.length !== sjndArr.length) {
callback.prevent('起始溶液浓度和目标溶液浓度格式不一致,请重新输入')
callback.prevent('起始溶液浓度和目标溶液浓度格式不一致,请重新选择')
} }
}, },
getFormDataByTemplateData() { getFormDataByTemplateData() {

Loading…
Cancel
Save