代码生成导入表优化

This commit is contained in:
不做码农 2023-12-19 20:27:11 +08:00
parent 09b6a8fb81
commit 589c707647
6 changed files with 49 additions and 35 deletions

View File

@ -159,7 +159,8 @@ namespace ZR.Admin.WebApi.Controllers
UserName = HttpContext.GetName(), UserName = HttpContext.GetName(),
TableName = table.Name, TableName = table.Name,
Desc = table.Description, Desc = table.Description,
CodeGen = OptionsSetting.CodeGen CodeGen = OptionsSetting.CodeGen,
FrontTpl = dto.FrontTpl,
}; };
GenTable genTable = CodeGeneratorTool.InitTable(initTableDto); GenTable genTable = CodeGeneratorTool.InitTable(initTableDto);

View File

@ -101,7 +101,6 @@
"moduleName": "business", "moduleName": "business",
"author": "admin", "author": "admin",
"tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)", "tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)",
"vuePath": "", //egD:\Work\ZRAdmin-Vue3 "vuePath": "" //egD:\Work\ZRAdmin-Vue3
"frontTpl": 2// 1element ui 2element plus
} }
} }

View File

@ -452,7 +452,7 @@ namespace ZR.CodeGenerator
SortType = "asc", SortType = "asc",
CheckedBtn = new int[] { 1, 2, 3 }, CheckedBtn = new int[] { 1, 2, 3 },
PermissionPrefix = className.ToLower(), PermissionPrefix = className.ToLower(),
FrontTpl = dto.CodeGen.FrontTpl, FrontTpl = dto.FrontTpl
} }
}; };

View File

@ -4,6 +4,7 @@ namespace ZR.CodeGenerator.Model
{ {
public class ImportCodeGenTableDto public class ImportCodeGenTableDto
{ {
public int FrontTpl { get; set; }
public string DbName { get; set; } public string DbName { get; set; }
public List<CodeGenTables> Tables { get; set; } public List<CodeGenTables> Tables { get; set; }
} }

View File

@ -4,6 +4,7 @@ namespace ZR.CodeGenerator.Model
{ {
public class InitTableDto public class InitTableDto
{ {
public int FrontTpl { get; set; }
public string DbName { get; set; } public string DbName { get; set; }
public string UserName { get; set; } public string UserName { get; set; }
public string TableName { get; set; } public string TableName { get; set; }

View File

@ -16,13 +16,26 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row> <el-row>
<el-table ref="table" @row-click="clickRow" :data="dbTableList" highlight-current-row height="300px" @selection-change="handleSelectionChange"> <el-table
ref="table"
@row-click="clickRow"
:data="dbTableList"
highlight-current-row
height="300px"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55"></el-table-column> <el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="name" label="表名" sortable="custom" width="380" /> <el-table-column prop="name" label="表名" sortable="custom" width="380" />
<el-table-column prop="description" label="表描述" /> <el-table-column prop="description" label="表描述" />
</el-table> </el-table>
<pagination background :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total" @pagination="getList" /> <pagination
background
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@pagination="getList"
/>
</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>
@ -32,7 +45,7 @@
</template> </template>
<script> <script>
import { listDbTable, importTable, codeGetDBList } from "@/api/tool/gen"; import { listDbTable, importTable, codeGetDBList } from '@/api/tool/gen'
export default { export default {
data() { data() {
@ -49,26 +62,24 @@ export default {
dbList: [], dbList: [],
// //
queryParams: { queryParams: {
dbName: "", dbName: '',
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
tableName: undefined, tableName: undefined,
}, },
rules: { rules: {
dbName: [ dbName: [{ required: true, message: '请选择数据库名称', trigger: 'blur' }],
{ required: true, message: "请选择数据库名称", trigger: "blur" },
]
}, },
}; }
}, },
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) {
@ -77,44 +88,45 @@ export default {
// //
getList() { getList() {
codeGetDBList().then((res) => { codeGetDBList().then((res) => {
const { dbList } = res.data; const { dbList } = res.data
this.dbList = dbList; this.dbList = dbList
}); })
if (this.queryParams.dbName !== "") { if (this.queryParams.dbName !== '') {
listDbTable(this.queryParams).then((res) => { listDbTable(this.queryParams).then((res) => {
this.dbTableList = res.data.result; this.dbTableList = res.data.result
this.total = res.data.totalNum; this.total = res.data.totalNum
}); })
} }
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm('queryForm')
this.handleQuery(); this.handleQuery()
}, },
handleShowTable() { handleShowTable() {
this.handleQuery(); this.handleQuery()
}, },
/** 导入按钮操作 */ /** 导入按钮操作 */
handleImportTable() { handleImportTable() {
console.log(JSON.stringify(this.tables)); console.log(JSON.stringify(this.tables))
importTable({ importTable({
tables: this.tables, tables: this.tables,
dbName: this.queryParams.dbName, dbName: this.queryParams.dbName,
frontTpl: 1,
}).then((res) => { }).then((res) => {
this.msgSuccess(res.msg); this.msgSuccess(res.msg)
if (res.code === 200) { if (res.code === 200) {
this.visible = false; this.visible = false
this.$emit("ok"); this.$emit('ok')
} }
}); })
}, },
}, },
}; }
</script> </script>