From 8befa8a505ba82571d77ac09245b732c6560b8f8 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Mon, 16 Mar 2026 21:52:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][sp0?= =?UTF-8?q?21]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/BaseInfoFormPackage.vue | 150 +++++++--------- src/components/Template/DecimalInput.vue | 194 ++++++++++----------- .../comps/template/comps/sp/comps/LadderConfig.vue | 22 +-- .../comps/template/formConfig/gsp/gsp015.js | 10 +- 4 files changed, 177 insertions(+), 199 deletions(-) diff --git a/src/components/Template/BaseInfoFormPackage.vue b/src/components/Template/BaseInfoFormPackage.vue index 79a754f..b8f4d96 100644 --- a/src/components/Template/BaseInfoFormPackage.vue +++ b/src/components/Template/BaseInfoFormPackage.vue @@ -104,10 +104,10 @@ {{ $t(sItem.subText) }} + @clickButton="(e, val, data) => handleClickButton(e, sItem, val, data, sItem.subKey)" /> + @clickButton="(e, val, data) => handleClickButton(e, sItem, val, data, sItem.thirdKey)" />
@@ -212,49 +212,52 @@
- - -
{{ - formFields[sItem.subKey] }}
- {{ $t(sItem.subText) }} -
- -
- - - -
+ +
+ :item="getThirdButtonItem(sItem)" :value="formFields[sItem.thirdKey]" + @clickButton="(e, val, data) => handleClickButton(e, sItem, val, data, sItem.thirdKey)" />
{{ sItem.otherLabel ? @@ -269,44 +272,9 @@ :orange-bg="orangeBgFields[sItem.otherCode]" />
- +
- +
+ @clickButton="(e, val, data) => handleClickButton(e, sItem, val, data, sItem.fourthKey)" />
@@ -427,6 +395,20 @@ export default { }; }, methods: { + isShowSub(item,type){ + if(type === 'thirdType'){ + if (item.hasOwnProperty("showThird")) { + return item.showThird + } + return item.thirdType && item.thirdKey; + } + if (item.hasOwnProperty("showSub")) { + return item.showSub + } else if (item.subType === 'text') {//如果是span没有值的话就隐藏 + return true; + } + return item.subType && item.subKey; + }, remoteMethod(query, sItem, key) { this.$emit('remoteMethod', { query, sItem, key, formFields: this.formFields }) }, @@ -439,11 +421,11 @@ export default { this.$emit('beforeReagentSubmit', { selectData: data, callback, key, formFields: this.formFields }) }, // 点击按钮 - handleClickButton(e, item, val, data,key) { + handleClickButton(e, item, val, data, key) { if (!item.isClearForm) { - this.formFields[item.subKey] = val; + this.formFields[key] = val; } - this.$emit("clickButton", item, data,key,this.formFields) + this.$emit("clickButton", item, data, key, this.formFields) }, // 获取按钮项 getButtonItem(sItem) { diff --git a/src/components/Template/DecimalInput.vue b/src/components/Template/DecimalInput.vue index e5adbd9..4c17c67 100644 --- a/src/components/Template/DecimalInput.vue +++ b/src/components/Template/DecimalInput.vue @@ -38,6 +38,7 @@ export default { internalValue: this.value !== null && this.value !== undefined ? String(this.value) : '', oldValue: null, oldPattern: null, + isNA: this.value !== null && this.value !== undefined ? /^NA$/i.test(String(this.value).toUpperCase()) : false, patternRules: [ { name: 'NA', pattern: /^NA$/i, inputPattern: /^N?A?$/i }, { name: 'FRACTION', pattern: /^\d+(\/\d+)*$/, inputPattern: /^(\d+\/?)*$/ } @@ -51,9 +52,11 @@ export default { this.internalValue = ''; this.oldValue = null; this.oldPattern = null; + this.isNA = false; } else { const strVal = String(newVal); this.internalValue = strVal; + this.isNA = /^NA$/i.test(strVal.toUpperCase()); this.updateOldValue(strVal); } }, @@ -84,123 +87,118 @@ export default { handleInput(val) { if (val === '') { this.internalValue = ''; + this.isNA = false; this.$emit('input', ''); return; } + // 检查是否已经输入了完整的NA + if (this.isNA) { + // 如果已经输入了NA,无论输入什么,都保持NA不变 + this.internalValue = 'NA'; + this.$emit('input', 'NA'); + return; + } + const upperVal = val.toUpperCase(); let cleaned = val; let matchedRule = null; - if (this.oldPattern) { - // 检查是否是旧模式的延续(以oldValue开头) - if (val.startsWith(this.oldValue)) { - // 是旧模式的延续,检查是否符合inputPattern - if (this.oldPattern.inputPattern.test(val)) { - matchedRule = this.oldPattern; - cleaned = val; - } else { - // 不符合,但如果是FRACTION类型,尝试特殊处理 - if (this.oldPattern.name === 'FRACTION') { - cleaned = val.replace(/[^\d/]/g, ''); - const parts = cleaned.split('/'); - const validParts = []; - for (let i = 0; i < parts.length; i++) { - if (parts[i] !== '') { - validParts.push(parts[i]); - } - } - cleaned = validParts.join('/'); - matchedRule = this.oldPattern; - } else { - cleaned = this.oldValue || ''; - this.internalValue = cleaned; - return; - } - } - } else if (this.oldPattern.inputPattern.test(val)) { - // 不是延续,但符合inputPattern(可能是清空后重新输入) - matchedRule = this.oldPattern; - cleaned = val; - } else { - // 尝试匹配新规则 - matchedRule = this.getMatchingRule(val); - if (!matchedRule) { - cleaned = this.oldValue || ''; - this.internalValue = cleaned; - return; - } - } + + // 检查是否匹配特殊模式(NA或FRACTION) + // 优先检查完整的NA模式 + if (/^NA$/i.test(upperVal)) { + matchedRule = { name: 'NA', pattern: /^NA$/i, inputPattern: /^N?A?$/i }; + cleaned = upperVal; + this.isNA = true; + } else if (upperVal === 'N' || upperVal === 'A') { + // 部分匹配NA模式 + matchedRule = { name: 'NA', pattern: /^NA$/i, inputPattern: /^N?A?$/i }; + cleaned = upperVal; } else { + // 检查FRACTION模式 matchedRule = this.getMatchingRule(val); - - if (matchedRule) { - if (matchedRule.name === 'FRACTION') { - cleaned = val.replace(/[^\d/]/g, ''); - const parts = cleaned.split('/'); - const validParts = []; - for (let i = 0; i < parts.length; i++) { - if (parts[i] !== '') { - validParts.push(parts[i]); - } + } + + if (matchedRule) { + if (matchedRule.name === 'FRACTION') { + cleaned = val.replace(/[^\d/]/g, ''); + const parts = cleaned.split('/'); + const validParts = []; + for (let i = 0; i < parts.length; i++) { + if (parts[i] !== '' || i === parts.length - 1) { + validParts.push(parts[i]); } - cleaned = validParts.join('/'); - } else { - cleaned = upperVal; } + cleaned = validParts.join('/'); } else { - cleaned = val - .replace(/[^\d.-]/g, '') - .replace(/^(-)\1+/, '$1'); + cleaned = upperVal; + } + } else { + // 处理数字和小数点输入 + cleaned = val + .replace(/[^\d.-]/g, '') + .replace(/^(-)\1+/, '$1'); - const firstDotIndex = cleaned.indexOf('.'); - if (firstDotIndex !== -1) { - const before = cleaned.slice(0, firstDotIndex); - const after = cleaned.slice(firstDotIndex + 1).replace(/\./g, ''); - cleaned = before + '.' + after; - } + // 确保只有一个小数点 + const firstDotIndex = cleaned.indexOf('.'); + if (firstDotIndex !== -1) { + const before = cleaned.slice(0, firstDotIndex); + const after = cleaned.slice(firstDotIndex + 1).replace(/\./g, ''); + cleaned = before + '.' + after; + } - if (this.decimalDigits > 0 && cleaned.includes('.')) { - const [intPart, decPart = ''] = cleaned.split('.'); - cleaned = intPart + '.' + decPart.slice(0, this.decimalDigits); - } else if (this.decimalDigits === 0) { - cleaned = cleaned.split('.')[0]; - } + // 处理小数点位数限制 + if (this.decimalDigits > 0 && cleaned.includes('.')) { + const [intPart, decPart = ''] = cleaned.split('.'); + cleaned = intPart + '.' + decPart.slice(0, this.decimalDigits); + } else if (this.decimalDigits === 0) { + cleaned = cleaned.split('.')[0]; + } - if (cleaned === '.') cleaned = '0.'; - else if (cleaned === '-.') cleaned = '-0.'; - else if (cleaned.startsWith('.')) cleaned = '0' + cleaned; - else if (cleaned.startsWith('-.')) cleaned = '-0.' + cleaned.slice(2); + // 处理以小数点开头的情况 + if (cleaned === '.') cleaned = '0.'; + else if (cleaned === '-.') cleaned = '-0.'; + else if (cleaned.startsWith('.')) cleaned = '0' + cleaned; + else if (cleaned.startsWith('-.')) cleaned = '-0.' + cleaned.slice(2); - if (cleaned.includes('.')) { - const [int, dec] = cleaned.split('.'); - let newInt = int; - if (/^-?0+\d/.test(int)) { - newInt = int.replace(/^-?0+(\d)/, '$1'); - } else if (int === '' || int === '-') { - newInt = int + '0'; - } else if (int === '00' || /^-00+$/.test(int)) { - newInt = int.startsWith('-') ? '-0' : '0'; - } - cleaned = newInt + '.' + dec; - } else { - if (/^-?0+\d/.test(cleaned)) { - cleaned = cleaned.replace(/^-?0+(\d)/, '$1'); - } else if (cleaned === '00' || /^-00+$/.test(cleaned)) { - cleaned = cleaned.startsWith('-') ? '-0' : '0'; - } + // 处理整数部分的前导零 + if (cleaned.includes('.')) { + const [int, dec] = cleaned.split('.'); + let newInt = int; + if (/^-?0+\d/.test(int)) { + newInt = int.replace(/^-?0+(\d)/, '$1'); + } else if (int === '' || int === '-') { + newInt = int + '0'; + } else if (int === '00' || /^-00+$/.test(int)) { + newInt = int.startsWith('-') ? '-0' : '0'; + } + cleaned = newInt + '.' + dec; + } else { + if (/^-?0+\d/.test(cleaned)) { + cleaned = cleaned.replace(/^-?0+(\d)/, '$1'); + } else if (cleaned === '00' || /^-00+$/.test(cleaned)) { + cleaned = cleaned.startsWith('-') ? '-0' : '0'; } } } this.internalValue = cleaned; + // 处理emit值 if (cleaned === '' || cleaned === '-') { this.$emit('input', cleaned === '-' ? '-' : ''); } else if (matchedRule && matchedRule.name !== 'FRACTION') { this.$emit('input', cleaned); } else if (cleaned.includes('/')) { this.$emit('input', cleaned); + } else if (cleaned.includes('.')) { + // 对于包含小数点的情况,先emit字符串以保持小数点 + this.$emit('input', cleaned); + } else if (matchedRule && matchedRule.name === 'FRACTION') { + // 对于FRACTION模式的整数,保持字符串形式以支持后续输入斜杠 + this.$emit('input', cleaned); } else { + // 对于纯数字,转换为数字 const num = parseFloat(cleaned); this.$emit('input', isNaN(num) ? '' : num); } @@ -238,6 +236,7 @@ export default { if (val === '') { this.oldValue = null; this.oldPattern = null; + this.isNA = false; this.$emit('input', ''); this.$emit('blur', ''); return; @@ -245,17 +244,20 @@ export default { const upperVal = val.toUpperCase(); + // 检查是否匹配特殊模式 for (const rule of this.patternRules) { if (rule.pattern.test(upperVal)) { this.oldValue = upperVal; this.oldPattern = rule; this.internalValue = upperVal; + this.isNA = /^NA$/i.test(upperVal); this.$emit('input', upperVal); this.$emit('blur', upperVal); return; } } + // 处理分数 if (val.includes('/')) { const parts = val.split('/'); const validParts = parts.filter(part => part !== ''); @@ -292,20 +294,12 @@ export default { return; } - if (this.oldValue && this.oldPattern) { - const partialMatch = this.oldPattern.inputPattern && this.oldPattern.inputPattern.test(val); - if (!partialMatch) { - this.internalValue = this.oldValue; - this.$emit('input', this.oldValue); - this.$emit('blur', this.oldValue); - return; - } - } - + // 处理数字 let formatted = this.handleDecimalDigits(val); this.internalValue = formatted; - this.$emit('input', parseFloat(formatted)); - this.$emit('blur', parseFloat(formatted)); + const num = parseFloat(formatted); + this.$emit('input', isNaN(num) ? '' : num); + this.$emit('blur', isNaN(num) ? '' : num); } } }; diff --git a/src/views/business/comps/template/comps/sp/comps/LadderConfig.vue b/src/views/business/comps/template/comps/sp/comps/LadderConfig.vue index c48435c..9e29f33 100644 --- a/src/views/business/comps/template/comps/sp/comps/LadderConfig.vue +++ b/src/views/business/comps/template/comps/sp/comps/LadderConfig.vue @@ -305,9 +305,9 @@ export default { const { rowData } = val; let postData = { bh: rowData.targetSolutionCode + rowData.subTargetSolutionCode, - studySubjectId: this.formData.studySubjectId, - studyId: this.formData.studyId, - studyFormId: this.formData.id, + studySubjectId: this.currentFormData.studySubjectId, + studyId: this.currentFormData.studyId, + studyFormId: this.currentFormData.id, } this.startConfigRequest(postData); }, @@ -321,9 +321,9 @@ export default { bh: rowData.targetSolutionCode + rowData.subTargetSolutionCode, nd: rowData.actSolutionConcentration,//实际目标溶液浓度 nddw: headerSelectFields.actSolutionConcentrationUnit, - studySubjectId: this.formData.studySubjectId, - studyId: this.formData.studyId, - studyFormId: this.formData.id, + studySubjectId: this.currentFormData.studySubjectId, + studyId: this.currentFormData.studyId, + studyFormId: this.currentFormData.id, kc: total, kcdw: unit, } @@ -342,14 +342,14 @@ export default { } }) let postData = { - studyId: this.formData.studyId, - studyFormId: this.formData.id, + studyId: this.currentFormData.studyId, + studyFormId: this.currentFormData.id, bh: mybh, nd: rowData.actSolutionConcentration || 0, nddw: headerSelectFields.actSolutionConcentrationUnit, - studySubjectId: this.formData.studySubjectId, - studyId: this.formData.studyId, - studyFormId: this.formData.id, + studySubjectId: this.currentFormData.studySubjectId, + studyId: this.currentFormData.studyId, + studyFormId: this.currentFormData.id, list: list } this.subPackageRequest(postData); diff --git a/src/views/business/comps/template/formConfig/gsp/gsp015.js b/src/views/business/comps/template/formConfig/gsp/gsp015.js index 95e22a2..c6703b7 100644 --- a/src/views/business/comps/template/formConfig/gsp/gsp015.js +++ b/src/views/business/comps/template/formConfig/gsp/gsp015.js @@ -90,6 +90,8 @@ export const getYbsmFormConfig = ($this) => { subKey: "startButton", buttonName:"开始", thirdType: 'button', + showSub:$this.fillType === 'actFill', + showThird:$this.fillType === 'actFill', thirdKey: 'endButton', thirdButtonName:"结束", }, @@ -159,7 +161,7 @@ export const getQyTableColumns = ($this) => { prop: 'ysqywz', width: 180, bodyType: 'select', - options: $this.getDictOptions('business_qywz'), + bodyOptions: $this.getDictOptions('business_qywz'), bodyFillType: 'actFill', }, { @@ -167,7 +169,7 @@ export const getQyTableColumns = ($this) => { prop: 'sjqywz', width: 180, bodyType: 'select', - options: $this.getDictOptions('business_qywz'), + bodyOptions: $this.getDictOptions('business_qywz'), bodyFillType: 'actFill', compareTo: 'ysqywz', }, @@ -192,8 +194,8 @@ export const getQyTableColumns = ($this) => { headerOptions: $this.getDictOptions('business_tjdw'), bodyType: 'inputNumber', bodyFillType: 'actFill', - copyFrom: 'ysqyldw', - compareTo: 'ysqyldw', + copyFrom: 'ysqyl', + compareTo: 'ysqyl', }, ] }