数据模型修改
This commit is contained in:
@@ -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,9 +90,9 @@ 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)
|
||||
const json = JSON.parse(res.data.config || null)
|
||||
this.form = {...res.data, json}
|
||||
this.$load(this.diagram).then(() => {
|
||||
this.diagram.render(json)
|
||||
@@ -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()
|
||||
},
|
||||
@@ -223,7 +228,8 @@ export default {
|
||||
.dataModel {
|
||||
height: 100vh;
|
||||
}
|
||||
.dndPanel{
|
||||
|
||||
.dndPanel {
|
||||
left: 16px;
|
||||
top: 16px;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user