parent
7fd4860ff2
commit
62d7ce5aa9
@ -1,321 +1,321 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-form-item label="表名称" prop="tableName">
|
<el-form-item label="表名称" prop="tableName">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.tableName"
|
v-model="queryParams.tableName"
|
||||||
placeholder="请输入表名称"
|
placeholder="请输入表名称"
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
size="small"
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="表描述" prop="tableComment">
|
<el-form-item label="表描述" prop="tableComment">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.tableComment"
|
v-model="queryParams.tableComment"
|
||||||
placeholder="请输入表描述"
|
placeholder="请输入表描述"
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
size="small"
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间">
|
<el-form-item label="创建时间">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="dateRange"
|
v-model="dateRange"
|
||||||
size="small"
|
size="small"
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
value-format="yyyy-MM-dd"
|
value-format="yyyy-MM-dd"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
range-separator="-"
|
range-separator="-"
|
||||||
start-placeholder="开始日期"
|
start-placeholder="开始日期"
|
||||||
end-placeholder="结束日期"
|
end-placeholder="结束日期"
|
||||||
></el-date-picker>
|
></el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
icon="el-icon-download"
|
icon="el-icon-download"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleGenTable"
|
@click="handleGenTable"
|
||||||
v-hasPermi="['tool:gen:code']"
|
v-hasPermi="['tool:gen:code']"
|
||||||
>生成</el-button>
|
>生成</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="info"
|
type="info"
|
||||||
icon="el-icon-upload"
|
icon="el-icon-upload"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="openImportTable"
|
@click="openImportTable"
|
||||||
v-hasPermi="['tool:gen:import']"
|
v-hasPermi="['tool:gen:import']"
|
||||||
>导入</el-button>
|
>导入</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="success"
|
type="success"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
size="mini"
|
size="mini"
|
||||||
:disabled="single"
|
:disabled="single"
|
||||||
@click="handleEditTable"
|
@click="handleEditTable"
|
||||||
v-hasPermi="['tool:gen:edit']"
|
v-hasPermi="['tool:gen:edit']"
|
||||||
>修改</el-button>
|
>修改</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
size="mini"
|
size="mini"
|
||||||
:disabled="multiple"
|
:disabled="multiple"
|
||||||
@click="handleDelete"
|
@click="handleDelete"
|
||||||
v-hasPermi="['tool:gen:remove']"
|
v-hasPermi="['tool:gen:remove']"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column type="selection" width="55"></el-table-column>
|
||||||
<el-table-column label="序号" type="index" width="50" align="center">
|
<el-table-column label="序号" type="index" width="50" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="表名称"
|
label="表名称"
|
||||||
align="center"
|
align="center"
|
||||||
prop="tableName"
|
prop="tableName"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
width="120"
|
width="120"
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="表描述"
|
label="表描述"
|
||||||
align="center"
|
align="center"
|
||||||
prop="tableComment"
|
prop="tableComment"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
width="120"
|
width="120"
|
||||||
/>
|
/>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="实体"
|
label="实体"
|
||||||
align="center"
|
align="center"
|
||||||
prop="className"
|
prop="className"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
width="120"
|
width="120"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="160" />
|
<el-table-column label="创建时间" align="center" prop="createTime" width="160" />
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" width="160" />
|
<el-table-column label="更新时间" align="center" prop="updateTime" width="160" />
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button
|
||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
icon="el-icon-view"
|
icon="el-icon-view"
|
||||||
@click="handlePreview(scope.row)"
|
@click="handlePreview(scope.row)"
|
||||||
v-hasPermi="['tool:gen:preview']"
|
v-hasPermi="['tool:gen:preview']"
|
||||||
>预览</el-button>
|
>预览</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
@click="handleEditTable(scope.row)"
|
@click="handleEditTable(scope.row)"
|
||||||
v-hasPermi="['tool:gen:edit']"
|
v-hasPermi="['tool:gen:edit']"
|
||||||
>编辑</el-button>
|
>编辑</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
@click="handleDelete(scope.row)"
|
@click="handleDelete(scope.row)"
|
||||||
v-hasPermi="['tool:gen:remove']"
|
v-hasPermi="['tool:gen:remove']"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
icon="el-icon-refresh"
|
icon="el-icon-refresh"
|
||||||
@click="handleSynchDb(scope.row)"
|
@click="handleSynchDb(scope.row)"
|
||||||
v-hasPermi="['tool:gen:edit']"
|
v-hasPermi="['tool:gen:edit']"
|
||||||
>同步</el-button>
|
>同步</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="text"
|
type="text"
|
||||||
size="small"
|
size="small"
|
||||||
icon="el-icon-download"
|
icon="el-icon-download"
|
||||||
@click="handleGenTable(scope.row)"
|
@click="handleGenTable(scope.row)"
|
||||||
v-hasPermi="['tool:gen:code']"
|
v-hasPermi="['tool:gen:code']"
|
||||||
>生成代码</el-button>
|
>生成代码</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<pagination
|
<pagination
|
||||||
v-show="total>0"
|
v-show="total>0"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page.sync="queryParams.pageNum"
|
:page.sync="queryParams.pageNum"
|
||||||
:limit.sync="queryParams.pageSize"
|
:limit.sync="queryParams.pageSize"
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
<!-- 预览界面 -->
|
<!-- 预览界面 -->
|
||||||
<el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
<el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
||||||
<el-tabs v-model="preview.activeName">
|
<el-tabs v-model="preview.activeName">
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
v-for="(value, key) in preview.data"
|
v-for="(value, key) in preview.data"
|
||||||
:label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
:label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
||||||
:name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
:name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
||||||
:key="key"
|
:key="key"
|
||||||
>
|
>
|
||||||
<highlightjs autodetect :code="value" />
|
<highlightjs autodetect :code="value" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<import-table ref="import" @ok="handleQuery" />
|
<import-table ref="import" @ok="handleQuery" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
||||||
import importTable from "./importTable";
|
import importTable from "./importTable";
|
||||||
import { downLoadZip } from "@/utils/zipdownload";
|
import { downLoadZip } from "@/utils/zipdownload";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Gen",
|
name: "Gen",
|
||||||
components: { importTable },
|
components: { importTable },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 唯一标识符
|
// 唯一标识符
|
||||||
uniqueId: "",
|
uniqueId: "",
|
||||||
// 选中数组
|
// 选中数组
|
||||||
ids: [],
|
ids: [],
|
||||||
// 选中表数组
|
// 选中表数组
|
||||||
tableNames: [],
|
tableNames: [],
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
single: true,
|
single: true,
|
||||||
// 非多个禁用
|
// 非多个禁用
|
||||||
multiple: true,
|
multiple: true,
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// 表数据
|
// 表数据
|
||||||
tableList: [],
|
tableList: [],
|
||||||
// 日期范围
|
// 日期范围
|
||||||
dateRange: "",
|
dateRange: "",
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
tableName: undefined,
|
tableName: undefined,
|
||||||
tableComment: undefined
|
tableComment: undefined
|
||||||
},
|
},
|
||||||
// 预览参数
|
// 预览参数
|
||||||
preview: {
|
preview: {
|
||||||
open: false,
|
open: false,
|
||||||
title: "代码预览",
|
title: "代码预览",
|
||||||
data: {},
|
data: {},
|
||||||
activeName: "domain.java"
|
activeName: "domain.java"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
const time = this.$route.query.t;
|
const time = this.$route.query.t;
|
||||||
if (time != null && time != this.uniqueId) {
|
if (time != null && time != this.uniqueId) {
|
||||||
this.uniqueId = time;
|
this.uniqueId = time;
|
||||||
this.resetQuery();
|
this.resetQuery();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询表集合 */
|
/** 查询表集合 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||||
this.tableList = response.rows;
|
this.tableList = response.rows;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.queryParams.pageNum = 1;
|
this.queryParams.pageNum = 1;
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
/** 生成代码操作 */
|
/** 生成代码操作 */
|
||||||
handleGenTable(row) {
|
handleGenTable(row) {
|
||||||
const tableNames = row.tableName || this.tableNames;
|
const tableNames = row.tableName || this.tableNames;
|
||||||
if (tableNames == "") {
|
if (tableNames == "") {
|
||||||
this.msgError("请选择要生成的数据");
|
this.msgError("请选择要生成的数据");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(row.genType === "1") {
|
if(row.genType === "1") {
|
||||||
genCode(row.tableName).then(response => {
|
genCode(row.tableName).then(response => {
|
||||||
this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
downLoadZip("/code/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 同步数据库操作 */
|
/** 同步数据库操作 */
|
||||||
handleSynchDb(row) {
|
handleSynchDb(row) {
|
||||||
const tableName = row.tableName;
|
const tableName = row.tableName;
|
||||||
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", {
|
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return synchDb(tableName);
|
return synchDb(tableName);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.msgSuccess("同步成功");
|
this.msgSuccess("同步成功");
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/** 打开导入表弹窗 */
|
/** 打开导入表弹窗 */
|
||||||
openImportTable() {
|
openImportTable() {
|
||||||
this.$refs.import.show();
|
this.$refs.import.show();
|
||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.dateRange = [];
|
this.dateRange = [];
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
/** 预览按钮 */
|
/** 预览按钮 */
|
||||||
handlePreview(row) {
|
handlePreview(row) {
|
||||||
previewTable(row.tableId).then(response => {
|
previewTable(row.tableId).then(response => {
|
||||||
this.preview.data = response.data;
|
this.preview.data = response.data;
|
||||||
this.preview.open = true;
|
this.preview.open = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.ids = selection.map(item => item.tableId);
|
this.ids = selection.map(item => item.tableId);
|
||||||
this.tableNames = selection.map(item => item.tableName);
|
this.tableNames = selection.map(item => item.tableName);
|
||||||
this.single = selection.length != 1;
|
this.single = selection.length != 1;
|
||||||
this.multiple = !selection.length;
|
this.multiple = !selection.length;
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleEditTable(row) {
|
handleEditTable(row) {
|
||||||
const tableId = row.tableId || this.ids[0];
|
const tableId = row.tableId || this.ids[0];
|
||||||
this.$router.push("/gen/edit/" + tableId);
|
this.$router.push("/gen/edit/" + tableId);
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const tableIds = row.tableId || this.ids;
|
const tableIds = row.tableId || this.ids;
|
||||||
this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", {
|
this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return delTable(tableIds);
|
return delTable(tableIds);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.msgSuccess("删除成功");
|
this.msgSuccess("删除成功");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in new issue