代码生成新增权限可配置
This commit is contained in:
parent
6b5ceafcdf
commit
3eafab8292
@ -44,7 +44,7 @@ namespace ZR.CodeGenerator
|
||||
string PKType = "int";
|
||||
ReplaceDto replaceDto = new();
|
||||
replaceDto.ModelTypeName = dto.GenTable.ClassName;//表名对应C# 实体类名
|
||||
replaceDto.PermissionPrefix = $"{dto.GenTable.ModuleName.ToLower()}:{dto.GenTable.ClassName.ToLower()}";//权限
|
||||
replaceDto.PermissionPrefix = dto.GenTable.PermissionPrefix;
|
||||
replaceDto.Author = dto.GenTable.FunctionAuthor;
|
||||
replaceDto.ShowBtnAdd = dto.GenTable.CheckedBtn.Any(f => f == 1);
|
||||
replaceDto.ShowBtnEdit = dto.GenTable.CheckedBtn.Any(f => f == 2);
|
||||
|
||||
@ -21,6 +21,7 @@ namespace ZR.Model.System.Dto
|
||||
public string FunctionAuthor { get; set; }
|
||||
public string GenType { get; set; }
|
||||
public string GenPath { get; set; }
|
||||
public string PermissionPrefix { get; set; }
|
||||
/// <summary>
|
||||
/// 额外参数
|
||||
/// </summary>
|
||||
@ -44,6 +45,7 @@ namespace ZR.Model.System.Dto
|
||||
/// 额外参数字符串
|
||||
/// </summary>
|
||||
public string checkedBtn { get; set; }
|
||||
public string permissionPrefix { get; set; }
|
||||
}
|
||||
public class GenTableColumnDto
|
||||
{
|
||||
|
||||
@ -96,6 +96,8 @@ namespace ZR.Model.System.Generate
|
||||
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
public object TreeParentCode { get; set; }
|
||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
public string PermissionPrefix { get; set; }
|
||||
/// <summary>
|
||||
/// 生成的按钮功能
|
||||
/// </summary>
|
||||
|
||||
@ -45,7 +45,7 @@ namespace ZR.Service.System
|
||||
/// <returns></returns>
|
||||
public int DeleteGenTableByTbName(string tableName)
|
||||
{
|
||||
return GenTableRepository.Delete(f => f.TableName == tableName) ? 1: 0;
|
||||
return GenTableRepository.Delete(f => f.TableName == tableName) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -83,16 +83,24 @@ namespace ZR.Service.System
|
||||
if (options == null) return;
|
||||
|
||||
genTable.ParentMenuId = options.GetValueOrDefault("parentMenuId") ?? null;
|
||||
|
||||
|
||||
genTable.SortType = options.GetValueOrDefault("sortType") ?? "asc";
|
||||
genTable.SortField = options.GetValueOrDefault("sortField") ?? "";
|
||||
|
||||
genTable.TreeParentCode = options.GetValueOrDefault("treeParentCode") ?? "";
|
||||
genTable.TreeName = options.GetValueOrDefault("treeName") ?? "";
|
||||
genTable.TreeCode = options.GetValueOrDefault("treeCode") ?? "";
|
||||
|
||||
|
||||
var checkdBtn = options.GetValueOrDefault("checkedBtn") ?? "";
|
||||
genTable.CheckedBtn = Tools.SpitIntArrary(checkdBtn.ToString());
|
||||
|
||||
var permPrefix = options.GetValueOrDefault("permissionPrefix", "");
|
||||
|
||||
genTable.PermissionPrefix = permPrefix?.ToString();
|
||||
}
|
||||
if (genTable.PermissionPrefix.IsEmpty())
|
||||
{
|
||||
genTable.PermissionPrefix = $"{genTable.ModuleName.ToLower()}:{genTable.ClassName.ToLower()}";//权限
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,7 +110,7 @@ namespace ZR.Service.System
|
||||
/// <param name="genTable"></param>
|
||||
/// <param name="pagerInfo"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<GenTable> GetGenTables(GenTable genTable, Model.PagerInfo pagerInfo)
|
||||
public PagedInfo<GenTable> GetGenTables(GenTable genTable, PagerInfo pagerInfo)
|
||||
{
|
||||
var predicate = Expressionable.Create<GenTable>();
|
||||
predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
|
||||
@ -165,7 +173,7 @@ namespace ZR.Service.System
|
||||
GenTableColumnService.Insert(insertColumns);
|
||||
|
||||
List<GenTableColumn> delColumns = tableColumns.FindAll(column => !dbTableColumneNames.Contains(column.ColumnName));
|
||||
if (delColumns!= null && delColumns.Count > 0)
|
||||
if (delColumns != null && delColumns.Count > 0)
|
||||
{
|
||||
GenTableColumnService.Delete(delColumns.Select(f => f.ColumnId).ToList());
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<el-option label="double" value="double" />
|
||||
<el-option label="decimal" value="decimal" />
|
||||
<el-option label="DateTime" value="DateTime" />
|
||||
<el-option label="bool" value="bool" />
|
||||
<el-option label="bool" value="bool" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -117,25 +117,25 @@
|
||||
</el-card>
|
||||
</template>
|
||||
<script>
|
||||
import { updateGenTable, getGenTable } from "@/api/tool/gen";
|
||||
import { listType } from "@/api/system/dict/type";
|
||||
import { listMenu as getMenuTreeselect } from "@/api/system/menu";
|
||||
import basicInfoForm from "./basicInfoForm";
|
||||
import genInfoForm from "./genInfoForm";
|
||||
import Sortable from "sortablejs";
|
||||
import { updateGenTable, getGenTable } from '@/api/tool/gen'
|
||||
import { listType } from '@/api/system/dict/type'
|
||||
import { listMenu as getMenuTreeselect } from '@/api/system/menu'
|
||||
import basicInfoForm from './basicInfoForm'
|
||||
import genInfoForm from './genInfoForm'
|
||||
import Sortable from 'sortablejs'
|
||||
|
||||
export default {
|
||||
name: "genedit",
|
||||
name: 'genedit',
|
||||
components: {
|
||||
basicInfoForm,
|
||||
genInfoForm,
|
||||
genInfoForm
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 选中选项卡的 name
|
||||
activeName: "cloum",
|
||||
activeName: 'cloum',
|
||||
// 表格的高度
|
||||
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
||||
tableHeight: document.documentElement.scrollHeight - 245 + 'px',
|
||||
// 表信息
|
||||
tables: [],
|
||||
// 表列信息
|
||||
@ -146,43 +146,43 @@ export default {
|
||||
menus: [],
|
||||
// 表详细信息
|
||||
info: {},
|
||||
loading: true,
|
||||
};
|
||||
loading: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.handleQuery();
|
||||
this.handleQuery()
|
||||
},
|
||||
methods: {
|
||||
handleQuery() {
|
||||
const tableId = this.$route.query && this.$route.query.tableId;
|
||||
const tableId = this.$route.query && this.$route.query.tableId
|
||||
|
||||
if (tableId) {
|
||||
// 获取表详细信息
|
||||
getGenTable(tableId).then((res) => {
|
||||
this.loading = false;
|
||||
this.columns = res.data.info.columns;
|
||||
this.info = res.data.info;
|
||||
this.tables = res.data.tables; //子表
|
||||
});
|
||||
this.loading = false
|
||||
this.columns = res.data.info.columns
|
||||
this.info = res.data.info
|
||||
this.tables = res.data.tables // 子表
|
||||
})
|
||||
/** 查询字典下拉列表 */
|
||||
listType({ pageSize: 100 }).then((response) => {
|
||||
this.dictOptions = response.data.result;
|
||||
});
|
||||
this.dictOptions = response.data.result
|
||||
})
|
||||
/** 查询菜单下拉列表 */
|
||||
getMenuTreeselect().then((response) => {
|
||||
this.menus = this.handleTree(response.data, "menuId");
|
||||
});
|
||||
this.menus = this.handleTree(response.data, 'menuId')
|
||||
})
|
||||
}
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
||||
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
||||
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.every((item) => !!item);
|
||||
const validateResult = res.every((item) => !!item)
|
||||
if (validateResult) {
|
||||
const genTable = Object.assign({}, basicForm.model, genForm.model);
|
||||
genTable.columns = this.columns;
|
||||
const genTable = Object.assign({}, basicForm.model, genForm.model)
|
||||
genTable.columns = this.columns
|
||||
// 额外参数拼接
|
||||
genTable.params = {
|
||||
treeCode: genTable.treeCode,
|
||||
@ -192,80 +192,84 @@ export default {
|
||||
sortField: genTable.sortField,
|
||||
sortType: genTable.sortType,
|
||||
checkedBtn: genTable.checkedBtn.toString(),
|
||||
};
|
||||
console.log("genForm", genTable);
|
||||
permissionPrefix: genTable.permissionPrefix
|
||||
}
|
||||
console.log('genForm', genTable)
|
||||
|
||||
updateGenTable(genTable).then((res) => {
|
||||
this.msgSuccess(res.msg);
|
||||
this.msgSuccess(res.msg)
|
||||
if (res.code === 200) {
|
||||
this.close();
|
||||
this.close()
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
this.msgError("表单校验未通过,请重新检查提交内容");
|
||||
this.msgError('表单校验未通过,请重新检查提交内容')
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
getFormPromise(form) {
|
||||
return new Promise((resolve) => {
|
||||
form.validate((res) => {
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
resolve(res)
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 关闭按钮 */
|
||||
close() {
|
||||
const obj = { path: "/tool/gen", query: { t: Date.now(), pageNum: this.$route.query.pageNum } };
|
||||
this.$tab.closeOpenPage(obj);
|
||||
const obj = {
|
||||
path: '/tool/gen',
|
||||
query: { t: Date.now(), pageNum: this.$route.query.pageNum }
|
||||
}
|
||||
this.$tab.closeOpenPage(obj)
|
||||
},
|
||||
/**
|
||||
* 排序保存
|
||||
*/
|
||||
sortTable(columns) {
|
||||
const el = this.$refs.dragTable.$el.querySelectorAll(
|
||||
".el-table__body-wrapper > table > tbody"
|
||||
)[0];
|
||||
var that = this;
|
||||
'.el-table__body-wrapper > table > tbody'
|
||||
)[0]
|
||||
var that = this
|
||||
const sortable = Sortable.create(el, {
|
||||
handle: ".allowDrag",
|
||||
handle: '.allowDrag',
|
||||
onEnd: (evt) => {
|
||||
const targetRow = that.columns.splice(evt.oldIndex, 1)[0];
|
||||
columns.splice(evt.newIndex, 0, targetRow);
|
||||
for (let index in columns) {
|
||||
columns[index].sort = parseInt(index) + 1;
|
||||
const targetRow = that.columns.splice(evt.oldIndex, 1)[0]
|
||||
columns.splice(evt.newIndex, 0, targetRow)
|
||||
for (const index in columns) {
|
||||
columns[index].sort = parseInt(index) + 1
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.columns = columns;
|
||||
});
|
||||
},
|
||||
});
|
||||
this.columns = columns
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 回车到下一行
|
||||
*/
|
||||
nextFocus(row, index, e) {
|
||||
// const val = e.target.value;
|
||||
var keyCode = e.keyCode || e.which || e.charCode;
|
||||
var keyCode = e.keyCode || e.which || e.charCode
|
||||
if (keyCode === 13) {
|
||||
this.$refs[row.columnId].blur();
|
||||
this.$refs[row.columnId].blur()
|
||||
if (Object.keys(this.$refs).length - 1 === index) {
|
||||
index = -1;
|
||||
index = -1
|
||||
}
|
||||
var num = Object.keys(this.$refs)[index + 1];
|
||||
var num = Object.keys(this.$refs)[index + 1]
|
||||
if (num > 0) {
|
||||
this.$refs[num].focus();
|
||||
this.$refs[num].focus()
|
||||
} else {
|
||||
console.warn("最后一行了");
|
||||
console.warn('最后一行了')
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
columns: {
|
||||
handler(val) {
|
||||
this.sortTable(val);
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
this.sortTable(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -75,11 +75,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
查询排序字段
|
||||
</span>
|
||||
|
||||
<el-form-item label="查询排序字段">
|
||||
<el-select v-model="info.sortField" placeholder="请选择字段" class="mr10" clearable="">
|
||||
<el-option v-for="item in columns" :key="item.columnId" :label="item.csharpField" :value="item.csharpField">
|
||||
</el-option>
|
||||
@ -89,7 +85,17 @@
|
||||
<el-radio v-model="info.sortType" label="desc">倒序</el-radio>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :lg="12">
|
||||
<el-form-item prop="permissionPrefix">
|
||||
<span slot="label">
|
||||
权限前缀
|
||||
<el-tooltip content="eg:system:user:add中的'system:user'" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-input v-model="info.permissionPrefix" placeholder="请输入权限前缀"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12">
|
||||
<el-form-item prop="genType">
|
||||
<span slot="label">
|
||||
@ -224,32 +230,32 @@
|
||||
</el-form>
|
||||
</template>
|
||||
<script>
|
||||
import { queryColumnInfo } from "@/api/tool/gen";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import { queryColumnInfo } from '@/api/tool/gen'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
|
||||
export default {
|
||||
name: "BasicInfoForm",
|
||||
name: 'BasicInfoForm',
|
||||
components: { Treeselect },
|
||||
props: {
|
||||
info: {
|
||||
type: Object,
|
||||
default: null,
|
||||
default: null
|
||||
},
|
||||
// 子表
|
||||
tables: {
|
||||
type: Array,
|
||||
default: null,
|
||||
default: null
|
||||
},
|
||||
menus: {
|
||||
type: Array,
|
||||
default: [],
|
||||
default: []
|
||||
},
|
||||
// 列
|
||||
columns: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
default: []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -257,82 +263,87 @@ export default {
|
||||
subColumns: [],
|
||||
rules: {
|
||||
tplCategory: [
|
||||
{ required: true, message: "请选择生成模板", trigger: "blur" },
|
||||
{ required: true, message: '请选择生成模板', trigger: 'blur' }
|
||||
],
|
||||
moduleName: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入生成模块名",
|
||||
trigger: "blur",
|
||||
pattern: /^[A-Za-z]+$/,
|
||||
},
|
||||
message: '请输入生成模块名',
|
||||
trigger: 'blur',
|
||||
pattern: /^[A-Za-z]+$/
|
||||
}
|
||||
],
|
||||
businessName: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入生成业务名",
|
||||
trigger: "blur",
|
||||
pattern: /^[A-Za-z]+$/,
|
||||
},
|
||||
message: '请输入生成业务名',
|
||||
trigger: 'blur',
|
||||
pattern: /^[A-Za-z]+$/
|
||||
}
|
||||
],
|
||||
functionName: [
|
||||
{ required: true, message: "请输入生成功能名", trigger: "blur" },
|
||||
{ required: true, message: '请输入生成功能名', trigger: 'blur' }
|
||||
],
|
||||
},
|
||||
};
|
||||
permissionPrefix: {
|
||||
required: true,
|
||||
message: '请输入权限前缀',
|
||||
trigger: 'blur'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"info.subTableName": function (val) {
|
||||
this.setSubTableColumns(val);
|
||||
},
|
||||
"info.checkedBtn": function (val) {
|
||||
console.log(val + ',checkedBtn');
|
||||
this.checkedBtn = val;
|
||||
'info.subTableName': function(val) {
|
||||
this.setSubTableColumns(val)
|
||||
},
|
||||
'info.checkedBtn': function(val) {
|
||||
console.log(val + ',checkedBtn')
|
||||
this.checkedBtn = val
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 转换菜单数据结构 */
|
||||
normalizer(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
delete node.children;
|
||||
delete node.children
|
||||
}
|
||||
return {
|
||||
id: node.menuId,
|
||||
label: node.menuName,
|
||||
children: node.children,
|
||||
};
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
/** 选择子表名触发 */
|
||||
subSelectChange(value) {
|
||||
this.info.subTableFkName = "";
|
||||
this.info.subTableFkName = ''
|
||||
},
|
||||
checkedBtnSelect(value) {
|
||||
this.info.checkedBtn = value
|
||||
},
|
||||
checkedBtnSelect(value) {
|
||||
this.info.checkedBtn = value;
|
||||
},
|
||||
/** 选择生成模板触发 */
|
||||
tplSelectChange(value) {
|
||||
if (value !== "sub") {
|
||||
this.info.subTableName = "";
|
||||
this.info.subTableFkName = "";
|
||||
if (value !== 'sub') {
|
||||
this.info.subTableName = ''
|
||||
this.info.subTableFkName = ''
|
||||
}
|
||||
},
|
||||
/** 设置关联外键 */
|
||||
setSubTableColumns(value) {
|
||||
if (value == null || value == undefined || value == "") {
|
||||
return;
|
||||
if (value == null || value == undefined || value == '') {
|
||||
return
|
||||
}
|
||||
for (var item in this.tables) {
|
||||
const obj = this.tables[item];
|
||||
const obj = this.tables[item]
|
||||
if (value === obj.tableName) {
|
||||
queryColumnInfo(obj.tableId).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.subColumns = res.data.columns;
|
||||
this.subColumns = res.data.columns
|
||||
}
|
||||
});
|
||||
break;
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -68,29 +68,29 @@ import {
|
||||
listTable,
|
||||
delTable,
|
||||
previewTable,
|
||||
synchDb,
|
||||
} from "@/api/tool/gen";
|
||||
import importTable from "./importTable";
|
||||
import { Loading } from "element-ui";
|
||||
import hljs from "highlight.js";
|
||||
import "highlight.js/styles/idea.css"; //这里有多个样式,自己可以根据需要切换
|
||||
synchDb
|
||||
} from '@/api/tool/gen'
|
||||
import importTable from './importTable'
|
||||
import { Loading } from 'element-ui'
|
||||
import hljs from 'highlight.js'
|
||||
import 'highlight.js/styles/idea.css' // 这里有多个样式,自己可以根据需要切换
|
||||
|
||||
export default {
|
||||
name: "gen",
|
||||
name: 'gen',
|
||||
components: { importTable, hljs },
|
||||
data() {
|
||||
return {
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
tableName: "",
|
||||
tableName: ''
|
||||
},
|
||||
// 预览参数
|
||||
preview: {
|
||||
open: false,
|
||||
title: "代码预览",
|
||||
title: '代码预览',
|
||||
data: {},
|
||||
activeName: "0",
|
||||
activeName: '0'
|
||||
},
|
||||
showGenerate: false,
|
||||
rules: {},
|
||||
@ -103,169 +103,169 @@ export default {
|
||||
currentSelected: {},
|
||||
// 选中的列
|
||||
checkedQueryColumn: [],
|
||||
//是否覆盖原先代码
|
||||
// 是否覆盖原先代码
|
||||
coverd: true,
|
||||
// 生成SQL脚本的数据库类型
|
||||
dbType: 1,
|
||||
// 选中的表
|
||||
tableIds: [],
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
};
|
||||
multiple: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.handleSearch();
|
||||
this.handleSearch()
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 点击查询
|
||||
*/
|
||||
handleSearch() {
|
||||
this.tableloading = true;
|
||||
this.tableloading = true
|
||||
|
||||
listTable(this.queryParams).then((res) => {
|
||||
this.tableData = res.data.result;
|
||||
this.total = res.data.totalNum;
|
||||
this.tableloading = false;
|
||||
});
|
||||
this.tableData = res.data.result
|
||||
this.total = res.data.totalNum
|
||||
this.tableloading = false
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 编辑表格
|
||||
*/
|
||||
handleEditTable(row) {
|
||||
this.queryParams.tableName = row.tableName;
|
||||
this.handleSearch();
|
||||
this.queryParams.tableName = row.tableName
|
||||
this.handleSearch()
|
||||
|
||||
this.$router.push({
|
||||
path: "/gen/editTable",
|
||||
query: { tableId: row.tableId },
|
||||
});
|
||||
path: '/gen/editTable',
|
||||
query: { tableId: row.tableId }
|
||||
})
|
||||
},
|
||||
// 代码预览
|
||||
handlePreview(row) {
|
||||
this.$refs["codeform"].validate((valid) => {
|
||||
this.$refs['codeform'].validate((valid) => {
|
||||
if (!valid) {
|
||||
this.msgError("请先完成表格");
|
||||
return;
|
||||
this.msgError('请先完成表格')
|
||||
return
|
||||
}
|
||||
this.$modal.loading('请稍后...')
|
||||
previewTable(row.tableId).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.showGenerate = false;
|
||||
this.preview.open = true;
|
||||
this.preview.data = res.data;
|
||||
this.showGenerate = false
|
||||
this.preview.open = true
|
||||
this.preview.data = res.data
|
||||
this.$modal.closeLoading()
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 点击生成服务端代码
|
||||
*/
|
||||
handleGenTable(row) {
|
||||
this.currentSelected = row;
|
||||
this.currentSelected = row
|
||||
if (!this.currentSelected) {
|
||||
this.msgError("请先选择要生成代码的数据表");
|
||||
return false;
|
||||
this.msgError('请先选择要生成代码的数据表')
|
||||
return false
|
||||
}
|
||||
this.$refs["codeform"].validate((valid) => {
|
||||
this.$refs['codeform'].validate((valid) => {
|
||||
if (valid) {
|
||||
var loadop = {
|
||||
lock: true,
|
||||
text: "正在生成代码...",
|
||||
spinner: "el-icon-loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
};
|
||||
const pageLoading = Loading.service(loadop);
|
||||
text: '正在生成代码...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
}
|
||||
const pageLoading = Loading.service(loadop)
|
||||
|
||||
var seachdata = {
|
||||
tableId: this.currentSelected.tableId,
|
||||
tableName: this.currentSelected.name,
|
||||
tableName: this.currentSelected.name
|
||||
// queryColumn: this.checkedQueryColumn,
|
||||
};
|
||||
}
|
||||
|
||||
codeGenerator(seachdata)
|
||||
.then((res) => {
|
||||
const { data } = res;
|
||||
this.showGenerate = false;
|
||||
if (row.genType === "1") {
|
||||
this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
||||
const { data } = res
|
||||
this.showGenerate = false
|
||||
if (row.genType === '1') {
|
||||
this.msgSuccess('成功生成到自定义路径')
|
||||
} else {
|
||||
this.msgSuccess("恭喜你,代码生成完成!");
|
||||
this.download(data.path);
|
||||
this.msgSuccess('恭喜你,代码生成完成!')
|
||||
this.download(data.path)
|
||||
}
|
||||
pageLoading.close();
|
||||
pageLoading.close()
|
||||
})
|
||||
.catch((erre) => {
|
||||
pageLoading.close();
|
||||
});
|
||||
pageLoading.close()
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
cancel() {
|
||||
this.showGenerate = false;
|
||||
this.currentSelected = {};
|
||||
this.showGenerate = false
|
||||
this.currentSelected = {}
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryParams");
|
||||
this.handleSearch();
|
||||
this.resetForm('queryParams')
|
||||
this.handleSearch()
|
||||
},
|
||||
/** 打开导入表弹窗 */
|
||||
openImportTable() {
|
||||
this.$refs.import.show();
|
||||
this.$refs.import.show()
|
||||
},
|
||||
handleDelete(row) {
|
||||
const tableIds = row.tableId || this.tableIds;
|
||||
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
const tableIds = row.tableId || this.tableIds
|
||||
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
delTable(tableIds.toString()).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.msgSuccess("删除成功");
|
||||
this.msgSuccess('删除成功')
|
||||
|
||||
this.handleSearch();
|
||||
this.handleSearch()
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
type: "info",
|
||||
message: "已取消删除",
|
||||
});
|
||||
});
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
})
|
||||
})
|
||||
},
|
||||
/** 复制代码成功 */
|
||||
clipboardSuccess() {
|
||||
this.msgSuccess("复制成功");
|
||||
this.msgSuccess('复制成功')
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(section) {
|
||||
this.tableIds = section.map((item) => item.tableId);
|
||||
this.multiple = !section.length;
|
||||
console.log(this.tableIds);
|
||||
this.tableIds = section.map((item) => item.tableId)
|
||||
this.multiple = !section.length
|
||||
console.log(this.tableIds)
|
||||
},
|
||||
/** 高亮显示 */
|
||||
highlightedCode(code, key) {
|
||||
// var language = key.substring(key.lastIndexOf(".") , key.length)
|
||||
const result = hljs.highlightAuto(code || "");
|
||||
return result.value || " ";
|
||||
const result = hljs.highlightAuto(code || '')
|
||||
return result.value || ' '
|
||||
},
|
||||
// 同步代码
|
||||
handleSynchDb(row) {
|
||||
const tableName = row.tableName;
|
||||
const tableName = row.tableName
|
||||
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?')
|
||||
.then(function () {
|
||||
return synchDb(row.tableId, { tableName, dbName: row.dbName });
|
||||
.then(function() {
|
||||
return synchDb(row.tableId, { tableName, dbName: row.dbName })
|
||||
})
|
||||
.then(() => {
|
||||
this.msgSuccess("同步成功");
|
||||
this.msgSuccess('同步成功')
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
},
|
||||
};
|
||||
.catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user