From bbf72424d846374eac0ba16b82ffedf40ba98b31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?ZHANGTENG=5C=E5=BC=A0=E8=85=BE?= <894697943@qq.com>
Date: Fri, 13 Mar 2026 09:51:02 +0800
Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86]DJ00?=
=?UTF-8?q?1,DL006=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Template/HandleFormItem.vue | 6 +-
.../business/comps/template/comps/dj/DJ001.vue | 70 +++++++++++++++-------
.../business/comps/template/comps/dl/DL006.vue | 23 ++++---
3 files changed, 66 insertions(+), 33 deletions(-)
diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue
index 2a2879b..e44f737 100644
--- a/src/components/Template/HandleFormItem.vue
+++ b/src/components/Template/HandleFormItem.vue
@@ -1164,8 +1164,8 @@ export default {
isSame = isEqual(current.oldValue, current.newValue);
isOldValueEmpty = isValueEmpty(current.oldValue);
} else if (this.type === "checkboxTree") {
- const current = this.getCheckboxTreeInfo();
- const { oldValue, newValue } = current;
+ const current = this.getCheckboxTreeInfo() || {};
+ const { oldValue = {}, newValue = {} } = current;
if (currentHandleType === "checkboxTreeCheckbox") {
isSame = isEqual(oldValue.checked, newValue.checked);
isOldValueEmpty = oldValue.checked === undefined;
@@ -1248,7 +1248,7 @@ export default {
const current = this.getCheckboxTreeInfo();
if (this.currentHandleType === "checkboxTreeCheckbox") {
const { oldValue, newValue } = current;
- recordOldVlaue = `${oldValue.label || ''}:${oldValue.checked ? '勾选' : '未勾选'}`;
+ recordOldVlaue = `${oldValue?.label || ''}:${oldValue?.checked ? '勾选' : '未勾选'}`;
recordValue = `${newValue.label || ''}:${newValue.checked ? '勾选' : '未勾选'}`;
isModify = newValue.checked !== undefined;
} else {
diff --git a/src/views/business/comps/template/comps/dj/DJ001.vue b/src/views/business/comps/template/comps/dj/DJ001.vue
index 93c6f09..14e7fde 100644
--- a/src/views/business/comps/template/comps/dj/DJ001.vue
+++ b/src/views/business/comps/template/comps/dj/DJ001.vue
@@ -13,7 +13,7 @@
-
{{ $t('template.dj.dj001.fhfw') }}
@@ -159,13 +159,14 @@ export default {
label: 'template.dj.dj001.fhfw',
type: "checkboxTree",
fillType: 'actFill',
- options: this.fhfwCheckOptions
+ options: Array.isArray(this.fhfwCheckOptions) ? this.fhfwCheckOptions : []
},
fhlrCheck: {
label: 'template.dj.dj001.fhlr',
type: "checkboxTree",
fillType: 'actFill',
- options: this.fhlrCheckOptions
+ options: Array.isArray(this.fhlrCheckOptions) ? this.fhlrCheckOptions : []
+
},
}
},
@@ -199,16 +200,17 @@ export default {
},
data() {
return {
- formData: {},
+ formData: {
+ fhfwCheck: { checkedValues: [], otherValues: {} },
+ fhlrCheck: { checkedValues: [], otherValues: {} },
+ },
fhfwCheckOptions:[],
fhlrCheckOptions:[],
isFirstTableDataRecorded: false,
};
},
mounted() {
- setTimeout(()=>{
- this.getTableData()
- },200)
+ this.getTableData()
},
methods: {
//获取已填写的表单数据
@@ -251,23 +253,47 @@ export default {
},
// 获取范围和内容表格数据(核心优化)
getTableData() {
- const formData = this.getFilledFormData() || {};
- const stepTableFormData = formData.stepTableFormData || [];
- const stepTableFormData_1 = formData.stepTableFormData_1 || [];
- // 处理数据为复选框options格式(去重+空值过滤)
- const firstList = stepTableFormData
- .filter(item => item.fhfw) // 过滤空值
- .map(item => ({ label: item.fhfw, value: item.fhfw }))
- .filter((item, index, arr) => arr.findIndex(i => i.value === item.value) === index); // 去重
+ try {
+ const formData = this.getFilledFormData() || {};
+ // 修复:增加空值保护
+ const stepTableFormData = formData.stepTableFormData || this.formData.stepTableFormData || [];
+ const stepTableFormData_1 = formData.stepTableFormData_1 || this.formData.stepTableFormData_1 || [];
+
+ // 处理数据为checkboxTree期望的格式(包含children结构)
+ const firstList = stepTableFormData
+ .filter(item => item && item.fhfw && item.fhfw.trim()) // 严格过滤空值
+ .map(item => ({
+ label: item.fhfw,
+ value: item.fhfw,
+ children: [] // 必须包含children字段,否则checkboxTree会报错
+ }))
+ // 去重优化
+ .filter((item, index, arr) => {
+ return arr.findIndex(i => i.value === item.value) === index;
+ });
- const secondList = stepTableFormData_1
- .filter(item => item.fhlr) // 过滤空值
- .map(item => ({ label: item.fhlr, value: item.fhlr }))
- .filter((item, index, arr) => arr.findIndex(i => i.value === item.value) === index); // 去重
+ const secondList = stepTableFormData_1
+ .filter(item => item && item.fhlr && item.fhlr.trim()) // 严格过滤空值
+ .map(item => ({
+ label: item.fhlr,
+ value: item.fhlr,
+ children: [] // 必须包含children字段
+ }))
+ .filter((item, index, arr) => {
+ return arr.findIndex(i => i.value === item.value) === index;
+ });
- // 更新响应式变量(触发computed更新)
- this.fhfwCheckOptions = firstList;
- this.fhlrCheckOptions = secondList;
+ // 响应式更新
+ this.$nextTick(()=>{
+ this.fhfwCheckOptions = firstList;
+ this.fhlrCheckOptions = secondList;
+ })
+
+ } catch (error) {
+ // 异常时重置为空数组,避免页面崩溃
+ this.fhfwCheckOptions = [];
+ this.fhlrCheckOptions = [];
+ }
},
}
};
diff --git a/src/views/business/comps/template/comps/dl/DL006.vue b/src/views/business/comps/template/comps/dl/DL006.vue
index f96eb7b..c785fde 100644
--- a/src/views/business/comps/template/comps/dl/DL006.vue
+++ b/src/views/business/comps/template/comps/dl/DL006.vue
@@ -659,9 +659,7 @@ export default {
// 关键修复2:先构建完整的数据源数组,再一次性更新
const newDataSource = [];
let rowIndexNew = 0;
- console.log(doseGroupCount, parallelDishCount,"doseGroupCount, parallelDishCount")
for (let doseIndex = 0; doseIndex < doseGroupCount; doseIndex++) {
-
for (let dishIndex = 0; dishIndex < parallelDishCount; dishIndex++) {
const rowData = {
jlzb: stepTableFormData[doseIndex]?.jlzmc || '',
@@ -671,19 +669,28 @@ export default {
newDataSource.push(rowData);
rowIndexNew++;
}
- newDataSource.map((item,index)=>{
- for (let i = 0; i < doseGroupCount; i++) {
- item[`czrxm_${i}Label`] = formatNumberByDigits((i*newDataSource.length)+index+1)
- }
- })
}
// 在构建 newDataSource 之后,补充编号生成逻辑
- console.log(this.getFilledFormData())
+ if (qsbh && /^\d+$/.test(qsbh)) {
+ let currentNum = parseInt(qsbh, 10);
+ const totalRows = newDataSource.length;
+ // 遍历每一列(菌种编号列)
+ for (let colIndex = 0; colIndex < Number(jzs); colIndex++) {
+ // 遍历每一行,为当前列赋值递增编号
+ for (let rowIndex = 0; rowIndex < totalRows; rowIndex++) {
+ const row = newDataSource[rowIndex];
+ // 格式化为3位数字(如 001、002)
+ row[`czrxm_${colIndex}Label`] = currentNum.toString().padStart(3, '0');
+ currentNum++;
+ }
+ }
+ }
// 关键修复3:一次性更新数据源,覆盖原空数据
this.$refs.czxxTableRef.updateDataSource(newDataSource);
justUpdateFilledFormData()
});
},
+
}
}