From fdbe0c4c37f683ce84819d4efd5b55aab69bb8c1 Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 31 Mar 2023 18:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B=E5=88=9D?= =?UTF-8?q?=E6=AD=A5=E6=8E=A5=E5=85=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../develop/AppDataModel/AppDataModel.vue | 3 -- .../oms/apps/develop/AppDataModel/dmAdd.vue | 29 +++++++------------ .../oms/apps/develop/AppDataModel/dmList.vue | 26 ++++++++--------- .../oms/apps/develop/AppDataModel/element.js | 20 ++++++------- 4 files changed, 33 insertions(+), 45 deletions(-) diff --git a/project/oms/apps/develop/AppDataModel/AppDataModel.vue b/project/oms/apps/develop/AppDataModel/AppDataModel.vue index 2cec7682..91069678 100644 --- a/project/oms/apps/develop/AppDataModel/AppDataModel.vue +++ b/project/oms/apps/develop/AppDataModel/AppDataModel.vue @@ -21,9 +21,6 @@ export default { let {hash} = this.$route return hash == "#add" ? DmAdd : DmList } - }, - created() { - this.dict.load("detailType") } } diff --git a/project/oms/apps/develop/AppDataModel/dmAdd.vue b/project/oms/apps/develop/AppDataModel/dmAdd.vue index e7846fab..b214b788 100644 --- a/project/oms/apps/develop/AppDataModel/dmAdd.vue +++ b/project/oms/apps/develop/AppDataModel/dmAdd.vue @@ -9,7 +9,7 @@ - +
@@ -74,7 +74,7 @@ export default { } }, computed: { - isEdit: v => !!v.$route.tableName, + isEdit: v => !!v.$route.query.tableName, pageTitle: v => v.isEdit ? "编辑数据关联模型" : "新增数据关联模型", }, methods: { @@ -85,9 +85,14 @@ export default { }, getDetail() { const {tableName} = this.$route.query - tableName && this.instance.post("/relation/list", null, {params: {tableName}}).then(res => { + tableName && this.instance.get("/relation/list", {params: {tableName}}).then(res => { if (res?.data) { - this.form = res.data + const json = JSON.parse(res.data.json) + this.form = {...res.data, json, tableName} + this.$load(this.diagram).then(() => { + this.diagram.render(json) + this.diagram.focusOn({id: tableName}) + }) } }) }, @@ -122,21 +127,9 @@ export default { }) this.diagram.on('node:click', this.onNodeClick) this.diagram.on('node:dnd-add', this.onNodeClick) - this.diagram.on('anchor:dragstart', () => { - this.diagram.graphModel.nodes.map(e => { - if (e.type == 'model') { - e.setProperties({isConnection: true}) - } - }) - }) this.diagram.on('anchor:drop', ({edgeModel}) => { const {sourceAnchorId, targetAnchorId, targetNodeId} = edgeModel - edgeModel.setProperties({joinField: targetAnchorId.replace(`${targetNodeId}_`, ''), mainField: sourceAnchorId, tableName: targetNodeId}) - this.diagram.graphModel.nodes.map(e => { - if (e.type == 'model') { - e.setProperties({isConnection: false}) - } - }) + edgeModel.setProperties({joinField: targetAnchorId.split("@").at(-1), mainField: sourceAnchorId.split("@").at(-1), tableName: targetNodeId}) }) this.diagram.render() }, @@ -195,8 +188,8 @@ export default { } }, created() { - this.getDetail() this.getEntries() + this.getDetail() }, mounted() { this.initLf() diff --git a/project/oms/apps/develop/AppDataModel/dmList.vue b/project/oms/apps/develop/AppDataModel/dmList.vue index 9970b2f8..5cf8415e 100644 --- a/project/oms/apps/develop/AppDataModel/dmList.vue +++ b/project/oms/apps/develop/AppDataModel/dmList.vue @@ -7,15 +7,14 @@ 添加 - + @@ -40,29 +39,30 @@ export default { total: 0, tableData: [], colConfigs: [ - {label: "数据模型", prop: "name"}, - {label: "模型别名", prop: "alias"}, + {label: "数据模型主表", prop: "tableName"}, + {label: "关联表单", prop: "relationTables"}, ] } }, methods: { getTableData() { - this.instance.get("/relation/list", null, { + this.instance.post("/app/appdatamodelconfig/list", null, { params: {...this.page, ...this.search} }).then(res => { if (res?.data) { - this.tableData = res.data.records + this.tableData = res.data.records.map(e => ({...e, relationTables: e.relations.map(r => r.tableName)?.toString()})) this.total = res.data.total } }) }, - handleAdd(id) { - this.$router.push({hash: "#add", query: {id}}) + handleAdd(tableName) { + tableName = tableName.split(":").at(-1) + this.$router.push({hash: "#add", query: {tableName}}) }, @confirm("是否要删除该模型?") - handleDelete(ids) { + handleDelete(tableName) { this.instance.post("/relation/remove", null, { - params: {ids} + params: {tableName} }).then(res => { if (res?.code == 0) { this.$message.success("删除成功") diff --git a/project/oms/apps/develop/AppDataModel/element.js b/project/oms/apps/develop/AppDataModel/element.js index f30eea40..054acce9 100644 --- a/project/oms/apps/develop/AppDataModel/element.js +++ b/project/oms/apps/develop/AppDataModel/element.js @@ -51,19 +51,17 @@ class DataModel extends HtmlNodeModel { y, width, height, - properties: {props, isConnection} + properties: {props} } = this; const anchors = []; props?.forEach((field, index) => { - if (isConnection) { - anchors.push({ - x: x - width / 2 + 6, - y: y - height / 2 + 58 + index * 20, - id: `${id}_${field.columnName}`, - edgeAddable: false, - type: "left" - }); - } + anchors.push({ + x: x - width / 2 + 6, + y: y - height / 2 + 58 + index * 20, + id: `${id}@${field.columnName}`, + edgeAddable: false, + type: "left" + }); }); return anchors; } @@ -92,7 +90,7 @@ class MainModel extends DataModel { anchors.push({ x: x + width / 2 - 6, y: y - height / 2 + 58 + index * 20, - id: `${id}_${index}_right`, + id: `${id}@${field.columnName}`, type: "right", field });