优化代码生成器
parent
e3f1397a80
commit
1138e501e4
|
@ -69,9 +69,17 @@ export function genCode(tableName) {
|
|||
}
|
||||
|
||||
// 同步数据库
|
||||
export function synchDb(tableName) {
|
||||
export function synchDb(tableName,databaseName) {
|
||||
return request({
|
||||
url: '/code/gen/synchDb/' + tableName,
|
||||
url: '/code/gen/synchDb/' + tableName + '/' + databaseName,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询db数据库
|
||||
export function getDataBaseList() {
|
||||
return request({
|
||||
url: '/code/gen/db/getDataBaseList',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ export default {
|
|||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
if (res.data.code === 200) {
|
||||
if (res.code === 200) {
|
||||
this.uploadList.push({name: res.data.url, url: res.data.url});
|
||||
this.uploadedSuccessfully();
|
||||
} else {
|
||||
|
|
|
@ -183,7 +183,7 @@ export default {
|
|||
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
||||
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
||||
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
|
||||
const validateResult = res.data.every(item => !!item);
|
||||
const validateResult = res.every(item => !!item);
|
||||
if (validateResult) {
|
||||
const genTable = Object.assign({}, basicForm.model, genForm.model);
|
||||
genTable.columns = this.columns;
|
||||
|
@ -194,7 +194,7 @@ export default {
|
|||
parentMenuId: genTable.parentMenuId
|
||||
};
|
||||
updateGenTable(genTable).then(res => {
|
||||
this.$modal.msgSuccess(res.data.msg);
|
||||
this.$modal.msgSuccess(res.msg);
|
||||
if (res.code === 200) {
|
||||
this.close();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
<!-- 导入表 -->
|
||||
<el-dialog :visible.sync="visible" append-to-body title="导入表" top="5vh" width="800px">
|
||||
<el-form ref="queryForm" :inline="true" :model="queryParams" size="small">
|
||||
<el-form-item label="数据库名称">
|
||||
<el-select v-model="queryParams.databaseName" placeholder="请选择数据库名称">
|
||||
<el-option v-for="databaseName in databaseNameList" :label="databaseName" :value="databaseName"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="表名称" prop="tableName">
|
||||
<el-input
|
||||
v-model="queryParams.tableName"
|
||||
|
@ -48,21 +53,25 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {importTable, listDbTable} from "@/api/tool/gen";
|
||||
import {importTable, listDbTable, getDataBaseList} from "@/api/tool/gen";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
visible: false,
|
||||
//数据库名称
|
||||
databaseName:'',
|
||||
// 选中数组值
|
||||
tables: [],
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 表数据
|
||||
dbTableList: [],
|
||||
databaseNameList:[],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
databaseName:undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
tableName: undefined,
|
||||
|
@ -73,6 +82,7 @@ export default {
|
|||
methods: {
|
||||
// 显示弹框
|
||||
show() {
|
||||
this.getDataBaseList();
|
||||
this.getList();
|
||||
this.visible = true;
|
||||
},
|
||||
|
@ -90,6 +100,14 @@ export default {
|
|||
this.total = res.data.total;
|
||||
});
|
||||
},
|
||||
// 查询表数据
|
||||
getDataBaseList() {
|
||||
getDataBaseList().then(res => {
|
||||
if (res.code === 200){
|
||||
this.databaseNameList = res.data;
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
|
@ -102,13 +120,15 @@ export default {
|
|||
},
|
||||
/** 导入按钮操作 */
|
||||
handleImportTable() {
|
||||
this.databaseName=this.queryParams.databaseName
|
||||
const tableNames = this.tables.join(",");
|
||||
if (tableNames == "") {
|
||||
this.$modal.msgError("请选择要导入的表");
|
||||
return;
|
||||
}
|
||||
importTable({tables: tableNames}).then(res => {
|
||||
this.$modal.msgSuccess(res.data.msg);
|
||||
const importTableReq ={tables: tableNames, databaseName:this.databaseName }
|
||||
importTable(importTableReq).then(res => {
|
||||
this.$modal.msgSuccess("导入成功");
|
||||
this.visible = false;
|
||||
this.$emit("ok");
|
||||
});
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-form v-show="showSearch" ref="queryForm" :inline="true" :model="queryParams" label-width="68px" size="small">
|
||||
<el-form-item label="数据库名称" prop="databaseName">
|
||||
<el-input
|
||||
v-model="queryParams.databaseName"
|
||||
clearable
|
||||
placeholder="请输入数据库名称"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="表名称" prop="tableName">
|
||||
<el-input
|
||||
v-model="queryParams.tableName"
|
||||
|
@ -91,6 +99,13 @@
|
|||
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:show-overflow-tooltip="true"
|
||||
align="center"
|
||||
label="数据库名称"
|
||||
prop="databaseName"
|
||||
width="120"
|
||||
/>
|
||||
<el-table-column
|
||||
:show-overflow-tooltip="true"
|
||||
align="center"
|
||||
|
@ -229,6 +244,7 @@ export default {
|
|||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
databaseName: '',
|
||||
tableName: undefined,
|
||||
tableComment: undefined
|
||||
},
|
||||
|
@ -286,8 +302,9 @@ export default {
|
|||
/** 同步数据库操作 */
|
||||
handleSynchDb(row) {
|
||||
const tableName = row.tableName;
|
||||
this.$modal.confirm('确认要强制同步"' + tableName + '"表结构吗?').then(function () {
|
||||
return synchDb(tableName);
|
||||
const databaseName = row.databaseName;
|
||||
this.$modal.confirm('确认要强制同步"'+databaseName + tableName + '"表结构吗?').then(function () {
|
||||
return synchDb(tableName,databaseName);
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess("同步成功");
|
||||
}).catch(() => {
|
||||
|
|
Loading…
Reference in New Issue