2 Commits

Author SHA1 Message Date
  欧骞 94d4a7ba7b Merge branch 'master' into ouqian 1 month ago
  欧骞 8b3cd24d36 feat:[模板管理][DL007~DL009前序表单逻辑] 1 month ago
5 changed files with 849 additions and 155 deletions
Unified View
  1. +8
    -3
      src/lang/en/template/dl.js
  2. +8
    -3
      src/lang/zh/template/dl.js
  3. +15
    -4
      src/views/business/comps/template/comps/dl/DL007.vue
  4. +316
    -93
      src/views/business/comps/template/comps/dl/DL008.vue
  5. +502
    -52
      src/views/business/comps/template/comps/dl/DL009.vue

+ 8
- 3
src/lang/en/template/dl.js View File

@ -77,7 +77,8 @@ export default {
czxx: 'Operation Information', czxx: 'Operation Information',
pykssj: 'Cultivation Start Time', pykssj: 'Cultivation Start Time',
pyjssj: 'Cultivation End Time', pyjssj: 'Cultivation End Time',
jsButton: 'End'
jsButton: 'End',
yqsyxxEmpty: 'Please add instrument usage information first'
}, },
dl008: { dl008: {
...common, ...common,
@ -87,7 +88,9 @@ export default {
jzbh1: 'Strain Number', jzbh1: 'Strain Number',
jzbh2: 'Strain Number', jzbh2: 'Strain Number',
jzbh3: 'Strain Number', jzbh3: 'Strain Number',
jzbh4: 'Strain Number'
jzbh4: 'Strain Number',
yqsyxxEmpty: 'Instrument usage information cannot be empty',
cxqkEmpty: 'Imaging status cannot be empty'
}, },
dl009: { dl009: {
...common, ...common,
@ -103,7 +106,9 @@ export default {
jls: 'Colony Count', jls: 'Colony Count',
czqkDesc: 'Precipitation codes: "P-" = "None"; "P+" = "Slight"; "P++" = "Moderate"; "P+++" = "Severe".', czqkDesc: 'Precipitation codes: "P-" = "None"; "P+" = "Slight"; "P++" = "Moderate"; "P+++" = "Severe".',
bjjtDesc: 'Background lawn codes: "N" = "Normal"; "R1" = "Weak, lawn covers 70%-90% of plate area"; "R2" = "Medium, lawn covers 40%-70% of plate area"; "R3" = "Strong, lawn covers 10%-40% of plate area"; "A" = "Absent, no lawn on plate"; "O" = "Precipitation present, affecting lawn assessment";', bjjtDesc: 'Background lawn codes: "N" = "Normal"; "R1" = "Weak, lawn covers 70%-90% of plate area"; "R2" = "Medium, lawn covers 40%-70% of plate area"; "R3" = "Strong, lawn covers 10%-40% of plate area"; "A" = "Absent, no lawn on plate"; "O" = "Precipitation present, affecting lawn assessment";',
jlsDesc: 'Colony count special case: "*" indicates pinpoint colonies visible on plate;'
jlsDesc: 'Colony count special case: "*" indicates pinpoint colonies visible on plate;',
yqsyxxEmpty: 'Instrument usage information cannot be empty',
jgxxEmpty: 'Result information cannot be empty'
}, },
dl010: { dl010: {
...common, ...common,

+ 8
- 3
src/lang/zh/template/dl.js View File

@ -80,7 +80,8 @@ export default {
czxx: '操作信息', czxx: '操作信息',
pykssj: '培养开始时间', pykssj: '培养开始时间',
pyjssj: '培养结束时间', pyjssj: '培养结束时间',
jsButton: '结束'
jsButton: '结束',
yqsyxxEmpty: '请先添加仪器使用信息'
}, },
dl008: { dl008: {
...common, ...common,
@ -90,7 +91,9 @@ export default {
jzbh1: '菌种编号', jzbh1: '菌种编号',
jzbh2: '菌种编号', jzbh2: '菌种编号',
jzbh3: '菌种编号', jzbh3: '菌种编号',
jzbh4: '菌种编号'
jzbh4: '菌种编号',
yqsyxxEmpty: '仪器使用信息不能为空',
cxqkEmpty: '成像情况不能为空'
}, },
dl009: { dl009: {
...common, ...common,
@ -106,7 +109,9 @@ export default {
jls: '菌落数(个)', jls: '菌落数(个)',
czqkDesc: '沉淀量以代码填入:"P-" 代表 "无沉淀";"P+" 代表 "少量";"P++" 代表 "中等";"P+++" 代表 "严重"。', czqkDesc: '沉淀量以代码填入:"P-" 代表 "无沉淀";"P+" 代表 "少量";"P++" 代表 "中等";"P+++" 代表 "严重"。',
bjjtDesc: '背景菌苔以代码填入:"N" 代表 "正常";"R1" 代表 "弱,菌苔约占平皿面积 70%-90%";"R2" 代表 "中,菌苔约占平皿面积 40%-70%";"R3" 代表 "强,菌苔约占平皿面积 10%-40%";"A" 代表 "消失,平皿上无菌苔";"O" 代表 "产生沉淀,影响背景菌苔判断";', bjjtDesc: '背景菌苔以代码填入:"N" 代表 "正常";"R1" 代表 "弱,菌苔约占平皿面积 70%-90%";"R2" 代表 "中,菌苔约占平皿面积 40%-70%";"R3" 代表 "强,菌苔约占平皿面积 10%-40%";"A" 代表 "消失,平皿上无菌苔";"O" 代表 "产生沉淀,影响背景菌苔判断";',
jlsDesc: '菌落数特殊情况:"*" 该平皿可见针尖样菌落;'
jlsDesc: '菌落数特殊情况:"*" 该平皿可见针尖样菌落;',
yqsyxxEmpty: '仪器使用信息不能为空',
jgxxEmpty: '结果信息不能为空'
}, },
dl010: { dl010: {
...common, ...common,

+ 15
- 4
src/views/business/comps/template/comps/dl/DL007.vue View File

@ -50,7 +50,7 @@
fieldItemLabel="template.dl.dl007.bz" fieldItemLabel="template.dl.dl007.bz"
label="template.dl.dl007.bz" label="template.dl.dl007.bz"
:ref="refConf.remark" :ref="refConf.remark"
:formConfig="remarkConig"
:formConfig="remarkConfig"
:formData="formData" :formData="formData"
/> />
</div> </div>
@ -79,6 +79,7 @@ const refNames = Object.values(refConf)
export default { export default {
name: 'DL007', name: 'DL007',
dicts: ['business_sydd'],
components: { components: {
BaseInfoFormPackage, BaseInfoFormPackage,
LineLabel, LineLabel,
@ -96,7 +97,7 @@ export default {
}, },
computed: { computed: {
// //
remarkConig() {
remarkConfig() {
return [ return [
{ {
type: 'cellItem', type: 'cellItem',
@ -257,10 +258,21 @@ export default {
}, },
// //
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.dl007.yqsyxxEmpty'))
return Promise.reject(this.$t('template.dl.dl007.yqsyxxEmpty'))
}
// 2.
return await this.validFormFields(refNames) return await this.validFormFields(refNames)
}, },
getResource() { getResource() {
@ -307,7 +319,6 @@ export default {
// //
async onSave() { async onSave() {
const formData = this.getStepResource() const formData = this.getStepResource()
console.log(formData, 'formData')
} }
} }
} }

+ 316
- 93
src/views/business/comps/template/comps/dl/DL008.vue View File

@ -85,7 +85,6 @@ import TableOpertaionDelete from '@/components/Template/operation/TableOpertaion
import CustomTable from '@/components/Template/CustomTable.vue' import CustomTable from '@/components/Template/CustomTable.vue'
import LineLabel from '@/components/Template/LineLabel' import LineLabel from '@/components/Template/LineLabel'
import TableList from '@/components/Template/Table' import TableList from '@/components/Template/Table'
import Step from '@/components/Template/Step'
import templateMixin from '../../mixins/templateMixin' import templateMixin from '../../mixins/templateMixin'
import moment from 'moment' import moment from 'moment'
const refConf = { const refConf = {
@ -100,11 +99,11 @@ const refNames = Object.values(refConf)
export default { export default {
name: 'DL008', name: 'DL008',
dicts: ['business_sydd', 'business_dl_ameswrqk'],
components: { components: {
BaseInfoFormPackage, BaseInfoFormPackage,
LineLabel, LineLabel,
TableList, TableList,
Step,
CustomTable, CustomTable,
TableOpertaionDelete TableOpertaionDelete
}, },
@ -213,44 +212,8 @@ export default {
}, },
// -checkbox // -checkbox
cxqkColumns() { cxqkColumns() {
return [
{
label: 'template.dl.dl008.jlzb',
prop: 'jlzb',
bodyType: 'input',
bodyFillType: 'actFill',
disabled: true,
width: 100
},
{
label: 'template.dl.dl008.jzbh1',
prop: 'jzbh1',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
},
{
label: 'template.dl.dl008.jzbh2',
prop: 'jzbh2',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
},
{
label: 'template.dl.dl008.jzbh3',
prop: 'jzbh3',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
},
{
label: 'template.dl.dl008.jzbh4',
prop: 'jzbh4',
bodyType: 'checkbox',
bodyFillType: 'actFill',
width: 150
}
]
//
return this.dynamicCxqkColumns
}, },
// 使 // 使
yqsyColumns() { yqsyColumns() {
@ -296,7 +259,7 @@ export default {
config: { config: {
cxqkqxbd: { cxqkqxbd: {
label: 'template.dl.dl007.qxbd', label: 'template.dl.dl007.qxbd',
qxbdType: 'DL006',
// qxbdType: 'DL006',
type: 'qxbd', type: 'qxbd',
fillType: 'actFill', fillType: 'actFill',
filledCodes: ['bdmc', 'bdbh'] filledCodes: ['bdmc', 'bdbh']
@ -309,15 +272,105 @@ export default {
data() { data() {
return { return {
formData: {}, formData: {},
refConf
refConf,
dynamicCxqkColumns: [], //
isDataLoaded: false //
}
},
mounted() {
//
this.$nextTick(() => {
this.initializeTableFromFormData()
})
},
watch: {
// formData
'formData.stepTableFormData_1': {
handler(newVal) {
if (newVal && newVal.length > 0 && !this.isDataLoaded) {
this.initializeTableFromFormData()
}
},
deep: true,
immediate: true
} }
}, },
mounted() {},
methods: { methods: {
// //
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 labelKeys = Object.keys(firstRow).filter(key => key.match(/^jzbh\d+Label$/))
if (labelKeys.length === 0) {
return
}
// Label
const dynamicColumns = [
{
label: 'template.dl.dl008.jlzb',
prop: 'jlzb',
bodyType: 'input',
bodyFillType: 'actFill',
bodyDisabled: true,
disabled: true,
width: 100
}
]
// headerSelectFields
labelKeys.sort().forEach((labelKey, index) => {
const colIndex = index + 1
// headerSelectFields 1_1, 1_2, 1_3
const headerValues = []
let rowIndex = 1
while (headerSelectFields[`${colIndex}_${rowIndex}`]) {
headerValues.push(headerSelectFields[`${colIndex}_${rowIndex}`])
rowIndex++
}
// 使
const headerLabel = headerValues.length > 0 ? headerValues.join(' ') : `菌种${colIndex}`
dynamicColumns.push({
label: headerLabel,
prop: `jzbh${colIndex}`,
bodyType: 'checkbox',
bodyFillType: 'actFill',
checkboxLabel: '',
width: 150
})
})
//
this.dynamicCxqkColumns = dynamicColumns
this.isDataLoaded = true
//
this.$nextTick(() => {
if (this.$refs[refConf.cxqk]) {
this.$refs[refConf.cxqk].updateDataSource(stepTableFormData_1)
}
})
} catch (error) {
console.error('初始化表格数据失败:', error)
}
},
// //
handleClickButton(_item, signData) { handleClickButton(_item, signData) {
this.$refs.cxqkqxbbInfoRef.updateFormData( this.$refs.cxqkqxbbInfoRef.updateFormData(
@ -328,79 +381,249 @@ export default {
}, },
// //
getFilledFormData() { getFilledFormData() {
return this.getFilledFormDataByRefs(refNames)
const baseData = this.getFilledFormDataByRefs(refNames)
//
const cxqkTableRef = this.$refs[refConf.cxqk]
if (cxqkTableRef) {
const cxqkData = cxqkTableRef.getFilledFormData()
baseData.stepTableFormData_1 = cxqkData.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.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'))
}
// 3.
return await this.validFormFields(refNames) return await this.validFormFields(refNames)
}, },
getResource() { getResource() {
const stepResource = this.$refs.yqsyTableRef.getStepResource()
// 使
this.resourceTmp = stepResource.sjResource || []
this.yqResourceTmp = stepResource.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) {
const { selectInfo, key, rowIndex } = e const { selectInfo, key, rowIndex } = e
const { row } = selectInfo const { row } = selectInfo
//
if (key === 'yqbh') { if (key === 'yqbh') {
const params = {
yqmc: row.mc,
yqxh: row.xh,
jzrq: row.jzrq
}
this.$refs.yqsyTableRef.updateDataSourceByRowIndex(rowIndex, params)
this.handleYqbhSelect(row, rowIndex)
return
} }
//
if (key === 'cxqkqxbd') { if (key === 'cxqkqxbd') {
// MOCK:
const mockData = [
{
jlzb: 'A',
jzbh1: undefined,
jzbh2: undefined,
jzbh3: undefined,
jzbh4: undefined,
jzbh1Label: '001',
jzbh2Label: '004',
jzbh3Label: '007',
jzbh4Label: '010'
},
{
jlzb: 'A',
jzbh1: undefined,
jzbh2: undefined,
jzbh3: undefined,
jzbh4: undefined,
jzbh1Label: '002',
jzbh2Label: '005',
jzbh3Label: '008',
jzbh4Label: '011'
},
{
jlzb: 'A',
jzbh1: undefined,
jzbh2: undefined,
jzbh3: undefined,
jzbh4: undefined,
jzbh1Label: '003',
jzbh2Label: '006',
jzbh3Label: '009',
jzbh4Label: '012'
}
]
this.$refs[refConf.cxqk].updateDataSource(mockData)
this.handleCxqkQxbdSelect(row)
} }
}, },
//
handleYqbhSelect(row, rowIndex) {
const params = {
yqmc: row.mc,
yqxh: row.xh,
jzrq: row.jzrq
}
this.$refs.yqsyTableRef.updateDataSourceByRowIndex(rowIndex, params)
},
//
handleCxqkQxbdSelect(row) {
//
this.isDataLoaded = false
try {
const bdnr = JSON.parse(row.bdnr)
const headerFields = bdnr.headerFields || {}
const stepTableFormData_1 = bdnr.stepTableFormData_1 || []
//
if (!stepTableFormData_1 || stepTableFormData_1.length === 0) {
this.clearCxqkTable()
return
}
// 1.
const dynamicColumns = this.generateDynamicColumns(headerFields)
if (!dynamicColumns) {
this.clearCxqkTable()
return
}
// 2.
const tableData = this.generateTableData(stepTableFormData_1, dynamicColumns.columnKeys)
if (tableData.length === 0) {
this.clearCxqkTable()
return
}
// 3.
this.updateCxqkTable(dynamicColumns.columns, tableData, headerFields)
} catch (error) {
console.error('解析前序表单数据失败:', error)
this.clearCxqkTable()
}
},
//
generateDynamicColumns(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.dl008.jlzb',
prop: 'jlzb',
bodyType: 'input',
bodyFillType: 'actFill',
bodyDisabled: true,
disabled: true,
width: 100
}
]
columnKeys.forEach((key, index) => {
const colIndex = index + 1
const baseColIndex = key.split('_')[0] // "1_1" -> "1"
// headerFields 1_1, 1_2, 1_3
const headerValues = []
let rowIndex = 1
while (headerFields[`${baseColIndex}_${rowIndex}`]) {
headerValues.push(headerFields[`${baseColIndex}_${rowIndex}`])
rowIndex++
}
//
const headerLabel = headerValues.join(' ')
columns.push({
label: headerLabel,
prop: `jzbh${colIndex}`,
bodyType: 'checkbox',
bodyFillType: 'actFill',
checkboxLabel: '',
width: 150
})
})
return { columns, columnKeys }
},
//
generateTableData(stepTableFormData_1, columnKeys) {
const tableData = []
stepTableFormData_1.forEach((item) => {
const rowData = { jlzb: item.jlzb || '' }
columnKeys.forEach((_key, index) => {
const colIndex = index + 1
const valueKey = `jzbh${colIndex}`
// DL006 label
// DL006 使 czrxm_${index}Label
const labelValue = item[`czrxm_${index}Label`] || ''
rowData[`${valueKey}Label`] = labelValue
rowData[valueKey] = '' //
})
tableData.push(rowData)
})
return tableData
},
//
updateCxqkTable(columns, tableData, headerFields) {
//
this.dynamicCxqkColumns = 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.cxqk]
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
})
},
//
clearCxqkTable() {
this.dynamicCxqkColumns = []
this.$set(this.formData, 'stepTableFormData_1', [])
this.$nextTick(() => {
this.$refs[refConf.cxqk]?.updateDataSource([])
})
},
// //
async onSave() { async onSave() {
const formData = this.getStepResource() const formData = this.getStepResource()
console.log(formData, 'formData')
} }
} }
} }

+ 502
- 52
src/views/business/comps/template/comps/dl/DL009.vue View File

@ -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()
} }
} }
} }

Loading…
Cancel
Save