| | |
| | | <template>
|
| | | <div class="app-container">
|
| | | <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
|
| | | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
| | | <el-form-item label="表名称" prop="tableName">
|
| | | <el-input
|
| | | v-model="queryParams.tableName"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="primary"
|
| | | plain
|
| | | icon="el-icon-download"
|
| | | size="mini"
|
| | | @click="handleGenTable"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="info"
|
| | | plain
|
| | | icon="el-icon-upload"
|
| | | size="mini"
|
| | | @click="openImportTable"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="success"
|
| | | plain
|
| | | icon="el-icon-edit"
|
| | | size="mini"
|
| | | :disabled="single"
|
| | |
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="danger"
|
| | | plain
|
| | | icon="el-icon-delete"
|
| | | size="mini"
|
| | | :disabled="multiple"
|
| | |
| | | v-hasPermi="['tool:gen:remove']"
|
| | | >删除</el-button>
|
| | | </el-col>
|
| | | <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
| | | </el-row>
|
| | |
|
| | | <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
| | | <el-table-column type="selection" width="55"></el-table-column>
|
| | | <el-table-column label="序号" align="center" prop="tableId" width="60px" />
|
| | | <el-table-column type="selection" align="center" width="55"></el-table-column>
|
| | | <el-table-column label="序号" type="index" width="50" align="center">
|
| | | <template slot-scope="scope">
|
| | | <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column
|
| | | label="表名称"
|
| | | align="center"
|
| | | prop="tableName"
|
| | | :show-overflow-tooltip="true"
|
| | | width="130"
|
| | | width="120"
|
| | | />
|
| | | <el-table-column
|
| | | label="表描述"
|
| | | align="center"
|
| | | prop="tableComment"
|
| | | :show-overflow-tooltip="true"
|
| | | width="130"
|
| | | width="120"
|
| | | />
|
| | | <el-table-column
|
| | | label="实体"
|
| | | align="center"
|
| | | prop="className"
|
| | | :show-overflow-tooltip="true"
|
| | | width="130"
|
| | | width="120"
|
| | | />
|
| | | <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
|
| | | <el-table-column label="更新时间" align="center" prop="updateTime" width="160" />
|
| | |
| | | <el-button
|
| | | type="text"
|
| | | size="small"
|
| | | icon="el-icon-refresh"
|
| | | @click="handleSynchDb(scope.row)"
|
| | | v-hasPermi="['tool:gen:edit']"
|
| | | >同步</el-button>
|
| | | <el-button
|
| | | type="text"
|
| | | size="small"
|
| | | icon="el-icon-download"
|
| | | @click="handleGenTable(scope.row)"
|
| | | v-hasPermi="['tool:gen:code']"
|
| | |
| | | :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
| | | :key="key"
|
| | | >
|
| | | <pre>{{ value }}</pre>
|
| | | <pre><code class="hljs" v-html="highlightedCode(value, key)"></code></pre>
|
| | | </el-tab-pane>
|
| | | </el-tabs>
|
| | | </el-dialog>
|
| | |
| | | </template>
|
| | |
|
| | | <script>
|
| | | import { listTable, previewTable, delTable } from "@/api/tool/gen";
|
| | | import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
| | | import importTable from "./importTable";
|
| | | import { downLoadZip } from "@/utils/zipdownload";
|
| | | import hljs from "highlight.js/lib/highlight";
|
| | | import "highlight.js/styles/github-gist.css";
|
| | | hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
|
| | | hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"));
|
| | | hljs.registerLanguage("html", require("highlight.js/lib/languages/xml"));
|
| | | hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml"));
|
| | | hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript"));
|
| | | hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"));
|
| | |
|
| | | export default {
|
| | | name: "Gen",
|
| | | components: { importTable },
|
| | |
| | | single: true,
|
| | | // 非多个禁用
|
| | | multiple: true,
|
| | | // 显示搜索条件
|
| | | showSearch: true,
|
| | | // 总条数
|
| | | total: 0,
|
| | | // 表数据
|
| | |
| | | this.msgError("请选择要生成的数据");
|
| | | return;
|
| | | }
|
| | | downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
| | | if(row.genType === "1") {
|
| | | genCode(row.tableName).then(response => {
|
| | | this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
| | | });
|
| | | } else {
|
| | | downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
| | | }
|
| | | },
|
| | | /** 同步数据库操作 */
|
| | | handleSynchDb(row) {
|
| | | const tableName = row.tableName;
|
| | | this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", {
|
| | | confirmButtonText: "确定",
|
| | | cancelButtonText: "取消",
|
| | | type: "warning"
|
| | | }).then(function() {
|
| | | return synchDb(tableName);
|
| | | }).then(() => {
|
| | | this.msgSuccess("同步成功");
|
| | | }).catch(() => {});
|
| | | },
|
| | | /** 打开导入表弹窗 */
|
| | | openImportTable() {
|
| | |
| | | this.preview.open = true;
|
| | | });
|
| | | },
|
| | | /** 高亮显示 */
|
| | | highlightedCode(code, key) {
|
| | | const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
|
| | | var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
| | | const result = hljs.highlight(language, code || "", true);
|
| | | return result.value || ' ';
|
| | | },
|
| | | // 多选框选中数据
|
| | | handleSelectionChange(selection) {
|
| | | this.ids = selection.map(item => item.tableId);
|
| | |
| | | /** 修改按钮操作 */
|
| | | handleEditTable(row) {
|
| | | const tableId = row.tableId || this.ids[0];
|
| | | this.$router.push({ path: "/gen/edit", query: { tableId: tableId } });
|
| | | this.$router.push("/gen/edit/" + tableId);
|
| | | },
|
| | | /** 删除按钮操作 */
|
| | | handleDelete(row) {
|
| | |
| | | }).then(() => {
|
| | | this.getList();
|
| | | this.msgSuccess("删除成功");
|
| | | }).catch(function() {});
|
| | | }).catch(() => {});
|
| | | }
|
| | | }
|
| | | };
|