This commit is contained in:
2023-05-31 10:19:05 +08:00
parent 1b65a7a9e5
commit 9c621c75cd
238 changed files with 9905 additions and 4034 deletions

View File

@@ -171,7 +171,11 @@ public class CodeGenFormControlDesignHelper
UserRelationAttr = GetUserRelationAttr(children, realisticControls, logic),
IsLinked = realisticControl.IsLinked,
IsLinkage = realisticControl.IsLinkage,
IsRelationForm = childrenConfig.jnpfKey.Equals(JnpfKeyConst.RELATIONFORM)
IsRelationForm = childrenConfig.jnpfKey.Equals(JnpfKeyConst.RELATIONFORM),
PathType = !string.IsNullOrEmpty(children.pathType) ? string.Format("pathType=\"{0}\" ", children.pathType) : string.Empty,
IsAccount = children.isAccount != -1 ? string.Format(":isAccount=\"{0}\" ", children.isAccount) : string.Empty,
Folder = !string.IsNullOrEmpty(children.folder) ? string.Format("folder=\"{0}\" ", children.folder) : string.Empty,
DefaultCurrent = childrenConfig.defaultCurrent,
});
}
@@ -194,6 +198,7 @@ public class CodeGenFormControlDesignHelper
required = childrenTableList.Any(it => it.required.Equals(true)),
AddType = item.addType,
IsRelationForm = childrenTableList.Any(it => it.IsRelationForm.Equals(true)),
DefaultCurrent = childrenTableList.Any(it => it.DefaultCurrent.Equals(true)),
});
}
@@ -496,7 +501,11 @@ public class CodeGenFormControlDesignHelper
UserRelationAttr = GetUserRelationAttr(item, realisticControls, logic),
IsLinked = realisticControl.IsLinked,
IsLinkage = realisticControl.IsLinkage,
IsRelationForm = config.jnpfKey.Equals(JnpfKeyConst.RELATIONFORM)
IsRelationForm = config.jnpfKey.Equals(JnpfKeyConst.RELATIONFORM),
PathType = !string.IsNullOrEmpty(item.pathType) ? string.Format("pathType=\"{0}\" ", item.pathType) : string.Empty,
IsAccount = item.isAccount != -1 ? string.Format(":isAccount=\"{0}\" ", item.isAccount) : string.Empty,
Folder = !string.IsNullOrEmpty(item.folder) ? string.Format("folder=\"{0}\" ", item.folder) : string.Empty,
DefaultCurrent = config.defaultCurrent,
});
}
@@ -507,6 +516,112 @@ public class CodeGenFormControlDesignHelper
return list;
}
/// <summary>
/// 表单默认值控件列表.
/// </summary>
/// <param name="fieldList">组件列表.</param>
/// <param name="searchField">查询字段.</param>
/// <param name="isMain">是否主表.</param>
/// <returns></returns>
public static DefaultFormControlModel DefaultFormControlList(List<FieldsModel> fieldList, List<IndexSearchFieldModel> searchField, string subTableName = null, bool isMain = true)
{
DefaultFormControlModel model = new DefaultFormControlModel();
model.DateField = new List<string>();
model.ComSelectList = new List<DefaultComSelectControl>();
model.DepSelectList = new List<DefaultDepSelectControl>();
model.UserSelectList = new List<DefaultUserSelectControl>();
model.SubTabelDefault = new List<DefaultFormControlModel>();
// 获取表单内存在默认值控件
foreach (var item in fieldList)
{
var config = item.__config__;
var search = new IndexSearchFieldModel();
switch (isMain && !config.jnpfKey.Equals(JnpfKeyConst.TABLE))
{
case false:
search = searchField?.Find(it => it.__vModel__.Equals(string.Format("{0}-{1}", subTableName, item.__vModel__)));
break;
default:
search = searchField?.Find(it => it.__vModel__.Equals(string.Format("{0}", item.__vModel__)));
break;
}
// 未作为查询条件
if (search == null)
{
search = new IndexSearchFieldModel();
search.searchMultiple = false;
}
switch (config.defaultCurrent)
{
case true:
switch (config.jnpfKey)
{
case JnpfKeyConst.TABLE:
model.SubTabelDefault.Add(DefaultFormControlList(item.__config__.children, searchField, item.__vModel__, false));
break;
case JnpfKeyConst.DATE:
model.DateField.Add(item.__vModel__);
break;
case JnpfKeyConst.COMSELECT:
model.ComSelectList.Add(new DefaultComSelectControl()
{
IsMultiple = item.multiple,
IsSearchMultiple = search.searchMultiple,
Field = item.__vModel__
});
break;
case JnpfKeyConst.DEPSELECT:
model.DepSelectList.Add(new DefaultDepSelectControl()
{
IsMultiple = item.multiple,
selectType = item.selectType,
IsSearchMultiple = search.searchMultiple,
Field = item.__vModel__,
ableDepIds = item.ableDepIds.ToJsonString(),
});
break;
case JnpfKeyConst.USERSELECT:
model.UserSelectList.Add(new DefaultUserSelectControl()
{
IsMultiple = item.multiple,
selectType = item.selectType,
IsSearchMultiple = search.searchMultiple,
Field = item.__vModel__,
ableDepIds = item.ableDepIds.ToJsonString(),
ableGroupIds = item.ableGroupIds.ToJsonString(),
ablePosIds = item.ablePosIds.ToJsonString(),
ableRoleIds = item.ableRoleIds.ToJsonString(),
ableUserIds = item.ableUserIds.ToJsonString(),
});
break;
}
break;
}
}
switch (isMain)
{
case false:
model.SubTableName = subTableName;
model.IsExistDate = model.DateField.Any();
model.IsExistComSelect = model.ComSelectList.Any();
model.IsExistDepSelect = model.DepSelectList.Any();
model.IsExistUserSelect = model.UserSelectList.Any();
break;
default:
model.IsExistDate = model.DateField.Any() || model.SubTabelDefault.Any(it => it.DateField.Any());
model.IsExistComSelect = model.ComSelectList.Any() || model.SubTabelDefault.Any(it => it.ComSelectList.Any());
model.IsExistDepSelect = model.DepSelectList.Any() || model.SubTabelDefault.Any(it => it.DepSelectList.Any());
model.IsExistUserSelect = model.UserSelectList.Any() || model.SubTabelDefault.Any(it => it.UserSelectList.Any());
model.IsExistSubTable = model.SubTabelDefault.Count > 0 ? true : false;
break;
}
return model;
}
/// <summary>
/// 表单控件选项配置.
/// </summary>
@@ -1071,6 +1186,40 @@ public class CodeGenFormControlDesignHelper
return list;
}
/// <summary>
/// 表单真实控件-剔除布局控件后.
/// </summary>
/// <param name="fieldList">组件列表</param>
/// <returns></returns>
public static List<CodeGenFormRealControlModel> FormRealControl(List<FieldsModel> fieldList)
{
var list = new List<CodeGenFormRealControlModel>();
foreach (var item in fieldList)
{
var config = item.__config__;
switch (config.jnpfKey)
{
case JnpfKeyConst.TABLE:
list.Add(new CodeGenFormRealControlModel
{
jnpfKey = config.jnpfKey,
vModel = item.__vModel__,
children = FormRealControl(config.children)
});
break;
default:
list.Add(new CodeGenFormRealControlModel
{
jnpfKey = config.jnpfKey,
vModel = item.__vModel__,
multiple = config.jnpfKey == JnpfKeyConst.CASCADER ? item.props.props.multiple : item.multiple
});
break;
}
}
return list;
}
/// <summary>
/// 表单脚本设计.
/// </summary>
@@ -1179,6 +1328,12 @@ public class CodeGenFormControlDesignHelper
break;
}
}
List<RegListModel> childrenRegList = new List<RegListModel>();
foreach (var reg in childrenFormScript.FindAll(it => it.RegList != null && it.RegList.Count > 0).Select(it => it.RegList))
{
childrenRegList.AddRange(reg);
}
formScript.Add(new FormScriptDesignModel()
{
@@ -1188,6 +1343,7 @@ public class CodeGenFormControlDesignHelper
jnpfKey = config.jnpfKey,
ChildrenList = childrenFormScript,
Required = childrenFormScript.Any(it => it.Required.Equals(true)),
RegList = childrenRegList,
ShowSummary = item.showSummary,
SummaryField = item.summaryField.ToJsonString(),
IsDataTransfer = item.addType == 1 ? true : false,
@@ -1417,4 +1573,51 @@ public class CodeGenFormControlDesignHelper
return res;
}
/// <summary>
/// 表单json.
/// </summary>
/// <param name="formScriptDesignModels"></param>
/// <returns></returns>
public static string GetPropertyJson(List<FormScriptDesignModel> formScriptDesignModels)
{
List<CodeGenExportPropertyJsonModel>? list = new List<CodeGenExportPropertyJsonModel>();
foreach (var item in formScriptDesignModels)
{
switch (item.jnpfKey)
{
case JnpfKeyConst.TABLE:
list.Add(new CodeGenExportPropertyJsonModel
{
filedName = item.Placeholder,
jnpfKey = item.jnpfKey,
filedId = item.OriginalName,
required = item.Required,
multiple = item.Multiple,
});
foreach (var subtable in item.ChildrenList)
{
list.Add(new CodeGenExportPropertyJsonModel
{
filedName = string.Format("{0}-{1}", item.Placeholder, subtable.Placeholder),
jnpfKey = subtable.jnpfKey,
filedId = string.Format("{0}-{1}", item.OriginalName, subtable.LowerName),
required = subtable.Required,
multiple = subtable.Multiple,
});
}
break;
default:
list.Add(new CodeGenExportPropertyJsonModel
{
filedName = item.Placeholder,
jnpfKey = item.jnpfKey,
filedId = item.LowerName,
required = item.Required,
multiple = item.Multiple,
});
break;
}
}
return list.ToJsonString();
}
}