Browse Source

(*)编辑模型完善

master
peng.peng 2 years ago
parent
commit
18865b6216
  1. 12
      api/app/lib/controllers/modelManagement/index.js
  2. 7
      web/client/src/sections/metadataManagement/containers/metaModelManagement.js

12
api/app/lib/controllers/modelManagement/index.js

@ -75,12 +75,24 @@ function editModelManagement(opts) {
const models = ctx.fs.dc.models;
const { id } = ctx.params;
const body = ctx.request.body;
let modelFind = await models.MetaModel.findOne({ where: { id: id } });
const { attributeName, attributeCode } = ctx.request.body;
const { modelType } = modelFind;
const checkName = await models.MetaModel.findOne({ where: { id: { $not: id }, attributeName, modelType } });
const checkCode = await models.MetaModel.findOne({ where: { id: { $not: id }, attributeCode, modelType } });
if (checkName || checkCode) {
ctx.status = 400;
ctx.body = { message: checkName ? '该属性名称已存在' : "该属性代码已存在" }
} else {
await models.MetaModel.update(
body,
{ where: { id: id, } }
)
ctx.status = 204;
ctx.body = { message: '修改模型成功' }
}
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;

7
web/client/src/sections/metadataManagement/containers/metaModelManagement.js

@ -36,8 +36,13 @@ function MetaModelManagement(props) {
const dataToSave = { ...values }
return dispatch(
actions.metadataManagement.modifyMetaModel(editData.id, dataToSave, values?.msg || ''),
).then(() => {
).then((res) => {
if (res.success) {
queryData();
return true;
} else {
return false;
}
});
}

Loading…
Cancel
Save