|
|
|
@ -12,9 +12,37 @@ |
|
|
|
@change="handleCheckAllChange"></el-checkbox> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div v-for="(col, index) in columns" :key="index" class="custom-table-cell header-cell" |
|
|
|
<div v-for="(col, colIndex) in columns" :key="colIndex" class="custom-table-cell header-cell" |
|
|
|
:style="getCellWidth(col)"> |
|
|
|
<div class="header-cell-content"> |
|
|
|
<div class="header-cell-content" v-if = "col.headerColumns && col.headerColumns.length > 0"> |
|
|
|
<div class="header-columns-grid" :style="{ 'grid-template-columns': `repeat(${col.span || 2}, 1fr)` }"> |
|
|
|
<div v-for="(headerCol, headerIndex) in col.headerColumns" :key="headerIndex" class="header-column-item"> |
|
|
|
<template v-if="headerCol.type === 'span'"> |
|
|
|
<div class="span-content">{{ $t(headerCol.label) }}</div> |
|
|
|
</template> |
|
|
|
<template v-else-if="headerCol.type === 'sj'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey+colIndex + '_' + headerCol.key + '_' + headerIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" :type="headerCol.type" class="body-clickable" |
|
|
|
sourceFrom="customTable" :item="getHeaderColumnItem(headerCol)" |
|
|
|
:value="headerFields[`${colIndex}_${headerIndex}`]" |
|
|
|
@onRegentSubmit="(data, inputValue) => onHeaderRegentSubmit(data, inputValue, colIndex, headerIndex)" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
<template v-else-if="headerCol.type === 'input' || headerCol.type === 'select'"> |
|
|
|
<HandleFormItem |
|
|
|
:fieldKey="prefixKey + '_header_' + colIndex + '_' + headerIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" |
|
|
|
:type="headerCol.type" |
|
|
|
:item="getHeaderColumnItem(headerCol)" |
|
|
|
v-model="headerFields[`${colIndex}_${headerIndex}`]" |
|
|
|
@change="onHeaderColumnChange(colIndex, headerIndex, headerCol, $event)" |
|
|
|
:error="hasHeaderError(colIndex, headerIndex, `${colIndex}_${headerIndex}`)" |
|
|
|
@update:error="onHeaderColumnErrorUpdate(colIndex, headerIndex, `${colIndex}_${headerIndex}`, $event)" /> |
|
|
|
</template> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="header-cell-content" v-else> |
|
|
|
<div>{{ $t(col.label) }}</div> |
|
|
|
<template |
|
|
|
v-if="col.headerSelectKey && col.headerOptions && (showHeaderSelect || templateFillType === 'preFill')"> |
|
|
|
@ -22,8 +50,8 @@ |
|
|
|
:fieldItemLabel="fieldItemLabel" type="select" class="header-select" |
|
|
|
:item="getHeaderItem(col)" v-model="headerSelectFields[col.headerSelectKey]" |
|
|
|
@change="onHeaderSelectChange(col, $event)" |
|
|
|
:error="hasError(-1, index, col.headerSelectKey)" |
|
|
|
@update:error="onErrorUpdate(-1, index, col.headerSelectKey, $event)" /> |
|
|
|
:error="hasError(-1, colIndex, col.headerSelectKey)" |
|
|
|
@update:error="onErrorUpdate(-1, colIndex, col.headerSelectKey, $event)" /> |
|
|
|
</template> |
|
|
|
<div v-else-if="headerSelectFields[col.headerSelectKey]" class="fill-type-icon" |
|
|
|
:style="{ width: (templateFillType !== 'actFill') ? '60px' : 'auto' }">({{ |
|
|
|
@ -247,7 +275,7 @@ export default { |
|
|
|
default: () => { |
|
|
|
return { |
|
|
|
stepTableFormData: [], |
|
|
|
headerSelectFields: {} |
|
|
|
headerSelectFields: {}, |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -279,6 +307,7 @@ export default { |
|
|
|
return { |
|
|
|
localDataSource: [], |
|
|
|
headerSelectFields: {}, |
|
|
|
headerFields: {}, // 存储 headerColumns 的数据 |
|
|
|
formErrors: [], // 表单错误状态管理 |
|
|
|
orangeBgCells: {}, // 存储需要橙色背景的单元格 {rowIndex-colIndex: true/false} |
|
|
|
isShowOther, |
|
|
|
@ -294,9 +323,10 @@ export default { |
|
|
|
formData: { |
|
|
|
immediate: true, |
|
|
|
handler(newData) { |
|
|
|
const { stepTableFormData = [], headerSelectFields = {} } = newData; |
|
|
|
const { stepTableFormData = [], headerSelectFields = {}, headerFields = {} } = newData; |
|
|
|
this.updateDataSource(stepTableFormData); |
|
|
|
this.headerSelectFields = JSON.parse(JSON.stringify(headerSelectFields)); |
|
|
|
this.headerFields = JSON.parse(JSON.stringify(headerFields)); |
|
|
|
// 在数据加载后检查 compareTo 逻辑 |
|
|
|
this.checkCompareToOnDataLoad(); |
|
|
|
} |
|
|
|
@ -318,6 +348,50 @@ export default { |
|
|
|
this.oldLocalDataSource = []; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getHeaderColumnItem(headerCol) { |
|
|
|
return { |
|
|
|
label: headerCol.label || '', |
|
|
|
fillType: headerCol.fillType, |
|
|
|
options: headerCol.options, |
|
|
|
maxlength: headerCol.maxlength, |
|
|
|
checkType: headerCol.checkType, |
|
|
|
regentFillType: headerCol.regentFillType, |
|
|
|
type:headerCol.type, |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
onHeaderColumnChange(colIndex, headerIndex, headerCol, value) { |
|
|
|
const fieldKey = `${colIndex}_${headerIndex}`; |
|
|
|
this.headerFields[fieldKey] = value; |
|
|
|
this.$emit('headerColumnChange', { |
|
|
|
colIndex, |
|
|
|
headerIndex, |
|
|
|
key: fieldKey, |
|
|
|
value, |
|
|
|
headerFields: this.headerFields |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
hasHeaderError(colIndex, headerIndex, key) { |
|
|
|
return this.formErrors.some(error => |
|
|
|
error.rowIndex === -1 && |
|
|
|
error.colIndex === colIndex && |
|
|
|
error.headerIndex === headerIndex && |
|
|
|
error.field === key |
|
|
|
); |
|
|
|
}, |
|
|
|
|
|
|
|
onHeaderColumnErrorUpdate(colIndex, headerIndex, key, isError) { |
|
|
|
if (!isError) { |
|
|
|
this.formErrors = this.formErrors.filter(error => |
|
|
|
!(error.rowIndex === -1 && |
|
|
|
error.colIndex === colIndex && |
|
|
|
error.headerIndex === headerIndex && |
|
|
|
error.field === key) |
|
|
|
); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 删除checkboxTag |
|
|
|
onDeleteCheckboxTag(rowIndex, col, tagIndex) { |
|
|
|
this.localDataSource[rowIndex][col.prop].splice(tagIndex, 1); |
|
|
|
@ -408,10 +482,14 @@ export default { |
|
|
|
} |
|
|
|
this.$emit("beforeReagentSubmit", { selectData: data, callback, key: col.prop, rowData: row }) |
|
|
|
}, |
|
|
|
onHeaderRegentSubmit(data, inputValue, colIndex, headerIndex) { |
|
|
|
this.headerFields[`${colIndex}_${headerIndex}`] = inputValue; |
|
|
|
this.$emit("onHeaderRegentSubmit", { selectInfo: data, key: col.prop, col, rowIndex, colIndex, rowData: row }) |
|
|
|
}, |
|
|
|
onRegentSubmit(data, inputValue, col, rowIndex, colIndex, row) { |
|
|
|
if (this.templateFillType !== 'actFill') { |
|
|
|
return |
|
|
|
} |
|
|
|
// if (this.templateFillType !== 'actFill') { |
|
|
|
// return |
|
|
|
// } |
|
|
|
this.updateDataSourceByRowIndex(rowIndex, { [col.prop]: inputValue }) |
|
|
|
this.$emit("onRegentSubmit", { selectInfo: data, key: col.prop, col, rowIndex, colIndex, rowData: row }) |
|
|
|
}, |
|
|
|
@ -447,6 +525,7 @@ export default { |
|
|
|
return { |
|
|
|
stepTableFormData: [...this.localDataSource], |
|
|
|
headerSelectFields: this.headerSelectFields, |
|
|
|
headerFields: this.headerFields, |
|
|
|
}; |
|
|
|
}, |
|
|
|
// 获取最新数据 |
|
|
|
@ -461,6 +540,7 @@ export default { |
|
|
|
resolve({ |
|
|
|
stepTableFormData: [...this.localDataSource], |
|
|
|
headerSelectFields: this.headerSelectFields, |
|
|
|
headerFields: this.headerFields, |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// this.$message.error("表单内容未填完,请填写后再提交"); |
|
|
|
@ -1045,6 +1125,17 @@ export default { |
|
|
|
justify-content: center; |
|
|
|
} |
|
|
|
|
|
|
|
.header-columns-grid { |
|
|
|
display: grid; |
|
|
|
gap: 10px; |
|
|
|
} |
|
|
|
|
|
|
|
.header-column-item { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
padding: 0 5px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 共同行样式 */ |
|
|
|
.custom-table-row { |
|
|
|
display: table; |
|
|
|
@ -1202,4 +1293,8 @@ export default { |
|
|
|
.c-cell { |
|
|
|
width: 50px; |
|
|
|
} |
|
|
|
.span-content { |
|
|
|
width: -webkit-fill-available; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
</style> |