diff --git a/mayfly_go_web/src/views/ops/db/SqlExec.vue b/mayfly_go_web/src/views/ops/db/SqlExec.vue index 5363e056..ab53b31f 100644 --- a/mayfly_go_web/src/views/ops/db/SqlExec.vue +++ b/mayfly_go_web/src/views/ops/db/SqlExec.vue @@ -16,12 +16,18 @@ {{ nowDbInst.tagPath }} - + + {{ nowDbInst.id }} - {{ nowDbInst.type }} - {{ nowDbInst.name }} + + {{ nowDbInst.host }} {{ state.db }} @@ -36,10 +42,7 @@ import('./component/sqleditor/DbSqlEditor.vue')); const DbTableDataOp = defineAsyncComponent(() => import('./component/table/DbTableDataOp.vue')); @@ -195,7 +207,10 @@ class ContextmenuClickId { // node节点点击时,触发改变db事件 const nodeClickChangeDb = (nodeData: TagTreeNode) => { const params = nodeData.params; - changeDb({ id: params.id, name: params.name, type: params.type, tagPath: params.tagPath, databases: params.database }, params.db); + changeDb( + { id: params.id, host: `${params.host}:${params.port}`, name: params.name, type: params.type, tagPath: params.tagPath, databases: params.database }, + params.db + ); }; // tagpath 节点类型 @@ -221,6 +236,7 @@ const NodeTypeDbInst = new NodeType(SqlExecNodeType.DbInst) id: params.id, name: params.name, type: params.type, + host: `${params.host}:${params.port}`, dbs: dbs, db: x, }) @@ -372,9 +388,9 @@ onBeforeUnmount(() => { * 设置editor高度和数据表高度 */ const setHeight = () => { - state.editorHeight = window.innerHeight - 518 + 'px'; - state.dataTabsTableHeight = window.innerHeight - 262 + 'px'; - state.tablesOpHeight = window.innerHeight - 240 + 'px'; + state.editorHeight = window.innerHeight - 500 + 'px'; + state.dataTabsTableHeight = window.innerHeight - 250 + 'px'; + state.tablesOpHeight = window.innerHeight - 220 + 'px'; state.tagTreeHeight = window.innerHeight - 165 + 'px'; }; @@ -420,7 +436,7 @@ const onCurrentContextmenuClick = (clickData: any) => { } }; -// 选择数据库 +// 选择数据库,改变当前正在操作的数据库信息 const changeDb = (db: any, dbName: string) => { state.nowDbInst = DbInst.getOrNewInst(db); state.db = dbName; @@ -428,7 +444,6 @@ const changeDb = (db: any, dbName: string) => { // 加载选中的表数据,即新增表数据操作tab const loadTableData = async (db: any, dbName: string, tableName: string) => { - changeDb(db, dbName); if (tableName == '') { return; } @@ -448,6 +463,7 @@ const loadTableData = async (db: any, dbName: string, tableName: string) => { tab.db = dbName; tab.type = TabType.TableData; tab.params = { + ...getNowDbInfo(), table: tableName, }; state.tabs.set(key, tab); @@ -459,7 +475,6 @@ const addQueryTab = async (db: any, dbName: string, sqlName: string = '') => { ElMessage.warning('请选择数据库实例及对应的schema'); return; } - changeDb(db, dbName); const dbId = db.id; let label; @@ -491,6 +506,7 @@ const addQueryTab = async (db: any, dbName: string, sqlName: string = '') => { tab.db = dbName; tab.type = TabType.Query; tab.params = { + ...getNowDbInfo(), sqlName: sqlName, dbs: db.dbs, }; @@ -510,7 +526,6 @@ const addTablesOpTab = async (db: any) => { ElMessage.warning('请选择数据库实例及对应的schema'); return; } - changeDb(db, dbName); const dbId = db.id; let key = `表操作:${dbId}:${dbName}.tablesOp`; @@ -528,6 +543,7 @@ const addTablesOpTab = async (db: any) => { tab.db = dbName; tab.type = TabType.TablesOp; tab.params = { + ...getNowDbInfo(), id: db.id, db: dbName, type: db.type, @@ -589,6 +605,21 @@ const reloadTables = (nodeKey: string) => { state.reloadStatus = true; tagTreeRef.value.reloadNode(nodeKey); }; + +/** + * 获取当前操作的数据库信息 + */ +const getNowDbInfo = () => { + const di = state.nowDbInst; + return { + tagPath: di.tagPath, + id: di.id, + name: di.name, + type: di.type, + host: di.host, + dbName: state.db, + }; +};