代码生成新增权限可配置

This commit is contained in:
不做码农 2022-04-10 12:38:26 +08:00
parent 6b5ceafcdf
commit 3eafab8292
7 changed files with 237 additions and 210 deletions

View File

@ -44,7 +44,7 @@ namespace ZR.CodeGenerator
string PKType = "int"; string PKType = "int";
ReplaceDto replaceDto = new(); ReplaceDto replaceDto = new();
replaceDto.ModelTypeName = dto.GenTable.ClassName;//表名对应C# 实体类名 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.Author = dto.GenTable.FunctionAuthor;
replaceDto.ShowBtnAdd = dto.GenTable.CheckedBtn.Any(f => f == 1); replaceDto.ShowBtnAdd = dto.GenTable.CheckedBtn.Any(f => f == 1);
replaceDto.ShowBtnEdit = dto.GenTable.CheckedBtn.Any(f => f == 2); replaceDto.ShowBtnEdit = dto.GenTable.CheckedBtn.Any(f => f == 2);

View File

@ -21,6 +21,7 @@ namespace ZR.Model.System.Dto
public string FunctionAuthor { get; set; } public string FunctionAuthor { get; set; }
public string GenType { get; set; } public string GenType { get; set; }
public string GenPath { get; set; } public string GenPath { get; set; }
public string PermissionPrefix { get; set; }
/// <summary> /// <summary>
/// 额外参数 /// 额外参数
/// </summary> /// </summary>
@ -44,6 +45,7 @@ namespace ZR.Model.System.Dto
/// 额外参数字符串 /// 额外参数字符串
/// </summary> /// </summary>
public string checkedBtn { get; set; } public string checkedBtn { get; set; }
public string permissionPrefix { get; set; }
} }
public class GenTableColumnDto public class GenTableColumnDto
{ {

View File

@ -96,6 +96,8 @@ namespace ZR.Model.System.Generate
[SqlSugar.SugarColumn(IsIgnore = true)] [SqlSugar.SugarColumn(IsIgnore = true)]
public object TreeParentCode { get; set; } public object TreeParentCode { get; set; }
[SqlSugar.SugarColumn(IsIgnore = true)]
public string PermissionPrefix { get; set; }
/// <summary> /// <summary>
/// 生成的按钮功能 /// 生成的按钮功能
/// </summary> /// </summary>

View File

@ -45,7 +45,7 @@ namespace ZR.Service.System
/// <returns></returns> /// <returns></returns>
public int DeleteGenTableByTbName(string tableName) public int DeleteGenTableByTbName(string tableName)
{ {
return GenTableRepository.Delete(f => f.TableName == tableName) ? 1: 0; return GenTableRepository.Delete(f => f.TableName == tableName) ? 1 : 0;
} }
/// <summary> /// <summary>
@ -93,6 +93,14 @@ namespace ZR.Service.System
var checkdBtn = options.GetValueOrDefault("checkedBtn") ?? ""; var checkdBtn = options.GetValueOrDefault("checkedBtn") ?? "";
genTable.CheckedBtn = Tools.SpitIntArrary(checkdBtn.ToString()); 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="genTable"></param>
/// <param name="pagerInfo"></param> /// <param name="pagerInfo"></param>
/// <returns></returns> /// <returns></returns>
public PagedInfo<GenTable> GetGenTables(GenTable genTable, Model.PagerInfo pagerInfo) public PagedInfo<GenTable> GetGenTables(GenTable genTable, PagerInfo pagerInfo)
{ {
var predicate = Expressionable.Create<GenTable>(); var predicate = Expressionable.Create<GenTable>();
predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName)); predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
@ -165,7 +173,7 @@ namespace ZR.Service.System
GenTableColumnService.Insert(insertColumns); GenTableColumnService.Insert(insertColumns);
List<GenTableColumn> delColumns = tableColumns.FindAll(column => !dbTableColumneNames.Contains(column.ColumnName)); 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()); GenTableColumnService.Delete(delColumns.Select(f => f.ColumnId).ToList());
} }

View File

@ -27,7 +27,7 @@
<el-option label="double" value="double" /> <el-option label="double" value="double" />
<el-option label="decimal" value="decimal" /> <el-option label="decimal" value="decimal" />
<el-option label="DateTime" value="DateTime" /> <el-option label="DateTime" value="DateTime" />
<el-option label="bool" value="bool" /> <el-option label="bool" value="bool" />
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
@ -117,25 +117,25 @@
</el-card> </el-card>
</template> </template>
<script> <script>
import { updateGenTable, getGenTable } from "@/api/tool/gen"; import { updateGenTable, getGenTable } from '@/api/tool/gen'
import { listType } from "@/api/system/dict/type"; import { listType } from '@/api/system/dict/type'
import { listMenu as getMenuTreeselect } from "@/api/system/menu"; import { listMenu as getMenuTreeselect } 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: [],
// //
@ -146,43 +146,43 @@ export default {
menus: [], menus: [],
// //
info: {}, info: {},
loading: true, loading: true
}; }
}, },
created() { created() {
this.handleQuery(); this.handleQuery()
}, },
methods: { methods: {
handleQuery() { handleQuery() {
const tableId = this.$route.query && this.$route.query.tableId; const tableId = this.$route.query && this.$route.query.tableId
if (tableId) { if (tableId) {
// //
getGenTable(tableId).then((res) => { getGenTable(tableId).then((res) => {
this.loading = false; this.loading = false
this.columns = res.data.info.columns; this.columns = res.data.info.columns
this.info = res.data.info; this.info = res.data.info
this.tables = res.data.tables; // this.tables = res.data.tables //
}); })
/** 查询字典下拉列表 */ /** 查询字典下拉列表 */
listType({ pageSize: 100 }).then((response) => { listType({ pageSize: 100 }).then((response) => {
this.dictOptions = response.data.result; this.dictOptions = response.data.result
}); })
/** 查询菜单下拉列表 */ /** 查询菜单下拉列表 */
getMenuTreeselect().then((response) => { getMenuTreeselect().then((response) => {
this.menus = this.handleTree(response.data, "menuId"); this.menus = this.handleTree(response.data, 'menuId')
}); })
} }
}, },
/** 提交按钮 */ /** 提交按钮 */
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 = Object.assign({}, basicForm.model, genForm.model); const genTable = Object.assign({}, basicForm.model, genForm.model)
genTable.columns = this.columns; genTable.columns = this.columns
// //
genTable.params = { genTable.params = {
treeCode: genTable.treeCode, treeCode: genTable.treeCode,
@ -192,80 +192,84 @@ export default {
sortField: genTable.sortField, sortField: genTable.sortField,
sortType: genTable.sortType, sortType: genTable.sortType,
checkedBtn: genTable.checkedBtn.toString(), checkedBtn: genTable.checkedBtn.toString(),
}; permissionPrefix: genTable.permissionPrefix
console.log("genForm", genTable); }
console.log('genForm', genTable)
updateGenTable(genTable).then((res) => { updateGenTable(genTable).then((res) => {
this.msgSuccess(res.msg); this.msgSuccess(res.msg)
if (res.code === 200) { if (res.code === 200) {
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() {
const obj = { path: "/tool/gen", query: { t: Date.now(), pageNum: this.$route.query.pageNum } }; const obj = {
this.$tab.closeOpenPage(obj); path: '/tool/gen',
query: { t: Date.now(), pageNum: this.$route.query.pageNum }
}
this.$tab.closeOpenPage(obj)
}, },
/** /**
* 排序保存 * 排序保存
*/ */
sortTable(columns) { sortTable(columns) {
const el = this.$refs.dragTable.$el.querySelectorAll( const el = this.$refs.dragTable.$el.querySelectorAll(
".el-table__body-wrapper > table > tbody" '.el-table__body-wrapper > table > tbody'
)[0]; )[0]
var that = this; var that = this
const sortable = Sortable.create(el, { const sortable = Sortable.create(el, {
handle: ".allowDrag", handle: '.allowDrag',
onEnd: (evt) => { onEnd: (evt) => {
const targetRow = that.columns.splice(evt.oldIndex, 1)[0]; const targetRow = that.columns.splice(evt.oldIndex, 1)[0]
columns.splice(evt.newIndex, 0, targetRow); columns.splice(evt.newIndex, 0, targetRow)
for (let index in columns) { for (const index in columns) {
columns[index].sort = parseInt(index) + 1; columns[index].sort = parseInt(index) + 1
} }
this.$nextTick(() => { this.$nextTick(() => {
this.columns = columns; this.columns = columns
}); })
}, }
}); })
}, },
/** /**
* 回车到下一行 * 回车到下一行
*/ */
nextFocus(row, index, e) { nextFocus(row, index, e) {
// const val = e.target.value; // const val = e.target.value;
var keyCode = e.keyCode || e.which || e.charCode; var keyCode = e.keyCode || e.which || e.charCode
if (keyCode === 13) { if (keyCode === 13) {
this.$refs[row.columnId].blur(); this.$refs[row.columnId].blur()
if (Object.keys(this.$refs).length - 1 === index) { 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) { if (num > 0) {
this.$refs[num].focus(); this.$refs[num].focus()
} else { } else {
console.warn("最后一行了"); console.warn('最后一行了')
} }
} }
}, }
}, },
watch: { watch: {
columns: { columns: {
handler(val) { handler(val) {
this.sortTable(val); this.sortTable(val)
}, }
}, }
}, }
}; }
</script> </script>

View File

@ -75,11 +75,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
<el-form-item> <el-form-item label="查询排序字段">
<span slot="label">
查询排序字段
</span>
<el-select v-model="info.sortField" placeholder="请选择字段" class="mr10" clearable=""> <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 v-for="item in columns" :key="item.columnId" :label="item.csharpField" :value="item.csharpField">
</el-option> </el-option>
@ -89,7 +85,17 @@
<el-radio v-model="info.sortType" label="desc">倒序</el-radio> <el-radio v-model="info.sortType" label="desc">倒序</el-radio>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :lg="12">
<el-form-item prop="permissionPrefix">
<span slot="label">
权限前缀
<el-tooltip content="egsystem: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-col :lg="12">
<el-form-item prop="genType"> <el-form-item prop="genType">
<span slot="label"> <span slot="label">
@ -224,32 +230,32 @@
</el-form> </el-form>
</template> </template>
<script> <script>
import { queryColumnInfo } from "@/api/tool/gen"; import { queryColumnInfo } from '@/api/tool/gen'
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from '@riophae/vue-treeselect'
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default { export default {
name: "BasicInfoForm", name: 'BasicInfoForm',
components: { Treeselect }, components: { Treeselect },
props: { props: {
info: { info: {
type: Object, type: Object,
default: null, default: null
}, },
// //
tables: { tables: {
type: Array, type: Array,
default: null, default: null
}, },
menus: { menus: {
type: Array, type: Array,
default: [], default: []
}, },
// //
columns: { columns: {
type: Array, type: Array,
default: [], default: []
}, }
}, },
data() { data() {
return { return {
@ -257,82 +263,87 @@ export default {
subColumns: [], subColumns: [],
rules: { rules: {
tplCategory: [ tplCategory: [
{ required: true, message: "请选择生成模板", trigger: "blur" }, { required: true, message: '请选择生成模板', trigger: 'blur' }
], ],
moduleName: [ moduleName: [
{ {
required: true, required: true,
message: "请输入生成模块名", message: '请输入生成模块名',
trigger: "blur", trigger: 'blur',
pattern: /^[A-Za-z]+$/, pattern: /^[A-Za-z]+$/
}, }
], ],
businessName: [ businessName: [
{ {
required: true, required: true,
message: "请输入生成业务名", message: '请输入生成业务名',
trigger: "blur", trigger: 'blur',
pattern: /^[A-Za-z]+$/, pattern: /^[A-Za-z]+$/
}, }
], ],
functionName: [ functionName: [
{ required: true, message: "请输入生成功能名", trigger: "blur" }, { required: true, message: '请输入生成功能名', trigger: 'blur' }
], ],
}, permissionPrefix: {
}; required: true,
message: '请输入权限前缀',
trigger: 'blur'
}
}
}
}, },
watch: { watch: {
"info.subTableName": function (val) { 'info.subTableName': function(val) {
this.setSubTableColumns(val); this.setSubTableColumns(val)
},
"info.checkedBtn": function (val) {
console.log(val + ',checkedBtn');
this.checkedBtn = val;
}, },
'info.checkedBtn': function(val) {
console.log(val + ',checkedBtn')
this.checkedBtn = val
}
}, },
methods: { methods: {
/** 转换菜单数据结构 */ /** 转换菜单数据结构 */
normalizer(node) { normalizer(node) {
if (node.children && !node.children.length) { if (node.children && !node.children.length) {
delete node.children; delete node.children
} }
return { return {
id: node.menuId, id: node.menuId,
label: node.menuName, label: node.menuName,
children: node.children, children: node.children
}; }
}, },
/** 选择子表名触发 */ /** 选择子表名触发 */
subSelectChange(value) { subSelectChange(value) {
this.info.subTableFkName = ""; this.info.subTableFkName = ''
},
checkedBtnSelect(value) {
this.info.checkedBtn = value
}, },
checkedBtnSelect(value) {
this.info.checkedBtn = value;
},
/** 选择生成模板触发 */ /** 选择生成模板触发 */
tplSelectChange(value) { tplSelectChange(value) {
if (value !== "sub") { if (value !== 'sub') {
this.info.subTableName = ""; this.info.subTableName = ''
this.info.subTableFkName = ""; this.info.subTableFkName = ''
} }
}, },
/** 设置关联外键 */ /** 设置关联外键 */
setSubTableColumns(value) { setSubTableColumns(value) {
if (value == null || value == undefined || value == "") { if (value == null || value == undefined || value == '') {
return; return
} }
for (var item in this.tables) { for (var item in this.tables) {
const obj = this.tables[item]; const obj = this.tables[item]
if (value === obj.tableName) { if (value === obj.tableName) {
queryColumnInfo(obj.tableId).then((res) => { queryColumnInfo(obj.tableId).then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.subColumns = res.data.columns; this.subColumns = res.data.columns
} }
}); })
break; break
} }
} }
}, }
}, }
}; }
</script> </script>

View File

@ -68,29 +68,29 @@ import {
listTable, listTable,
delTable, delTable,
previewTable, previewTable,
synchDb, synchDb
} from "@/api/tool/gen"; } from '@/api/tool/gen'
import importTable from "./importTable"; import importTable from './importTable'
import { Loading } from "element-ui"; import { Loading } from 'element-ui'
import hljs from "highlight.js"; import hljs from 'highlight.js'
import "highlight.js/styles/idea.css"; // import 'highlight.js/styles/idea.css' //
export default { export default {
name: "gen", name: 'gen',
components: { importTable, hljs }, components: { importTable, hljs },
data() { data() {
return { return {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 20, pageSize: 20,
tableName: "", tableName: ''
}, },
// //
preview: { preview: {
open: false, open: false,
title: "代码预览", title: '代码预览',
data: {}, data: {},
activeName: "0", activeName: '0'
}, },
showGenerate: false, showGenerate: false,
rules: {}, rules: {},
@ -103,169 +103,169 @@ export default {
currentSelected: {}, currentSelected: {},
// //
checkedQueryColumn: [], checkedQueryColumn: [],
// //
coverd: true, coverd: true,
// SQL
dbType: 1,
// //
tableIds: [], tableIds: [],
// //
multiple: true, multiple: true
}; }
}, },
created() { created() {
this.handleSearch(); this.handleSearch()
}, },
methods: { methods: {
/** /**
* 点击查询 * 点击查询
*/ */
handleSearch() { handleSearch() {
this.tableloading = true; this.tableloading = true
listTable(this.queryParams).then((res) => { listTable(this.queryParams).then((res) => {
this.tableData = res.data.result; this.tableData = res.data.result
this.total = res.data.totalNum; this.total = res.data.totalNum
this.tableloading = false; this.tableloading = false
}); })
}, },
/** /**
* 编辑表格 * 编辑表格
*/ */
handleEditTable(row) { handleEditTable(row) {
this.queryParams.tableName = row.tableName; this.queryParams.tableName = row.tableName
this.handleSearch(); this.handleSearch()
this.$router.push({ this.$router.push({
path: "/gen/editTable", path: '/gen/editTable',
query: { tableId: row.tableId }, query: { tableId: row.tableId }
}); })
}, },
// //
handlePreview(row) { handlePreview(row) {
this.$refs["codeform"].validate((valid) => { this.$refs['codeform'].validate((valid) => {
if (!valid) { if (!valid) {
this.msgError("请先完成表格"); this.msgError('请先完成表格')
return; return
} }
this.$modal.loading('请稍后...')
previewTable(row.tableId).then((res) => { previewTable(row.tableId).then((res) => {
if (res.code === 200) { if (res.code === 200) {
this.showGenerate = false; this.showGenerate = false
this.preview.open = true; this.preview.open = true
this.preview.data = res.data; this.preview.data = res.data
this.$modal.closeLoading()
} }
}); })
}); })
}, },
/** /**
* 点击生成服务端代码 * 点击生成服务端代码
*/ */
handleGenTable(row) { handleGenTable(row) {
this.currentSelected = row; this.currentSelected = row
if (!this.currentSelected) { if (!this.currentSelected) {
this.msgError("请先选择要生成代码的数据表"); this.msgError('请先选择要生成代码的数据表')
return false; return false
} }
this.$refs["codeform"].validate((valid) => { this.$refs['codeform'].validate((valid) => {
if (valid) { if (valid) {
var loadop = { var loadop = {
lock: true, lock: true,
text: "正在生成代码...", text: '正在生成代码...',
spinner: "el-icon-loading", spinner: 'el-icon-loading',
background: "rgba(0, 0, 0, 0.7)", background: 'rgba(0, 0, 0, 0.7)'
}; }
const pageLoading = Loading.service(loadop); const pageLoading = Loading.service(loadop)
var seachdata = { var seachdata = {
tableId: this.currentSelected.tableId, tableId: this.currentSelected.tableId,
tableName: this.currentSelected.name, tableName: this.currentSelected.name
// queryColumn: this.checkedQueryColumn, // queryColumn: this.checkedQueryColumn,
}; }
codeGenerator(seachdata) codeGenerator(seachdata)
.then((res) => { .then((res) => {
const { data } = res; const { data } = res
this.showGenerate = false; this.showGenerate = false
if (row.genType === "1") { if (row.genType === '1') {
this.msgSuccess("成功生成到自定义路径:" + row.genPath); this.msgSuccess('成功生成到自定义路径')
} else { } else {
this.msgSuccess("恭喜你,代码生成完成!"); this.msgSuccess('恭喜你,代码生成完成!')
this.download(data.path); this.download(data.path)
} }
pageLoading.close(); pageLoading.close()
}) })
.catch((erre) => { .catch((erre) => {
pageLoading.close(); pageLoading.close()
}); })
} else { } else {
return false; return false
} }
}); })
}, },
cancel() { cancel() {
this.showGenerate = false; this.showGenerate = false
this.currentSelected = {}; this.currentSelected = {}
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryParams"); this.resetForm('queryParams')
this.handleSearch(); this.handleSearch()
}, },
/** 打开导入表弹窗 */ /** 打开导入表弹窗 */
openImportTable() { openImportTable() {
this.$refs.import.show(); this.$refs.import.show()
}, },
handleDelete(row) { handleDelete(row) {
const tableIds = row.tableId || this.tableIds; const tableIds = row.tableId || this.tableIds
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", { this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: "确定", confirmButtonText: '确定',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning", type: 'warning'
}) })
.then(() => { .then(() => {
delTable(tableIds.toString()).then((res) => { delTable(tableIds.toString()).then((res) => {
if (res.code == 200) { if (res.code == 200) {
this.msgSuccess("删除成功"); this.msgSuccess('删除成功')
this.handleSearch(); this.handleSearch()
} }
}); })
}) })
.catch(() => { .catch(() => {
this.$message({ this.$message({
type: "info", type: 'info',
message: "已取消删除", message: '已取消删除'
}); })
}); })
}, },
/** 复制代码成功 */ /** 复制代码成功 */
clipboardSuccess() { clipboardSuccess() {
this.msgSuccess("复制成功"); this.msgSuccess('复制成功')
}, },
// //
handleSelectionChange(section) { handleSelectionChange(section) {
this.tableIds = section.map((item) => item.tableId); this.tableIds = section.map((item) => item.tableId)
this.multiple = !section.length; this.multiple = !section.length
console.log(this.tableIds); console.log(this.tableIds)
}, },
/** 高亮显示 */ /** 高亮显示 */
highlightedCode(code, key) { highlightedCode(code, key) {
// var language = key.substring(key.lastIndexOf(".") , key.length) // var language = key.substring(key.lastIndexOf(".") , key.length)
const result = hljs.highlightAuto(code || ""); const result = hljs.highlightAuto(code || '')
return result.value || "&nbsp;"; return result.value || '&nbsp;'
}, },
// //
handleSynchDb(row) { handleSynchDb(row) {
const tableName = row.tableName; const tableName = row.tableName
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?') this.$confirm('确认要强制同步"' + tableName + '"表结构吗?')
.then(function () { .then(function() {
return synchDb(row.tableId, { tableName, dbName: row.dbName }); return synchDb(row.tableId, { tableName, dbName: row.dbName })
}) })
.then(() => { .then(() => {
this.msgSuccess("同步成功"); this.msgSuccess('同步成功')
}) })
.catch(() => {}); .catch(() => {})
}, }
}, }
}; }
</script> </script>