|
|
|
@ -30,10 +30,11 @@ |
|
|
|
:item="getHeaderColumnItem(headerCol)" |
|
|
|
:value="headerFields[`${colIndex}_${headerIndex}`]" |
|
|
|
:error="hasHeaderError(colIndex, headerIndex, headerCol.key)" |
|
|
|
@update:error="onHeaderColumnErrorUpdate(colIndex, headerIndex, headerCol.key, $event)" |
|
|
|
@update:error="onHeaderColumnErrorUpdate(colIndex, headerIndex, headerCol.key, $event)" |
|
|
|
@onRegentSubmit="(data, inputValue) => onHeaderRegentSubmit(data, inputValue, colIndex, headerIndex)" /> |
|
|
|
</template> |
|
|
|
<template v-else-if="headerCol.type === 'input' || headerCol.type === 'select'|| headerCol.type === 'inputNumber'"> |
|
|
|
<template |
|
|
|
v-else-if="headerCol.type === 'input' || headerCol.type === 'select' || headerCol.type === 'inputNumber'"> |
|
|
|
<HandleFormItem |
|
|
|
:fieldKey="prefixKey + '_header_' + colIndex + '_' + headerIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" :type="headerCol.type" |
|
|
|
@ -105,21 +106,31 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
</template> |
|
|
|
<!-- |
|
|
|
<template v-else-if="col.bodyType === 'select'"> |
|
|
|
<div class="flex flex1"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="select" class="body-select" |
|
|
|
@blur="onBlur(rowIndex, col.prop, $event)" |
|
|
|
:item="getBodyItem(col, rowIndex)" v-model="row[col.prop]" |
|
|
|
@change="onBodyValueChange(rowIndex, colIndex, $event, row, 'select')" |
|
|
|
:error="hasError(rowIndex, colIndex, col.prop)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" /> |
|
|
|
|
|
|
|
<div v-else-if="col.bodyType === 'operableInput'" class="flex flex1"> |
|
|
|
<div class="flex1 grid-container"> |
|
|
|
<div class="flex" |
|
|
|
:class="{ 'full-row': row[col.prop] && row[col.prop].length == 1 }" |
|
|
|
v-for="(opItem, itemIndex) in row[col.prop]" :key="itemIndex"> |
|
|
|
<HandleFormItem |
|
|
|
:fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex + '_' + itemIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="input" |
|
|
|
@blur="onOperableInputBlur(opItem, $event)" class="body-input" |
|
|
|
:item="getBodyItem(col, rowIndex)" :value="opItem.value" |
|
|
|
:error="hasError(rowIndex, colIndex, rowIndex+col.prop+itemIndex)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, rowIndex+col.prop+itemIndex, $event)" |
|
|
|
:orange-bg="hasOrangeBg(rowIndex, colIndex, rowIndex+col.prop+itemIndex)" /> |
|
|
|
<el-popconfirm confirm-button-text='确认' cancel-button-text='取消' |
|
|
|
icon="el-icon-info" icon-color="red" title="确认删除当前输入框?" |
|
|
|
@confirm="removeOperableInput(rowIndex, colIndex, col.prop, itemIndex)"> |
|
|
|
<i slot="reference" class="el-icon-remove-outline remove-icon" |
|
|
|
v-if="itemIndex > 0 && templateFillType === 'actFill' && !row.isComplete"></i> |
|
|
|
</el-popconfirm> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<i class="el-icon-circle-plus add-icon" v-if="templateFillType === 'actFill' && !row.isComplete" |
|
|
|
@click="addOperableInput(rowIndex, colIndex, col.prop)"></i> |
|
|
|
</div> |
|
|
|
|
|
|
|
</template> --> |
|
|
|
<div class="flex flex1" v-else-if="col.bodyType === 'clickable'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.prop + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" type="clickable" class="body-clickable" |
|
|
|
@ -183,7 +194,8 @@ |
|
|
|
</div> |
|
|
|
<div class="m-l-5" :class="{ 'flex1': col.bodySubType !== 'button' }" |
|
|
|
v-if="isShowBodySub(col, row)"> |
|
|
|
<template v-if="col.bodySubType === 'inputNumber' || col.bodySubType === 'input' || col.bodySubType === 'select'"> |
|
|
|
<template |
|
|
|
v-if="col.bodySubType === 'inputNumber' || col.bodySubType === 'input' || col.bodySubType === 'select'"> |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.bodySubKey + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" :type="col.bodySubType" |
|
|
|
@blur="onSubBlur(rowIndex, col.bodySubKey, $event)" |
|
|
|
@ -208,7 +220,8 @@ |
|
|
|
<HandleFormItem :fieldKey="prefixKey + '_' + col.bodySubKey + '_' + rowIndex" |
|
|
|
:fieldItemLabel="fieldItemLabel" :type="col.bodySubType" class="body-clickable" |
|
|
|
sourceFrom="customTable" :item="getBodySubItem(col, rowIndex)" |
|
|
|
:value="row[col.bodySubKey]" :error="hasError(rowIndex, colIndex, col.bodySubKey)" |
|
|
|
:value="row[col.bodySubKey]" |
|
|
|
:error="hasError(rowIndex, colIndex, col.bodySubKey)" |
|
|
|
@onRegentSubmit="(data, inputValue) => onRegentSubmit(data, inputValue, col, rowIndex, colIndex, row, col.bodySubKey)" |
|
|
|
@beforeReagentSubmit="(data, callback) => onBeforeReagentSubmit(data, callback, col, row)" |
|
|
|
@update:error="onErrorUpdate(rowIndex, colIndex, col.bodySubKey, $event)" |
|
|
|
@ -362,6 +375,19 @@ export default { |
|
|
|
this.oldLocalDataSource = []; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 删除operableInput |
|
|
|
removeOperableInput(rowIndex, colIndex, prop, itemIndex) { |
|
|
|
this.localDataSource[rowIndex][prop].splice(itemIndex, 1); |
|
|
|
justUpdateFilledFormData(); |
|
|
|
}, |
|
|
|
// 添加operableInput |
|
|
|
addOperableInput(rowIndex, colIndex, prop) { |
|
|
|
this.localDataSource[rowIndex][prop].push({ value: undefined }); |
|
|
|
justUpdateFilledFormData(); |
|
|
|
}, |
|
|
|
onOperableInputBlur(opItem, e) { |
|
|
|
opItem.value = e; |
|
|
|
}, |
|
|
|
getHeaderColumnItem(headerCol) { |
|
|
|
return { |
|
|
|
label: headerCol.label || '', |
|
|
|
@ -387,7 +413,7 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
hasHeaderError(colIndex, headerIndex, key) { |
|
|
|
console.log(colIndex, headerIndex, key,this.formErrors,"headerError") |
|
|
|
console.log(colIndex, headerIndex, key, this.formErrors, "headerError") |
|
|
|
return this.formErrors.some(error => |
|
|
|
error.rowIndex === -1 && |
|
|
|
error.colIndex === colIndex && |
|
|
|
@ -499,11 +525,11 @@ export default { |
|
|
|
}, |
|
|
|
onHeaderRegentSubmit(data, inputValue, colIndex, headerIndex) { |
|
|
|
this.headerFields[`${colIndex}_${headerIndex}`] = inputValue; |
|
|
|
console.log("onHeaderRegentSubmit", data, inputValue, colIndex, headerIndex,this.headerFields) |
|
|
|
console.log("onHeaderRegentSubmit", data, inputValue, colIndex, headerIndex, this.headerFields) |
|
|
|
|
|
|
|
this.$emit("onHeaderRegentSubmit", { selectInfo: data, headerIndex, colIndex, headerFields: this.headerFields }) |
|
|
|
}, |
|
|
|
onRegentSubmit(data, inputValue, col, rowIndex, colIndex, row,key) { |
|
|
|
onRegentSubmit(data, inputValue, col, rowIndex, colIndex, row, key) { |
|
|
|
// if (this.templateFillType !== 'actFill') { |
|
|
|
// return |
|
|
|
// } |
|
|
|
@ -669,7 +695,22 @@ export default { |
|
|
|
this.formErrors.push(errorItem); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else if(col.bodyType === "operableInput"){ |
|
|
|
mainValue.forEach((itemItem, itemIndex) => { |
|
|
|
if (isValueEmpty(itemItem.value)) { |
|
|
|
const errorItem = { |
|
|
|
rowIndex, |
|
|
|
colIndex, |
|
|
|
field: rowIndex+col.prop+itemIndex, |
|
|
|
label: this.$t(col.label), |
|
|
|
error: `请填写${this.$t(col.label)}` |
|
|
|
}; |
|
|
|
errors.push(errorItem); |
|
|
|
this.formErrors.push(errorItem); |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
}else { |
|
|
|
if (isValueEmpty(mainValue) && !col.bodyDisabled && col.bodyType !== 'span' && col.bodyType !== 'button') { |
|
|
|
const errorItem = { |
|
|
|
rowIndex, |
|
|
|
@ -682,7 +723,7 @@ export default { |
|
|
|
this.formErrors.push(errorItem); |
|
|
|
} |
|
|
|
// 检查子字段(如果有) |
|
|
|
if (col.bodySubKey && !col.bodySubDisabled &&col.bodySubFillType === this.templateFillType&& col.bodySubType !== 'span' && col.bodySubType !== "button") { |
|
|
|
if (col.bodySubKey && !col.bodySubDisabled && col.bodySubFillType === this.templateFillType && col.bodySubType !== 'span' && col.bodySubType !== "button") { |
|
|
|
const subValue = row[col.bodySubKey]; |
|
|
|
if (isValueEmpty(subValue)) { |
|
|
|
const errorItem = { |
|
|
|
@ -729,7 +770,7 @@ export default { |
|
|
|
errors: errors |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 表头选择器变化 |
|
|
|
onHeaderSelectChange(col, value) { |
|
|
|
if (col.headerSelectTo) { |
|
|
|
@ -884,6 +925,13 @@ export default { |
|
|
|
// 否则使用列配置的checkboxLabel |
|
|
|
item.checkboxLabel = this.$t(col.checkboxLabel); |
|
|
|
} |
|
|
|
if (col.bodyType === "operableInput" ) { |
|
|
|
if(currentItem.isComplete){ |
|
|
|
item.disabled = true; |
|
|
|
}else{ |
|
|
|
item.disabled = false; |
|
|
|
} |
|
|
|
} |
|
|
|
return item |
|
|
|
}, |
|
|
|
getBodyButtonItem(col,) { |
|
|
|
@ -922,14 +970,14 @@ export default { |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
deleteSelectedRows(rowsIndex){ |
|
|
|
deleteSelectedRows(rowsIndex) { |
|
|
|
this.deleteRows(rowsIndex); |
|
|
|
this.selectedRows = []; |
|
|
|
this.isIndeterminate = false; |
|
|
|
this.$emit('selectionChange', this.selectedRows); |
|
|
|
}, |
|
|
|
updateHeaderSelectFields(fields) { |
|
|
|
this.headerSelectFields = {...this.headerSelectFields, ...fields}; |
|
|
|
this.headerSelectFields = { ...this.headerSelectFields, ...fields }; |
|
|
|
}, |
|
|
|
// 更新数据方法,可在formData变更时调用,也可由父组件调用 |
|
|
|
updateDataSource(dataSource = []) { |
|
|
|
@ -1330,4 +1378,32 @@ export default { |
|
|
|
width: -webkit-fill-available; |
|
|
|
text-align: center; |
|
|
|
} |
|
|
|
|
|
|
|
.add-icon { |
|
|
|
color: #409eff; |
|
|
|
font-size: 20px; |
|
|
|
margin-left: 10px; |
|
|
|
cursor: pointer; |
|
|
|
} |
|
|
|
|
|
|
|
.remove-icon { |
|
|
|
color: #ff4949; |
|
|
|
font-size: 20px; |
|
|
|
margin-left: 5px; |
|
|
|
cursor: pointer; |
|
|
|
} |
|
|
|
|
|
|
|
.full-row { |
|
|
|
grid-column: span 2; |
|
|
|
} |
|
|
|
|
|
|
|
.grid-container { |
|
|
|
display: grid; |
|
|
|
grid-template-columns: repeat(2, 1fr); |
|
|
|
/* 默认2列 */ |
|
|
|
gap: 5px; |
|
|
|
/* 防止网格容器被分割到不同页面 */ |
|
|
|
page-break-inside: avoid; |
|
|
|
break-inside: avoid; |
|
|
|
} |
|
|
|
</style> |