代码生成导入表优化

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(),
TableName = table.Name,
Desc = table.Description,
CodeGen = OptionsSetting.CodeGen
CodeGen = OptionsSetting.CodeGen,
FrontTpl = dto.FrontTpl,
};
GenTable genTable = CodeGeneratorTool.InitTable(initTableDto);

View File

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

View File

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

View File

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

View File

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

View File

@ -16,13 +16,26 @@
</el-form-item>
</el-form>
<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 prop="name" label="表名" sortable="custom" width="380" />
<el-table-column prop="description" label="表描述" />
</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>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleImportTable"> </el-button>
@ -32,7 +45,7 @@
</template>
<script>
import { listDbTable, importTable, codeGetDBList } from "@/api/tool/gen";
import { listDbTable, importTable, codeGetDBList } from '@/api/tool/gen'
export default {
data() {
@ -49,72 +62,71 @@ export default {
dbList: [],
//
queryParams: {
dbName: "",
dbName: '',
pageNum: 1,
pageSize: 10,
tableName: undefined,
},
rules: {
dbName: [
{ required: true, message: "请选择数据库名称", trigger: "blur" },
]
dbName: [{ required: true, message: '请选择数据库名称', trigger: 'blur' }],
},
};
}
},
methods: {
//
show() {
this.getList();
this.visible = true;
this.getList()
this.visible = true
},
clickRow(row) {
this.$refs.table.toggleRowSelection(row);
this.$refs.table.toggleRowSelection(row)
},
//
handleSelectionChange(selection) {
this.tables = selection//.map((item) => item.name);
this.tables = selection //.map((item) => item.name);
},
//
getList() {
codeGetDBList().then((res) => {
const { dbList } = res.data;
this.dbList = dbList;
});
if (this.queryParams.dbName !== "") {
const { dbList } = res.data
this.dbList = dbList
})
if (this.queryParams.dbName !== '') {
listDbTable(this.queryParams).then((res) => {
this.dbTableList = res.data.result;
this.total = res.data.totalNum;
});
this.dbTableList = res.data.result
this.total = res.data.totalNum
})
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.resetForm('queryForm')
this.handleQuery()
},
handleShowTable() {
this.handleQuery();
this.handleQuery()
},
/** 导入按钮操作 */
handleImportTable() {
console.log(JSON.stringify(this.tables));
console.log(JSON.stringify(this.tables))
importTable({
tables: this.tables,
dbName: this.queryParams.dbName,
frontTpl: 1,
}).then((res) => {
this.msgSuccess(res.msg);
this.msgSuccess(res.msg)
if (res.code === 200) {
this.visible = false;
this.$emit("ok");
this.visible = false
this.$emit('ok')
}
});
})
},
},
};
}
</script>