|
|
@ -155,6 +155,7 @@ export default { |
|
|
options: this.getDictOptions('business_dl_ameswrqk'), |
|
|
options: this.getDictOptions('business_dl_ameswrqk'), |
|
|
fillType: 'actFill', |
|
|
fillType: 'actFill', |
|
|
otherCode: 'cxqkwrqkOther', |
|
|
otherCode: 'cxqkwrqkOther', |
|
|
|
|
|
otherMaxlength:200, |
|
|
showOtherLabel: false |
|
|
showOtherLabel: false |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -307,14 +308,20 @@ export default { |
|
|
const headerSelectFields = this.formData.headerSelectFields || {} |
|
|
const headerSelectFields = this.formData.headerSelectFields || {} |
|
|
|
|
|
|
|
|
// 如果没有数据或已经加载过,不处理 |
|
|
// 如果没有数据或已经加载过,不处理 |
|
|
if (!stepTableFormData_1 || stepTableFormData_1.length === 0 || this.isDataLoaded) { |
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
!stepTableFormData_1 || |
|
|
|
|
|
stepTableFormData_1.length === 0 || |
|
|
|
|
|
this.isDataLoaded |
|
|
|
|
|
) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 从第一行数据中提取列信息(查找 jzbh 开头的 Label 字段) |
|
|
// 从第一行数据中提取列信息(查找 jzbh 开头的 Label 字段) |
|
|
const firstRow = stepTableFormData_1[0] |
|
|
const firstRow = stepTableFormData_1[0] |
|
|
const labelKeys = Object.keys(firstRow).filter(key => key.match(/^jzbh\d+Label$/)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const labelKeys = Object.keys(firstRow).filter((key) => |
|
|
|
|
|
key.match(/^jzbh\d+Label$/) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
if (labelKeys.length === 0) { |
|
|
if (labelKeys.length === 0) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
@ -335,7 +342,7 @@ export default { |
|
|
// 从 headerSelectFields 生成表头 |
|
|
// 从 headerSelectFields 生成表头 |
|
|
labelKeys.sort().forEach((labelKey, index) => { |
|
|
labelKeys.sort().forEach((labelKey, index) => { |
|
|
const colIndex = index + 1 |
|
|
const colIndex = index + 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 收集该列的所有 headerSelectFields 值(如 1_1, 1_2, 1_3) |
|
|
// 收集该列的所有 headerSelectFields 值(如 1_1, 1_2, 1_3) |
|
|
const headerValues = [] |
|
|
const headerValues = [] |
|
|
let rowIndex = 1 |
|
|
let rowIndex = 1 |
|
|
@ -343,10 +350,11 @@ export default { |
|
|
headerValues.push(headerSelectFields[`${colIndex}_${rowIndex}`]) |
|
|
headerValues.push(headerSelectFields[`${colIndex}_${rowIndex}`]) |
|
|
rowIndex++ |
|
|
rowIndex++ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将多个值用空格拼接,如果没有则使用默认值 |
|
|
// 将多个值用空格拼接,如果没有则使用默认值 |
|
|
const headerLabel = headerValues.length > 0 ? headerValues.join(' ') : `菌种${colIndex}` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const headerLabel = |
|
|
|
|
|
headerValues.length > 0 ? headerValues.join(' ') : `菌种${colIndex}` |
|
|
|
|
|
|
|
|
dynamicColumns.push({ |
|
|
dynamicColumns.push({ |
|
|
label: headerLabel, |
|
|
label: headerLabel, |
|
|
prop: `jzbh${colIndex}`, |
|
|
prop: `jzbh${colIndex}`, |
|
|
@ -382,19 +390,19 @@ export default { |
|
|
//获取已填写的表单数据 |
|
|
//获取已填写的表单数据 |
|
|
getFilledFormData() { |
|
|
getFilledFormData() { |
|
|
const baseData = this.getFilledFormDataByRefs(refNames) |
|
|
const baseData = this.getFilledFormDataByRefs(refNames) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从成像情况表格中获取最新数据 |
|
|
// 从成像情况表格中获取最新数据 |
|
|
const cxqkTableRef = this.$refs[refConf.cxqk] |
|
|
const cxqkTableRef = this.$refs[refConf.cxqk] |
|
|
if (cxqkTableRef) { |
|
|
if (cxqkTableRef) { |
|
|
const cxqkData = cxqkTableRef.getFilledFormData() |
|
|
const cxqkData = cxqkTableRef.getFilledFormData() |
|
|
baseData.stepTableFormData_1 = cxqkData.stepTableFormData || [] |
|
|
baseData.stepTableFormData_1 = cxqkData.stepTableFormData || [] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 确保 headerSelectFields 被包含在返回的数据中 |
|
|
// 确保 headerSelectFields 被包含在返回的数据中 |
|
|
if (this.formData.headerSelectFields) { |
|
|
if (this.formData.headerSelectFields) { |
|
|
baseData.headerSelectFields = this.formData.headerSelectFields |
|
|
baseData.headerSelectFields = this.formData.headerSelectFields |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return baseData |
|
|
return baseData |
|
|
}, |
|
|
}, |
|
|
//获取填写完成的表单数据 |
|
|
//获取填写完成的表单数据 |
|
|
@ -404,24 +412,25 @@ export default { |
|
|
}, |
|
|
}, |
|
|
//只做校验 |
|
|
//只做校验 |
|
|
async validFields() { |
|
|
async validFields() { |
|
|
// 1. 校验仪器使用信息表格是否为空(只在 actFill 时校验) |
|
|
|
|
|
|
|
|
// 只在 actFill 时校验表格是否为空 |
|
|
if (this.fillType === 'actFill') { |
|
|
if (this.fillType === 'actFill') { |
|
|
|
|
|
// 1. 校验仪器使用信息表格是否为空 |
|
|
const yqsyTableRef = this.$refs[refConf.yqsy] |
|
|
const yqsyTableRef = this.$refs[refConf.yqsy] |
|
|
const yqsyTableData = yqsyTableRef?.getDataSource() || [] |
|
|
const yqsyTableData = yqsyTableRef?.getDataSource() || [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (yqsyTableData.length === 0) { |
|
|
if (yqsyTableData.length === 0) { |
|
|
this.$message.warning(this.$t('template.dl.dl008.yqsyxxEmpty')) |
|
|
this.$message.warning(this.$t('template.dl.dl008.yqsyxxEmpty')) |
|
|
return Promise.reject(this.$t('template.dl.dl008.yqsyxxEmpty')) |
|
|
return Promise.reject(this.$t('template.dl.dl008.yqsyxxEmpty')) |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2. 校验成像情况表格是否为空 |
|
|
|
|
|
const cxqkTableRef = this.$refs[refConf.cxqk] |
|
|
|
|
|
const cxqkTableData = cxqkTableRef?.getDataSource() || [] |
|
|
|
|
|
|
|
|
|
|
|
if (cxqkTableData.length === 0) { |
|
|
|
|
|
this.$message.warning(this.$t('template.dl.dl008.cxqkEmpty')) |
|
|
|
|
|
return Promise.reject(this.$t('template.dl.dl008.cxqkEmpty')) |
|
|
|
|
|
|
|
|
// 2. 校验成像情况表格是否为空 |
|
|
|
|
|
const cxqkTableRef = this.$refs[refConf.cxqk] |
|
|
|
|
|
const cxqkTableData = cxqkTableRef?.getDataSource() || [] |
|
|
|
|
|
|
|
|
|
|
|
if (cxqkTableData.length === 0) { |
|
|
|
|
|
this.$message.warning(this.$t('template.dl.dl008.cxqkEmpty')) |
|
|
|
|
|
return Promise.reject(this.$t('template.dl.dl008.cxqkEmpty')) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 3. 执行其他表单字段校验 |
|
|
// 3. 执行其他表单字段校验 |
|
|
@ -457,7 +466,7 @@ export default { |
|
|
this.handleCxqkQxbdSelect(row) |
|
|
this.handleCxqkQxbdSelect(row) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理仪器编号选择 |
|
|
// 处理仪器编号选择 |
|
|
handleYqbhSelect(row, rowIndex) { |
|
|
handleYqbhSelect(row, rowIndex) { |
|
|
const params = { |
|
|
const params = { |
|
|
@ -467,15 +476,15 @@ export default { |
|
|
} |
|
|
} |
|
|
this.$refs.yqsyTableRef.updateDataSourceByRowIndex(rowIndex, params) |
|
|
this.$refs.yqsyTableRef.updateDataSourceByRowIndex(rowIndex, params) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理成像情况前序表单选择 |
|
|
// 处理成像情况前序表单选择 |
|
|
handleCxqkQxbdSelect(row) { |
|
|
handleCxqkQxbdSelect(row) { |
|
|
// 重置加载标记,允许重新加载数据 |
|
|
// 重置加载标记,允许重新加载数据 |
|
|
this.isDataLoaded = false |
|
|
this.isDataLoaded = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const bdnr = JSON.parse(row.bdnr) |
|
|
const bdnr = JSON.parse(row.bdnr) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const headerFields = bdnr.headerFields || {} |
|
|
const headerFields = bdnr.headerFields || {} |
|
|
const stepTableFormData_1 = bdnr.stepTableFormData_1 || [] |
|
|
const stepTableFormData_1 = bdnr.stepTableFormData_1 || [] |
|
|
|
|
|
|
|
|
@ -493,7 +502,10 @@ export default { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 2. 生成表格数据 |
|
|
// 2. 生成表格数据 |
|
|
const tableData = this.generateTableData(stepTableFormData_1, dynamicColumns.columnKeys) |
|
|
|
|
|
|
|
|
const tableData = this.generateTableData( |
|
|
|
|
|
stepTableFormData_1, |
|
|
|
|
|
dynamicColumns.columnKeys |
|
|
|
|
|
) |
|
|
if (tableData.length === 0) { |
|
|
if (tableData.length === 0) { |
|
|
this.clearCxqkTable() |
|
|
this.clearCxqkTable() |
|
|
return |
|
|
return |
|
|
@ -501,18 +513,17 @@ export default { |
|
|
|
|
|
|
|
|
// 3. 更新表格 |
|
|
// 3. 更新表格 |
|
|
this.updateCxqkTable(dynamicColumns.columns, tableData, headerFields) |
|
|
this.updateCxqkTable(dynamicColumns.columns, tableData, headerFields) |
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error('解析前序表单数据失败:', error) |
|
|
console.error('解析前序表单数据失败:', error) |
|
|
this.clearCxqkTable() |
|
|
this.clearCxqkTable() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成动态列配置 |
|
|
// 生成动态列配置 |
|
|
generateDynamicColumns(headerFields) { |
|
|
generateDynamicColumns(headerFields) { |
|
|
// 获取所有以 _1 结尾的 key,这些代表列的索引 |
|
|
// 获取所有以 _1 结尾的 key,这些代表列的索引 |
|
|
const columnKeys = Object.keys(headerFields) |
|
|
const columnKeys = Object.keys(headerFields) |
|
|
.filter(key => key.endsWith('_1')) |
|
|
|
|
|
|
|
|
.filter((key) => key.endsWith('_1')) |
|
|
.sort((a, b) => parseInt(a.split('_')[0]) - parseInt(b.split('_')[0])) |
|
|
.sort((a, b) => parseInt(a.split('_')[0]) - parseInt(b.split('_')[0])) |
|
|
|
|
|
|
|
|
if (columnKeys.length === 0) { |
|
|
if (columnKeys.length === 0) { |
|
|
@ -534,7 +545,7 @@ export default { |
|
|
columnKeys.forEach((key, index) => { |
|
|
columnKeys.forEach((key, index) => { |
|
|
const colIndex = index + 1 |
|
|
const colIndex = index + 1 |
|
|
const baseColIndex = key.split('_')[0] // 获取列索引,如 "1_1" -> "1" |
|
|
const baseColIndex = key.split('_')[0] // 获取列索引,如 "1_1" -> "1" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 收集该列的所有 headerFields 值(如 1_1, 1_2, 1_3) |
|
|
// 收集该列的所有 headerFields 值(如 1_1, 1_2, 1_3) |
|
|
const headerValues = [] |
|
|
const headerValues = [] |
|
|
let rowIndex = 1 |
|
|
let rowIndex = 1 |
|
|
@ -542,10 +553,10 @@ export default { |
|
|
headerValues.push(headerFields[`${baseColIndex}_${rowIndex}`]) |
|
|
headerValues.push(headerFields[`${baseColIndex}_${rowIndex}`]) |
|
|
rowIndex++ |
|
|
rowIndex++ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将多个值用空格拼接 |
|
|
// 将多个值用空格拼接 |
|
|
const headerLabel = headerValues.join(' ') |
|
|
const headerLabel = headerValues.join(' ') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
columns.push({ |
|
|
columns.push({ |
|
|
label: headerLabel, |
|
|
label: headerLabel, |
|
|
prop: `jzbh${colIndex}`, |
|
|
prop: `jzbh${colIndex}`, |
|
|
@ -558,42 +569,42 @@ export default { |
|
|
|
|
|
|
|
|
return { columns, columnKeys } |
|
|
return { columns, columnKeys } |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成表格数据 |
|
|
// 生成表格数据 |
|
|
generateTableData(stepTableFormData_1, columnKeys) { |
|
|
generateTableData(stepTableFormData_1, columnKeys) { |
|
|
const tableData = [] |
|
|
const tableData = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stepTableFormData_1.forEach((item) => { |
|
|
stepTableFormData_1.forEach((item) => { |
|
|
const rowData = { jlzb: item.jlzb || '' } |
|
|
const rowData = { jlzb: item.jlzb || '' } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
columnKeys.forEach((_key, index) => { |
|
|
columnKeys.forEach((_key, index) => { |
|
|
const colIndex = index + 1 |
|
|
const colIndex = index + 1 |
|
|
const valueKey = `jzbh${colIndex}` |
|
|
const valueKey = `jzbh${colIndex}` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从 DL006 生成的数据中获取 label 值 |
|
|
// 从 DL006 生成的数据中获取 label 值 |
|
|
// DL006 使用的字段名格式是 czrxm_${index}Label |
|
|
// DL006 使用的字段名格式是 czrxm_${index}Label |
|
|
const labelValue = item[`czrxm_${index}Label`] || '' |
|
|
const labelValue = item[`czrxm_${index}Label`] || '' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowData[`${valueKey}Label`] = labelValue |
|
|
rowData[`${valueKey}Label`] = labelValue |
|
|
rowData[valueKey] = '' // 空字符串表示初始未填写,不会触发修改确认框 |
|
|
rowData[valueKey] = '' // 空字符串表示初始未填写,不会触发修改确认框 |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tableData.push(rowData) |
|
|
tableData.push(rowData) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
return tableData |
|
|
return tableData |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新成像情况表格 |
|
|
// 更新成像情况表格 |
|
|
updateCxqkTable(columns, tableData, headerFields) { |
|
|
updateCxqkTable(columns, tableData, headerFields) { |
|
|
// 更新动态列配置 |
|
|
// 更新动态列配置 |
|
|
this.dynamicCxqkColumns = columns |
|
|
this.dynamicCxqkColumns = columns |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存 headerFields 到 formData,用于数据回显 |
|
|
// 保存 headerFields 到 formData,用于数据回显 |
|
|
if (!this.formData.headerSelectFields) { |
|
|
if (!this.formData.headerSelectFields) { |
|
|
this.$set(this.formData, 'headerSelectFields', {}) |
|
|
this.$set(this.formData, 'headerSelectFields', {}) |
|
|
} |
|
|
} |
|
|
Object.keys(headerFields).forEach(key => { |
|
|
|
|
|
|
|
|
Object.keys(headerFields).forEach((key) => { |
|
|
this.$set(this.formData.headerSelectFields, key, headerFields[key]) |
|
|
this.$set(this.formData.headerSelectFields, key, headerFields[key]) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
@ -602,19 +613,21 @@ export default { |
|
|
if (tableRef) { |
|
|
if (tableRef) { |
|
|
// 更新表格数据 |
|
|
// 更新表格数据 |
|
|
tableRef.updateDataSource(tableData) |
|
|
tableRef.updateDataSource(tableData) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将 oldLocalDataSource 设置为当前数据的副本 |
|
|
// 将 oldLocalDataSource 设置为当前数据的副本 |
|
|
// 这样初始加载时不会触发修改确认框,但后续修改会正常触发 |
|
|
// 这样初始加载时不会触发修改确认框,但后续修改会正常触发 |
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
tableRef.oldLocalDataSource = JSON.parse(JSON.stringify(tableRef.localDataSource)) |
|
|
|
|
|
|
|
|
tableRef.oldLocalDataSource = JSON.parse( |
|
|
|
|
|
JSON.stringify(tableRef.localDataSource) |
|
|
|
|
|
) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.$set(this.formData, 'stepTableFormData_1', tableData) |
|
|
this.$set(this.formData, 'stepTableFormData_1', tableData) |
|
|
this.isDataLoaded = true |
|
|
this.isDataLoaded = true |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清空成像情况表格 |
|
|
// 清空成像情况表格 |
|
|
clearCxqkTable() { |
|
|
clearCxqkTable() { |
|
|
this.dynamicCxqkColumns = [] |
|
|
this.dynamicCxqkColumns = [] |
|
|
|