From 89c406d8025704b1d9fc607d488b03e715abad04 Mon Sep 17 00:00:00 2001 From: aixianling Date: Tue, 4 Apr 2023 14:10:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oms/apps/develop/AppDataModel/dmAdd.vue | 107 ++++++++++++------ .../oms/apps/develop/AppDataModel/dmList.vue | 13 +-- .../oms/apps/develop/AppDataModel/element.js | 6 +- ui/lib/styles/common.scss | 9 ++ ui/packages/basic/AiSelect.vue | 80 ++++++------- 5 files changed, 129 insertions(+), 86 deletions(-) diff --git a/project/oms/apps/develop/AppDataModel/dmAdd.vue b/project/oms/apps/develop/AppDataModel/dmAdd.vue index b214b788..7779cd21 100644 --- a/project/oms/apps/develop/AppDataModel/dmAdd.vue +++ b/project/oms/apps/develop/AppDataModel/dmAdd.vue @@ -2,18 +2,25 @@ -
取消 @@ -62,19 +66,20 @@ export default { entries: [], form: {}, rules: { - tableName: {required: true, message: "请选择主表模型"}, + name: {required: true, message: "请选择主表模型"}, }, diagram: null, drawer: false, current: {}, currentCols: [ - {label: "属性", prop: "columnName"}, - {label: "属性名", prop: "columnComment"}, - ] + {label: "属性", prop: "field"}, + {label: "属性名", prop: "fieldName"}, + ], + fullscreen: false, } }, computed: { - isEdit: v => !!v.$route.query.tableName, + isEdit: v => !!v.$route.query.name, pageTitle: v => v.isEdit ? "编辑数据关联模型" : "新增数据关联模型", }, methods: { @@ -84,14 +89,14 @@ export default { this.$router.push({}) }, getDetail() { - const {tableName} = this.$route.query - tableName && this.instance.get("/relation/list", {params: {tableName}}).then(res => { + const {id} = this.$route.query + id && this.instance.post("/app/appdatamodelconfig/queryDetailById", null, {params: {id}}).then(res => { if (res?.data) { const json = JSON.parse(res.data.json) - this.form = {...res.data, json, tableName} + this.form = {...res.data, json} this.$load(this.diagram).then(() => { this.diagram.render(json) - this.diagram.focusOn({id: tableName}) + this.diagram.focusOn({id: this.form.name}) }) } }) @@ -100,9 +105,9 @@ export default { const jsonData = this.diagram.getGraphData() this.form.relationNodes = jsonData.edges.map(e => e.properties) this.$refs.DataModelForm.validate() - .then(() => this.instance.post("/relation/setting", {...this.form, jsonData: JSON.stringify(jsonData)})) + .then(() => this.instance.post("/app/appdatamodelconfig/addOrUpdate", {...this.form, config: JSON.stringify(jsonData)})) .then(res => { - if (res?.code == 200) { + if (res?.code == 0) { this.$message.success("提交成功") this.back() } @@ -137,7 +142,7 @@ export default { this.diagram.dnd.startDrag({type: "model"}) }, onNodeClick({data}) { - if (data.id != this.form.tableName) { + if (data.id != this.form.name) { const {id: oldId, type} = data this.current = this.$copy({props: [], ...data.properties, oldId, type}) this.drawer = true @@ -153,7 +158,7 @@ export default { initMainModel(v) { this.diagram.clearData() if (!!v?.id) { - this.getTableFields(v.id).then(list => { + this.getTableFields(v).then(list => { this.diagram.addNode({ type: 'main', x: 200, @@ -163,28 +168,27 @@ export default { }) this.diagram.focusOn({id: v.id}) }) - } }, changeModel(v) { if (!!v?.id) { this.current.name = v.id - this.getTableFields(v.id).then((list = []) => this.current.props = list) + this.getTableFields(v).then((list = []) => this.current.props = list) } }, getEntries() { - this.instance.get("/relation/table").then(res => { - if (res?.data) { - this.entries = res.data.map(e => ({...e, id: e.name, label: [e.entityName, e.des].filter(Boolean).join(" | ") || e.name})) + this.instance.get("/app/v2/api-docs").then(res => { + if (res?.definitions) { + this.entries = Object.entries(res.definitions).filter(([id]) => id?.startsWith("App"))?.map(([id, e]) => ({...e, id, label: id})) || [] } }) }, - getTableFields(tableName) { - return this.instance.get(`/relation/fields`, {params: {tableName}}).then(res => { - if (res?.data) { - return res.data - } - }) + getTableFields(entry) { + const props = [] + for (const i in entry.properties) { + props.push({field: i, fieldName: entry.properties[i]?.description}) + } + return Promise.resolve(props) } }, created() { @@ -199,13 +203,32 @@ export default {