优化代码生成主键、自增字段form表单显示
This commit is contained in:
parent
05aac2fadf
commit
ed703e7770
@ -134,7 +134,7 @@ $end
|
||||
// 表单校验
|
||||
rules: {
|
||||
$foreach(column in genTable.Columns)
|
||||
$if(column.IsRequired)
|
||||
$if(column.IsRequired && column.IsIncrement == false)
|
||||
${column.CsharpFieldFl}: [
|
||||
{ required: true, message: "${column.ColumnComment}不能为空", trigger: $if(column.htmlType == "select")"change"$else"blur"$end
|
||||
$if(column.CsharpType == "int" || column.CsharpType == "long"), type: "number"$end }
|
||||
@ -284,8 +284,8 @@ $if(genTable.SortField != "" && genTable.SortField != null)
|
||||
$end
|
||||
$if(replaceDto.UploadFile == 1)
|
||||
//图片上传成功方法
|
||||
handleUploadSuccess(CsharpFieldFl, filelist) {
|
||||
this.form[CsharpFieldFl] = filelist;
|
||||
handleUploadSuccess(column, filelist) {
|
||||
this.form[column] = filelist;
|
||||
},
|
||||
$end
|
||||
$foreach(item in genTable.Columns)
|
||||
|
||||
@ -30,10 +30,29 @@ namespace ZR.CodeGenerator
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
if (!dbFieldInfo.IsInsert && !dbFieldInfo.IsEdit && !dbFieldInfo.IsPk)
|
||||
if (!dbFieldInfo.IsInsert && !dbFieldInfo.IsEdit && !dbFieldInfo.IsPk && !dbFieldInfo.IsIncrement)
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
//主键、非自增要插入,不能编辑
|
||||
if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
|
||||
{
|
||||
sb.AppendLine(" <el-col :lg=\"12\">");
|
||||
sb.AppendLine($" <el-form-item label=\"{labelName}\" prop=\"{columnName}\">");
|
||||
//主键非自增 显示input
|
||||
if (dbFieldInfo.IsPk && !dbFieldInfo.IsIncrement)
|
||||
{
|
||||
sb.AppendLine($" <el-input-number v-model.number=\"form.{columnName}\" placeholder=\"请输入{labelName}\" :disabled=\"title=='修改数据'\"/>");
|
||||
}
|
||||
else if (dbFieldInfo.IsIncrement) //只有是 自增 就显示label
|
||||
{
|
||||
sb.AppendLine($" <span v-html=\"form.{columnName}\"/>");
|
||||
}
|
||||
|
||||
sb.AppendLine(" </el-form-item>");
|
||||
sb.AppendLine(" </el-col>");
|
||||
return sb.ToString();
|
||||
}
|
||||
if (dbFieldInfo.HtmlType == GenConstants.HTML_INPUT_NUMBER)
|
||||
{
|
||||
//数字框
|
||||
|
||||
@ -275,7 +275,7 @@ namespace ZR.CodeGenerator
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 首字母转大写,输出前端
|
||||
/// 首字母转大写
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
@ -367,6 +367,12 @@ namespace ZR.CodeGenerator
|
||||
return genTableColumns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化表字段数据
|
||||
/// </summary>
|
||||
/// <param name="genTable"></param>
|
||||
/// <param name="column"></param>
|
||||
/// <returns></returns>
|
||||
private static GenTableColumn InitColumnField(GenTable genTable, DbColumnInfo column)
|
||||
{
|
||||
GenTableColumn genTableColumn = new()
|
||||
@ -378,7 +384,7 @@ namespace ZR.CodeGenerator
|
||||
TableId = genTable.TableId,
|
||||
TableName = genTable.TableName,
|
||||
CsharpType = GetCSharpDatatype(column.DataType),
|
||||
CsharpField = column.DbColumnName.Substring(0, 1).ToUpper() + column.DbColumnName[1..],
|
||||
CsharpField = FirstUpperCase(column.DbColumnName),//TODO 优化下划线处理
|
||||
IsRequired = !column.IsNullable,
|
||||
IsIncrement = column.IsIdentity,
|
||||
Create_by = genTable.Create_by,
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="插入" min-width="5%">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.isInsert" :disabled="scope.row.isPk || scope.row.isIncrement"></el-checkbox>
|
||||
<el-checkbox v-model="scope.row.isInsert" :disabled="scope.row.isIncrement"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编辑" min-width="5%">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user