完成代码生成器~
parent
95757db6be
commit
2f66829a41
@ -1,45 +0,0 @@
|
|||||||
package com.ruoyi.generator.domain;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import com.ruoyi.common.constant.GenConstants;
|
|
||||||
import com.ruoyi.common.core.domain.BaseEntity;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务表 gen_table
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class GenTable extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成包路径
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "生成包路径不能为空")
|
|
||||||
private String packageName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 其它生成选项
|
|
||||||
*/
|
|
||||||
private String options;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树编码字段
|
|
||||||
*/
|
|
||||||
private String treeCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树父编码字段
|
|
||||||
*/
|
|
||||||
private String treeParentCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 树名称字段
|
|
||||||
*/
|
|
||||||
private String treeName;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,61 +1,61 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px">
|
<el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="表名称" prop="tableName">
|
<el-form-item label="表名称" prop="tableName">
|
||||||
<el-input placeholder="请输入仓库名称" v-model="info.tableName" />
|
<el-input placeholder="请输入仓库名称" v-model="info.tableName" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="表描述" prop="tableComment">
|
<el-form-item label="表描述" prop="tableComment">
|
||||||
<el-input placeholder="请输入" v-model="info.tableComment" />
|
<el-input placeholder="请输入" v-model="info.tableComment" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="实体类名称" prop="className">
|
<el-form-item label="实体类名称" prop="className">
|
||||||
<el-input placeholder="请输入" v-model="info.className" />
|
<el-input placeholder="请输入" v-model="info.className" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="作者" prop="author">
|
<el-form-item label="作者" prop="author">
|
||||||
<el-input placeholder="请输入" v-model="info.author" />
|
<el-input placeholder="请输入" v-model="info.author" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input type="textarea" :rows="3" v-model="info.remark"></el-input>
|
<el-input type="textarea" :rows="3" v-model="info.remark"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "BasicInfoForm",
|
name: "BasicInfoForm",
|
||||||
props: {
|
props: {
|
||||||
info: {
|
info: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
rules: {
|
rules: {
|
||||||
tableName: [
|
tableName: [
|
||||||
{ required: true, message: "请输入表名称", trigger: "blur" }
|
{ required: true, message: "请输入表名称", trigger: "blur" }
|
||||||
],
|
],
|
||||||
tableComment: [
|
tableComment: [
|
||||||
{ required: true, message: "请输入表描述", trigger: "blur" }
|
{ required: true, message: "请输入表描述", trigger: "blur" }
|
||||||
],
|
],
|
||||||
className: [
|
className: [
|
||||||
{ required: true, message: "请输入实体类名称", trigger: "blur" }
|
{ required: true, message: "请输入实体类名称", trigger: "blur" }
|
||||||
],
|
],
|
||||||
author: [
|
author: [
|
||||||
{ required: true, message: "请输入作者", trigger: "blur" }
|
{ required: true, message: "请输入作者", trigger: "blur" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -1,233 +1,232 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-card>
|
<el-card>
|
||||||
<el-tabs v-model="activeName">
|
<el-tabs v-model="activeName">
|
||||||
<el-tab-pane label="基本信息" name="basic">
|
<el-tab-pane label="基本信息" name="basic">
|
||||||
<basic-info-form ref="basicInfo" :info="table" />
|
<basic-info-form ref="basicInfo" :info="table" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="字段信息" name="cloum">
|
<el-tab-pane label="字段信息" name="cloum">
|
||||||
<el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
|
<el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="字段列名"
|
label="字段列名"
|
||||||
prop="columnName"
|
prop="columnName"
|
||||||
min-width="10%"
|
min-width="10%"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="字段描述" min-width="10%">
|
<el-table-column label="字段描述" min-width="10%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input v-model="scope.row.columnComment"></el-input>
|
<el-input v-model="scope.row.columnComment"></el-input>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="物理类型"
|
label="物理类型"
|
||||||
prop="columnType"
|
prop="columnType"
|
||||||
min-width="10%"
|
min-width="10%"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="Java类型" min-width="11%">
|
<el-table-column label="Java类型" min-width="11%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.javaType">
|
<el-select v-model="scope.row.javaType">
|
||||||
<el-option label="Long" value="Long" />
|
<el-option label="Long" value="Long" />
|
||||||
<el-option label="String" value="String" />
|
<el-option label="String" value="String" />
|
||||||
<el-option label="Integer" value="Integer" />
|
<el-option label="Integer" value="Integer" />
|
||||||
<el-option label="Double" value="Double" />
|
<el-option label="Double" value="Double" />
|
||||||
<el-option label="BigDecimal" value="BigDecimal" />
|
<el-option label="BigDecimal" value="BigDecimal" />
|
||||||
<el-option label="Date" value="Date" />
|
<el-option label="Date" value="Date" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="java属性" min-width="10%">
|
<el-table-column label="java属性" min-width="10%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input v-model="scope.row.javaField"></el-input>
|
<el-input v-model="scope.row.javaField"></el-input>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="插入" min-width="4%">
|
<el-table-column label="插入" min-width="4%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-checkbox true-label="true" false-label="false" v-model="scope.row.createOperation"></el-checkbox>
|
<el-checkbox true-label="true" false-label="false" v-model="scope.row.createOperation"></el-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="编辑" min-width="4%">
|
<el-table-column label="编辑" min-width="4%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-checkbox true-label="true" false-label="false" v-model="scope.row.updateOperation"></el-checkbox>
|
<el-checkbox true-label="true" false-label="false" v-model="scope.row.updateOperation"></el-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="列表" min-width="4%">
|
<el-table-column label="列表" min-width="4%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-checkbox true-label="true" false-label="false" v-model="scope.row.listOperationResult"></el-checkbox>
|
<el-checkbox true-label="true" false-label="false" v-model="scope.row.listOperationResult"></el-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="查询" min-width="4%">
|
<el-table-column label="查询" min-width="4%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-checkbox true-label="true" false-label="false" v-model="scope.row.listOperation"></el-checkbox>
|
<el-checkbox true-label="true" false-label="false" v-model="scope.row.listOperation"></el-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="查询方式" min-width="10%">
|
<el-table-column label="查询方式" min-width="10%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.listOperationCondition">
|
<el-select v-model="scope.row.listOperationCondition">
|
||||||
<el-option label="=" value="=" />
|
<el-option label="=" value="=" />
|
||||||
<el-option label="!=" value="!=" />
|
<el-option label="!=" value="!=" />
|
||||||
<el-option label=">" value=">" />
|
<el-option label=">" value=">" />
|
||||||
<el-option label=">=" value=">=" />
|
<el-option label=">=" value=">=" />
|
||||||
<el-option label="<" value="<>" />
|
<el-option label="<" value="<>" />
|
||||||
<el-option label="<=" value="<=" />
|
<el-option label="<=" value="<=" />
|
||||||
<el-option label="LIKE" value="LIKE" />
|
<el-option label="LIKE" value="LIKE" />
|
||||||
<el-option label="BETWEEN" value="BETWEEN" />
|
<el-option label="BETWEEN" value="BETWEEN" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="允许空" min-width="5%">
|
<el-table-column label="允许空" min-width="5%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-checkbox true-label="true" false-label="false" v-model="scope.row.nullable"></el-checkbox>
|
<el-checkbox true-label="true" false-label="false" v-model="scope.row.nullable"></el-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="显示类型" min-width="12%">
|
<el-table-column label="显示类型" min-width="12%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.htmlType">
|
<el-select v-model="scope.row.htmlType">
|
||||||
<el-option label="文本框" value="input" />
|
<el-option label="文本框" value="input" />
|
||||||
<el-option label="文本域" value="textarea" />
|
<el-option label="文本域" value="textarea" />
|
||||||
<el-option label="下拉框" value="select" />
|
<el-option label="下拉框" value="select" />
|
||||||
<el-option label="单选框" value="radio" />
|
<el-option label="单选框" value="radio" />
|
||||||
<el-option label="复选框" value="checkbox" />
|
<el-option label="复选框" value="checkbox" />
|
||||||
<el-option label="日期控件" value="datetime" />
|
<el-option label="日期控件" value="datetime" />
|
||||||
<el-option label="图片上传" value="imageUpload" />
|
<el-option label="图片上传" value="imageUpload" />
|
||||||
<el-option label="文件上传" value="fileUpload" />
|
<el-option label="文件上传" value="fileUpload" />
|
||||||
<el-option label="富文本控件" value="editor" />
|
<el-option label="富文本控件" value="editor" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="字典类型" min-width="12%">
|
<el-table-column label="字典类型" min-width="12%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
|
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in dictOptions"
|
v-for="dict in dictOptions"
|
||||||
:key="dict.id"
|
:key="dict.id"
|
||||||
:label="dict.name"
|
:label="dict.name"
|
||||||
:value="dict.type"
|
:value="dict.type"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="示例" min-width="10%">
|
<el-table-column label="示例" min-width="10%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input v-model="scope.row.example"></el-input>
|
<el-input v-model="scope.row.example"></el-input>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="生成信息" name="genInfo">
|
<el-tab-pane label="生成信息" name="genInfo">
|
||||||
<gen-info-form ref="genInfo" :info="table" :tables="tables" :menus="menus"/>
|
<gen-info-form ref="genInfo" :info="table" :tables="tables" :menus="menus"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
<el-form label-width="100px">
|
<el-form label-width="100px">
|
||||||
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
|
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
|
||||||
<el-button type="primary" @click="submitForm()">提交</el-button>
|
<el-button type="primary" @click="submitForm()">提交</el-button>
|
||||||
<el-button @click="close()">返回</el-button>
|
<el-button @click="close()">返回</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { getCodegenDetail, updateCodegen } from "@/api/tool/codegen";
|
import { getCodegenDetail, updateCodegen } from "@/api/tool/codegen";
|
||||||
import { listAllSimple as listAllSimpleDictType } from "@/api/system/dict/type";
|
import { listAllSimple as listAllSimpleDictType } from "@/api/system/dict/type";
|
||||||
import { listMenu as getMenuTreeselect } from "@/api/system/menu";
|
import { listSimpleMenus } from "@/api/system/menu";
|
||||||
import { listSimpleMenus } from "@/api/system/menu";
|
import basicInfoForm from "./basicInfoForm";
|
||||||
import basicInfoForm from "./basicInfoForm";
|
import genInfoForm from "./genInfoForm";
|
||||||
import genInfoForm from "./genInfoForm";
|
import Sortable from 'sortablejs'
|
||||||
import Sortable from 'sortablejs'
|
|
||||||
|
export default {
|
||||||
export default {
|
name: "GenEdit",
|
||||||
name: "GenEdit",
|
components: {
|
||||||
components: {
|
basicInfoForm,
|
||||||
basicInfoForm,
|
genInfoForm
|
||||||
genInfoForm
|
},
|
||||||
},
|
data() {
|
||||||
data() {
|
return {
|
||||||
return {
|
// 选中选项卡的 name
|
||||||
// 选中选项卡的 name
|
activeName: "cloum",
|
||||||
activeName: "cloum",
|
// 表格的高度
|
||||||
// 表格的高度
|
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
||||||
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
// 表信息
|
||||||
// 表信息
|
tables: [],
|
||||||
tables: [],
|
// 表列信息
|
||||||
// 表列信息
|
columns: [],
|
||||||
columns: [],
|
// 字典信息
|
||||||
// 字典信息
|
dictOptions: [],
|
||||||
dictOptions: [],
|
// 菜单信息
|
||||||
// 菜单信息
|
menus: [],
|
||||||
menus: [],
|
// 表详细信息
|
||||||
// 表详细信息
|
table: {}
|
||||||
table: {}
|
};
|
||||||
};
|
},
|
||||||
},
|
created() {
|
||||||
created() {
|
const tableId = this.$route.params && this.$route.params.tableId;
|
||||||
const tableId = this.$route.params && this.$route.params.tableId;
|
if (tableId) {
|
||||||
if (tableId) {
|
// 获取表详细信息
|
||||||
// 获取表详细信息
|
getCodegenDetail(tableId).then(res => {
|
||||||
getCodegenDetail(tableId).then(res => {
|
this.table = res.data.table;
|
||||||
this.table = res.data.table;
|
this.columns = res.data.columns;
|
||||||
this.columns = res.data.columns;
|
});
|
||||||
});
|
/** 查询字典下拉列表 */
|
||||||
/** 查询字典下拉列表 */
|
listAllSimpleDictType().then(response => {
|
||||||
listAllSimpleDictType().then(response => {
|
this.dictOptions = response.data;
|
||||||
this.dictOptions = response.data;
|
});
|
||||||
});
|
/** 查询菜单下拉列表 */
|
||||||
/** 查询菜单下拉列表 */
|
listSimpleMenus().then(response => {
|
||||||
listSimpleMenus().then(response => {
|
this.menus = [];
|
||||||
this.menus = [];
|
this.menus.push(...this.handleTree(response.data, "id"));
|
||||||
this.menus.push(...this.handleTree(response.data, "id"));
|
});
|
||||||
});
|
}
|
||||||
}
|
},
|
||||||
},
|
methods: {
|
||||||
methods: {
|
/** 提交按钮 */
|
||||||
/** 提交按钮 */
|
submitForm() {
|
||||||
submitForm() {
|
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
||||||
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
||||||
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
|
||||||
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
|
const validateResult = res.every(item => !!item);
|
||||||
const validateResult = res.every(item => !!item);
|
if (validateResult) {
|
||||||
if (validateResult) {
|
const genTable = {};
|
||||||
const genTable = {};
|
genTable.table = Object.assign({}, basicForm.model, genForm.model);
|
||||||
genTable.table = Object.assign({}, basicForm.model, genForm.model);
|
genTable.columns = this.columns;
|
||||||
genTable.columns = this.columns;
|
genTable.params = {
|
||||||
genTable.params = {
|
treeCode: genTable.treeCode,
|
||||||
treeCode: genTable.treeCode,
|
treeName: genTable.treeName,
|
||||||
treeName: genTable.treeName,
|
treeParentCode: genTable.treeParentCode,
|
||||||
treeParentCode: genTable.treeParentCode,
|
parentMenuId: genTable.parentMenuId
|
||||||
parentMenuId: genTable.parentMenuId
|
};
|
||||||
};
|
updateCodegen(genTable).then(res => {
|
||||||
updateCodegen(genTable).then(res => {
|
this.msgSuccess("修改成功!");
|
||||||
this.msgSuccess("修改成功!");
|
this.close();
|
||||||
this.close();
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
this.msgError("表单校验未通过,请重新检查提交内容");
|
||||||
this.msgError("表单校验未通过,请重新检查提交内容");
|
}
|
||||||
}
|
});
|
||||||
});
|
},
|
||||||
},
|
getFormPromise(form) {
|
||||||
getFormPromise(form) {
|
return new Promise(resolve => {
|
||||||
return new Promise(resolve => {
|
form.validate(res => {
|
||||||
form.validate(res => {
|
resolve(res);
|
||||||
resolve(res);
|
});
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
},
|
/** 关闭按钮 */
|
||||||
/** 关闭按钮 */
|
close() {
|
||||||
close() {
|
this.$store.dispatch("tagsView/delView", this.$route);
|
||||||
this.$store.dispatch("tagsView/delView", this.$route);
|
this.$router.push({ path: "/tool/gen", query: { t: Date.now()}})
|
||||||
this.$router.push({ path: "/tool/gen", query: { t: Date.now()}})
|
}
|
||||||
}
|
},
|
||||||
},
|
mounted() {
|
||||||
mounted() {
|
const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0];
|
||||||
const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0];
|
const sortable = Sortable.create(el, {
|
||||||
const sortable = Sortable.create(el, {
|
handle: ".allowDrag",
|
||||||
handle: ".allowDrag",
|
onEnd: evt => {
|
||||||
onEnd: evt => {
|
const targetRow = this.columns.splice(evt.oldIndex, 1)[0];
|
||||||
const targetRow = this.columns.splice(evt.oldIndex, 1)[0];
|
this.columns.splice(evt.newIndex, 0, targetRow);
|
||||||
this.columns.splice(evt.newIndex, 0, targetRow);
|
for (let index in this.columns) {
|
||||||
for (let index in this.columns) {
|
this.columns[index].sort = parseInt(index) + 1;
|
||||||
this.columns[index].sort = parseInt(index) + 1;
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
};
|
||||||
};
|
</script>
|
||||||
</script>
|
|
||||||
@ -1,106 +1,106 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 导入表 -->
|
<!-- 导入表 -->
|
||||||
<el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body>
|
<el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body>
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true">
|
<el-form :model="queryParams" ref="queryForm" :inline="true">
|
||||||
<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>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" 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>
|
<el-row>
|
||||||
<el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
|
<el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px">
|
||||||
<el-table-column type="selection" width="55"></el-table-column>
|
<el-table-column type="selection" width="55"></el-table-column>
|
||||||
<el-table-column prop="tableSchema" label="数据库" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="tableSchema" label="数据库" :show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
|
<el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column>
|
||||||
<el-table-column prop="createTime" label="创建时间">
|
<el-table-column prop="createTime" label="创建时间">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button type="primary" @click="handleImportTable">确 定</el-button>
|
<el-button type="primary" @click="handleImportTable">确 定</el-button>
|
||||||
<el-button @click="visible = false">取 消</el-button>
|
<el-button @click="visible = false">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getSchemaTableList, createCodegenList } from "@/api/tool/codegen";
|
import { getSchemaTableList, createCodegenListFromDB } from "@/api/tool/codegen";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
visible: false,
|
visible: false,
|
||||||
// 选中数组值
|
// 选中数组值
|
||||||
tables: [],
|
tables: [],
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// 表数据
|
// 表数据
|
||||||
dbTableList: [],
|
dbTableList: [],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
tableName: undefined,
|
tableName: undefined,
|
||||||
tableComment: undefined
|
tableComment: undefined
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 显示弹框
|
// 显示弹框
|
||||||
show() {
|
show() {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
clickRow(row) {
|
clickRow(row) {
|
||||||
this.$refs.table.toggleRowSelection(row);
|
this.$refs.table.toggleRowSelection(row);
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
this.tables = selection.map(item => item.tableName);
|
this.tables = selection.map(item => item.tableName);
|
||||||
},
|
},
|
||||||
// 查询表数据
|
// 查询表数据
|
||||||
getList() {
|
getList() {
|
||||||
getSchemaTableList(this.queryParams).then(res => {
|
getSchemaTableList(this.queryParams).then(res => {
|
||||||
this.dbTableList = res.data;
|
this.dbTableList = res.data;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
/** 导入按钮操作 */
|
/** 导入按钮操作 */
|
||||||
handleImportTable() {
|
handleImportTable() {
|
||||||
createCodegenList(this.tables.join(",")).then(res => {
|
createCodegenListFromDB(this.tables.join(",")).then(res => {
|
||||||
this.msgSuccess("导入成功");
|
this.msgSuccess("导入成功");
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.$emit("ok");
|
this.$emit("ok");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -1,228 +1,316 @@
|
|||||||
<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-item label="表名称" prop="tableName">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
<el-input
|
<el-form-item label="表名称" prop="tableName">
|
||||||
v-model="queryParams.tableName"
|
<el-input
|
||||||
placeholder="请输入表名称"
|
v-model="queryParams.tableName"
|
||||||
clearable
|
placeholder="请输入表名称"
|
||||||
size="small"
|
clearable
|
||||||
@keyup.enter.native="handleQuery"
|
size="small"
|
||||||
/>
|
@keyup.enter.native="handleQuery"
|
||||||
</el-form-item>
|
/>
|
||||||
<el-form-item label="表描述" prop="tableComment">
|
</el-form-item>
|
||||||
<el-input
|
<el-form-item label="表描述" prop="tableComment">
|
||||||
v-model="queryParams.tableComment"
|
<el-input
|
||||||
placeholder="请输入表描述"
|
v-model="queryParams.tableComment"
|
||||||
clearable
|
placeholder="请输入表描述"
|
||||||
size="small"
|
clearable
|
||||||
@keyup.enter.native="handleQuery"
|
size="small"
|
||||||
/>
|
@keyup.enter.native="handleQuery"
|
||||||
</el-form-item>
|
/>
|
||||||
<el-form-item label="创建时间">
|
</el-form-item>
|
||||||
<el-date-picker
|
<el-form-item label="创建时间">
|
||||||
v-model="dateRange"
|
<el-date-picker
|
||||||
size="small"
|
v-model="dateRange"
|
||||||
style="width: 240px"
|
size="small"
|
||||||
value-format="yyyy-MM-dd"
|
style="width: 240px"
|
||||||
type="daterange"
|
value-format="yyyy-MM-dd"
|
||||||
range-separator="-"
|
type="daterange"
|
||||||
start-placeholder="开始日期"
|
range-separator="-"
|
||||||
end-placeholder="结束日期"
|
start-placeholder="开始日期"
|
||||||
></el-date-picker>
|
end-placeholder="结束日期"
|
||||||
</el-form-item>
|
></el-date-picker>
|
||||||
<el-form-item>
|
</el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-form-item>
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
</el-form-item>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-form>
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
<el-row :gutter="10" class="mb8">
|
|
||||||
<el-col :span="1.5">
|
<!-- 操作工作栏 -->
|
||||||
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="openImportTable" v-hasPermi="['tool:gen:import']">导入</el-button>
|
<el-row :gutter="10" class="mb8">
|
||||||
</el-col>
|
<el-col :span="1.5">
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="openImportTable"
|
||||||
</el-row>
|
v-hasPermi="['tool:codegen:create']">基于 DB 导入</el-button>
|
||||||
|
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="openImportSQL"
|
||||||
<el-table v-loading="loading" :data="tableList">
|
v-hasPermi="['tool:codegen:create']">基于 SQL 导入</el-button>
|
||||||
<el-table-column label="表名称" align="center" prop="tableName" :show-overflow-tooltip="true" width="200"/>
|
</el-col>
|
||||||
<el-table-column label="表描述" align="center" prop="tableComment" :show-overflow-tooltip="true" width="120"/>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
<el-table-column label="实体" align="center" prop="className" :show-overflow-tooltip="true" width="200"/>
|
</el-row>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
|
|
||||||
<template slot-scope="scope">
|
<!-- 列表 -->
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
<el-table v-loading="loading" :data="tableList">
|
||||||
</template>
|
<el-table-column label="表名称" align="center" prop="tableName" :show-overflow-tooltip="true" width="200"/>
|
||||||
</el-table-column>
|
<el-table-column label="表描述" align="center" prop="tableComment" :show-overflow-tooltip="true" width="120"/>
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
|
<el-table-column label="实体" align="center" prop="className" :show-overflow-tooltip="true" width="200"/>
|
||||||
<template slot-scope="scope">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
|
||||||
<span>{{ parseTime(scope.row.updateTime) }}</span>
|
<template slot-scope="scope">
|
||||||
</template>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</el-table-column>
|
</template>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
</el-table-column>
|
||||||
<template slot-scope="scope">
|
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
|
||||||
<el-button type="text" size="small" icon="el-icon-view" @click="handlePreview(scope.row)" v-hasPermi="['tool:gen:preview']">预览</el-button>
|
<template slot-scope="scope">
|
||||||
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEditTable(scope.row)" v-hasPermi="['tool:gen:edit']">编辑</el-button>
|
<span>{{ parseTime(scope.row.updateTime) }}</span>
|
||||||
<el-button type="text" size="small" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:gen:remove']">删除</el-button>
|
</template>
|
||||||
<el-button type="text" size="small" icon="el-icon-refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['tool:gen:edit']">同步</el-button>
|
</el-table-column>
|
||||||
<el-button type="text" size="small" icon="el-icon-download" @click="handleGenTable(scope.row)" v-hasPermi="['tool:gen:code']">生成代码</el-button>
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
</template>
|
<template slot-scope="scope">
|
||||||
</el-table-column>
|
<el-button type="text" size="small" icon="el-icon-view" @click="handlePreview(scope.row)" v-hasPermi="['tool:codegen:preview']">预览</el-button>
|
||||||
</el-table>
|
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEditTable(scope.row)" v-hasPermi="['tool:codegen:update']">编辑</el-button>
|
||||||
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" @pagination="getList"/>
|
<el-button type="text" size="small" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:codegen:delete']">删除</el-button>
|
||||||
<!-- 预览界面 -->
|
<el-button type="text" size="small" icon="el-icon-refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['tool:codegen:update']">同步</el-button>
|
||||||
<el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
<el-button type="text" size="small" icon="el-icon-download" @click="handleGenTable(scope.row)" v-hasPermi="['tool:codegen:download']">生成代码</el-button>
|
||||||
<el-tabs tab-position="left" v-model="preview.activeName">
|
</template>
|
||||||
<el-tab-pane v-for="item in preview.data" :label="item.filePath.substring(item.filePath.lastIndexOf('/') + 1)" :name="item.filePath" :key="item.filePath">
|
</el-table-column>
|
||||||
<pre><code class="hljs" v-html="highlightedCode(item)"></code></pre>
|
</el-table>
|
||||||
</el-tab-pane>
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" @pagination="getList"/>
|
||||||
</el-tabs>
|
|
||||||
</el-dialog>
|
<!-- 预览界面 -->
|
||||||
<import-table ref="import" @ok="handleQuery" />
|
<el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
||||||
</div>
|
<el-tabs tab-position="left" v-model="preview.activeName">
|
||||||
</template>
|
<el-tab-pane v-for="item in preview.data" :label="item.filePath.substring(item.filePath.lastIndexOf('/') + 1)" :name="item.filePath" :key="item.filePath">
|
||||||
|
<pre><code class="hljs" v-html="highlightedCode(item)"></code></pre>
|
||||||
<script>
|
</el-tab-pane>
|
||||||
import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen, syncCodegen } from "@/api/tool/codegen";
|
</el-tabs>
|
||||||
|
</el-dialog>
|
||||||
import importTable from "./importTable";
|
|
||||||
// 代码高亮插件
|
<!-- 基于 DB 导入 -->
|
||||||
import hljs from "highlight.js/lib/highlight";
|
<import-table ref="import" @ok="handleQuery" />
|
||||||
import "highlight.js/styles/github-gist.css";
|
|
||||||
hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
|
<!-- 基于 SQL 导入 -->
|
||||||
hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"));
|
<el-dialog :title="importSQL.title" :visible.sync="importSQL.open" width="800px" append-to-body>
|
||||||
hljs.registerLanguage("html", require("highlight.js/lib/languages/xml"));
|
<el-form ref="importSQLForm" :model="importSQL.form" :rules="importSQL.rules" label-width="120px">
|
||||||
hljs.registerLanguage("vue", require("highlight.js/lib/languages/xml"));
|
<el-row>
|
||||||
hljs.registerLanguage("javascript", require("highlight.js/lib/languages/javascript"));
|
<el-col :span="12">
|
||||||
hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"));
|
<el-form-item label="建表 SQL 语句" prop="sql">
|
||||||
|
<el-input v-model="importSQL.form.sql" type="textarea" rows="30" style="width: 650px;" placeholder="请输入建 SQL 语句" />
|
||||||
export default {
|
</el-form-item>
|
||||||
name: "Gen",
|
</el-col>
|
||||||
components: { importTable },
|
</el-row>
|
||||||
data() {
|
</el-form>
|
||||||
return {
|
<div slot="footer" class="dialog-footer">
|
||||||
// 遮罩层
|
<el-button type="primary" @click="submitImportSQLForm">确 定</el-button>
|
||||||
loading: true,
|
<el-button @click="cancel">取 消</el-button>
|
||||||
// 唯一标识符
|
</div>
|
||||||
uniqueId: "",
|
</el-dialog>
|
||||||
// 选中表数组
|
</div>
|
||||||
tableNames: [],
|
</template>
|
||||||
// 显示搜索条件
|
|
||||||
showSearch: true,
|
<script>
|
||||||
// 总条数
|
import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen,
|
||||||
total: 0,
|
syncCodegenFromDB, syncCodegenFromSQL, createCodegenListFromSQL } from "@/api/tool/codegen";
|
||||||
// 表数据
|
|
||||||
tableList: [],
|
import importTable from "./importTable";
|
||||||
// 日期范围
|
// 代码高亮插件
|
||||||
dateRange: "",
|
import hljs from "highlight.js/lib/highlight";
|
||||||
// 查询参数
|
import "highlight.js/styles/github-gist.css";
|
||||||
queryParams: {
|
import {SysCommonStatusEnum} from "@/utils/constants";
|
||||||
pageNo: 1,
|
import {createTestDemo, updateTestDemo} from "@/api/tool/testDemo";
|
||||||
pageSize: 10,
|
hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
|
||||||
tableName: undefined,
|
hljs.registerLanguage("xml", require("highlight.js/lib/languages/xml"));
|
||||||
tableComment: undefined
|
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"));
|
||||||
preview: {
|
hljs.registerLanguage("sql", require("highlight.js/lib/languages/sql"));
|
||||||
open: false,
|
|
||||||
title: "代码预览",
|
export default {
|
||||||
data: {},
|
name: "Codegen",
|
||||||
activeName: "domain.java"
|
components: { importTable },
|
||||||
}
|
data() {
|
||||||
};
|
return {
|
||||||
},
|
// 遮罩层
|
||||||
created() {
|
loading: true,
|
||||||
this.getList();
|
// 唯一标识符
|
||||||
},
|
uniqueId: "",
|
||||||
activated() {
|
// 选中表数组
|
||||||
const time = this.$route.query.t;
|
tableNames: [],
|
||||||
if (time != null && time !== this.uniqueId) {
|
// 显示搜索条件
|
||||||
this.uniqueId = time;
|
showSearch: true,
|
||||||
this.resetQuery();
|
// 总条数
|
||||||
}
|
total: 0,
|
||||||
},
|
// 表数据
|
||||||
methods: {
|
tableList: [],
|
||||||
/** 查询表集合 */
|
// 日期范围
|
||||||
getList() {
|
dateRange: "",
|
||||||
this.loading = true;
|
// 查询参数
|
||||||
getCodegenTablePage(this.addDateRange(this.queryParams, [
|
queryParams: {
|
||||||
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
|
pageNo: 1,
|
||||||
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
|
pageSize: 10,
|
||||||
], 'CreateTime')).then(response => {
|
tableName: undefined,
|
||||||
this.tableList = response.data.list;
|
tableComment: undefined
|
||||||
this.total = response.data.total;
|
},
|
||||||
this.loading = false;
|
// 预览参数
|
||||||
}
|
preview: {
|
||||||
);
|
open: false,
|
||||||
},
|
title: "代码预览",
|
||||||
/** 搜索按钮操作 */
|
data: {},
|
||||||
handleQuery() {
|
activeName: "domain.java"
|
||||||
this.queryParams.pageNo = 1;
|
},
|
||||||
this.getList();
|
// 基于 SQL 导入
|
||||||
},
|
importSQL: {
|
||||||
/** 生成代码操作 */
|
open: false,
|
||||||
handleGenTable(row) {
|
title: "",
|
||||||
downloadCodegen(row.id).then(response => {
|
form: {
|
||||||
this.downloadZip(response, 'codegen-' + row.tableName + '.zip');
|
|
||||||
})
|
},
|
||||||
},
|
rules: {
|
||||||
/** 同步数据库操作 */
|
sql: [{ required: true, message: "SQL 不能为空", trigger: "blur" }]
|
||||||
handleSynchDb(row) {
|
}
|
||||||
const tableName = row.tableName;
|
}
|
||||||
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", {
|
};
|
||||||
confirmButtonText: "确定",
|
},
|
||||||
cancelButtonText: "取消",
|
created() {
|
||||||
type: "warning"
|
this.getList();
|
||||||
}).then(function() {
|
},
|
||||||
return syncCodegen(row.id);
|
activated() {
|
||||||
}).then(() => {
|
const time = this.$route.query.t;
|
||||||
this.msgSuccess("同步成功");
|
if (time != null && time !== this.uniqueId) {
|
||||||
})
|
this.uniqueId = time;
|
||||||
},
|
this.resetQuery();
|
||||||
/** 打开导入表弹窗 */
|
}
|
||||||
openImportTable() {
|
},
|
||||||
this.$refs.import.show();
|
methods: {
|
||||||
},
|
/** 查询表集合 */
|
||||||
/** 重置按钮操作 */
|
getList() {
|
||||||
resetQuery() {
|
this.loading = true;
|
||||||
this.dateRange = [];
|
getCodegenTablePage(this.addDateRange(this.queryParams, [
|
||||||
this.resetForm("queryForm");
|
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
|
||||||
this.handleQuery();
|
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
|
||||||
},
|
], 'CreateTime')).then(response => {
|
||||||
/** 预览按钮 */
|
this.tableList = response.data.list;
|
||||||
handlePreview(row) {
|
this.total = response.data.total;
|
||||||
previewCodegen(row.id).then(response => {
|
this.loading = false;
|
||||||
this.preview.data = response.data;
|
}
|
||||||
this.preview.activeName = response.data[0].filePath;
|
);
|
||||||
this.preview.open = true;
|
},
|
||||||
});
|
/** 搜索按钮操作 */
|
||||||
},
|
handleQuery() {
|
||||||
/** 高亮显示 */
|
this.queryParams.pageNo = 1;
|
||||||
highlightedCode(item) {
|
this.getList();
|
||||||
// const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
|
},
|
||||||
// var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
/** 生成代码操作 */
|
||||||
var language = item.filePath.substring(item.filePath.lastIndexOf(".") + 1);
|
handleGenTable(row) {
|
||||||
const result = hljs.highlight(language, item.code || "", true);
|
downloadCodegen(row.id).then(response => {
|
||||||
return result.value || ' ';
|
this.downloadZip(response, 'codegen-' + row.tableName + '.zip');
|
||||||
},
|
})
|
||||||
/** 修改按钮操作 */
|
},
|
||||||
handleEditTable(row) {
|
/** 同步数据库操作 */
|
||||||
const tableId = row.id;
|
handleSynchDb(row) {
|
||||||
this.$router.push("/gen/edit/" + tableId);
|
// 基于 SQL 同步
|
||||||
},
|
if (row.importType === 2) {
|
||||||
/** 删除按钮操作 */
|
this.importSQL.open = true;
|
||||||
handleDelete(row) {
|
this.importSQL.form.tableId = row.id;
|
||||||
const tableIds = row.id;
|
return;
|
||||||
this.$confirm('是否确认删除表名称为"' + row.tableName + '"的数据项?', "警告", {
|
}
|
||||||
confirmButtonText: "确定",
|
// 基于 DB 同步
|
||||||
cancelButtonText: "取消",
|
const tableName = row.tableName;
|
||||||
type: "warning"
|
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", {
|
||||||
}).then(function() {
|
confirmButtonText: "确定",
|
||||||
return deleteCodegen(tableIds);
|
cancelButtonText: "取消",
|
||||||
}).then(() => {
|
type: "warning"
|
||||||
this.getList();
|
}).then(function() {
|
||||||
this.msgSuccess("删除成功");
|
return syncCodegenFromDB(row.id);
|
||||||
})
|
}).then(() => {
|
||||||
}
|
this.msgSuccess("同步成功");
|
||||||
}
|
})
|
||||||
};
|
},
|
||||||
</script>
|
/** 打开导入表弹窗 */
|
||||||
|
openImportTable() {
|
||||||
|
this.$refs.import.show();
|
||||||
|
},
|
||||||
|
/** 打开 SQL 导入的弹窗 **/
|
||||||
|
openImportSQL() {
|
||||||
|
this.importSQL.open = true;
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.dateRange = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 预览按钮 */
|
||||||
|
handlePreview(row) {
|
||||||
|
previewCodegen(row.id).then(response => {
|
||||||
|
this.preview.data = response.data;
|
||||||
|
this.preview.activeName = response.data[0].filePath;
|
||||||
|
this.preview.open = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 高亮显示 */
|
||||||
|
highlightedCode(item) {
|
||||||
|
// const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
|
||||||
|
// var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
||||||
|
var language = item.filePath.substring(item.filePath.lastIndexOf(".") + 1);
|
||||||
|
const result = hljs.highlight(language, item.code || "", true);
|
||||||
|
return result.value || ' ';
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleEditTable(row) {
|
||||||
|
const tableId = row.id;
|
||||||
|
this.$router.push("/codegen/edit/" + tableId);
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const tableIds = row.id;
|
||||||
|
this.$confirm('是否确认删除表名称为"' + row.tableName + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return deleteCodegen(tableIds);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.importSQL.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.importSQL.form = {
|
||||||
|
tableId: undefined,
|
||||||
|
sql: undefined,
|
||||||
|
};
|
||||||
|
this.resetForm("importSQLForm");
|
||||||
|
},
|
||||||
|
// 提交 import SQL 表单
|
||||||
|
submitImportSQLForm() {
|
||||||
|
this.$refs["importSQLForm"].validate(valid => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 修改的提交
|
||||||
|
let form = this.importSQL.form;
|
||||||
|
if (form.tableId != null) {
|
||||||
|
syncCodegenFromSQL(form.tableId, form.sql).then(response => {
|
||||||
|
this.msgSuccess("同步成功");
|
||||||
|
this.importSQL.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 添加的提交
|
||||||
|
createCodegenListFromSQL(form).then(response => {
|
||||||
|
this.msgSuccess("导入成功");
|
||||||
|
this.importSQL.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue