优化节点配置效果

master
面包骑士 2024-08-30 22:30:08 +08:00
parent 735c661936
commit aae80d6113
5 changed files with 364 additions and 56 deletions

View File

@ -1,9 +1,9 @@
<template>
<!-- 修改节点配置-->
<div align="center">
<div>
<!-- 自定义表单对话框 -->
<el-drawer :modal="false" :visible.sync="disp.updFlag" direction="rtl" title="节点配置" append-to-body size="60%">
<div align="center">
<div>
<span v-if="node.type === 'table'">
<TableUpd :disp="disp" />
@ -12,9 +12,7 @@
<ExporUpd :disp="disp" :data="data" :node="node" />
</span>
<br><br>
<el-button type="primary" @click="saveDisposition"> </el-button>
<el-button @click="disp.updFlag = false"> </el-button>
</div>
</el-drawer>
</div>
@ -54,44 +52,6 @@ export default {
computed: {},
// ",
methods: {
//
saveDisposition() {
const dispData = this.disp.formData
const dispList = this.getMysqlDisp(dispData.db,dispData.fields)
console.log(dispData)
console.log(dispList)
batchAddUpd(dispList, this.disp.nodeCode).then(res => {
this.$message.success(res.msg)
this.disp.updFlag = false
})
},
/** 类型转换 vue -> mysql*/
getMysqlDisp(db, fields) {
const dispList = []
dispList.push({
nodeCode: this.disp.nodeCode,
dispKey: 'db',
dispLabel: '数据库',
dispValue: db.dbName,
dispType: 'string'
},{
nodeCode: this.disp.nodeCode,
dispKey: 'table',
dispLabel: db.tableComment,
dispValue: db.tableName,
dispType: 'string'
})
fields.forEach(field => {
dispList.push({
nodeCode: this.disp.nodeCode,
dispKey: 'fields',
dispLabel: field.fieldComment,
dispValue: field.fieldName,
dispType: field.fieldType
})
})
return dispList;
},
}
}

View File

@ -61,12 +61,6 @@ export default {
getInfo() {
console.log(this.data)
console.log(this.node)
/** 1.查询该结点的上一级节点,并获取其信息*/
// this.data.lineList.forEach(line => {
// if (line.to === this.node.id){
//
// }
// })
},
/** 类型转换 mysql -> vue */
getVueDisp(dispList) {

View File

@ -1,12 +1,35 @@
<template>
<div>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<span v-if="reqDispData && reqDispData.dbTableName">:
<span v-for="item in reqDispData.dbTableName">{{ item }} &nbsp; &nbsp; </span>
</span>
<span v-else></span>
</el-col>
</el-row>
<span>
<el-table ref="table" :data="reqDispData.fields" height="300px"
@row-click="clickRow" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column :show-overflow-tooltip="true" label="字段名称" prop="fieldName" />
<el-table-column :show-overflow-tooltip="true" label="字段描述" prop="fieldComment" />
<el-table-column :show-overflow-tooltip="true" label="字段类型" prop="fieldType" />
</el-table>
</span>
<br><br>
<div align="center">
<el-button type="primary" @click="toSelectResp"> </el-button>
<el-button @click="disp.updFlag = false"> </el-button>
</div>
</div>
</template>
<script>
// jsjsjson,
// import from ',
import {listDisposition} from "@/api/quest/disposition";
export default {
// import使"
name: 'exporUpd',
@ -22,19 +45,113 @@ export default {
db: {},
fields: []
}
}
},
},
data() {
// "
return {}
return {
//
preNodeId: [],
//
preNodeDisp: [],
//
selectDisp: [],
//
reqDispData: {
dbTableName: [],
fields: []
},
respDispData: {
dbTableName: [],
fields: []
}
}
},
// data",
computed: {},
// - 访this",
created() {
this.init()
},
// ",
methods: {}
methods: {
init() {
/** 1.查询该节点的上一级节点*/
this.data.lineList.forEach(line => {
if (line.to === this.node.id){
this.preNodeId.push(line.from)
}
})
this.preNodeId = [...new Set(this.preNodeId)]
console.log(1,this.preNodeId)
/** 2.获取上一级节点的配置参数*/
if (this.preNodeId){
this.preNodeId.forEach(id => {
this.findDisp(id)
})
}
setTimeout(() => {
this.init2()
},1000)
},
init2() {
console.log(2,this.preNodeDisp)
this.preNodeDisp.forEach(nodeDisp => {
console.log(3, nodeDisp)
let dbTableName = nodeDisp.db.dbName + '.' +
nodeDisp.db.tableName + '(' + nodeDisp.db.tableComment + ')';
this.reqDispData.dbTableName.push(dbTableName)
nodeDisp.fields.forEach(field => this.reqDispData.fields.push(field))
})
console.log(4, this.reqDispData)
},
findDisp(nodeCode) {
listDisposition({nodeCode: nodeCode}).then(res => {
this.preNodeDisp.push(this.getVueDisp(res.data.rows))
})
},
//
clickRow(row) {
this.$refs.table.toggleRowSelection(row);
},
//
handleSelectionChange(selection) {
this.selectDisp.formFields = selection.map(item => {
return {
fieldName: item.fieldName,
fieldType: item.fieldComment,
fieldComment: item.fieldType
};
});
},
//
toSelectResp() {
console.log(this.selectDisp)
},
/** 类型转换 mysql -> vue */
getVueDisp(dispList) {
const db = {}
const fields = []
dispList.forEach(disp => {
if (disp.dispKey === 'db') {
db.dbName = disp.dispValue
}
if (disp.dispKey === 'table') {
db.tableName = disp.dispValue
db.tableComment = disp.dispLabel
}
if (disp.dispKey === 'fields') {
fields.push({
fieldName: disp.dispValue,
fieldType: disp.dispType,
fieldComment: disp.dispLabel
})
}
})
return {db, fields}
}
}
}
</script>
<style scoped>

View File

@ -0,0 +1,194 @@
<template>
<div @click="csh">
<div style="padding-left: 10px;padding-right: 10px;">
<el-form ref="queryForm" :inline="true" :model="queryParams" size="small">
<el-form-item label="数据库名称" prop="dbName">
<el-select v-model="queryParams.dbName" placeholder="请选择数据库" clearable @change="handleQuery">
<el-option v-for="item in dbNameOptions" :key="item" :label="item" :value="item"/>
</el-select>
</el-form-item>
<el-form-item label="表名称" prop="tableName">
<el-input
v-model="queryParams.tableName"
clearable
@change="handleQuery"
placeholder="请输入表名称" />
</el-form-item>
<el-form-item label="表描述" prop="tableComment">
<el-input
v-model="queryParams.tableComment"
clearable
@change="handleQuery"
placeholder="请输入表描述" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-table ref="table" :data="tableOptions" height="300px">
<el-table-column :show-overflow-tooltip="true" label="表名称" prop="tableName" />
<el-table-column :show-overflow-tooltip="true" label="表描述" prop="tableComment" />
<el-table-column label="操作" width="50px">
<template slot-scope="scope">
<el-button type="text" @click="selectTable(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<el-divider content-position="left">选择字段 v</el-divider>
<el-table ref="table" :data="fieldsOptions" height="300px"
@row-click="clickRow" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column :show-overflow-tooltip="true" label="字段名称" prop="columnName" />
<el-table-column :show-overflow-tooltip="true" label="字段描述" prop="columnComment" />
<el-table-column :show-overflow-tooltip="true" label="字段类型" prop="columnType" />
</el-table>
<br><br>
<div align="center">
<el-button type="primary" @click="saveDisposition"> </el-button>
<el-button @click="disp.updFlag = false"> </el-button>
</div>
</div>
</div>
</template>
<script>
// jsjsjson,
// import from ',
import {listDbTableAll, selDbNameAll, selectDbTableColumnsByName} from "@/api/tool/gen";
import {batchAddUpd} from "@/api/quest/disposition";
export default {
// import使"
name: 'tableUpd',
props: {
disp: {
nodeCode: undefined,
nodeType: undefined,
findFlag: false,
updFlag: false,
formData: {
db: {},
fields: []
}
}
},
data() {
// "
return {
//
dbNameOptions: [],
//
tableOptions: [],
//
fieldsOptions: [],
//
tableList: [],
queryParams: {}
}
},
// data",
computed: {},
// - 访this",
created() {
},
// ",
methods: {
/** 搜索按钮操作 */
handleQuery() {
this.tableOptions = []
this.tableList.forEach(table => {
const params = this.queryParams
if ((table.dbName === params.dbName || !params.dbName) &&
(table.tableName.includes(params.tableName) || !params.tableName) &&
(table.tableComment.includes(params.tableComment) || !params.tableComment)){
this.tableOptions.push(table)
}
})
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 表字段查询*/
selectTable(row) {
this.disp.formData.db = row
selectDbTableColumnsByName(row.dbName, row.tableName).then(res => {
this.fieldsOptions = res.data
})
},
clickRow(row) {
this.$refs.table.toggleRowSelection(row);
},
//
handleSelectionChange(selection) {
this.disp.formData.fields = selection.map(item => {
return {
fieldName: item.columnName,
fieldType: item.columnType,
fieldComment: item.columnComment
};
});
},
//
selDbNameList() {
selDbNameAll().then(res => {
this.dbNameOptions = res.data
})
},
//
getListAll() {
listDbTableAll().then(res => {
this.tableList = res.data;
this.tableOptions = res.data;
});
},
// csh() {
// this.selDbNameList()
// this.getListAll()
// },
//
saveDisposition() {
const dispData = this.disp.formData
const dispList = this.getMysqlDisp(dispData.db,dispData.fields)
batchAddUpd(dispList, this.disp.nodeCode).then(res => {
this.$message.success(res.msg)
this.disp.updFlag = false
})
},
/** 类型转换 vue -> mysql*/
getMysqlDisp(db, fields) {
const dispList = []
dispList.push({
nodeCode: this.disp.nodeCode,
dispKey: 'db',
dispLabel: '数据库',
dispValue: db.dbName,
dispType: 'string'
},{
nodeCode: this.disp.nodeCode,
dispKey: 'table',
dispLabel: db.tableComment,
dispValue: db.tableName,
dispType: 'string'
})
fields.forEach(field => {
dispList.push({
nodeCode: this.disp.nodeCode,
dispKey: 'fields',
dispLabel: field.fieldComment,
dispValue: field.fieldName,
dispType: field.fieldType
})
})
return dispList;
},
}
}
</script>
<style scoped>
</style>

View File

@ -1,5 +1,5 @@
<template>
<div @click="csh">
<div>
<div style="padding-left: 10px;padding-right: 10px;">
<el-form ref="queryForm" :inline="true" :model="queryParams" size="small">
<el-form-item label="数据库名称" prop="dbName">
@ -43,6 +43,11 @@
<el-table-column :show-overflow-tooltip="true" label="字段描述" prop="columnComment" />
<el-table-column :show-overflow-tooltip="true" label="字段类型" prop="columnType" />
</el-table>
<br><br>
<div align="center">
<el-button type="primary" @click="saveDisposition"> </el-button>
<el-button @click="disp.updFlag = false"> </el-button>
</div>
</div>
</div>
</template>
@ -51,6 +56,7 @@
// jsjsjson,
// import from ',
import {listDbTableAll, selDbNameAll, selectDbTableColumnsByName} from "@/api/tool/gen";
import {batchAddUpd} from "@/api/quest/disposition";
export default {
// import使"
@ -85,7 +91,7 @@ export default {
computed: {},
// - 访this",
created() {
this.csh()
},
// ",
methods: {
@ -142,7 +148,44 @@ export default {
csh() {
this.selDbNameList()
this.getListAll()
}
},
//
saveDisposition() {
const dispData = this.disp.formData
const dispList = this.getMysqlDisp(dispData.db,dispData.fields)
batchAddUpd(dispList, this.disp.nodeCode).then(res => {
this.$message.success(res.msg)
this.disp.updFlag = false
})
},
/** 类型转换 vue -> mysql*/
getMysqlDisp(db, fields) {
const dispList = []
dispList.push({
nodeCode: this.disp.nodeCode,
dispKey: 'db',
dispLabel: '数据库',
dispValue: db.dbName,
dispType: 'string'
},{
nodeCode: this.disp.nodeCode,
dispKey: 'table',
dispLabel: db.tableComment,
dispValue: db.tableName,
dispType: 'string'
})
fields.forEach(field => {
dispList.push({
nodeCode: this.disp.nodeCode,
dispKey: 'fields',
dispLabel: field.fieldComment,
dispValue: field.fieldName,
dispType: field.fieldType
})
})
return dispList;
},
}
}
</script>