mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
refactor:
1.修改表后,刷新表数据 2.修改索引sql拼接bug 3.暂时只有mysql支持编辑表
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
<el-dropdown :show-timeout="70" :hide-timeout="50" @command="onHandleCommandClick">
|
<el-dropdown :show-timeout="70" :hide-timeout="50" @command="onHandleCommandClick">
|
||||||
<span class="layout-navbars-breadcrumb-user-link" style="cursor: pointer">
|
<span class="layout-navbars-breadcrumb-user-link" style="cursor: pointer">
|
||||||
<img :src="getUserInfos.photo" class="layout-navbars-breadcrumb-user-link-photo mr5" />
|
<img :src="getUserInfos.photo" class="layout-navbars-breadcrumb-user-link-photo mr5" />
|
||||||
{{ getUserInfos.username === '' ? 'test' : getUserInfos.username }}
|
{{ getUserInfos.name || 'test' }}
|
||||||
<i class="el-icon-arrow-down el-icon--right"></i>
|
<i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
</span>
|
</span>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ const submit = async () => {
|
|||||||
db: props.db,
|
db: props.db,
|
||||||
runSuccessCallback: () => {
|
runSuccessCallback: () => {
|
||||||
proxy.$parent.openEditTable({ tableName: state.tableData.tableName });
|
proxy.$parent.openEditTable({ tableName: state.tableData.tableName });
|
||||||
proxy.$parent.refreshTableInfo();
|
proxy.$parent.refreshTableInfo();
|
||||||
// cancel();
|
// cancel();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -507,12 +507,12 @@ const genSql = () => {
|
|||||||
sql = sql.substring(0, sql.length - 1)
|
sql = sql.substring(0, sql.length - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(addIndexs.length > 0){
|
if (addIndexs.length > 0) {
|
||||||
if(dropIndexNames.length > 0){
|
if (dropIndexNames.length > 0){
|
||||||
sql +=','
|
sql += ','
|
||||||
}
|
}
|
||||||
addIndexs.forEach(a=>{
|
addIndexs.forEach(a => {
|
||||||
sql += ` ADD ${a.unique?'UNIQUE':''} INDEX ${a.indexName}(${a.columnNames.join(',')}) USING ${a.indexType} COMMENT '${a.indexComment}',`;
|
sql += ` ADD ${a.unique ? 'UNIQUE' : ''} INDEX ${a.indexName}(${a.columnNames.join(',')}) USING ${a.indexType} COMMENT '${a.indexComment}',`;
|
||||||
})
|
})
|
||||||
sql = sql.substring(0, sql.length - 1)
|
sql = sql.substring(0, sql.length - 1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,9 @@
|
|||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-link @click.prevent="showColumns(scope.row)" type="primary">字段</el-link>
|
<el-link @click.prevent="showColumns(scope.row)" type="primary">字段</el-link>
|
||||||
<el-link class="ml5" @click.prevent="showTableIndex(scope.row)" type="success">索引</el-link>
|
<el-link class="ml5" @click.prevent="showTableIndex(scope.row)" type="success">索引</el-link>
|
||||||
<el-link class="ml5" @click.prevent="openEditTable(scope.row)" type="warning">编辑表</el-link>
|
<el-link class="ml5"
|
||||||
|
v-if="tableCreateDialog.enableEditTypes.indexOf(tableCreateDialog.type) > -1"
|
||||||
|
@click.prevent="openEditTable(scope.row)" type="warning">编辑表</el-link>
|
||||||
<el-link class="ml5" @click.prevent="showCreateDdl(scope.row)" type="info">DDL</el-link>
|
<el-link class="ml5" @click.prevent="showCreateDdl(scope.row)" type="info">DDL</el-link>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -347,11 +349,13 @@ const state = reactive({
|
|||||||
title: '创建表',
|
title: '创建表',
|
||||||
visible: false,
|
visible: false,
|
||||||
activeName: '1',
|
activeName: '1',
|
||||||
|
type: '',
|
||||||
|
enableEditTypes:['mysql'], // 支持"编辑表"的数据库类型
|
||||||
data: { // 修改表时,传递修改数据
|
data: { // 修改表时,传递修改数据
|
||||||
edit: false,
|
edit: false,
|
||||||
row: {},
|
row: {},
|
||||||
indexs: [],
|
indexs: [],
|
||||||
columns: []
|
columns: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
filterDb: {
|
filterDb: {
|
||||||
@@ -569,6 +573,7 @@ const showTableInfo = async (row: any, db: string) => {
|
|||||||
state.tableInfoDialog.visible = true;
|
state.tableInfoDialog.visible = true;
|
||||||
try {
|
try {
|
||||||
state.tableInfoDialog.infos = await dbApi.tableInfos.request({ id: row.id, db });
|
state.tableInfoDialog.infos = await dbApi.tableInfos.request({ id: row.id, db });
|
||||||
|
state.tableCreateDialog.type = row.type
|
||||||
state.dbId = row.id;
|
state.dbId = row.id;
|
||||||
state.row = row;
|
state.row = row;
|
||||||
state.db = db;
|
state.db = db;
|
||||||
@@ -579,9 +584,11 @@ const showTableInfo = async (row: any, db: string) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const refreshTableInfo = async () => {
|
// 给子组件调用,勿删
|
||||||
state.tableInfoDialog.infos = await dbApi.tableInfos.request({ id: state.dbId, db: state.db });
|
// eslint-disable-next-line no-unused-vars
|
||||||
}
|
const refreshTableInfo = async () => {
|
||||||
|
state.tableInfoDialog.infos = await dbApi.tableInfos.request({ id: state.dbId, db: state.db });
|
||||||
|
}
|
||||||
|
|
||||||
const closeTableInfo = () => {
|
const closeTableInfo = () => {
|
||||||
state.showDumpInfo = false;
|
state.showDumpInfo = false;
|
||||||
@@ -680,8 +687,8 @@ const openEditTable = async (row: any) => {
|
|||||||
state.tableCreateDialog.visible = true
|
state.tableCreateDialog.visible = true
|
||||||
state.tableCreateDialog.activeName = '1'
|
state.tableCreateDialog.activeName = '1'
|
||||||
|
|
||||||
if (row === false) {
|
if(row === false){
|
||||||
state.tableCreateDialog.data = { edit: false, row: {}, indexs: [], columns: [] }
|
state.tableCreateDialog.data = {edit: false, row: {}, indexs: [], columns: [] }
|
||||||
state.tableCreateDialog.title = '创建表'
|
state.tableCreateDialog.title = '创建表'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user