1536 lines
100 KiB
C#
1536 lines
100 KiB
C#
using JNPF.Common.Const;
|
|
using JNPF.Common.Enums;
|
|
using JNPF.Common.Extension;
|
|
using JNPF.Common.Security;
|
|
using JNPF.FriendlyException;
|
|
using JNPF.Systems.Entitys.Model.DataBase;
|
|
using JNPF.VisualDev.Engine.Model.CodeGen;
|
|
using JNPF.VisualDev.Engine.Security;
|
|
using JNPF.VisualDev.Entitys;
|
|
|
|
namespace JNPF.VisualDev.Engine.CodeGen;
|
|
|
|
/// <summary>
|
|
/// 代码生成方式.
|
|
/// </summary>
|
|
public class CodeGenWay
|
|
{
|
|
/// <summary>
|
|
/// 副表表字段配置.
|
|
/// </summary>
|
|
/// <param name="tableName">表名称.</param>
|
|
/// <param name="dbTableFields">表字段.</param>
|
|
/// <param name="controls">控件列表.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <param name="tableNo">表序号.</param>
|
|
/// <param name="modelType">0-主带副,1-主带子副.</param>
|
|
/// <returns></returns>
|
|
public static CodeGenConfigModel AuxiliaryTableBackEnd(string? tableName, List<DbTableFieldModel> dbTableFields, List<FieldsModel> controls, VisualDevEntity templateEntity, int tableNo, int modelType)
|
|
{
|
|
// 表单数据
|
|
ColumnDesignModel columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
columnDesignModel.searchList = GetMultiEndQueryMerging(templateEntity, controls);
|
|
columnDesignModel.columnList = GetMultiTerminalListDisplayAndConsolidation(templateEntity);
|
|
FormDataModel formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
|
|
|
// 移除乐观锁
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("version"));
|
|
|
|
// 移除真实流程ID
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("flowtaskid"));
|
|
|
|
var tableColumnList = new List<TableColumnConfigModel>();
|
|
foreach (DbTableFieldModel? column in dbTableFields)
|
|
{
|
|
var field = column.field.ReplaceRegex("^f_", string.Empty).ParseToPascalCase().ToLowerCase();
|
|
switch (column.primaryKey)
|
|
{
|
|
case true:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = true,
|
|
IsConversion = false,
|
|
IsSystemControl = false,
|
|
IsAuxiliary = true,
|
|
IsUpdate = false,
|
|
TableNo = tableNo,
|
|
TableName = tableName,
|
|
});
|
|
break;
|
|
default:
|
|
switch (controls.Any(c => c.__vModel__.Equals(string.Format("jnpf_{0}_jnpf_{1}", tableName, field))))
|
|
{
|
|
case true:
|
|
var childControl = string.Empty;
|
|
childControl = string.Format("jnpf_{0}_jnpf_{1}", tableName, field);
|
|
FieldsModel control = controls.Find(c => c.__vModel__.Equals(string.Format("jnpf_{0}_jnpf_{1}", tableName, field)));
|
|
var isImportField = templateEntity.WebType == 1 ? false : columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(childControl));
|
|
switch (control.__config__.jnpfKey)
|
|
{
|
|
case JnpfKeyConst.MODIFYUSER:
|
|
case JnpfKeyConst.CREATEUSER:
|
|
case JnpfKeyConst.CURRORGANIZE:
|
|
case JnpfKeyConst.CURRPOSITION:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsUnique = control.__config__.unique,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsSecondaryTableDateTime(control),
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, "", CodeGenFieldJudgeHelper.IsMultipleColumn(controls, string.Format("jnpf_{0}_jnpf_{1}", tableName, field))),
|
|
IsConversion = modelType == 1 ? CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey) : CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, "", CodeGenFieldJudgeHelper.IsMultipleColumn(controls, string.Format("jnpf_{0}_jnpf_{1}", tableName, field))),
|
|
IsSystemControl = true,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
IsAuxiliary = true,
|
|
TableNo = tableNo,
|
|
TableName = tableName,
|
|
FormatTableName = tableName.ParseToPascalCase(),
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField.ParseToBool(),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
default:
|
|
var dataType = control.__config__.dataType != null ? control.__config__.dataType : null;
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = CodeGenFieldJudgeHelper.IsColumnQueryWhether(searchList: columnDesignModel.searchList, string.Format("jnpf_{0}_jnpf_{1}", tableName, field)),
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, string.Format("jnpf_{0}_jnpf_{1}", tableName, field)),
|
|
IsShow = CodeGenFieldJudgeHelper.IsShowColumn(columnDesignModel.columnList, string.Format("jnpf_{0}_jnpf_{1}", tableName, field)),
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, string.Format("jnpf_{0}_jnpf_{1}", tableName, field)),
|
|
IsUnique = control.__config__.unique,
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsSecondaryTableDateTime(control),
|
|
Format = control.format,
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
ControlsDataType = dataType,
|
|
StaticData = control.__config__.jnpfKey.Equals(JnpfKeyConst.CASCADER) || control.__config__.jnpfKey.Equals(JnpfKeyConst.TREESELECT) ? CodeGenControlsAttributeHelper.ConversionStaticData(control.options.ToJsonString()) : CodeGenControlsAttributeHelper.ConversionStaticData(control.__slot__?.options.ToJsonString()),
|
|
propsUrl = CodeGenControlsAttributeHelper.GetControlsPropsUrl(control.__config__.jnpfKey, dataType, control),
|
|
Label = CodeGenControlsAttributeHelper.GetControlsLabel(control.__config__.jnpfKey, dataType, control),
|
|
Value = CodeGenControlsAttributeHelper.GetControlsValue(control.__config__.jnpfKey, dataType, control),
|
|
Children = CodeGenControlsAttributeHelper.GetControlsChildren(control.__config__.jnpfKey, dataType, control),
|
|
Separator = control.separator,
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, dataType, CodeGenFieldJudgeHelper.IsMultipleColumn(controls, string.Format("jnpf_{0}_jnpf_{1}", tableName, field))),
|
|
IsConversion = modelType == 1 ? CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey) : CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, "", CodeGenFieldJudgeHelper.IsMultipleColumn(controls, string.Format("jnpf_{0}_jnpf_{1}", tableName, field))),
|
|
IsSystemControl = false,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
IsAuxiliary = true,
|
|
TableNo = tableNo,
|
|
TableName = tableName,
|
|
FormatTableName = tableName.ParseToPascalCase(),
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField.ParseToBool(),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
}
|
|
break;
|
|
case false:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
TableName = tableName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = false,
|
|
ForeignKeyField = true,
|
|
IsImportField = false,
|
|
IsSystemControl = false,
|
|
IsAuxiliary = true,
|
|
IsUpdate = false,
|
|
TableNo = tableNo,
|
|
});
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!tableColumnList.Any(t => t.PrimaryKey))
|
|
{
|
|
throw Oops.Oh(ErrorCode.D2104);
|
|
}
|
|
|
|
// 是否存在上传控件.
|
|
bool isUpload = tableColumnList.Any(it => it.PrimaryKey.Equals(false) && it.ForeignKeyField.Equals(false) && (it.jnpfKey.Equals(JnpfKeyConst.UPLOADIMG) || it.jnpfKey.Equals(JnpfKeyConst.UPLOADFZ)));
|
|
|
|
// 是否对象映射
|
|
bool isMapper = CodeGenFieldJudgeHelper.IsChildTableMapper(tableColumnList);
|
|
|
|
return new CodeGenConfigModel()
|
|
{
|
|
NameSpace = formDataModel.areasName,
|
|
BusName = templateEntity.FullName,
|
|
ClassName = formDataModel.className.FirstOrDefault(),
|
|
PrimaryKey = tableColumnList.Find(t => t.PrimaryKey).ColumnName,
|
|
OriginalPrimaryKey = tableColumnList.Find(t => t.PrimaryKey).OriginalColumnName,
|
|
MainTable = tableName.ParseToPascalCase(),
|
|
OriginalMainTableName = tableName,
|
|
TableField = tableColumnList,
|
|
IsUpload = isUpload,
|
|
IsMapper = isMapper,
|
|
WebType = templateEntity.WebType,
|
|
Type = templateEntity.Type,
|
|
PrimaryKeyPolicy = formDataModel.primaryKeyPolicy,
|
|
IsImportData = tableColumnList.Any(it => it.IsImportField.Equals(true)),
|
|
EnableFlow = templateEntity.EnableFlow == 1 ? true : false,
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 子表表字段配置.
|
|
/// </summary>
|
|
/// <param name="tableName">表名称.</param>
|
|
/// <param name="className">功能名称.</param>
|
|
/// <param name="dbTableFields">表字段.</param>
|
|
/// <param name="controls">控件列表.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <param name="controlId">子表控件vModel.</param>
|
|
/// <returns></returns>
|
|
public static CodeGenConfigModel ChildTableBackEnd(string tableName, string className, List<DbTableFieldModel> dbTableFields, List<FieldsModel> controls, VisualDevEntity templateEntity, string controlId)
|
|
{
|
|
// 表单数据
|
|
ColumnDesignModel columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
columnDesignModel.searchList = GetMultiEndQueryMerging(templateEntity, controls);
|
|
columnDesignModel.columnList = GetMultiTerminalListDisplayAndConsolidation(templateEntity);
|
|
FormDataModel formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
|
|
|
// 移除乐观锁
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("version"));
|
|
|
|
// 移除真实流程ID
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("flowtaskid"));
|
|
|
|
var tableColumnList = new List<TableColumnConfigModel>();
|
|
foreach (DbTableFieldModel? column in dbTableFields)
|
|
{
|
|
var field = column.field.ReplaceRegex("^f_", string.Empty).ParseToPascalCase().ToLowerCase();
|
|
switch (column.primaryKey)
|
|
{
|
|
case true:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = true,
|
|
});
|
|
break;
|
|
default:
|
|
switch (controls.Any(c => c.__vModel__ == field))
|
|
{
|
|
case true:
|
|
FieldsModel control = controls.Find(c => c.__vModel__ == field);
|
|
var dataType = control.__config__.dataType != null ? control.__config__.dataType : null;
|
|
var isImportField = templateEntity.WebType == 1 ? false : columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(string.Format("{0}-{1}", controlId, field)));
|
|
var staticData = control.__config__.jnpfKey.Equals(JnpfKeyConst.CASCADER) ? CodeGenControlsAttributeHelper.ConversionStaticData(control.options.ToJsonString()) : CodeGenControlsAttributeHelper.ConversionStaticData(control.__slot__?.options.ToJsonString());
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, string.Format("{0}-{1}", controlId, field)),
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
IsUnique = control.__config__.unique,
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
IsShow = control.isIndexShow,
|
|
ControlsDataType = dataType,
|
|
StaticData = staticData,
|
|
Format = control.format,
|
|
propsUrl = CodeGenControlsAttributeHelper.GetControlsPropsUrl(control.__config__.jnpfKey, dataType, control),
|
|
Label = CodeGenControlsAttributeHelper.GetControlsLabel(control.__config__.jnpfKey, dataType, control),
|
|
Value = CodeGenControlsAttributeHelper.GetControlsValue(control.__config__.jnpfKey, dataType, control),
|
|
Children = CodeGenControlsAttributeHelper.GetControlsChildren(control.__config__.jnpfKey, dataType, control),
|
|
Separator = control.separator,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey),
|
|
ControlLabel = control.__config__.label,
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
IsImportField = isImportField.ParseToBool(),
|
|
ChildControlKey = controlId,
|
|
});
|
|
break;
|
|
case false:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
ForeignKeyField = true,
|
|
IsImportField = false,
|
|
});
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!tableColumnList.Any(t => t.PrimaryKey))
|
|
{
|
|
throw Oops.Oh(ErrorCode.D2104, tableName);
|
|
}
|
|
|
|
// 是否存在上传控件.
|
|
bool isUpload = tableColumnList.Any(it => it.PrimaryKey.Equals(false) && it.ForeignKeyField.Equals(false) && (it.jnpfKey.Equals(JnpfKeyConst.UPLOADIMG) || it.jnpfKey.Equals(JnpfKeyConst.UPLOADFZ)));
|
|
|
|
// 是否对象映射
|
|
bool isMapper = CodeGenFieldJudgeHelper.IsChildTableMapper(tableColumnList);
|
|
|
|
bool isShowSubTableField = tableColumnList.Any(it => it.IsShow.Equals(true));
|
|
|
|
return new CodeGenConfigModel()
|
|
{
|
|
NameSpace = formDataModel.areasName,
|
|
BusName = templateEntity.FullName,
|
|
ClassName = className,
|
|
PrimaryKey = tableColumnList.Find(t => t.PrimaryKey).ColumnName,
|
|
OriginalPrimaryKey = tableColumnList.Find(t => t.PrimaryKey).OriginalColumnName,
|
|
TableField = tableColumnList,
|
|
IsUpload = isUpload,
|
|
IsMapper = isMapper,
|
|
WebType = templateEntity.WebType,
|
|
Type = templateEntity.Type,
|
|
PrimaryKeyPolicy = formDataModel.primaryKeyPolicy,
|
|
IsImportData = tableColumnList.Any(it => it.IsImportField.Equals(true)),
|
|
IsShowSubTableField = isShowSubTableField,
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主表带子表.
|
|
/// </summary>
|
|
/// <param name="tableName">表名称.</param>
|
|
/// <param name="dbTableFields">表字段.</param>
|
|
/// <param name="controls">控件列表.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static CodeGenConfigModel MainBeltBackEnd(string? tableName, List<DbTableFieldModel> dbTableFields, List<FieldsModel> controls, VisualDevEntity templateEntity)
|
|
{
|
|
// 表单数据
|
|
ColumnDesignModel columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
columnDesignModel.searchList = GetMultiEndQueryMerging(templateEntity, controls);
|
|
columnDesignModel.columnList = GetMultiTerminalListDisplayAndConsolidation(templateEntity);
|
|
FormDataModel formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
|
|
|
// 移除乐观锁
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("version"));
|
|
|
|
// 移除真实流程ID
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("flowtaskid"));
|
|
|
|
var table = templateEntity.Tables.ToObject<List<DbTableRelationModel>>();
|
|
|
|
var tableColumnList = new List<TableColumnConfigModel>();
|
|
foreach (DbTableFieldModel? column in dbTableFields)
|
|
{
|
|
var field = column.field.ReplaceRegex("^f_", string.Empty).ParseToPascalCase().ToLowerCase();
|
|
switch (column.primaryKey)
|
|
{
|
|
case true:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = true,
|
|
IsConversion = false,
|
|
IsSystemControl = false,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
default:
|
|
switch (controls.Any(c => c.__vModel__ == field))
|
|
{
|
|
case true:
|
|
FieldsModel control = controls.Find(c => c.__vModel__ == field);
|
|
var childControl = string.Empty;
|
|
var isImportField = templateEntity.WebType == 1 ? false : columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field));
|
|
|
|
switch (control.__config__.jnpfKey)
|
|
{
|
|
case JnpfKeyConst.MODIFYUSER:
|
|
case JnpfKeyConst.CREATEUSER:
|
|
case JnpfKeyConst.CURRORGANIZE:
|
|
case JnpfKeyConst.CURRPOSITION:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsUnique = control.__config__.unique,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, "", CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsSystemControl = true,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField == null ? false : (bool)isImportField,
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
default:
|
|
var dataType = control.__config__.dataType != null ? control.__config__.dataType : null;
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
IsUnique = control.__config__.unique,
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
Format = control.format,
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
ControlsDataType = dataType,
|
|
StaticData = control.__config__.jnpfKey.Equals(JnpfKeyConst.CASCADER) || control.__config__.jnpfKey.Equals(JnpfKeyConst.TREESELECT) ? CodeGenControlsAttributeHelper.ConversionStaticData(control.options.ToJsonString()) : CodeGenControlsAttributeHelper.ConversionStaticData(control.__slot__?.options.ToJsonString()),
|
|
propsUrl = CodeGenControlsAttributeHelper.GetControlsPropsUrl(control.__config__.jnpfKey, dataType, control),
|
|
Label = CodeGenControlsAttributeHelper.GetControlsLabel(control.__config__.jnpfKey, dataType, control),
|
|
Value = CodeGenControlsAttributeHelper.GetControlsValue(control.__config__.jnpfKey, dataType, control),
|
|
Children = CodeGenControlsAttributeHelper.GetControlsChildren(control.__config__.jnpfKey, dataType, control),
|
|
Separator = control.separator,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, dataType, CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsSystemControl = false,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField == null ? false : (bool)isImportField,
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
}
|
|
break;
|
|
case false:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = false,
|
|
IsConversion = false,
|
|
IsSystemControl = false,
|
|
ForeignKeyField = true,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!tableColumnList.Any(t => t.PrimaryKey)) throw Oops.Oh(ErrorCode.D2104);
|
|
|
|
return GetCodeGenConfigModel(formDataModel, columnDesignModel, tableColumnList, controls, tableName, templateEntity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主表带副表.
|
|
/// </summary>
|
|
/// <param name="tableName">表名称.</param>
|
|
/// <param name="dbTableFields">表字段.</param>
|
|
/// <param name="auxiliaryTableColumnList">副表字段配置.</param>
|
|
/// <param name="controls">控件列表.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static CodeGenConfigModel MainBeltViceBackEnd(string? tableName, List<DbTableFieldModel> dbTableFields, List<TableColumnConfigModel> auxiliaryTableColumnList, List<FieldsModel> controls, VisualDevEntity templateEntity)
|
|
{
|
|
// 表单数据
|
|
ColumnDesignModel columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
columnDesignModel.searchList = GetMultiEndQueryMerging(templateEntity, controls);
|
|
columnDesignModel.columnList = GetMultiTerminalListDisplayAndConsolidation(templateEntity);
|
|
FormDataModel formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
|
|
|
// 移除乐观锁
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("version"));
|
|
|
|
// 移除真实流程ID
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("flowtaskid"));
|
|
|
|
var tableColumnList = new List<TableColumnConfigModel>();
|
|
foreach (DbTableFieldModel? column in dbTableFields)
|
|
{
|
|
var field = column.field.ReplaceRegex("^f_", string.Empty).ParseToPascalCase().ToLowerCase();
|
|
switch (column.primaryKey)
|
|
{
|
|
case true:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = true,
|
|
IsConversion = false,
|
|
IsSystemControl = false,
|
|
IsAuxiliary = false,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
default:
|
|
switch (controls.Any(c => c.__vModel__ == field))
|
|
{
|
|
case true:
|
|
FieldsModel control = controls.Find(c => c.__vModel__ == field);
|
|
var isImportField = templateEntity.WebType == 1 ? false : columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field));
|
|
switch (control.__config__.jnpfKey)
|
|
{
|
|
case JnpfKeyConst.MODIFYUSER:
|
|
case JnpfKeyConst.CREATEUSER:
|
|
case JnpfKeyConst.CURRORGANIZE:
|
|
case JnpfKeyConst.CURRPOSITION:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsUnique = control.__config__.unique,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, "", CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, "", CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsSystemControl = true,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
IsAuxiliary = false,
|
|
TableName = tableName,
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField.ParseToBool(),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
default:
|
|
var dataType = control.__config__.dataType != null ? control.__config__.dataType : null;
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
IsUnique = control.__config__.unique,
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
Format = control.format,
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
ControlsDataType = dataType,
|
|
StaticData = control.__config__.jnpfKey.Equals(JnpfKeyConst.CASCADER) || control.__config__.jnpfKey.Equals(JnpfKeyConst.TREESELECT) ? CodeGenControlsAttributeHelper.ConversionStaticData(control.options.ToJsonString()) : CodeGenControlsAttributeHelper.ConversionStaticData(control.__slot__?.options.ToJsonString()),
|
|
propsUrl = CodeGenControlsAttributeHelper.GetControlsPropsUrl(control.__config__.jnpfKey, dataType, control),
|
|
Label = CodeGenControlsAttributeHelper.GetControlsLabel(control.__config__.jnpfKey, dataType, control),
|
|
Value = CodeGenControlsAttributeHelper.GetControlsValue(control.__config__.jnpfKey, dataType, control),
|
|
Children = CodeGenControlsAttributeHelper.GetControlsChildren(control.__config__.jnpfKey, dataType, control),
|
|
Separator = control.separator,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, dataType, CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, dataType, CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsSystemControl = false,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
IsAuxiliary = false,
|
|
TableName = tableName,
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField.ParseToBool(),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
}
|
|
break;
|
|
case false:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = false,
|
|
IsConversion = false,
|
|
IsSystemControl = false,
|
|
IsAuxiliary = false,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!tableColumnList.Any(t => t.PrimaryKey))
|
|
{
|
|
throw Oops.Oh(ErrorCode.D2104);
|
|
}
|
|
|
|
tableColumnList.AddRange(auxiliaryTableColumnList);
|
|
|
|
return GetCodeGenConfigModel(formDataModel, columnDesignModel, tableColumnList, controls, tableName, templateEntity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主表带子副表.
|
|
/// </summary>
|
|
/// <param name="tableName">表名称.</param>
|
|
/// <param name="dbTableFields">表字段.</param>
|
|
/// <param name="auxiliaryTableColumnList">副表字段配置.</param>
|
|
/// <param name="controls">控件列表.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static CodeGenConfigModel PrimarySecondaryBackEnd(string? tableName, List<DbTableFieldModel> dbTableFields, List<TableColumnConfigModel> auxiliaryTableColumnList, List<FieldsModel> controls, VisualDevEntity templateEntity)
|
|
{
|
|
// 表单数据
|
|
ColumnDesignModel columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
columnDesignModel.searchList = GetMultiEndQueryMerging(templateEntity, controls);
|
|
columnDesignModel.columnList = GetMultiTerminalListDisplayAndConsolidation(templateEntity);
|
|
FormDataModel formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
|
|
|
// 移除乐观锁
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("version"));
|
|
|
|
// 移除真实流程ID
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("flowtaskid"));
|
|
|
|
var tableColumnList = new List<TableColumnConfigModel>();
|
|
|
|
foreach (DbTableFieldModel? column in dbTableFields)
|
|
{
|
|
var field = column.field.ReplaceRegex("^f_", string.Empty).ParseToPascalCase().ToLowerCase();
|
|
switch (column.primaryKey)
|
|
{
|
|
case true:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = true,
|
|
IsAuxiliary = false,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
default:
|
|
switch (controls.Any(c => c.__vModel__.Equals(field)))
|
|
{
|
|
case true:
|
|
FieldsModel control = controls.Find(c => c.__vModel__ == field);
|
|
switch (control.__config__.jnpfKey)
|
|
{
|
|
case JnpfKeyConst.MODIFYUSER:
|
|
case JnpfKeyConst.CREATEUSER:
|
|
case JnpfKeyConst.CURRORGANIZE:
|
|
case JnpfKeyConst.CURRPOSITION:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsUnique = control.__config__.unique,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, "", CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsSystemControl = true,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
IsAuxiliary = false,
|
|
TableName = tableName,
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)) == null ? false : (bool)columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
default:
|
|
var dataType = control.__config__.dataType != null ? control.__config__.dataType : null;
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
IsUnique = control.__config__.unique,
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
Format = control.format,
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
ControlsDataType = dataType,
|
|
StaticData = control.__config__.jnpfKey.Equals(JnpfKeyConst.CASCADER) || control.__config__.jnpfKey.Equals(JnpfKeyConst.TREESELECT) ? CodeGenControlsAttributeHelper.ConversionStaticData(control.options.ToJsonString()) : CodeGenControlsAttributeHelper.ConversionStaticData(control.__slot__?.options.ToJsonString()),
|
|
propsUrl = CodeGenControlsAttributeHelper.GetControlsPropsUrl(control.__config__.jnpfKey, dataType, control),
|
|
Label = CodeGenControlsAttributeHelper.GetControlsLabel(control.__config__.jnpfKey, dataType, control),
|
|
Value = CodeGenControlsAttributeHelper.GetControlsValue(control.__config__.jnpfKey, dataType, control),
|
|
Children = CodeGenControlsAttributeHelper.GetControlsChildren(control.__config__.jnpfKey, dataType, control),
|
|
Separator = control.separator,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeContainsChildTableControlIsDataConversion(control.__config__.jnpfKey),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, dataType, CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsSystemControl = false,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
IsAuxiliary = false,
|
|
TableName = tableName,
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)) == null ? false : (bool)columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field)),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
}
|
|
break;
|
|
case false:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = false,
|
|
IsAuxiliary = false,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!tableColumnList.Any(t => t.PrimaryKey)) throw Oops.Oh(ErrorCode.D2104);
|
|
|
|
tableColumnList.AddRange(auxiliaryTableColumnList);
|
|
|
|
return GetCodeGenConfigModel(formDataModel, columnDesignModel, tableColumnList, controls, tableName, templateEntity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单表后端.
|
|
/// </summary>
|
|
/// <param name="tableName">表名称.</param>
|
|
/// <param name="dbTableFields">表字段.</param>
|
|
/// <param name="controls">控件列表.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static CodeGenConfigModel SingleTableBackEnd(string? tableName, List<DbTableFieldModel> dbTableFields, List<FieldsModel> controls, VisualDevEntity templateEntity)
|
|
{
|
|
// 表单数据
|
|
ColumnDesignModel columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
columnDesignModel.searchList = GetMultiEndQueryMerging(templateEntity, controls);
|
|
columnDesignModel.columnList = GetMultiTerminalListDisplayAndConsolidation(templateEntity);
|
|
FormDataModel formDataModel = templateEntity.FormData.ToObject<FormDataModel>();
|
|
var tableColumnList = new List<TableColumnConfigModel>();
|
|
|
|
// 移除乐观锁
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("version"));
|
|
|
|
// 移除真实流程ID
|
|
dbTableFields.RemoveAll(it => it.field.ReplaceRegex("^f_", string.Empty).ToLower().Equals("flowtaskid"));
|
|
|
|
foreach (DbTableFieldModel? column in dbTableFields)
|
|
{
|
|
var field = column.field.ReplaceRegex("^f_", string.Empty).ParseToPascalCase().ToLowerCase();
|
|
switch (column.primaryKey)
|
|
{
|
|
case true:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = true,
|
|
IsConversion = false,
|
|
IsSystemControl = false,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
default:
|
|
// 存在表单内控件
|
|
switch (controls.Any(c => c.__vModel__ == field))
|
|
{
|
|
case true:
|
|
FieldsModel control = controls.Find(c => c.__vModel__ == field);
|
|
bool? isImportField = templateEntity.WebType == 1 ? false : columnDesignModel?.uploaderTemplateJson?.selectKey?.Any(it => it.Equals(field));
|
|
switch (control.__config__.jnpfKey)
|
|
{
|
|
case JnpfKeyConst.MODIFYUSER:
|
|
case JnpfKeyConst.CREATEUSER:
|
|
case JnpfKeyConst.CURRORGANIZE:
|
|
case JnpfKeyConst.CURRPOSITION:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsUnique = control.__config__.unique,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
IsConversion = false,
|
|
IsDetailConversion = false,
|
|
IsSystemControl = true,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField.ParseToBool(),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
default:
|
|
var dataType = control.__config__.dataType != null ? control.__config__.dataType : null;
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = column.primaryKey.ParseToBool(),
|
|
QueryWhether = control.isQueryField,
|
|
QueryType = CodeGenFieldJudgeHelper.ColumnQueryType(searchList: columnDesignModel.searchList, field),
|
|
IsShow = control.isIndexShow,
|
|
IsMultiple = CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field),
|
|
IsUnique = control.__config__.unique,
|
|
jnpfKey = control.__config__.jnpfKey,
|
|
Rule = control.__config__.rule,
|
|
IsDateTime = CodeGenFieldJudgeHelper.IsDateTime(control),
|
|
Format = control.format,
|
|
ActiveTxt = control.activeTxt,
|
|
InactiveTxt = control.inactiveTxt,
|
|
ControlsDataType = dataType,
|
|
StaticData = control.__config__.jnpfKey.Equals(JnpfKeyConst.CASCADER) || control.__config__.jnpfKey.Equals(JnpfKeyConst.TREESELECT) ? CodeGenControlsAttributeHelper.ConversionStaticData(control.options.ToJsonString()) : CodeGenControlsAttributeHelper.ConversionStaticData(control.__slot__?.options.ToJsonString()),
|
|
propsUrl = CodeGenControlsAttributeHelper.GetControlsPropsUrl(control.__config__.jnpfKey, dataType, control),
|
|
Label = CodeGenControlsAttributeHelper.GetControlsLabel(control.__config__.jnpfKey, dataType, control),
|
|
Value = CodeGenControlsAttributeHelper.GetControlsValue(control.__config__.jnpfKey, dataType, control),
|
|
Children = CodeGenControlsAttributeHelper.GetControlsChildren(control.__config__.jnpfKey, dataType, control),
|
|
Separator = control.separator,
|
|
IsConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, dataType, CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsDetailConversion = CodeGenControlsAttributeHelper.JudgeControlIsDataConversion(control.__config__.jnpfKey, dataType, CodeGenFieldJudgeHelper.IsMultipleColumn(controls, field)),
|
|
IsSystemControl = false,
|
|
IsUpdate = CodeGenControlsAttributeHelper.JudgeControlIsSystemControls(control.__config__.jnpfKey),
|
|
ControlLabel = control.__config__.label,
|
|
IsImportField = isImportField.ParseToBool(),
|
|
ImportConfig = CodeGenControlsAttributeHelper.GetImportConfig(control, column.field, tableName),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
});
|
|
break;
|
|
}
|
|
|
|
break;
|
|
case false:
|
|
tableColumnList.Add(new TableColumnConfigModel()
|
|
{
|
|
ColumnName = field.ToUpperCase(),
|
|
OriginalColumnName = column.field,
|
|
ColumnComment = column.fieldName,
|
|
DataType = column.dataType,
|
|
NetType = CodeGenHelper.ConvertDataType(column.dataType),
|
|
PrimaryKey = false,
|
|
IsConversion = false,
|
|
IsSystemControl = false,
|
|
IsUpdate = false,
|
|
});
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!tableColumnList.Any(t => t.PrimaryKey))
|
|
throw Oops.Oh(ErrorCode.D2104);
|
|
|
|
return GetCodeGenConfigModel(formDataModel, columnDesignModel, tableColumnList, controls, tableName, templateEntity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 前端.
|
|
/// </summary>
|
|
/// <param name="logic">生成逻辑;4-pc,5-app.</param>
|
|
/// <param name="formDataModel">表单Json包.</param>
|
|
/// <param name="controls">移除布局控件后的控件列表.</param>
|
|
/// <param name="tableColumns">表字段.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static FrontEndGenConfigModel SingleTableFrontEnd(int logic, FormDataModel formDataModel, List<FieldsModel> controls, List<TableColumnConfigModel> tableColumns, VisualDevEntity templateEntity)
|
|
{
|
|
ColumnDesignModel columnDesignModel = new ColumnDesignModel();
|
|
bool isInlineEditor = false;
|
|
switch (logic)
|
|
{
|
|
case 4:
|
|
columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
isInlineEditor = columnDesignModel.type == 4 ? true : false;
|
|
break;
|
|
case 5:
|
|
ColumnDesignModel pcColumnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
isInlineEditor = pcColumnDesignModel?.type == 4 ? true : false;
|
|
columnDesignModel = templateEntity.AppColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
|
|
// 移动端的分页遵循PC端
|
|
columnDesignModel.hasPage = templateEntity.WebType == 1 ? false : pcColumnDesignModel.hasPage;
|
|
break;
|
|
}
|
|
|
|
switch (templateEntity.Type)
|
|
{
|
|
case 3:
|
|
break;
|
|
default:
|
|
if (templateEntity.WebType != 1)
|
|
controls = CodeGenUnifiedHandlerHelper.UnifiedHandlerFormDataModel(controls, columnDesignModel);
|
|
break;
|
|
}
|
|
|
|
// 联动关系链判断
|
|
controls = CodeGenUnifiedHandlerHelper.LinkageChainJudgment(controls, columnDesignModel);
|
|
|
|
Dictionary<string, List<string>> listQueryControls = CodeGenQueryControlClassificationHelper.ListQueryControl(logic);
|
|
Dictionary<string, List<string>> listColumnControlsType = CodeGenQueryControlClassificationHelper.ListColumnControls();
|
|
|
|
// 表单脚本设计
|
|
var formScriptDesign = CodeGenFormControlDesignHelper.FormScriptDesign("SingleTable", controls, tableColumns, columnDesignModel?.columnList);
|
|
|
|
// 整个表单控件
|
|
var formControlList = CodeGenFormControlDesignHelper.FormControlDesign(formDataModel.fields, controls, formDataModel.gutter, formDataModel.labelWidth, columnDesignModel?.columnList, columnDesignModel.type, logic, true);
|
|
|
|
// 列表控件Option
|
|
var indnxControlOption = CodeGenFormControlDesignHelper.FormControlProps(formDataModel.fields, controls, columnDesignModel, logic, true);
|
|
|
|
// 列表查询字段设计
|
|
var indexSearchFieldDesign = new List<IndexSearchFieldDesignModel>();
|
|
|
|
// 列表顶部按钮
|
|
var indexTopButton = new List<IndexButtonDesign>();
|
|
|
|
// 列表行按钮
|
|
var indexColumnButtonDesign = new List<IndexButtonDesign>();
|
|
|
|
// 列表页列表
|
|
var indexColumnDesign = new List<IndexColumnDesign>();
|
|
|
|
switch (templateEntity.Type)
|
|
{
|
|
case 3:
|
|
break;
|
|
default:
|
|
switch (templateEntity.WebType)
|
|
{
|
|
case 2:
|
|
// 本身查询列表内带有控件全属性 单表不需要匹配表字段
|
|
foreach (var item in columnDesignModel?.searchList)
|
|
{
|
|
// 查询控件分类
|
|
var queryControls = listQueryControls.Where(q => q.Value.Contains(item.__config__.jnpfKey)).FirstOrDefault();
|
|
|
|
var childTableLabel = string.Empty;
|
|
var childControl = item.__vModel__.Split('-');
|
|
|
|
// 是否子表查询
|
|
bool isChildQuery = false;
|
|
|
|
// 表单真实控件
|
|
FieldsModel? column = new FieldsModel();
|
|
if (item.__config__.relationTable != null && !item.__vModel__.IsMatch("_jnpf_"))
|
|
{
|
|
isChildQuery = true;
|
|
column = controls.Find(it => it.__config__.jnpfKey.Equals(JnpfKeyConst.TABLE) && it.__vModel__.Equals(childControl[0]) && it.__config__.children.Any(child => child.__vModel__.Equals(childControl[1])));
|
|
childTableLabel = column.__config__.label + "-";
|
|
column = column.__config__.children.Find(it => it.__vModel__ == childControl[1]);
|
|
}
|
|
else
|
|
{
|
|
column = controls.Find(c => c.__vModel__ == item.__vModel__);
|
|
}
|
|
|
|
indexSearchFieldDesign.Add(new IndexSearchFieldDesignModel()
|
|
{
|
|
OriginalName = string.IsNullOrEmpty(column.superiorVModel) ? column.__vModel__ : string.Format("{0}_{1}", column.superiorVModel, column.__vModel__),
|
|
Name = string.IsNullOrEmpty(column.superiorVModel) ? column.__vModel__ : string.Format("{0}_{1}", column.superiorVModel, column.__vModel__),
|
|
LowerName = column.__vModel__,
|
|
Tag = column.__config__.tag,
|
|
Clearable = item.clearable ? "clearable " : string.Empty,
|
|
Format = column.format,
|
|
ValueFormat = column.valueformat,
|
|
Label = childTableLabel + column.__config__.label,
|
|
IsChildQuery = isChildQuery,
|
|
QueryControlsKey = queryControls.Key != null ? queryControls.Key : null,
|
|
Props = column.__config__.props,
|
|
Index = columnDesignModel.searchList.IndexOf(item),
|
|
Type = column.type,
|
|
ShowAllLevels = column.showalllevels ? "true" : "false",
|
|
Level = column.level,
|
|
SelectType = column.selectType != null ? column.selectType.Equals("custom") ? string.Format("selectType='{0}' ", column.selectType) : string.Format("selectType='all' ") : string.Empty,
|
|
AbleDepIds = column.selectType != null && column.selectType == "custom" ? string.Format(":ableDepIds='{0}_AbleDepIds' ", childControl.Length >= 2 ? string.Format("{0}_{1}", childControl[0], column.__vModel__) : item.__vModel__) : string.Empty,
|
|
AblePosIds = column.selectType != null && column.selectType == "custom" && (column.__config__.jnpfKey.Equals(JnpfKeyConst.USERSELECT) || column.__config__.jnpfKey.Equals(JnpfKeyConst.POSSELECT)) ? string.Format(":ablePosIds='{0}_AblePosIds' ", childControl.Length >= 2 ? string.Format("{0}_{1}", childControl[0], column.__vModel__) : item.__vModel__) : string.Empty,
|
|
AbleUserIds = column.selectType != null && column.selectType == "custom" && column.__config__.jnpfKey.Equals(JnpfKeyConst.USERSELECT) ? string.Format(":ableUserIds='{0}_AbleUserIds' ", childControl.Length >= 2 ? string.Format("{0}_{1}", childControl[0], column.__vModel__) : item.__vModel__) : string.Empty,
|
|
AbleRoleIds = column.selectType != null && column.selectType == "custom" && column.__config__.jnpfKey.Equals(JnpfKeyConst.USERSELECT) ? string.Format(":ableRoleIds='{0}_AbleRoleIds' ", childControl.Length >= 2 ? string.Format("{0}_{1}", childControl[0], column.__vModel__) : item.__vModel__) : string.Empty,
|
|
AbleGroupIds = column.selectType != null && column.selectType == "custom" && column.__config__.jnpfKey.Equals(JnpfKeyConst.USERSELECT) ? string.Format(":ableGroupIds='{0}_AbleGroupIds' ", childControl.Length >= 2 ? string.Format("{0}_{1}", childControl[0], column.__vModel__) : item.__vModel__) : string.Empty,
|
|
AbleIds = column.selectType != null && column.selectType == "custom" && column.__config__.jnpfKey.Equals(JnpfKeyConst.USERSSELECT) ? string.Format(":ableIds='{0}_AbleIds' ", childControl.Length >= 2 ? string.Format("{0}_{1}", childControl[0], column.__vModel__) : item.__vModel__) : string.Empty,
|
|
});
|
|
}
|
|
|
|
// 生成头部按钮信息
|
|
foreach (var item in columnDesignModel?.btnsList)
|
|
{
|
|
indexTopButton.Add(new IndexButtonDesign()
|
|
{
|
|
Type = columnDesignModel.btnsList.IndexOf(item) == 0 ? "primary" : "text",
|
|
Icon = item.icon,
|
|
Method = GetCodeGenIndexButtonHelper.IndexTopButton(item.value),
|
|
Value = item.value,
|
|
Label = item.label
|
|
});
|
|
}
|
|
|
|
// 生成行按钮信息
|
|
foreach (var item in columnDesignModel.columnBtnsList)
|
|
{
|
|
indexColumnButtonDesign.Add(new IndexButtonDesign()
|
|
{
|
|
Type = item.value == "remove" ? "class='JNPF-table-delBtn' " : string.Empty,
|
|
Icon = item.icon,
|
|
Method = GetCodeGenIndexButtonHelper.IndexColumnButton(item.value, tableColumns.Find(it => it.PrimaryKey.Equals(true))?.LowerColumnName, formDataModel.primaryKeyPolicy, templateEntity.EnableFlow == 1 ? true : false, columnDesignModel?.type == 4 ? true : false),
|
|
Value = item.value,
|
|
Label = item.label,
|
|
Disabled = GetCodeGenIndexButtonHelper.WorkflowIndexColumnButton(item.value),
|
|
IsDetail = item.value == "detail" ? true : false
|
|
});
|
|
}
|
|
|
|
List<string> ChildControlField = new List<string>();
|
|
|
|
// 生成列信息
|
|
foreach (var item in columnDesignModel.columnList)
|
|
{
|
|
if (!ChildControlField.Any(it => it == item.__vModel__))
|
|
{
|
|
// 控件对应的控件类型
|
|
var conversion = listColumnControlsType.Where(q => q.Value.Contains(item.jnpfKey)).FirstOrDefault();
|
|
var relationTable = item?.__config__?.relationTable;
|
|
if (relationTable != null && !indexColumnDesign.Any(it => it.TableName == relationTable))
|
|
{
|
|
var childTableAll = columnDesignModel.columnList.FindAll(it => it.__config__.relationTable == relationTable);
|
|
var childTable = controls.Find(it => it.__config__.tableName == relationTable);
|
|
if (childTable.__config__.jnpfKey.Equals(JnpfKeyConst.TABLE))
|
|
{
|
|
var childTableColumnDesign = new List<IndexColumnDesign>();
|
|
foreach (var child in childTableAll)
|
|
{
|
|
var columnControl = childTable.__config__.children.Find(it => it.__vModel__.Equals(child.__vModel__.Split('-')[1]));
|
|
conversion = listColumnControlsType.Where(q => q.Value.Contains(child.jnpfKey)).FirstOrDefault();
|
|
childTableColumnDesign.Add(new IndexColumnDesign()
|
|
{
|
|
TableName = child.__config__.tableName,
|
|
Name = columnControl.__vModel__,
|
|
OptionsName = columnControl.__vModel__,
|
|
LowerName = columnControl.__vModel__,
|
|
jnpfKey = child.jnpfKey,
|
|
Label = columnControl.__config__.label,
|
|
Width = child.width.ToString() == "0" ? "0" : string.Format("{0}", child.width),
|
|
Align = child.align,
|
|
IsAutomatic = conversion.Key == null ? false : true,
|
|
IsSort = child.sortable ? string.Format("sortable='custom' ") : string.Empty,
|
|
IsChildTable = true,
|
|
Format = child.format?.ToLower().Replace(":mm", ":MM"),
|
|
});
|
|
ChildControlField.Add(string.Format("{0}", child.__vModel__));
|
|
}
|
|
|
|
indexColumnDesign.Add(new IndexColumnDesign()
|
|
{
|
|
TableName = relationTable,
|
|
Name = childTable.__vModel__,
|
|
Label = childTable.__config__.label,
|
|
jnpfKey = JnpfKeyConst.TABLE,
|
|
IsChildTable = true,
|
|
ChildTableDesigns = childTableColumnDesign,
|
|
IsAutomatic = childTableColumnDesign.Any(it => it.IsAutomatic),
|
|
Fixed = string.Empty,
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
indexColumnDesign.Add(new IndexColumnDesign()
|
|
{
|
|
TableName = item?.__config__?.tableName,
|
|
Name = item.prop,
|
|
OptionsName = item.prop,
|
|
LowerName = item.prop,
|
|
jnpfKey = item.jnpfKey,
|
|
Label = item.label,
|
|
Width = item.width == null ? string.Empty : string.Format("width='{0}' ", item.width),
|
|
Fixed = columnDesignModel.childTableStyle == 1 ? (item.@fixed == "none" || item.@fixed == null ? string.Empty : string.Format("fixed='{0}' ", item.@fixed)) : string.Empty,
|
|
Align = item.align,
|
|
Format = item.format?.ToLower().Replace(":mm", ":MM"),
|
|
IsAutomatic = conversion.Key == null ? false : true,
|
|
IsSort = item.sortable ? string.Format("sortable='custom' ") : string.Empty,
|
|
IsChildTable = false,
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
var isBatchRemoveDel = indexTopButton.Any(it => it.Value == "batchRemove");
|
|
var isUpload = indexTopButton.Any(it => it.Value == "upload");
|
|
var isDownload = indexTopButton.Any(it => it.Value == "download");
|
|
var isRemoveDel = indexColumnButtonDesign.Any(it => it.Value == "remove");
|
|
var isEdit = indexColumnButtonDesign.Any(it => it.Value == "edit");
|
|
var isDetail = indexColumnButtonDesign.Any(it => it.IsDetail.Equals(true));
|
|
var isSort = columnDesignModel?.columnList?.Any(it => it.sortable) ?? false;
|
|
var isSummary = formScriptDesign.Any(it => it.jnpfKey.Equals("table") && it.ShowSummary.Equals(true));
|
|
var isAdd = indexTopButton.Any(it => it.Value == "add");
|
|
var isTreeRelation = !string.IsNullOrEmpty(columnDesignModel?.treeRelation);
|
|
var isRelationForm = formControlList.Any(it => it.IsRelationForm);
|
|
var isFixed = columnDesignModel.childTableStyle == 1 ? indexColumnDesign.Any(it => it.Fixed.Any()) : false;
|
|
|
|
switch (logic)
|
|
{
|
|
case 4:
|
|
columnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
break;
|
|
case 5:
|
|
ColumnDesignModel pcColumnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel = templateEntity.AppColumnData?.ToObject<ColumnDesignModel>();
|
|
columnDesignModel ??= new ColumnDesignModel();
|
|
|
|
// 移动端的分页遵循PC端
|
|
columnDesignModel.hasPage = templateEntity.WebType == 1 ? false : pcColumnDesignModel.hasPage;
|
|
break;
|
|
}
|
|
|
|
switch (templateEntity.WebType)
|
|
{
|
|
case 1:
|
|
return new FrontEndGenConfigModel()
|
|
{
|
|
NameSpace = formDataModel.areasName,
|
|
ClassName = formDataModel.className.FirstOrDefault(),
|
|
FormRef = formDataModel.formRef,
|
|
FormModel = formDataModel.formModel,
|
|
Size = formDataModel.size,
|
|
LabelPosition = formDataModel.labelPosition,
|
|
LabelWidth = formDataModel.labelWidth,
|
|
FormRules = formDataModel.formRules,
|
|
GeneralWidth = formDataModel.generalWidth,
|
|
FullScreenWidth = formDataModel.fullScreenWidth,
|
|
DrawerWidth = formDataModel.drawerWidth,
|
|
FormStyle = formDataModel.formStyle,
|
|
Type = columnDesignModel.type,
|
|
PrimaryKey = tableColumns?.Find(it => it.PrimaryKey.Equals(true))?.LowerColumnName,
|
|
FormList = formScriptDesign,
|
|
PopupType = formDataModel.popupType,
|
|
OptionsList = indnxControlOption,
|
|
IsRemoveDel = isRemoveDel,
|
|
IsDetail = isDetail,
|
|
IsEdit = isEdit,
|
|
IsAdd = isAdd,
|
|
IsSort = isSort,
|
|
HasPage = columnDesignModel.hasPage,
|
|
FormAllContols = formControlList,
|
|
CancelButtonText = formDataModel.cancelButtonText,
|
|
ConfirmButtonText = formDataModel.confirmButtonText,
|
|
UseBtnPermission = columnDesignModel.useBtnPermission,
|
|
UseColumnPermission = columnDesignModel.useColumnPermission,
|
|
UseFormPermission = columnDesignModel.useFormPermission,
|
|
IsSummary = isSummary,
|
|
PageSize = columnDesignModel.pageSize,
|
|
Sort = columnDesignModel.sort,
|
|
HasPrintBtn = formDataModel.hasPrintBtn,
|
|
PrintButtonText = formDataModel.printButtonText,
|
|
PrintId = formDataModel.printId,
|
|
IsChildDataTransfer = formScriptDesign.Any(it => it.IsDataTransfer.Equals(true)),
|
|
IsChildTableQuery = indexSearchFieldDesign.Any(it => it.IsChildQuery.Equals(true)),
|
|
IsChildTableShow = indexColumnDesign.Any(it => it.IsChildTable.Equals(true)),
|
|
ColumnList = columnDesignModel.columnList.ToJsonString(),
|
|
IsInlineEditor = isInlineEditor,
|
|
IndexDataType = columnDesignModel.type,
|
|
GroupField = columnDesignModel.groupField,
|
|
GroupShowField = columnDesignModel?.columnList?.Where(x => x.__vModel__.ToLower() != columnDesignModel?.groupField?.ToLower()).FirstOrDefault()?.__vModel__,
|
|
PrimaryKeyPolicy = formDataModel.primaryKeyPolicy,
|
|
IsRelationForm = isRelationForm,
|
|
ChildTableStyle = columnDesignModel.childTableStyle,
|
|
};
|
|
break;
|
|
default:
|
|
return new FrontEndGenConfigModel()
|
|
{
|
|
NameSpace = formDataModel.areasName,
|
|
ClassName = formDataModel.className.FirstOrDefault(),
|
|
FormRef = formDataModel.formRef,
|
|
FormModel = formDataModel.formModel,
|
|
Size = formDataModel.size,
|
|
LabelPosition = formDataModel.labelPosition,
|
|
LabelWidth = formDataModel.labelWidth,
|
|
FormRules = formDataModel.formRules,
|
|
GeneralWidth = formDataModel.generalWidth,
|
|
FullScreenWidth = formDataModel.fullScreenWidth,
|
|
DrawerWidth = formDataModel.drawerWidth,
|
|
FormStyle = formDataModel.formStyle,
|
|
Type = columnDesignModel.type,
|
|
TreeRelation = columnDesignModel?.treeRelation?.Replace("-", "_"),
|
|
TreeTitle = columnDesignModel?.treeTitle,
|
|
TreePropsValue = columnDesignModel?.treePropsValue,
|
|
TreeDataSource = columnDesignModel?.treeDataSource,
|
|
TreeDictionary = columnDesignModel?.treeDictionary,
|
|
TreePropsUrl = columnDesignModel?.treePropsUrl,
|
|
TreePropsChildren = columnDesignModel?.treePropsChildren,
|
|
TreePropsLabel = columnDesignModel?.treePropsLabel,
|
|
IsExistQuery = templateEntity.Type == 3 ? false : (bool)columnDesignModel?.searchList?.Any(it => it.prop.Equals(columnDesignModel?.treeRelation)),
|
|
PrimaryKey = tableColumns?.Find(it => it.PrimaryKey.Equals(true))?.LowerColumnName,
|
|
FormList = formScriptDesign,
|
|
PopupType = formDataModel.popupType,
|
|
SearchColumnDesign = indexSearchFieldDesign,
|
|
TopButtonDesign = indexTopButton,
|
|
ColumnButtonDesign = indexColumnButtonDesign,
|
|
ColumnDesign = indexColumnDesign,
|
|
OptionsList = indnxControlOption,
|
|
IsBatchRemoveDel = isBatchRemoveDel,
|
|
IsDownload = isDownload,
|
|
IsRemoveDel = isRemoveDel,
|
|
IsDetail = isDetail,
|
|
IsEdit = isEdit,
|
|
IsAdd = isAdd,
|
|
IsUpload = isUpload,
|
|
IsSort = isSort,
|
|
HasPage = columnDesignModel.hasPage,
|
|
FormAllContols = formControlList,
|
|
CancelButtonText = formDataModel.cancelButtonText,
|
|
ConfirmButtonText = formDataModel.confirmButtonText,
|
|
UseBtnPermission = columnDesignModel.useBtnPermission,
|
|
UseColumnPermission = columnDesignModel.useColumnPermission,
|
|
UseFormPermission = columnDesignModel.useFormPermission,
|
|
IsSummary = isSummary,
|
|
PageSize = columnDesignModel.pageSize,
|
|
Sort = columnDesignModel.sort,
|
|
HasPrintBtn = formDataModel.hasPrintBtn,
|
|
PrintButtonText = formDataModel.printButtonText,
|
|
PrintId = formDataModel.printId,
|
|
IsChildDataTransfer = formScriptDesign.Any(it => it.IsDataTransfer.Equals(true)),
|
|
IsChildTableQuery = indexSearchFieldDesign.Any(it => it.IsChildQuery.Equals(true)),
|
|
IsChildTableShow = indexColumnDesign.Any(it => it.IsChildTable.Equals(true)),
|
|
ColumnList = columnDesignModel.columnList.ToJsonString(),
|
|
HasSuperQuery = columnDesignModel.hasSuperQuery,
|
|
ColumnOptions = columnDesignModel.columnOptions.ToJsonString(),
|
|
IsInlineEditor = isInlineEditor,
|
|
IndexDataType = columnDesignModel.type,
|
|
GroupField = columnDesignModel.groupField,
|
|
GroupShowField = columnDesignModel?.columnList?.Where(x => x.__vModel__.ToLower() != columnDesignModel?.groupField?.ToLower()).FirstOrDefault()?.__vModel__,
|
|
PrimaryKeyPolicy = formDataModel.primaryKeyPolicy,
|
|
IsRelationForm = isRelationForm,
|
|
ChildTableStyle = columnDesignModel.childTableStyle,
|
|
IsFixed = isFixed,
|
|
};
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 多端查询合并.
|
|
/// </summary>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static List<IndexSearchFieldModel> GetMultiEndQueryMerging(VisualDevEntity templateEntity, List<FieldsModel> controls)
|
|
{
|
|
ColumnDesignModel pcColumnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
ColumnDesignModel appColumnDesignModel = templateEntity.AppColumnData?.ToObject<ColumnDesignModel>();
|
|
if (templateEntity.Type != 3 && templateEntity.WebType == 2 && pcColumnDesignModel.type == 2 && (pcColumnDesignModel.searchList.Count == 0 || pcColumnDesignModel.searchList.Any(it => !it.prop.Equals(pcColumnDesignModel.treeRelation))))
|
|
{
|
|
var search = controls.Find(x => x.__vModel__.Equals(pcColumnDesignModel.treeRelation));
|
|
if (search != null)
|
|
{
|
|
pcColumnDesignModel.searchList.Add(new IndexSearchFieldModel
|
|
{
|
|
label = search.__config__.label,
|
|
prop = search.__vModel__,
|
|
jnpfKey = search.__config__.jnpfKey,
|
|
searchType = 1,
|
|
__vModel__ = search.__vModel__
|
|
});
|
|
}
|
|
}
|
|
return pcColumnDesignModel?.searchList.Union(appColumnDesignModel?.searchList, EqualityHelper<IndexSearchFieldModel>.CreateComparer(it => it.prop)).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 多端列表展示合并.
|
|
/// </summary>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static List<IndexGridFieldModel> GetMultiTerminalListDisplayAndConsolidation(VisualDevEntity templateEntity)
|
|
{
|
|
ColumnDesignModel pcColumnDesignModel = templateEntity.ColumnData?.ToObject<ColumnDesignModel>();
|
|
ColumnDesignModel appColumnDesignModel = templateEntity.AppColumnData?.ToObject<ColumnDesignModel>();
|
|
return pcColumnDesignModel?.columnList.Union(appColumnDesignModel?.columnList, EqualityHelper<IndexGridFieldModel>.CreateComparer(it => it.prop)).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 代码生成配置模型.
|
|
/// </summary>
|
|
/// <param name="formDataModel">表单Json包.</param>
|
|
/// <param name="columnDesignModel">列设计模型.</param>
|
|
/// <param name="tableColumnList">数据库表列.</param>
|
|
/// <param name="controls">表单控件列表.</param>
|
|
/// <param name="tableName">表名称.</param>
|
|
/// <param name="templateEntity">模板实体.</param>
|
|
/// <returns></returns>
|
|
public static CodeGenConfigModel GetCodeGenConfigModel(FormDataModel formDataModel, ColumnDesignModel columnDesignModel, List<TableColumnConfigModel> tableColumnList, List<FieldsModel> controls, string tableName, VisualDevEntity templateEntity)
|
|
{
|
|
// 默认排序 没设置以ID排序.
|
|
var defaultSidx = string.Empty;
|
|
|
|
// 是否导出
|
|
bool isExport = false;
|
|
|
|
// 是否批量删除
|
|
bool isBatchRemove = false;
|
|
|
|
switch (templateEntity.WebType)
|
|
{
|
|
case 2:
|
|
// 默认排序 没设置以ID排序.
|
|
defaultSidx = columnDesignModel.defaultSidx ?? tableColumnList.Find(t => t.PrimaryKey).ColumnName;
|
|
isExport = columnDesignModel.btnsList.Any(it => it.value == "download");
|
|
isBatchRemove = columnDesignModel.btnsList.Any(it => it.value == "batchRemove");
|
|
break;
|
|
}
|
|
|
|
// 是否存在上传
|
|
bool isUpload = tableColumnList.Any(it => it.jnpfKey != null && (it.jnpfKey.Equals(JnpfKeyConst.UPLOADIMG) || it.jnpfKey.Equals(JnpfKeyConst.UPLOADFZ)));
|
|
|
|
// 是否对象映射
|
|
bool isMapper = tableColumnList.Any(it => it.jnpfKey != null && (it.jnpfKey.Equals(JnpfKeyConst.CHECKBOX) || it.jnpfKey.Equals(JnpfKeyConst.CASCADER) || it.jnpfKey.Equals(JnpfKeyConst.ADDRESS) || it.jnpfKey.Equals(JnpfKeyConst.COMSELECT) || it.jnpfKey.Equals(JnpfKeyConst.UPLOADIMG) || it.jnpfKey.Equals(JnpfKeyConst.UPLOADFZ) || (it.jnpfKey.Equals(JnpfKeyConst.SELECT) && it.IsMultiple) || (it.jnpfKey.Equals(JnpfKeyConst.USERSELECT) && it.IsMultiple) || (it.jnpfKey.Equals(JnpfKeyConst.TREESELECT) && it.IsMultiple) || (it.jnpfKey.Equals(JnpfKeyConst.DEPSELECT) && it.IsMultiple) || (it.jnpfKey.Equals(JnpfKeyConst.POSSELECT) && it.IsMultiple)));
|
|
|
|
// 是否存在单据规则控件
|
|
bool isBillRule = controls.Any(it => it.__config__.jnpfKey.Equals(JnpfKeyConst.BILLRULE));
|
|
|
|
bool isSystemControl = tableColumnList.Any(it => it.IsSystemControl);
|
|
|
|
bool isUpdate = tableColumnList.Any(it => it.IsUpdate);
|
|
|
|
List<CodeGenFunctionModel> function = new List<CodeGenFunctionModel>();
|
|
|
|
switch (templateEntity.Type)
|
|
{
|
|
case 3:
|
|
function = CodeGenFunctionHelper.GetPureFormWithProcessMethod();
|
|
break;
|
|
default:
|
|
// 是否启用流程
|
|
switch (templateEntity.EnableFlow)
|
|
{
|
|
case 1:
|
|
switch (templateEntity.WebType)
|
|
{
|
|
case 1:
|
|
function = CodeGenFunctionHelper.GetPureFormWithProcessMethod();
|
|
break;
|
|
case 2:
|
|
columnDesignModel.btnsList.RemoveAll(it => it.value.Equals("add"));
|
|
columnDesignModel.btnsList.Add(new ButtonConfigModel()
|
|
{
|
|
value = "save",
|
|
});
|
|
columnDesignModel.columnBtnsList.RemoveAll(it => it.value.Equals("edit"));
|
|
function = CodeGenFunctionHelper.GetGeneralListWithProcessMethod(columnDesignModel.hasPage, columnDesignModel.btnsList, columnDesignModel.columnBtnsList);
|
|
break;
|
|
}
|
|
|
|
break;
|
|
default:
|
|
switch (templateEntity.WebType)
|
|
{
|
|
case 1:
|
|
function = CodeGenFunctionHelper.GetPureFormMethod();
|
|
break;
|
|
default:
|
|
function = CodeGenFunctionHelper.GetGeneralListMethod(columnDesignModel.hasPage, columnDesignModel.btnsList, columnDesignModel.columnBtnsList);
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
|
|
return new CodeGenConfigModel()
|
|
{
|
|
NameSpace = formDataModel.areasName,
|
|
BusName = templateEntity.FullName,
|
|
ClassName = formDataModel.className.FirstOrDefault(),
|
|
PrimaryKey = tableColumnList.Find(t => t.PrimaryKey).ColumnName,
|
|
OriginalPrimaryKey = tableColumnList.Find(t => t.PrimaryKey).OriginalColumnName,
|
|
MainTable = tableName.ParseToPascalCase(),
|
|
OriginalMainTableName = tableName,
|
|
hasPage = columnDesignModel.hasPage,
|
|
Function = function,
|
|
TableField = tableColumnList,
|
|
DefaultSidx = defaultSidx,
|
|
IsExport = isExport,
|
|
IsBatchRemove = isBatchRemove,
|
|
IsUpload = isUpload,
|
|
IsTableRelations = false,
|
|
IsMapper = isMapper,
|
|
IsBillRule = isBillRule,
|
|
DbLinkId = templateEntity.DbLinkId,
|
|
FormId = templateEntity.Id,
|
|
WebType = templateEntity.WebType,
|
|
Type = templateEntity.Type,
|
|
EnableFlow = templateEntity.EnableFlow.ParseToBool(),
|
|
IsMainTable = true,
|
|
EnCode = templateEntity.EnCode,
|
|
UseDataPermission = (bool)columnDesignModel?.useDataPermission,
|
|
SearchControlNum = tableColumnList.FindAll(it => it.QueryType.Equals(1) || it.QueryType.Equals(2)).Count(),
|
|
IsAuxiliaryTable = false,
|
|
ExportField = templateEntity.Type == 3 || templateEntity.WebType == 1 ? null : CodeGenExportFieldHelper.ExportColumnField(columnDesignModel?.columnList),
|
|
FullName = templateEntity.FullName,
|
|
IsConversion = tableColumnList.Any(it => it.IsConversion.Equals(true)),
|
|
PrimaryKeyPolicy = formDataModel.primaryKeyPolicy,
|
|
ConcurrencyLock = formDataModel.concurrencyLock,
|
|
HasSuperQuery = columnDesignModel.hasSuperQuery,
|
|
IsInlineEditor = columnDesignModel.type == 4 ? true : false,
|
|
IsUnique = tableColumnList.Any(it => it.IsUnique),
|
|
IndexDataType = columnDesignModel.type,
|
|
GroupField = columnDesignModel?.groupField,
|
|
GroupShowField = columnDesignModel?.columnList?.Where(x => x.__vModel__.ToLower() != columnDesignModel?.groupField?.ToLower()).FirstOrDefault()?.__vModel__,
|
|
IsImportData = tableColumnList.Any(it => it.IsImportField.Equals(true)),
|
|
ParsJnpfKeyConstList = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstList(controls, (bool)columnDesignModel?.type.Equals(4)),
|
|
ParsJnpfKeyConstListDetails = CodeGenControlsAttributeHelper.GetParsJnpfKeyConstListDetails(controls),
|
|
ImportDataType = columnDesignModel?.uploaderTemplateJson?.dataType,
|
|
IsSystemControl = isSystemControl,
|
|
IsUpdate = isUpdate,
|
|
};
|
|
}
|
|
} |