Browse Source

(*)编辑模型完善

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

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

@ -75,12 +75,24 @@ function editModelManagement(opts) {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { id } = ctx.params; const { id } = ctx.params;
const body = ctx.request.body; const body = ctx.request.body;
await models.MetaModel.update( let modelFind = await models.MetaModel.findOne({ where: { id: id } });
body, const { attributeName, attributeCode } = ctx.request.body;
{ where: { id: id, } } const { modelType } = modelFind;
) const checkName = await models.MetaModel.findOne({ where: { id: { $not: id }, attributeName, modelType } });
ctx.status = 204; const checkCode = await models.MetaModel.findOne({ where: { id: { $not: id }, attributeCode, modelType } });
ctx.body = { message: '修改模型成功' } 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) { } catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400; ctx.status = 400;

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

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

Loading…
Cancel
Save