diff --git a/project/oms/apps/develop/AppDataModel/dmAdd.vue b/project/oms/apps/develop/AppDataModel/dmAdd.vue
index 7779cd21..bf6915f0 100644
--- a/project/oms/apps/develop/AppDataModel/dmAdd.vue
+++ b/project/oms/apps/develop/AppDataModel/dmAdd.vue
@@ -3,9 +3,9 @@
-
+
-
+
@@ -15,7 +15,7 @@
全屏
-
+
@@ -29,7 +29,7 @@
-
+
@@ -79,7 +79,7 @@ export default {
}
},
computed: {
- isEdit: v => !!v.$route.query.name,
+ isEdit: v => !!v.$route.query.id,
pageTitle: v => v.isEdit ? "编辑数据关联模型" : "新增数据关联模型",
},
methods: {
@@ -90,12 +90,12 @@ export default {
},
getDetail() {
const {id} = this.$route.query
- id && this.instance.post("/app/appdatamodelconfig/queryDetailById", null, {params: {id}}).then(res => {
+ id && this.instance.post("/app/appdatamodel/queryDetailById", null, {params: {id}}).then(res => {
if (res?.data) {
- const json = JSON.parse(res.data.json)
- this.form = {...res.data, json}
+ const config = JSON.parse(res.data.config || null)
+ this.form = {...res.data, config}
this.$load(this.diagram).then(() => {
- this.diagram.render(json)
+ this.diagram.render(config)
this.diagram.focusOn({id: this.form.name})
})
}
@@ -103,9 +103,9 @@ export default {
},
submit() {
const jsonData = this.diagram.getGraphData()
- this.form.relationNodes = jsonData.edges.map(e => e.properties)
+ this.form.configs = jsonData.edges.map(e => e.properties)
this.$refs.DataModelForm.validate()
- .then(() => this.instance.post("/app/appdatamodelconfig/addOrUpdate", {...this.form, config: JSON.stringify(jsonData)}))
+ .then(() => this.instance.post("/app/appdatamodel/addOrUpdate", {...this.form, config: JSON.stringify(jsonData)}))
.then(res => {
if (res?.code == 0) {
this.$message.success("提交成功")
@@ -133,8 +133,13 @@ export default {
this.diagram.on('node:click', this.onNodeClick)
this.diagram.on('node:dnd-add', this.onNodeClick)
this.diagram.on('anchor:drop', ({edgeModel}) => {
- const {sourceAnchorId, targetAnchorId, targetNodeId} = edgeModel
- edgeModel.setProperties({joinField: targetAnchorId.split("@").at(-1), mainField: sourceAnchorId.split("@").at(-1), tableName: targetNodeId})
+ const {sourceAnchorId, sourceNodeId, targetAnchorId, targetNodeId} = edgeModel
+ edgeModel.setProperties({
+ relationField: targetAnchorId.split("@").at(-1),
+ idField: sourceAnchorId.split("@").at(-1),
+ relationTableName: targetNodeId,
+ tableName: sourceNodeId
+ })
})
this.diagram.render()
},
@@ -157,29 +162,30 @@ export default {
},
initMainModel(v) {
this.diagram.clearData()
- if (!!v?.id) {
+ if (!!v?.tableName) {
this.getTableFields(v).then(list => {
this.diagram.addNode({
type: 'main',
x: 200,
y: 60,
- id: v.id,
- properties: {id: v.id, props: list}
+ id: v.tableName,
+ properties: {id: v.tableName, props: list}
})
- this.diagram.focusOn({id: v.id})
+ this.diagram.focusOn({id: v.tableName})
})
}
},
changeModel(v) {
- if (!!v?.id) {
- this.current.name = v.id
+ if (!!v?.tableName) {
+ this.current.id = v.tableName
this.getTableFields(v).then((list = []) => this.current.props = list)
}
},
getEntries() {
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})) || []
+ this.entries = Object.entries(res.definitions).filter(([id]) => id?.startsWith("App"))
+ ?.map(([id, e]) => ({...e, id, label: id, tableName: id.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()})) || []
}
})
},
@@ -223,7 +229,8 @@ export default {
.dataModel {
height: 100vh;
}
- .dndPanel{
+
+ .dndPanel {
left: 16px;
top: 16px;
}
diff --git a/project/oms/apps/develop/AppDataModel/dmList.vue b/project/oms/apps/develop/AppDataModel/dmList.vue
index 2be5ab08..c47a1937 100644
--- a/project/oms/apps/develop/AppDataModel/dmList.vue
+++ b/project/oms/apps/develop/AppDataModel/dmList.vue
@@ -39,28 +39,28 @@ export default {
total: 0,
tableData: [],
colConfigs: [
- {label: "数据模型主表", prop: "tableName"},
- {label: "关联表单", prop: "relationTables"},
+ {label: "数据模型主表", prop: "name"},
+ {label: "数据模型别名", prop: "alias"},
]
}
},
methods: {
getTableData() {
- this.instance.post("/app/appdatamodelconfig/list", null, {
+ this.instance.post("/app/appdatamodel/list", null, {
params: {...this.page, ...this.search}
}).then(res => {
if (res?.data) {
- this.tableData = res.data.records.map(e => ({...e, relationTables: e.relations.map(r => r.tableName)?.toString()}))
+ this.tableData = res.data.records
this.total = res.data.total
}
})
},
handleAdd(id) {
- id && this.$router.push({hash: "#add", query: {id}})
+ this.$router.push({hash: "#add", query: {id}})
},
@confirm("是否要删除该模型?")
handleDelete(ids) {
- this.instance.post("/app/appdatamodelconfig/delete", null, {
+ this.instance.post("/app/appdatamodel/delete", null, {
params: {ids}
}).then(res => {
if (res?.code == 0) {