|
|
@ -29,7 +29,7 @@ |
|
|
@onRegentSubmit="(e) => onRegentSubmit(e)" |
|
|
@onRegentSubmit="(e) => onRegentSubmit(e)" |
|
|
:showOperation="fillType === 'actFill'" |
|
|
:showOperation="fillType === 'actFill'" |
|
|
:showAddRow="fillType === 'actFill'" |
|
|
:showAddRow="fillType === 'actFill'" |
|
|
:formData="formData" |
|
|
|
|
|
|
|
|
:formData="yqsyFormData" |
|
|
:prefixKey="`yqsyTable`" |
|
|
:prefixKey="`yqsyTable`" |
|
|
> |
|
|
> |
|
|
<template slot="operation" slot-scope="{ row, rowIndex, columns }"> |
|
|
<template slot="operation" slot-scope="{ row, rowIndex, columns }"> |
|
|
@ -49,6 +49,7 @@ |
|
|
:ref="refConf.jgxxQxbd" |
|
|
:ref="refConf.jgxxQxbd" |
|
|
:formConfig="jgxxQxbdFormConfig" |
|
|
:formConfig="jgxxQxbdFormConfig" |
|
|
:formData="formData" |
|
|
:formData="formData" |
|
|
|
|
|
@onRegentSubmit="onRegentSubmit" |
|
|
/> |
|
|
/> |
|
|
<div class="jgxx-description"> |
|
|
<div class="jgxx-description"> |
|
|
<p>{{ $t('template.dl.dl009.czqkDesc') }}</p> |
|
|
<p>{{ $t('template.dl.dl009.czqkDesc') }}</p> |
|
|
@ -60,7 +61,7 @@ |
|
|
:ref="refConf.jgxx" |
|
|
:ref="refConf.jgxx" |
|
|
:showOperation="false" |
|
|
:showOperation="false" |
|
|
:showAddRow="false" |
|
|
:showAddRow="false" |
|
|
:formData="formData" |
|
|
|
|
|
|
|
|
:formData="jgxxFormData" |
|
|
:prefixKey="`jgxxTable`" |
|
|
:prefixKey="`jgxxTable`" |
|
|
> |
|
|
> |
|
|
</CustomTable> |
|
|
</CustomTable> |
|
|
@ -99,6 +100,12 @@ const refNames = Object.values(refConf) |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'DL009', |
|
|
name: 'DL009', |
|
|
|
|
|
dicts: [ |
|
|
|
|
|
'business_dl_amescltj', |
|
|
|
|
|
'business_sydd', |
|
|
|
|
|
'business_dl_amescdqk', |
|
|
|
|
|
'business_dl_amesbjjt' |
|
|
|
|
|
], |
|
|
components: { |
|
|
components: { |
|
|
BaseInfoFormPackage, |
|
|
BaseInfoFormPackage, |
|
|
LineLabel, |
|
|
LineLabel, |
|
|
@ -115,6 +122,20 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
|
|
|
// 仪器使用信息表格数据 |
|
|
|
|
|
yqsyFormData() { |
|
|
|
|
|
return { |
|
|
|
|
|
stepTableFormData: this.formData.stepTableFormData || [], |
|
|
|
|
|
headerSelectFields: {} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 结果信息表格数据 |
|
|
|
|
|
jgxxFormData() { |
|
|
|
|
|
return { |
|
|
|
|
|
stepTableFormData: this.formData.stepTableFormData_1 || [], |
|
|
|
|
|
headerSelectFields: {} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
// 备注表单配置 |
|
|
// 备注表单配置 |
|
|
remarkConfig() { |
|
|
remarkConfig() { |
|
|
return [ |
|
|
return [ |
|
|
@ -246,7 +267,7 @@ export default { |
|
|
jgxxQxbd: { |
|
|
jgxxQxbd: { |
|
|
label: 'template.dl.dl009.qxbd', |
|
|
label: 'template.dl.dl009.qxbd', |
|
|
type: 'qxbd', |
|
|
type: 'qxbd', |
|
|
qxbdType: 'DL006', |
|
|
|
|
|
|
|
|
// qxbdType: 'DL006', |
|
|
fillType: 'actFill', |
|
|
fillType: 'actFill', |
|
|
filledCodes: ['bdmc', 'bdbh'] |
|
|
filledCodes: ['bdmc', 'bdbh'] |
|
|
} |
|
|
} |
|
|
@ -256,46 +277,54 @@ export default { |
|
|
}, |
|
|
}, |
|
|
// 结果信息列表 |
|
|
// 结果信息列表 |
|
|
jgxxColumns() { |
|
|
jgxxColumns() { |
|
|
return [ |
|
|
|
|
|
{ |
|
|
|
|
|
label: 'template.dl.dl009.jlzb', |
|
|
|
|
|
prop: 'jlzb', |
|
|
|
|
|
bodyType: 'input', |
|
|
|
|
|
bodyFillType: 'actFill' |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: 'template.dl.dl009.jzbh', |
|
|
|
|
|
prop: 'jzbh', |
|
|
|
|
|
bodyType: 'input', |
|
|
|
|
|
bodyFillType: 'actFill' |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: 'template.dl.dl009.czqk', |
|
|
|
|
|
prop: 'czqk', |
|
|
|
|
|
bodyType: 'select', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyOptions: this.getDictOptions('business_dl_amescdqk') |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: 'template.dl.dl009.bjjt', |
|
|
|
|
|
prop: 'bjjt', |
|
|
|
|
|
bodyType: 'select', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyOptions: this.getDictOptions('business_dl_amesbjjt') |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: 'template.dl.dl009.jls', |
|
|
|
|
|
prop: 'jls', |
|
|
|
|
|
bodyType: 'inputNumber', |
|
|
|
|
|
bodyFillType: 'actFill' |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
// 只有在有动态列配置时才返回列配置,否则返回空数组(不显示表格) |
|
|
|
|
|
return this.dynamicJgxxColumns |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
formData: {}, |
|
|
formData: {}, |
|
|
refConf |
|
|
|
|
|
|
|
|
refConf, |
|
|
|
|
|
dynamicJgxxColumns: [], // 动态结果信息表格列配置 |
|
|
|
|
|
isDataLoaded: false // 标记数据是否已加载 |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
mounted() { |
|
|
|
|
|
// 组件挂载后,检查是否有已填报的数据需要回显 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.initializeTableFromFormData() |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
watch: { |
|
|
|
|
|
// 监听结果信息表格数据变化,用于数据回显 |
|
|
|
|
|
'formData.stepTableFormData_1': { |
|
|
|
|
|
handler(newVal) { |
|
|
|
|
|
if (newVal && newVal.length > 0 && !this.isDataLoaded) { |
|
|
|
|
|
this.initializeTableFromFormData() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
deep: true, |
|
|
|
|
|
immediate: true |
|
|
|
|
|
}, |
|
|
|
|
|
// 监听仪器使用信息表格数据变化,用于数据回显 |
|
|
|
|
|
'formData.stepTableFormData': { |
|
|
|
|
|
handler(newVal) { |
|
|
|
|
|
if (newVal && newVal.length > 0) { |
|
|
|
|
|
this.initializeYqsyTableFromFormData() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
deep: true, |
|
|
|
|
|
immediate: true |
|
|
|
|
|
}, |
|
|
|
|
|
// 监听字典数据加载完成后,如果有动态列配置需要更新 |
|
|
|
|
|
'dict.type.business_dl_amescdqk': { |
|
|
|
|
|
handler(newVal) { |
|
|
|
|
|
if (newVal && newVal.length > 0 && this.dynamicJgxxColumns.length > 0) { |
|
|
|
|
|
// 如果已经有动态列配置,需要更新 bodyOptions |
|
|
|
|
|
this.updateDynamicColumnsOptions() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
immediate: true |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
@ -303,30 +332,212 @@ export default { |
|
|
deleteTableRow(rowIndex, refName) { |
|
|
deleteTableRow(rowIndex, refName) { |
|
|
this.$refs[refName].deleteRow(rowIndex) |
|
|
this.$refs[refName].deleteRow(rowIndex) |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 从已填报数据初始化表格(用于数据回显) |
|
|
|
|
|
initializeTableFromFormData() { |
|
|
|
|
|
try { |
|
|
|
|
|
const stepTableFormData_1 = this.formData.stepTableFormData_1 |
|
|
|
|
|
const headerSelectFields = this.formData.headerSelectFields || {} |
|
|
|
|
|
|
|
|
|
|
|
// 如果没有数据或已经加载过,不处理 |
|
|
|
|
|
if (!stepTableFormData_1 || stepTableFormData_1.length === 0 || this.isDataLoaded) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 从第一行数据中提取列信息(查找 jzbh 开头的字段,不包括 Label) |
|
|
|
|
|
const firstRow = stepTableFormData_1[0] |
|
|
|
|
|
const jzbhKeys = Object.keys(firstRow) |
|
|
|
|
|
.filter(key => key.match(/^jzbh\d+$/) && !key.endsWith('Label')) |
|
|
|
|
|
.sort((a, b) => { |
|
|
|
|
|
const numA = parseInt(a.replace('jzbh', '')) |
|
|
|
|
|
const numB = parseInt(b.replace('jzbh', '')) |
|
|
|
|
|
return numA - numB |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if (jzbhKeys.length === 0) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 根据已有的 jzbh 字段生成动态列配置 |
|
|
|
|
|
const dynamicColumns = [ |
|
|
|
|
|
{ |
|
|
|
|
|
label: 'template.dl.dl009.jlzb', |
|
|
|
|
|
prop: 'jlzb', |
|
|
|
|
|
bodyType: 'input', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyDisabled: true, |
|
|
|
|
|
disabled: true, |
|
|
|
|
|
width: 100 |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
// 从 headerSelectFields 生成表头 |
|
|
|
|
|
jzbhKeys.forEach((_jzbhKey, index) => { |
|
|
|
|
|
const colIndex = index + 1 |
|
|
|
|
|
|
|
|
|
|
|
// 只获取第一个 headerSelectFields 值作为菌种编号(如 T-A02) |
|
|
|
|
|
const jzbhLabel = headerSelectFields[`${colIndex}_1`] || `菌种${colIndex}` |
|
|
|
|
|
|
|
|
|
|
|
// 为每个菌种编号添加四列:菌种编号、沉淀情况、背景菌苔、菌落数 |
|
|
|
|
|
dynamicColumns.push({ |
|
|
|
|
|
label: jzbhLabel, |
|
|
|
|
|
prop: `jzbh${colIndex}`, |
|
|
|
|
|
bodyType: 'input', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyDisabled: true, |
|
|
|
|
|
disabled: true, |
|
|
|
|
|
width: 150 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
dynamicColumns.push({ |
|
|
|
|
|
label: `${jzbhLabel}${this.$t('template.dl.dl009.czqk')}`, |
|
|
|
|
|
prop: `czqk${colIndex}`, |
|
|
|
|
|
bodyType: 'select', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyOptions: this.getDictOptions('business_dl_amescdqk'), |
|
|
|
|
|
width: 200 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
dynamicColumns.push({ |
|
|
|
|
|
label: `${jzbhLabel}${this.$t('template.dl.dl009.bjjt')}`, |
|
|
|
|
|
prop: `bjjt${colIndex}`, |
|
|
|
|
|
bodyType: 'select', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyOptions: this.getDictOptions('business_dl_amesbjjt'), |
|
|
|
|
|
width: 200 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
dynamicColumns.push({ |
|
|
|
|
|
label: `${jzbhLabel}${this.$t('template.dl.dl009.jls')}`, |
|
|
|
|
|
prop: `jls${colIndex}`, |
|
|
|
|
|
bodyType: 'inputNumber', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyMaxlength: 10, |
|
|
|
|
|
width: 200 |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 更新动态列配置 |
|
|
|
|
|
this.dynamicJgxxColumns = dynamicColumns |
|
|
|
|
|
|
|
|
|
|
|
// 保存 headerSelectFields 到 formData.headerSelectFields(确保数据一致) |
|
|
|
|
|
if (!this.formData.headerSelectFields) { |
|
|
|
|
|
this.$set(this.formData, 'headerSelectFields', {}) |
|
|
|
|
|
} |
|
|
|
|
|
Object.keys(headerSelectFields).forEach((key) => { |
|
|
|
|
|
this.$set(this.formData.headerSelectFields, key, headerSelectFields[key]) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
this.isDataLoaded = true |
|
|
|
|
|
|
|
|
|
|
|
// 等待列配置更新后,更新表格数据 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
const tableRef = this.$refs[refConf.jgxx] |
|
|
|
|
|
if (tableRef) { |
|
|
|
|
|
tableRef.updateDataSource(stepTableFormData_1) |
|
|
|
|
|
|
|
|
|
|
|
// 将 oldLocalDataSource 设置为当前数据的副本 |
|
|
|
|
|
// 这样初始加载时不会触发修改确认框,但后续修改会正常触发 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
tableRef.oldLocalDataSource = JSON.parse(JSON.stringify(tableRef.localDataSource)) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('初始化结果信息表格数据失败:', error) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 从已填报数据初始化仪器使用信息表格(用于数据回显) |
|
|
|
|
|
initializeYqsyTableFromFormData() { |
|
|
|
|
|
try { |
|
|
|
|
|
const stepTableFormData = this.formData.stepTableFormData |
|
|
|
|
|
|
|
|
|
|
|
if (!stepTableFormData || stepTableFormData.length === 0) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
const tableRef = this.$refs[refConf.yqsy] |
|
|
|
|
|
if (tableRef) { |
|
|
|
|
|
tableRef.updateDataSource(stepTableFormData) |
|
|
|
|
|
|
|
|
|
|
|
// 将 oldLocalDataSource 设置为当前数据的副本 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
tableRef.oldLocalDataSource = JSON.parse(JSON.stringify(tableRef.localDataSource)) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('初始化仪器使用信息表格数据失败:', error) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
// 获取已填写的表单数据 |
|
|
// 获取已填写的表单数据 |
|
|
getFilledFormData() { |
|
|
getFilledFormData() { |
|
|
return this.getFilledFormDataByRefs(refNames) |
|
|
|
|
|
|
|
|
const baseData = this.getFilledFormDataByRefs(refNames) |
|
|
|
|
|
|
|
|
|
|
|
// 从仪器使用信息表格中获取最新数据 |
|
|
|
|
|
const yqsyTableRef = this.$refs[refConf.yqsy] |
|
|
|
|
|
if (yqsyTableRef) { |
|
|
|
|
|
const yqsyData = yqsyTableRef.getFilledFormData() |
|
|
|
|
|
// 仪器使用信息保存到 stepTableFormData(与后端保存的字段名一致) |
|
|
|
|
|
baseData.stepTableFormData = yqsyData.stepTableFormData || [] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 从结果信息表格中获取最新数据 |
|
|
|
|
|
const jgxxTableRef = this.$refs[refConf.jgxx] |
|
|
|
|
|
if (jgxxTableRef) { |
|
|
|
|
|
const jgxxData = jgxxTableRef.getFilledFormData() |
|
|
|
|
|
// 结果信息保存到 stepTableFormData_1(与后端保存的字段名一致) |
|
|
|
|
|
baseData.stepTableFormData_1 = jgxxData.stepTableFormData || [] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 确保 headerSelectFields 被包含在返回的数据中 |
|
|
|
|
|
if (this.formData.headerSelectFields) { |
|
|
|
|
|
baseData.headerSelectFields = this.formData.headerSelectFields |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return baseData |
|
|
}, |
|
|
}, |
|
|
// 获取填写完成的表单数据 |
|
|
// 获取填写完成的表单数据 |
|
|
async getFormData() { |
|
|
async getFormData() { |
|
|
return await this.validFormFields(refNames) |
|
|
|
|
|
|
|
|
// 先执行自定义校验(包括表格非空校验) |
|
|
|
|
|
return await this.validFields() |
|
|
}, |
|
|
}, |
|
|
// 只做校验 |
|
|
// 只做校验 |
|
|
async validFields() { |
|
|
async validFields() { |
|
|
|
|
|
// 1. 校验仪器使用信息表格是否为空 |
|
|
|
|
|
const yqsyTableRef = this.$refs[refConf.yqsy] |
|
|
|
|
|
const yqsyTableData = yqsyTableRef?.getDataSource() || [] |
|
|
|
|
|
|
|
|
|
|
|
if (yqsyTableData.length === 0) { |
|
|
|
|
|
this.$message.warning(this.$t('template.dl.dl009.yqsyxxEmpty')) |
|
|
|
|
|
return Promise.reject(this.$t('template.dl.dl009.yqsyxxEmpty')) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2. 校验结果信息表格是否为空 |
|
|
|
|
|
const jgxxTableRef = this.$refs[refConf.jgxx] |
|
|
|
|
|
const jgxxTableData = jgxxTableRef?.getDataSource() || [] |
|
|
|
|
|
|
|
|
|
|
|
if (jgxxTableData.length === 0) { |
|
|
|
|
|
this.$message.warning(this.$t('template.dl.dl009.jgxxEmpty')) |
|
|
|
|
|
return Promise.reject(this.$t('template.dl.dl009.jgxxEmpty')) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 3. 执行其他表单字段校验 |
|
|
return await this.validFormFields(refNames) |
|
|
return await this.validFormFields(refNames) |
|
|
}, |
|
|
}, |
|
|
getResource() { |
|
|
getResource() { |
|
|
const yqsyStepResource = this.$refs.yqsyTableRef.getStepResource() |
|
|
|
|
|
const jgxxStepResource = this.$refs.jgxxTableRef.getStepResource() |
|
|
|
|
|
// 使用的试剂、仪器 |
|
|
|
|
|
this.resourceTmp = [ |
|
|
|
|
|
...(yqsyStepResource.sjResource || []), |
|
|
|
|
|
...(jgxxStepResource.sjResource || []) |
|
|
|
|
|
] |
|
|
|
|
|
this.yqResourceTmp = [ |
|
|
|
|
|
...(yqsyStepResource.yqResource || []), |
|
|
|
|
|
...(jgxxStepResource.yqResource || []) |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
const yqsyData = this.$refs.yqsyTableRef?.getFilledFormData() |
|
|
|
|
|
const yqsyList = yqsyData?.stepTableFormData || [] |
|
|
|
|
|
|
|
|
|
|
|
// 从仪器使用信息表格中提取仪器资源 |
|
|
|
|
|
this.yqResourceTmp = yqsyList |
|
|
|
|
|
.filter((item) => item.yqbh) |
|
|
|
|
|
.map((item) => ({ |
|
|
|
|
|
bh: item.yqbh, |
|
|
|
|
|
type: 'yq' |
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
this.resourceTmp = [] |
|
|
return this.resourceTmp |
|
|
return this.resourceTmp |
|
|
}, |
|
|
}, |
|
|
onRegentSubmit(e) { |
|
|
onRegentSubmit(e) { |
|
|
@ -340,12 +551,251 @@ export default { |
|
|
jzrq: row.jzrq |
|
|
jzrq: row.jzrq |
|
|
} |
|
|
} |
|
|
this.$refs.yqsyTableRef.updateDataSourceByRowIndex(rowIndex, params) |
|
|
this.$refs.yqsyTableRef.updateDataSourceByRowIndex(rowIndex, params) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 处理结果信息前序表单选择 |
|
|
|
|
|
if (key === 'jgxxQxbd') { |
|
|
|
|
|
// 在处理前序表单之前,先保存当前的仪器使用信息和表头数据 |
|
|
|
|
|
const currentYqsyData = this.formData.stepTableFormData ? JSON.parse(JSON.stringify(this.formData.stepTableFormData)) : [] |
|
|
|
|
|
const currentHeaderFields = this.formData.headerSelectFields ? JSON.parse(JSON.stringify(this.formData.headerSelectFields)) : {} |
|
|
|
|
|
|
|
|
|
|
|
// 使用 $nextTick 确保在下一个 tick 中恢复数据 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.handleJgxxQxbdSelect(row) |
|
|
|
|
|
|
|
|
|
|
|
// 再次使用 $nextTick 确保在 handleJgxxQxbdSelect 完成后恢复数据 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
if (currentYqsyData.length > 0 && (!this.formData.stepTableFormData || this.formData.stepTableFormData.length === 0)) { |
|
|
|
|
|
this.$set(this.formData, 'stepTableFormData', currentYqsyData) |
|
|
|
|
|
|
|
|
|
|
|
// 同时更新表格显示 |
|
|
|
|
|
const yqsyTableRef = this.$refs[refConf.yqsy] |
|
|
|
|
|
if (yqsyTableRef) { |
|
|
|
|
|
yqsyTableRef.updateDataSource(currentYqsyData) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果当前表头数据为空,恢复之前的表头数据 |
|
|
|
|
|
if (Object.keys(currentHeaderFields).length > 0 && (!this.formData.headerSelectFields || Object.keys(this.formData.headerSelectFields).length === 0)) { |
|
|
|
|
|
this.$set(this.formData, 'headerSelectFields', currentHeaderFields) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 处理结果信息前序表单选择 |
|
|
|
|
|
handleJgxxQxbdSelect(row) { |
|
|
|
|
|
// 重置加载标记,允许重新加载数据 |
|
|
|
|
|
this.isDataLoaded = false |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
if (!row.bdnr) { |
|
|
|
|
|
this.clearJgxxTable() |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const bdnr = JSON.parse(row.bdnr) |
|
|
|
|
|
|
|
|
|
|
|
const headerFields = bdnr.headerFields || {} |
|
|
|
|
|
const stepTableFormData_1 = bdnr.stepTableFormData_1 || [] |
|
|
|
|
|
|
|
|
|
|
|
// 验证数据有效性 |
|
|
|
|
|
if (!stepTableFormData_1 || stepTableFormData_1.length === 0) { |
|
|
|
|
|
this.clearJgxxTable() |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 1. 生成动态列配置 |
|
|
|
|
|
const dynamicColumns = this.generateDynamicJgxxColumns(headerFields) |
|
|
|
|
|
if (!dynamicColumns) { |
|
|
|
|
|
this.clearJgxxTable() |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2. 生成表格数据 |
|
|
|
|
|
const tableData = this.generateJgxxTableData( |
|
|
|
|
|
stepTableFormData_1, |
|
|
|
|
|
dynamicColumns.columnKeys |
|
|
|
|
|
) |
|
|
|
|
|
if (tableData.length === 0) { |
|
|
|
|
|
this.clearJgxxTable() |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 3. 更新表格 |
|
|
|
|
|
this.updateJgxxTable(dynamicColumns.columns, tableData, headerFields) |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('解析前序表单数据失败:', error) |
|
|
|
|
|
this.clearJgxxTable() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 保存 |
|
|
// 保存 |
|
|
async onSave() { |
|
|
async onSave() { |
|
|
const formData = this.getStepResource() |
|
|
const formData = this.getStepResource() |
|
|
console.log(formData, 'formData') |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 生成动态列配置 |
|
|
|
|
|
generateDynamicJgxxColumns(headerFields) { |
|
|
|
|
|
// 获取所有以 _1 结尾的 key,这些代表列的索引 |
|
|
|
|
|
const columnKeys = Object.keys(headerFields) |
|
|
|
|
|
.filter((key) => key.endsWith('_1')) |
|
|
|
|
|
.sort((a, b) => parseInt(a.split('_')[0]) - parseInt(b.split('_')[0])) |
|
|
|
|
|
|
|
|
|
|
|
if (columnKeys.length === 0) { |
|
|
|
|
|
return null |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const columns = [ |
|
|
|
|
|
{ |
|
|
|
|
|
label: 'template.dl.dl009.jlzb', |
|
|
|
|
|
prop: 'jlzb', |
|
|
|
|
|
bodyType: 'input', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyDisabled: true, |
|
|
|
|
|
disabled: true, |
|
|
|
|
|
width: 100 |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
columnKeys.forEach((key, index) => { |
|
|
|
|
|
const colIndex = index + 1 |
|
|
|
|
|
// 获取列索引,如 "1_1" -> "1" |
|
|
|
|
|
const baseColIndex = key.split('_')[0] |
|
|
|
|
|
|
|
|
|
|
|
// 只获取第一个 headerField 值作为菌种编号(如 T-A02) |
|
|
|
|
|
const jzbhLabel = headerFields[`${baseColIndex}_1`] || '' |
|
|
|
|
|
|
|
|
|
|
|
// 为每个菌种编号添加四列:菌种编号、沉淀情况、背景菌苔、菌落数 |
|
|
|
|
|
columns.push({ |
|
|
|
|
|
label: jzbhLabel, |
|
|
|
|
|
prop: `jzbh${colIndex}`, |
|
|
|
|
|
bodyType: 'input', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyDisabled: true, |
|
|
|
|
|
disabled: true, |
|
|
|
|
|
width: 150 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
columns.push({ |
|
|
|
|
|
label: `${jzbhLabel}${this.$t('template.dl.dl009.czqk')}`, |
|
|
|
|
|
prop: `czqk${colIndex}`, |
|
|
|
|
|
bodyType: 'select', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyOptions: this.getDictOptions('business_dl_amescdqk'), |
|
|
|
|
|
width: 200 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
columns.push({ |
|
|
|
|
|
label: `${jzbhLabel}${this.$t('template.dl.dl009.bjjt')}`, |
|
|
|
|
|
prop: `bjjt${colIndex}`, |
|
|
|
|
|
bodyType: 'select', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyOptions: this.getDictOptions('business_dl_amesbjjt'), |
|
|
|
|
|
width: 200 |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
columns.push({ |
|
|
|
|
|
label: `${jzbhLabel}${this.$t('template.dl.dl009.jls')}`, |
|
|
|
|
|
prop: `jls${colIndex}`, |
|
|
|
|
|
bodyType: 'inputNumber', |
|
|
|
|
|
bodyFillType: 'actFill', |
|
|
|
|
|
bodyMaxlength: 10, |
|
|
|
|
|
width: 200 |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return { columns, columnKeys } |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 生成表格数据 |
|
|
|
|
|
generateJgxxTableData(stepTableFormData_1, columnKeys) { |
|
|
|
|
|
const tableData = [] |
|
|
|
|
|
|
|
|
|
|
|
stepTableFormData_1.forEach((item) => { |
|
|
|
|
|
const rowData = { jlzb: item.jlzb || '' } |
|
|
|
|
|
|
|
|
|
|
|
columnKeys.forEach((_key, index) => { |
|
|
|
|
|
const colIndex = index + 1 |
|
|
|
|
|
|
|
|
|
|
|
// 收集该列的所有 headerFields 值作为菌种编号 |
|
|
|
|
|
const jzbhValue = item[`czrxm_${index}Label`] || '' |
|
|
|
|
|
|
|
|
|
|
|
// 设置菌种编号、沉淀情况、背景菌苔、菌落数的初始值 |
|
|
|
|
|
rowData[`jzbh${colIndex}`] = jzbhValue |
|
|
|
|
|
rowData[`czqk${colIndex}`] = '' |
|
|
|
|
|
rowData[`bjjt${colIndex}`] = '' |
|
|
|
|
|
rowData[`jls${colIndex}`] = '' |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
tableData.push(rowData) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return tableData |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 更新结果信息表格 |
|
|
|
|
|
updateJgxxTable(columns, tableData, headerFields) { |
|
|
|
|
|
// 更新动态列配置 |
|
|
|
|
|
this.dynamicJgxxColumns = columns |
|
|
|
|
|
|
|
|
|
|
|
// 保存 headerFields 到 formData,用于数据回显 |
|
|
|
|
|
if (!this.formData.headerSelectFields) { |
|
|
|
|
|
this.$set(this.formData, 'headerSelectFields', {}) |
|
|
|
|
|
} |
|
|
|
|
|
Object.keys(headerFields).forEach((key) => { |
|
|
|
|
|
this.$set(this.formData.headerSelectFields, key, headerFields[key]) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
const tableRef = this.$refs[refConf.jgxx] |
|
|
|
|
|
if (tableRef) { |
|
|
|
|
|
// 更新表格数据 |
|
|
|
|
|
tableRef.updateDataSource(tableData) |
|
|
|
|
|
|
|
|
|
|
|
// 将 oldLocalDataSource 设置为当前数据的副本 |
|
|
|
|
|
// 这样初始加载时不会触发修改确认框,但后续修改会正常触发 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
tableRef.oldLocalDataSource = JSON.parse( |
|
|
|
|
|
JSON.stringify(tableRef.localDataSource) |
|
|
|
|
|
) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.$set(this.formData, 'stepTableFormData_1', tableData) |
|
|
|
|
|
this.isDataLoaded = true |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 清空结果信息表格 |
|
|
|
|
|
clearJgxxTable() { |
|
|
|
|
|
this.dynamicJgxxColumns = [] |
|
|
|
|
|
this.$set(this.formData, 'stepTableFormData_1', []) |
|
|
|
|
|
this.$set(this.formData, 'headerSelectFields', {}) |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
this.$refs[refConf.jgxx]?.updateDataSource([]) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 更新动态列配置的字典选项 |
|
|
|
|
|
updateDynamicColumnsOptions() { |
|
|
|
|
|
if (this.dynamicJgxxColumns.length === 0) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 遍历动态列配置,更新 select 类型的 bodyOptions |
|
|
|
|
|
this.dynamicJgxxColumns.forEach(col => { |
|
|
|
|
|
if (col.bodyType === 'select') { |
|
|
|
|
|
if (col.prop.startsWith('czqk')) { |
|
|
|
|
|
col.bodyOptions = this.getDictOptions('business_dl_amescdqk') |
|
|
|
|
|
} else if (col.prop.startsWith('bjjt')) { |
|
|
|
|
|
col.bodyOptions = this.getDictOptions('business_dl_amesbjjt') |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 强制更新视图 |
|
|
|
|
|
this.$forceUpdate() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|