Merge branch 'dev_372'
This commit is contained in:
@@ -157,7 +157,7 @@ export default {
|
||||
getGenTable(tableId).then((res) => {
|
||||
this.columns = res.data.columns;
|
||||
this.info = res.data.info;
|
||||
this.tables = res.data.tables; //子表
|
||||
this.tables = res.data.tables;//子表
|
||||
});
|
||||
/** 查询字典下拉列表 */
|
||||
listType({ pageSize: 100 }).then((response) => {
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
<el-select v-model="info.tplCategory" @change="tplSelectChange">
|
||||
<el-option label="单表(增删改查)" value="crud" />
|
||||
<!-- <el-option label="树表(增删改查)" value="tree" />
|
||||
<el-option label="主子表(增删改查)" value="sub" /> -->
|
||||
<el-option label="导航查询" value="subNav"></el-option> -->
|
||||
<!-- <el-option label="主子表(增删改查)" value="sub" /> -->
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -179,7 +180,7 @@
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-select v-model="info.subTableName" placeholder="请选择" @change="subSelectChange">
|
||||
<el-select v-model="info.subTableName" placeholder="请选择" @change="subSelectChange(this)">
|
||||
<el-option v-for="(table, index) in tables" :key="index" :label="table.tableName + ':' + table.tableComment" :value="table.tableName">
|
||||
</el-option>
|
||||
</el-select>
|
||||
@@ -203,6 +204,7 @@
|
||||
</el-form>
|
||||
</template>
|
||||
<script>
|
||||
import { queryColumnInfo } from "@/api/tool/gen";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
@@ -214,7 +216,7 @@ export default {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
// 字表
|
||||
// 子表
|
||||
tables: {
|
||||
type: Array,
|
||||
default: null,
|
||||
@@ -237,10 +239,20 @@ export default {
|
||||
{ required: true, message: "请选择生成模板", trigger: "blur" },
|
||||
],
|
||||
moduleName: [
|
||||
{ required: true, message: "请输入生成模块名", trigger: "blur", pattern:/^[A-Za-z]+$/ },
|
||||
{
|
||||
required: true,
|
||||
message: "请输入生成模块名",
|
||||
trigger: "blur",
|
||||
pattern: /^[A-Za-z]+$/,
|
||||
},
|
||||
],
|
||||
businessName: [
|
||||
{ required: true, message: "请输入生成业务名", trigger: "blur", pattern:/^[A-Za-z]+$/},
|
||||
{
|
||||
required: true,
|
||||
message: "请输入生成业务名",
|
||||
trigger: "blur",
|
||||
pattern: /^[A-Za-z]+$/,
|
||||
},
|
||||
],
|
||||
functionName: [
|
||||
{ required: true, message: "请输入生成功能名", trigger: "blur" },
|
||||
@@ -281,10 +293,18 @@ export default {
|
||||
},
|
||||
/** 设置关联外键 */
|
||||
setSubTableColumns(value) {
|
||||
console.log(value);
|
||||
if (value == null || value == undefined || value == "") {
|
||||
return;
|
||||
}
|
||||
for (var item in this.tables) {
|
||||
const name = this.tables[item].tableName;
|
||||
if (value === name) {
|
||||
this.subColumns = this.tables[item].columns;
|
||||
const obj = this.tables[item];
|
||||
if (value === obj.tableName) {
|
||||
queryColumnInfo(obj.tableId).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.subColumns = res.data.columns;
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch()">查询</el-button>
|
||||
<el-button type="default" icon="el-icon-refresh" size="small" @click="loadTableData()">刷新</el-button>
|
||||
<!-- <el-button type="default" icon="el-icon-refresh" size="small" @click="loadTableData()">刷新</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="tableName" label="表名" sortable="custom" width="180" />
|
||||
<el-table-column prop="dbName" label="数据库名" width="100" />
|
||||
<el-table-column prop="tableId" label="表id" width="80" />
|
||||
<el-table-column prop="tableName" label="表名" sortable="custom" width="110" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="className" label="实体" />
|
||||
<el-table-column prop="className" label="实体" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="createTime" label="创建时间" />
|
||||
<el-table-column prop="updateTime" label="更新时间" />
|
||||
<el-table-column label="操作" align="center" width="350">
|
||||
@@ -38,7 +40,7 @@
|
||||
<el-button type="text" icon="el-icon-view" @click="handleShowDialog(scope.row, 'preview')" v-hasPermi="['tool:gen:preview']">预览</el-button>
|
||||
<el-button type="text" icon="el-icon-edit" @click="handleEditTable(scope.row)" v-hasPermi="['tool:gen:edit']">编辑</el-button>
|
||||
<el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:gen:remove']">删除</el-button>
|
||||
<!-- <el-button type="text" icon="el-icon-refresh" @click="handleRefresh(scope.row)" v-hasPermi="['tool:gen:refresh']">同步</el-button> -->
|
||||
<el-button type="text" icon="el-icon-refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['tool:gen:edit']">同步</el-button>
|
||||
<el-button type="text" icon="el-icon-download" @click="handleShowDialog(scope.row, 'generate')" v-hasPermi="['tool:gen:code']">生成代码
|
||||
</el-button>
|
||||
</template>
|
||||
@@ -50,8 +52,9 @@
|
||||
<el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
||||
<el-tabs v-model="preview.activeName">
|
||||
<el-tab-pane v-for="(item, key) in preview.data" :label="item.title" :name="key.toString()" :key="key">
|
||||
<pre v-html="highlightedCode(item.content)">
|
||||
</pre>
|
||||
<el-link :underline="false" icon="el-icon-document-copy" v-clipboard:copy="item.content" v-clipboard:success="clipboardSuccess"
|
||||
style="float:right">复制</el-link>
|
||||
<pre><code class="hljs" v-html="highlightedCode(item.content, item.title)"></code></pre>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
@@ -91,11 +94,11 @@
|
||||
<script>
|
||||
import {
|
||||
codeGenerator,
|
||||
getGenTable,
|
||||
listTable,
|
||||
delTable,
|
||||
previewTable,
|
||||
synchDb
|
||||
} from "@/api/tool/gen";
|
||||
import { downloadFile } from "@/utils/zipdownload.js";
|
||||
import importTable from "./importTable";
|
||||
import { Loading } from "element-ui";
|
||||
import hljs from "highlight.js";
|
||||
@@ -151,7 +154,7 @@ export default {
|
||||
handleSearch() {
|
||||
this.tableloading = true;
|
||||
|
||||
getGenTable(this.queryParams).then((res) => {
|
||||
listTable(this.queryParams).then((res) => {
|
||||
this.tableData = res.data.result;
|
||||
this.total = res.data.totalNum;
|
||||
this.tableloading = false;
|
||||
@@ -230,10 +233,7 @@ export default {
|
||||
if (code == 200) {
|
||||
this.showGenerate = false;
|
||||
this.msgSuccess("恭喜你,代码生成完成!");
|
||||
downloadFile(
|
||||
process.env.VUE_APP_BASE_API + data.zipPath,
|
||||
data.fileName
|
||||
);
|
||||
this.download(data.path);
|
||||
} else {
|
||||
this.msgError(res.msg);
|
||||
}
|
||||
@@ -278,6 +278,11 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 复制代码成功 */
|
||||
clipboardSuccess() {
|
||||
this.msgSuccess("复制成功");
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(section) {
|
||||
this.tableIds = section.map((item) => item.tableId);
|
||||
this.multiple = !section.length;
|
||||
@@ -285,15 +290,21 @@ export default {
|
||||
},
|
||||
/** 高亮显示 */
|
||||
highlightedCode(code, key) {
|
||||
// var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
||||
// var language = key.substring(key.lastIndexOf(".") , key.length)
|
||||
const result = hljs.highlightAuto(code || "");
|
||||
return result.value || " ";
|
||||
},
|
||||
handleRefresh(row) {
|
||||
this.$message({
|
||||
type: "info",
|
||||
message: "敬请期待",
|
||||
});
|
||||
// 同步代码
|
||||
handleSynchDb(row) {
|
||||
const tableName = row.tableName;
|
||||
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?')
|
||||
.then(function () {
|
||||
return synchDb(row.tableId, { tableName, dbName: row.dbName });
|
||||
})
|
||||
.then(() => {
|
||||
this.msgSuccess("同步成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user