Browse Source

修复内置编辑功能出现验证错误时行数据被修改以及再次打开窗口验证信息未清空的缺陷

main
likunming 3 months ago
parent
commit
ff4f29dec1
  1. 10
      io.sc.platform.core.frontend/src/platform/components/form/WForm.vue
  2. 3
      io.sc.platform.core.frontend/src/platform/components/grid/extra/Editor.vue
  3. 17
      io.sc.platform.core.frontend/src/platform/components/grid/extra/inline-edit/CellEditor.vue

10
io.sc.platform.core.frontend/src/platform/components/form/WForm.vue

@ -337,6 +337,15 @@ const getFieldComponent = (name) => {
return componentRef.value[name];
};
const resetValidation = () => {
formRef.value.resetValidation();
Object.keys(formFields).forEach((field) => {
if (Tools.hasOwnProperty(formFields[field], 'error') && formFields[field]['error']) {
formFields[field]['error'] = false;
}
});
};
defineExpose({
getFields,
getData,
@ -350,6 +359,7 @@ defineExpose({
getColsNum,
setValidationErrors,
getFieldComponent,
resetValidation,
});
const instance = getCurrentInstance();

3
io.sc.platform.core.frontend/src/platform/components/grid/extra/Editor.vue

@ -4,9 +4,10 @@
v-bind="tools.props.editor.dialog"
:title="dialog.dialogTitle"
:buttons="dialogButtonsComputed"
@hide="
@before-hide="
() => {
saveLoading = false;
dialogFormRef.resetValidation();
}
"
>

17
io.sc.platform.core.frontend/src/platform/components/grid/extra/inline-edit/CellEditor.vue

@ -4,10 +4,11 @@
:title="dialog.title"
v-bind="bindDialogComputed"
:buttons="dialog.buttons"
@hide="
@before-hide="
() => {
saveLoading = false;
tools.table.store.inlineEditStatus = Constant.EDIT_STATUS.NONE;
dialogFormRef.resetValidation();
}
"
>
@ -79,20 +80,22 @@ const dialog = {
const data = dialogFormRef.value.getData();
const row = tools.dataFM.getRow(tools.table.rows, cellSelected.row[Constant.FIELD_NAMES.ROW_KEY], false);
if (row) {
row[cellSelected.colName] = data[cellSelected.colName];
//
if (!tools.props.localMode) {
const data = GridTools.removeExtraFields(toRaw(row));
const url = getUrl(data[tools.props.primaryKey]);
const oldData = GridTools.removeExtraFields(toRaw(row));
const newData = { ...oldData, ...data };
const url = getUrl(oldData[tools.props.primaryKey]);
const callback = () => {
saveLoading.value = false;
updateLocalData(row, data, cellSelected);
dialogRef.value.hide();
};
const errorCallback = () => {
saveLoading.value = false;
};
tools.reqApiFM.save('PUT', data, url, dialogFormRef.value, callback, errorCallback);
tools.reqApiFM.save('PUT', newData, url, dialogFormRef.value, callback, errorCallback);
} else {
updateLocalData(row, data, cellSelected);
dialogRef.value.hide();
}
}
@ -103,6 +106,10 @@ const dialog = {
],
};
const updateLocalData = (row, data, cellSelected) => {
row[cellSelected.colName] = data[cellSelected.colName];
};
const getUrl = (primaryKey) => {
if (!Tools.isEmpty(tools.table.url.editDataUrl)) {
return tools.table.url.editDataUrl + '/' + primaryKey;

Loading…
Cancel
Save