优化代码生成

This commit is contained in:
不做码农 2022-01-05 17:38:06 +08:00
parent 3f0357fe77
commit 9eda5bb74f
7 changed files with 21 additions and 24 deletions

View File

@ -80,6 +80,7 @@ $end
return SUCCESS(response);
}
$if(replaceDto.ShowBtnAdd)
/// <summary>
/// 添加${genTable.FunctionName}
/// </summary>
@ -106,7 +107,9 @@ ${end}
});
return ToResponse(response);
}
$end
$if(replaceDto.ShowBtnEdit)
/// <summary>
/// 更新${genTable.FunctionName}
/// </summary>
@ -135,7 +138,9 @@ ${end}
return ToResponse(response);
}
$end
$if(replaceDto.ShowBtnDelete)
/// <summary>
/// 删除${genTable.FunctionName}
/// </summary>
@ -152,6 +157,7 @@ ${end}
return ToResponse(response);
}
$end
$if(replaceDto.ShowBtnExport)
/// <summary>

View File

@ -34,7 +34,7 @@ ${VueViewListContent}
<el-table-column label="操作" align="center" width="140">
<template slot-scope="scope">
<el-button size="mini" v-hasPermi="['${replaceDto.PermissionPrefix}:edit']" type="success" icon="el-icon-edit" title="编辑"
@click="handleUpdate(scope.row)"></el-button>
@click="handleUpdate(scope.row)"></el-button>
<el-button size="mini" v-hasPermi="['${replaceDto.PermissionPrefix}:delete']" type="danger" icon="el-icon-delete" title="删除"
@click="handleDelete(scope.row)"></el-button>
</template>

View File

@ -46,10 +46,10 @@ namespace ZR.CodeGenerator
replaceDto.ModelTypeName = dto.GenTable.ClassName;//表名对应C# 实体类名
replaceDto.PermissionPrefix = $"{dto.GenTable.ModuleName.ToLower()}:{dto.GenTable.ClassName.ToLower()}";//权限
replaceDto.Author = dto.GenTable.FunctionAuthor;
replaceDto.ShowBtnAdd = dto.CheckedBtn.Any(f => f == 1);
replaceDto.ShowBtnEdit = dto.CheckedBtn.Any(f => f == 2);
replaceDto.ShowBtnDelete = dto.CheckedBtn.Any(f => f == 3);
replaceDto.ShowBtnExport = dto.CheckedBtn.Any(f => f == 4);
replaceDto.ShowBtnAdd = dto.GenTable.CheckedBtn.Any(f => f == 1);
replaceDto.ShowBtnEdit = dto.GenTable.CheckedBtn.Any(f => f == 2);
replaceDto.ShowBtnDelete = dto.GenTable.CheckedBtn.Any(f => f == 3);
replaceDto.ShowBtnExport = dto.GenTable.CheckedBtn.Any(f => f == 4);
//循环表字段信息
foreach (GenTableColumn dbFieldInfo in dto.GenTable.Columns.OrderBy(x => x.Sort))

View File

@ -1,13 +1,8 @@
using JinianNet.JNTemplate;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using ZR.CodeGenerator.Model;
namespace ZR.CodeGenerator
{

View File

@ -41,7 +41,7 @@ namespace ZR.CodeGenerator.Model
/// 生成代码方式0zip压缩包 1自定义路径
/// </summary>
public string GenType { get; set; }
public string GenPath { get; set; } = "/";
public string GenPath { get; set; } = "";
#endregion
}

View File

@ -127,13 +127,13 @@
<el-col :lg="24">
<el-form-item label="显示按钮">
<el-checkbox-group v-model="checkedBtn" @change="checkedBtnSelect">
<el-checkbox :label="1" disabled>
<el-checkbox :label="1">
<el-tag type="primary">添加</el-tag>
</el-checkbox>
<el-checkbox :label="2" disabled>
<el-checkbox :label="2">
<el-tag type="success">修改</el-tag>
</el-checkbox>
<el-checkbox :label="3" disabled>
<el-checkbox :label="3">
<el-tag type="danger">删除</el-tag>
</el-checkbox>
<el-checkbox :label="4">

View File

@ -183,17 +183,13 @@ export default {
codeGenerator(seachdata)
.then((res) => {
const { code, data } = res;
if (code == 200) {
this.showGenerate = false;
if (row.genType === "1") {
this.msgSuccess("成功生成到自定义路径:" + row.genPath);
} else {
this.msgSuccess("恭喜你,代码生成完成!");
this.download(data.path);
}
const { data } = res;
this.showGenerate = false;
if (row.genType === "1") {
this.msgSuccess("成功生成到自定义路径:" + row.genPath);
} else {
this.msgError(res.msg);
this.msgSuccess("恭喜你,代码生成完成!");
this.download(data.path);
}
pageLoading.close();
})