v3.4.6
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
using JNPF.Common.Const;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Models;
|
||||
using JNPF.Common.Models.Authorize;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.VisualDev.Engine.Core;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Enum;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.VisualDev.Engine.Security;
|
||||
|
||||
@@ -261,6 +267,7 @@ public class CodeGenControlsAttributeHelper
|
||||
case JnpfKeyConst.COMSELECT:
|
||||
case JnpfKeyConst.ADDRESS:
|
||||
case JnpfKeyConst.SWITCH:
|
||||
case JnpfKeyConst.DATE:
|
||||
tag = true;
|
||||
break;
|
||||
}
|
||||
@@ -467,7 +474,7 @@ public class CodeGenControlsAttributeHelper
|
||||
res[JnpfKeyConst.RELATIONFORM].Add(item.__vModel__);
|
||||
break;
|
||||
case JnpfKeyConst.TABLE: // 遍历 子表 控件
|
||||
var ctRes = GetParsJnpfKeyConstList(item.__config__.children, isInlineEditor);
|
||||
var ctRes = GetParsJnpfKeyConstList(item.__config__.children, false);
|
||||
if (ctRes != null && ctRes.Any())
|
||||
{
|
||||
foreach (var ct in ctRes)
|
||||
@@ -547,4 +554,254 @@ public class CodeGenControlsAttributeHelper
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取模板配置的数据过滤.
|
||||
/// </summary>
|
||||
/// <param name="templateEntity"></param>
|
||||
/// <param name="codeGenConfigModel"></param>
|
||||
/// <returns></returns>
|
||||
public static List<CodeGenDataRuleModuleResourceModel> GetDataRuleList(VisualDevEntity templateEntity, Model.CodeGen.CodeGenConfigModel codeGenConfigModel)
|
||||
{
|
||||
var ruleList = new List<CodeGenDataRuleModuleResourceModel>();
|
||||
var tInfo = new TemplateParsingBase(templateEntity);
|
||||
|
||||
// 数据过滤
|
||||
if (tInfo.ColumnData.ruleList != null && tInfo.ColumnData.ruleList.Any()) tInfo.ColumnData.ruleList.ForEach(item => ruleList.Add(GetItemRule(item, tInfo, "pc", codeGenConfigModel, ref ruleList)));
|
||||
if (tInfo.AppColumnData.ruleListApp != null && tInfo.AppColumnData.ruleListApp.Any()) tInfo.AppColumnData.ruleListApp.ForEach(item => ruleList.Add(GetItemRule(item, tInfo, "app", codeGenConfigModel, ref ruleList)));
|
||||
|
||||
var res = new List<CodeGenDataRuleModuleResourceModel>();
|
||||
foreach (var userOriginItem in new List<string>() { "pc", "app" })
|
||||
{
|
||||
ruleList.Where(x => x.UserOrigin.Equals(userOriginItem)).Select(x => x.TableName).Distinct().ToList().ForEach(tName =>
|
||||
{
|
||||
var first = ruleList.FirstOrDefault(x => x.UserOrigin.Equals(userOriginItem) && x.TableName.Equals(tName));
|
||||
var condList = ruleList.Where(x => x.UserOrigin.Equals(userOriginItem) && x.TableName.Equals(tName)).Select(x => x.conditionalModel.First()).ToList();
|
||||
var dataRuleListJson = new List<IConditionalModel>();
|
||||
var condTree = new ConditionalTree() { ConditionalList = new List<KeyValuePair<WhereType, IConditionalModel>>() };
|
||||
condList.ForEach(cItem => condTree.ConditionalList.Add(new KeyValuePair<WhereType, IConditionalModel>(WhereType.And, cItem)));
|
||||
res.Add(new CodeGenDataRuleModuleResourceModel()
|
||||
{
|
||||
FieldRule = first.TableName.Contains("@ChildFieldIsNull") ? -1 : first.FieldRule,
|
||||
TableName = first.TableName.Replace("@ChildFieldIsNull", string.Empty),
|
||||
UserOrigin = first.UserOrigin,
|
||||
conditionalModelJson = new List<IConditionalModel>() { condTree }.ToJsonString()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static CodeGenDataRuleModuleResourceModel GetItemRule(RuleFieldModel item, TemplateParsingBase tInfo, string userOrigin, Model.CodeGen.CodeGenConfigModel codeGenConfigModel, ref List<CodeGenDataRuleModuleResourceModel> ruleList)
|
||||
{
|
||||
var result = new CodeGenDataRuleModuleResourceModel() { FieldRule = 0, TableName = tInfo.MainTableName.ToLower(), UserOrigin = userOrigin, conditionalModel = new List<IConditionalModel>() };
|
||||
if (tInfo.AuxiliaryTableFields.ContainsKey(item.__vModel__))
|
||||
{
|
||||
var tf = tInfo.AuxiliaryTableFields[item.__vModel__].Split('.');
|
||||
result.FieldRule = 1;
|
||||
result.TableName = tf.FirstOrDefault().ToLower();
|
||||
item.field = tf.LastOrDefault();
|
||||
}
|
||||
else if (tInfo.ChildTableFields.ContainsKey(item.__vModel__))
|
||||
{
|
||||
var tf = tInfo.ChildTableFields[item.__vModel__].Split('.');
|
||||
result.FieldRule = 2;
|
||||
result.TableName = tf.FirstOrDefault().ToLower();
|
||||
item.field = tf.LastOrDefault();
|
||||
|
||||
if (item.symbol.Equals("null"))
|
||||
{
|
||||
var mainTableRelationsQuery = result.Copy();
|
||||
mainTableRelationsQuery.TableName = mainTableRelationsQuery.TableName + "@ChildFieldIsNull";
|
||||
var ctPrimaryKey = codeGenConfigModel.TableRelations.Find(x => x.OriginalTableName.Equals(result.TableName)).ChilderColumnConfigList.Find(x => x.ColumnName.Equals(codeGenConfigModel.TableRelations.Find(x => x.OriginalTableName.Equals(result.TableName)).PrimaryKey)).OriginalColumnName;
|
||||
var condTree = new ConditionalCollections()
|
||||
{
|
||||
ConditionalList = new List<KeyValuePair<WhereType, SqlSugar.ConditionalModel>>()
|
||||
{
|
||||
new KeyValuePair<WhereType, ConditionalModel>(WhereType.Or, new ConditionalModel() { FieldName = ctPrimaryKey, ConditionalType = ConditionalType.NoEqual, FieldValue = "0", FieldValueConvertFunc = it => SqlSugar.UtilMethods.ChangeType2(it, typeof(string)) })
|
||||
}
|
||||
};
|
||||
|
||||
mainTableRelationsQuery.conditionalModel = new List<IConditionalModel>() { condTree };
|
||||
ruleList.Add(mainTableRelationsQuery);
|
||||
}
|
||||
}
|
||||
|
||||
if (codeGenConfigModel.TableField.Any(x => x.LowerColumnName.Equals(item.field)))
|
||||
{
|
||||
var fieldList = codeGenConfigModel.TableField.Where(x => x.LowerColumnName.Equals(item.field)).ToList();
|
||||
if (fieldList.Any() && fieldList.Count.Equals(1)) item.field = fieldList.First().OriginalColumnName;
|
||||
else item.field = fieldList.Find(x => x.TableName != null && x.TableName.Equals(item.__config__.tableName)).OriginalColumnName;
|
||||
}
|
||||
else if (codeGenConfigModel.TableRelations.Any(x => x.OriginalTableName.Equals(result.TableName)))
|
||||
{
|
||||
var tableRelations = codeGenConfigModel.TableRelations.Find(x => x.OriginalTableName.Equals(result.TableName) && x.ChilderColumnConfigList.Any(xx => xx.LowerColumnName.Equals(item.field)));
|
||||
if (tableRelations != null) item.field = tableRelations.ChilderColumnConfigList.Find(x => x.LowerColumnName.Equals(item.field)).OriginalColumnName;
|
||||
}
|
||||
|
||||
var conditionalType = ConditionalType.Equal;
|
||||
var between = new List<string>();
|
||||
if (item.fieldValue.IsNotEmptyOrNull())
|
||||
{
|
||||
if (item.symbol.Equals("between")) between = item.fieldValue.ToObject<List<string>>();
|
||||
switch (item.jnpfKey)
|
||||
{
|
||||
case JnpfKeyConst.CREATETIME:
|
||||
case JnpfKeyConst.MODIFYTIME:
|
||||
case JnpfKeyConst.DATE:
|
||||
{
|
||||
if (item.symbol.Equals("between"))
|
||||
{
|
||||
var startTime = between.First().TimeStampToDateTime();
|
||||
var endTime = between.Last().TimeStampToDateTime();
|
||||
between[0] = startTime.ToString();
|
||||
between[1] = endTime.ToString();
|
||||
if (item.format == "yyyy-MM-dd")
|
||||
{
|
||||
between[0] = new DateTime(startTime.Year, startTime.Month, startTime.Day, 0, 0, 0, 0).ToString();
|
||||
between[1] = new DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 59, 999).ToString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DateTime dtDate;
|
||||
if (DateTime.TryParse(item.fieldValue.ToString(), out dtDate)) item.fieldValue = item.fieldValue.ToString();
|
||||
else item.fieldValue = string.Format("{0:yyyy-MM-dd HH:mm:ss}", item.fieldValue.ToString().TimeStampToDateTime());
|
||||
if (item.format == "yyyy-MM-dd")
|
||||
{
|
||||
var value = item.fieldValue.ToString().ParseToDateTime();
|
||||
item.fieldValue = new DateTime(value.Year, value.Month, value.Day, 0, 0, 0, 0).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.fieldValue = item.fieldValue.IsNotEmptyOrNull() ? item.fieldValue.ToString() : item.fieldValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (item.symbol)
|
||||
{
|
||||
case ">=":
|
||||
conditionalType = ConditionalType.GreaterThanOrEqual;
|
||||
break;
|
||||
case ">":
|
||||
conditionalType = ConditionalType.GreaterThan;
|
||||
break;
|
||||
case "==":
|
||||
conditionalType = ConditionalType.Equal;
|
||||
break;
|
||||
case "<=":
|
||||
conditionalType = ConditionalType.LessThanOrEqual;
|
||||
break;
|
||||
case "<":
|
||||
conditionalType = ConditionalType.LessThan;
|
||||
break;
|
||||
case "<>":
|
||||
conditionalType = ConditionalType.NoEqual;
|
||||
break;
|
||||
case "like":
|
||||
if (item.fieldValue != null && item.fieldValue.ToString().Contains("[")) item.fieldValue = item.fieldValue.ToString().Replace("[", string.Empty).Replace("]", string.Empty);
|
||||
conditionalType = ConditionalType.Like;
|
||||
break;
|
||||
case "notLike":
|
||||
if (item.fieldValue != null && item.fieldValue.ToString().Contains("[")) item.fieldValue = item.fieldValue.ToString().Replace("[", string.Empty).Replace("]", string.Empty);
|
||||
conditionalType = ConditionalType.NoLike;
|
||||
break;
|
||||
case "in":
|
||||
case "notIn":
|
||||
if (item.fieldValue != null && item.fieldValue.ToString().Contains("["))
|
||||
{
|
||||
var isListValue = false;
|
||||
var itemField = tInfo.AllFieldsModel.Find(x => x.__vModel__.Equals(item.__vModel__));
|
||||
if (itemField.multiple || item.jnpfKey.Equals(JnpfKeyConst.CHECKBOX) || item.jnpfKey.Equals(JnpfKeyConst.CASCADER) || item.jnpfKey.Equals(JnpfKeyConst.ADDRESS))
|
||||
isListValue = true;
|
||||
var conditionalList = new ConditionalCollections() { ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>() };
|
||||
var ids = new List<string>();
|
||||
if (item.fieldValue.ToString().Replace("\r\n", "").Replace(" ", "").Contains("[[")) ids = item.fieldValue.ToObject<List<List<string>>>().Select(x => x.Last()).ToList();
|
||||
else ids = item.fieldValue.ToObject<List<string>>();
|
||||
for (var i = 0; i < ids.Count; i++)
|
||||
{
|
||||
var it = ids[i];
|
||||
var whereType = WhereType.And;
|
||||
if (item.symbol.Equals("in")) whereType = i.Equals(0) && item.logic.Equals("&&") ? WhereType.And : WhereType.Or;
|
||||
else whereType = i.Equals(0) && item.logic.Equals("||") ? WhereType.Or : WhereType.And;
|
||||
conditionalList.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(whereType, new ConditionalModel
|
||||
{
|
||||
FieldName = item.field,
|
||||
ConditionalType = item.symbol.Equals("in") ? ConditionalType.Like : ConditionalType.NoLike,
|
||||
FieldValue = isListValue ? it.ToJsonString() : it
|
||||
}));
|
||||
}
|
||||
|
||||
if (item.symbol.Equals("notIn"))
|
||||
{
|
||||
conditionalList.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
FieldName = item.field,
|
||||
ConditionalType = ConditionalType.IsNot,
|
||||
FieldValue = null
|
||||
}));
|
||||
conditionalList.ConditionalList.Add(new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
FieldName = item.field,
|
||||
ConditionalType = ConditionalType.IsNot,
|
||||
FieldValue = string.Empty
|
||||
}));
|
||||
}
|
||||
|
||||
result.conditionalModel.Add(conditionalList);
|
||||
return result;
|
||||
}
|
||||
conditionalType = item.symbol.Equals("in") ? ConditionalType.In : ConditionalType.NotIn;
|
||||
break;
|
||||
case "null":
|
||||
conditionalType = (item.jnpfKey.Equals(JnpfKeyConst.CALCULATE) || item.jnpfKey.Equals(JnpfKeyConst.NUMINPUT)) ? ConditionalType.EqualNull : ConditionalType.IsNullOrEmpty;
|
||||
break;
|
||||
case "notNull":
|
||||
conditionalType = ConditionalType.IsNot;
|
||||
break;
|
||||
case "between":
|
||||
var condItem = new ConditionalCollections()
|
||||
{
|
||||
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
||||
{
|
||||
new KeyValuePair<WhereType, ConditionalModel>((item.logic.Equals("&&") ? WhereType.And : WhereType.Or), new ConditionalModel
|
||||
{
|
||||
FieldName = item.field,
|
||||
ConditionalType = ConditionalType.GreaterThanOrEqual,
|
||||
FieldValue = between.First(),
|
||||
FieldValueConvertFunc = it => Convert.ToDateTime(it)
|
||||
}),
|
||||
new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
FieldName = item.field,
|
||||
ConditionalType = ConditionalType.LessThanOrEqual,
|
||||
FieldValue = between.Last(),
|
||||
FieldValueConvertFunc = it => Convert.ToDateTime(it)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
result.conditionalModel.Add(condItem);
|
||||
return result;
|
||||
}
|
||||
|
||||
var resItem = new ConditionalCollections()
|
||||
{
|
||||
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
||||
{
|
||||
new KeyValuePair<WhereType, ConditionalModel>((item.logic.Equals("&&") ? WhereType.And : WhereType.Or), new ConditionalModel
|
||||
{
|
||||
FieldName = item.field,
|
||||
ConditionalType = conditionalType,
|
||||
FieldValue = item.fieldValue == null ? null : item.fieldValue.ToString()
|
||||
})
|
||||
}
|
||||
};
|
||||
result.conditionalModel.Add(resItem);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,18 @@ public class CodeGenFieldJudgeHelper
|
||||
return column?.searchType ?? 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表查询多选.
|
||||
/// </summary>
|
||||
/// <param name="searchList">模板内查询列表.</param>
|
||||
/// <param name="fieldName">字段名称.</param>
|
||||
/// <returns></returns>
|
||||
public static bool ColumnQueryMultiple(List<IndexSearchFieldModel>? searchList, string fieldName)
|
||||
{
|
||||
var column = searchList?.Find(s => s.prop == fieldName);
|
||||
return (column?.searchMultiple).ParseToBool();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否展示列.
|
||||
/// </summary>
|
||||
@@ -74,7 +86,7 @@ public class CodeGenFieldJudgeHelper
|
||||
/// <summary>
|
||||
/// 获取是否多选.
|
||||
/// </summary>
|
||||
/// <param name="columnList">模板内控件列表.</param>
|
||||
/// <param name="column">模板内控件.</param>
|
||||
/// <param name="fieldName">字段名称.</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsMultipleColumn(FieldsModel column, string fieldName)
|
||||
@@ -96,6 +108,25 @@ public class CodeGenFieldJudgeHelper
|
||||
return isMultiple;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制解析.
|
||||
/// </summary>
|
||||
/// <param name="column"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsControlParsing(FieldsModel column)
|
||||
{
|
||||
bool isExist = false;
|
||||
switch (column?.__config__.jnpfKey)
|
||||
{
|
||||
case JnpfKeyConst.RELATIONFORM:
|
||||
case JnpfKeyConst.POPUPSELECT:
|
||||
case JnpfKeyConst.USERSSELECT:
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
return isExist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否datetime.
|
||||
/// </summary>
|
||||
|
||||
@@ -28,18 +28,10 @@ public class GetCodeGenIndexButtonHelper
|
||||
method = string.Format("scope.row.rowEdit=true");
|
||||
break;
|
||||
default:
|
||||
switch (primaryKeyPolicy)
|
||||
switch (isFlow)
|
||||
{
|
||||
case 2:
|
||||
switch (isFlow)
|
||||
{
|
||||
case true:
|
||||
method = string.Format("addOrUpdateHandle(scope.row.flowTaskId)");
|
||||
break;
|
||||
default:
|
||||
method = string.Format("addOrUpdateHandle(scope.row.{0})", primaryKey);
|
||||
break;
|
||||
}
|
||||
case true:
|
||||
method = string.Format("updateHandle(scope.row)");
|
||||
break;
|
||||
default:
|
||||
method = string.Format("addOrUpdateHandle(scope.row.{0})", primaryKey);
|
||||
@@ -61,23 +53,15 @@ public class GetCodeGenIndexButtonHelper
|
||||
switch (primaryKeyPolicy)
|
||||
{
|
||||
case 2:
|
||||
method = string.Format("goDetail(scope.row.flowTaskId,scope.row.flowState)");
|
||||
method = string.Format("goDetail(scope.row.flowTaskId,scope.row.flowState, scope.row.flowId)");
|
||||
break;
|
||||
default:
|
||||
method = string.Format("goDetail(scope.row.{0},scope.row.flowState)", primaryKey);
|
||||
method = string.Format("goDetail(scope.row.{0},scope.row.flowState, scope.row.flowId)", primaryKey);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (primaryKeyPolicy)
|
||||
{
|
||||
case 2:
|
||||
method = string.Format("addOrUpdateHandle(scope.row.flowTaskId,scope.row.flowState)");
|
||||
break;
|
||||
default:
|
||||
method = string.Format("addOrUpdateHandle(scope.row.{0},scope.row.flowState)", primaryKey);
|
||||
break;
|
||||
}
|
||||
method = string.Format("detailHandle(scope.row)", primaryKey);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -95,14 +79,24 @@ public class GetCodeGenIndexButtonHelper
|
||||
/// <summary>
|
||||
/// 代码生成单表Index列表头部按钮方法.
|
||||
/// </summary>
|
||||
/// <param name="value">按钮类型.</param>
|
||||
/// <param name="isFlow">是否工作流表单.</param>
|
||||
/// <returns></returns>
|
||||
public static string IndexTopButton(string value)
|
||||
public static string IndexTopButton(string value, bool isFlow)
|
||||
{
|
||||
var method = string.Empty;
|
||||
switch (value)
|
||||
{
|
||||
case "add":
|
||||
method = "addOrUpdateHandle()";
|
||||
switch (isFlow)
|
||||
{
|
||||
case true:
|
||||
method = "addHandle()";
|
||||
break;
|
||||
default:
|
||||
method = "addOrUpdateHandle()";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "download":
|
||||
method = "exportData()";
|
||||
@@ -113,6 +107,9 @@ public class GetCodeGenIndexButtonHelper
|
||||
case "upload":
|
||||
method = "handelUpload()";
|
||||
break;
|
||||
case "batchPrint":
|
||||
method = "printDialog()";
|
||||
break;
|
||||
}
|
||||
|
||||
return method;
|
||||
|
||||
@@ -123,9 +123,10 @@ public class CodeGenTargetPathHelper
|
||||
{
|
||||
var frontendPath = Path.Combine(KeyVariable.SystemPath, "CodeGenerate", fileName, "Net");
|
||||
var indexPath = Path.Combine(frontendPath, "html", "PC", tableName, "index.vue");
|
||||
var extraForm = Path.Combine(frontendPath, "html", "PC", tableName, "extraForm.vue");
|
||||
var detailPath = Path.Combine(frontendPath, "html", "PC", tableName, "Detail.vue");
|
||||
var formPath = Path.Combine(frontendPath, "html", "PC", tableName, "Form.vue");
|
||||
var exportJsonPath = Path.Combine(frontendPath, "fff", "ExportJson.fff");
|
||||
var exportJsonPath = Path.Combine(frontendPath, "fff", "flowForm.fff");
|
||||
var columnJsonPath = Path.Combine(frontendPath, "html", "PC", tableName, "columnList.js");
|
||||
var superQueryJsonPath = Path.Combine(frontendPath, "html", "PC", tableName, "superQueryJson.js");
|
||||
var pathList = new List<string>();
|
||||
@@ -134,6 +135,7 @@ public class CodeGenTargetPathHelper
|
||||
switch (enableFlow)
|
||||
{
|
||||
case 0:
|
||||
pathList.Add(extraForm);
|
||||
if (isDetail)
|
||||
pathList.Add(detailPath);
|
||||
break;
|
||||
@@ -165,6 +167,7 @@ public class CodeGenTargetPathHelper
|
||||
{
|
||||
case 0:
|
||||
pathList.Add(Path.Combine(templatePath, "editorIndex.vue.vm"));
|
||||
pathList.Add(Path.Combine(templatePath, "extraForm.vue.vm"));
|
||||
if (isDetail)
|
||||
pathList.Add(Path.Combine(templatePath, "Detail.vue.vm"));
|
||||
break;
|
||||
@@ -278,7 +281,7 @@ public class CodeGenTargetPathHelper
|
||||
var frontendPath = Path.Combine(KeyVariable.SystemPath, "CodeGenerate", fileName, "Net");
|
||||
var indexPath = Path.Combine(frontendPath, "html", "App", tableName, "index.vue");
|
||||
var formPath = Path.Combine(frontendPath, "html", "App", tableName, "form.vue");
|
||||
var detailPath = Path.Combine(frontendPath, "html", "App", tableName, "Detail.vue");
|
||||
var detailPath = Path.Combine(frontendPath, "html", "App", tableName, "detail.vue");
|
||||
var columnJsonPath = Path.Combine(frontendPath, "html", "App", tableName, "columnList.js");
|
||||
var pathList = new List<string>();
|
||||
switch (webType)
|
||||
|
||||
@@ -17,7 +17,7 @@ public class CodeGenUnifiedHandlerHelper
|
||||
var template = new List<FieldsModel>();
|
||||
|
||||
// 循环表单内控件
|
||||
formDataModel.ForEach(item =>
|
||||
foreach (var item in formDataModel)
|
||||
{
|
||||
var config = item.__config__;
|
||||
switch (config.jnpfKey)
|
||||
@@ -67,7 +67,7 @@ public class CodeGenUnifiedHandlerHelper
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return template;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class CodeGenUnifiedHandlerHelper
|
||||
// dataType = dynamic && templateJson属性有长度,则代表有远端联动
|
||||
if (config.dataType == "dynamic" && config.templateJson?.Count() > 0)
|
||||
{
|
||||
config.templateJson.FindAll(it => it.relationField.Any()).ForEach(items =>
|
||||
config.templateJson.FindAll(it => it.relationField != null && it.relationField.Any()).ForEach(items =>
|
||||
{
|
||||
var fieldModel = NewFormDataModel.Where(it => it.__vModel__.Equals(items.relationField) && it.__config__.jnpfKey.Equals(items.jnpfKey)).FirstOrDefault();
|
||||
fieldModel.IsLinked = true;
|
||||
@@ -199,7 +199,7 @@ public class CodeGenUnifiedHandlerHelper
|
||||
{
|
||||
var childrenFieldModel = childrenFormModel.Where(it => item.__vModel__.Equals(it.__vModel__) && it.__config__.jnpfKey.Equals(config.jnpfKey)).FirstOrDefault();
|
||||
childrenFieldModel.IsLinkage = true;
|
||||
config.templateJson.FindAll(it => it.relationField.Any()).ForEach(items =>
|
||||
config.templateJson.FindAll(it => it.relationField != null && it.relationField.Any()).ForEach(items =>
|
||||
{
|
||||
var isTrigger = false;
|
||||
var fieldModel = childrenFormModel.Where(it => items.relationField.Equals(string.Format("{0}-{1}", tableControlsKey, it.__vModel__)) && it.__config__.jnpfKey.Equals(items.jnpfKey)).FirstOrDefault();
|
||||
@@ -233,27 +233,30 @@ public class CodeGenUnifiedHandlerHelper
|
||||
case true:
|
||||
var mainFieldModel = NewFormDataModel.Where(it => item.__vModel__.Equals(it.__vModel__) && it.__config__.jnpfKey.Equals(config.jnpfKey)).FirstOrDefault();
|
||||
mainFieldModel.IsLinkage = true;
|
||||
item.templateJson?.FindAll(it => it.relationField.Any()).ForEach(items =>
|
||||
item.templateJson?.FindAll(it => it.relationField != null && it.relationField.Any()).ForEach(items =>
|
||||
{
|
||||
var fieldModel = NewFormDataModel.Where(it => it.__vModel__.Equals(items.relationField) && it.__config__.jnpfKey.Equals(items.jnpfKey)).FirstOrDefault();
|
||||
fieldModel.IsLinked = true;
|
||||
List<LinkageConfig> linkageConfigs = new List<LinkageConfig>
|
||||
if (fieldModel != null)
|
||||
{
|
||||
new LinkageConfig()
|
||||
fieldModel.IsLinked = true;
|
||||
List<LinkageConfig> linkageConfigs = new List<LinkageConfig>
|
||||
{
|
||||
field = item.__vModel__,
|
||||
fieldName = item.__vModel__.ToLowerCase(),
|
||||
jnpfKey = config.jnpfKey,
|
||||
IsMultiple = config.jnpfKey.Equals(JnpfKeyConst.CASCADER) ? item.props.props.multiple : config.jnpfKey.Equals(JnpfKeyConst.CHECKBOX) ? true : item.multiple,
|
||||
}
|
||||
};
|
||||
fieldModel.linkageReverseRelationship.AddRange(linkageConfigs);
|
||||
new LinkageConfig()
|
||||
{
|
||||
field = item.__vModel__,
|
||||
fieldName = item.__vModel__.ToLowerCase(),
|
||||
jnpfKey = config.jnpfKey,
|
||||
IsMultiple = config.jnpfKey.Equals(JnpfKeyConst.CASCADER) ? item.props.props.multiple : config.jnpfKey.Equals(JnpfKeyConst.CHECKBOX) ? true : item.multiple,
|
||||
}
|
||||
};
|
||||
fieldModel.linkageReverseRelationship.AddRange(linkageConfigs);
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
var childrenFieldModel = childrenFormModel.Where(it => item.__vModel__.Equals(it.__vModel__) && it.__config__.jnpfKey.Equals(config.jnpfKey)).FirstOrDefault();
|
||||
childrenFieldModel.IsLinkage = true;
|
||||
item.templateJson?.FindAll(it => it.relationField.Any()).ForEach(items =>
|
||||
item.templateJson?.FindAll(it => it.relationField != null && it.relationField.Any()).ForEach(items =>
|
||||
{
|
||||
var isTrigger = false;
|
||||
var fieldModel = childrenFormModel.Where(it => items.relationField.Equals(string.Format("{0}-{1}", tableControlsKey, it.__vModel__)) && it.__config__.jnpfKey.Equals(items.jnpfKey)).FirstOrDefault();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class CodeGenQueryControlClassificationHelper
|
||||
|
||||
var usersSelectList = new List<string>();
|
||||
usersSelectList.Add(JnpfKeyConst.USERSSELECT);
|
||||
listQueryControl["usersSelectList"] = usersSelectList;
|
||||
listQueryControl["usersSelect"] = usersSelectList;
|
||||
|
||||
var treeSelectList = new List<string>();
|
||||
treeSelectList.Add(JnpfKeyConst.TREESELECT);
|
||||
@@ -159,6 +159,10 @@ public class CodeGenQueryControlClassificationHelper
|
||||
var addressList = new List<string>();
|
||||
addressList.Add(JnpfKeyConst.ADDRESS);
|
||||
listQueryControl["address"] = addressList;
|
||||
|
||||
listQueryControl["groupSelect"] = new List<string>() { JnpfKeyConst.GROUPSELECT };
|
||||
|
||||
listQueryControl["roleSelect"] = new List<string>() { JnpfKeyConst.ROLESELECT };
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -166,21 +170,4 @@ public class CodeGenQueryControlClassificationHelper
|
||||
|
||||
return listQueryControl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 需要转换的列表列控件.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, List<string>> ListColumnControls()
|
||||
{
|
||||
Dictionary<string, List<string>> listColumnControlsType = new Dictionary<string, List<string>>();
|
||||
var columnList = new List<string>();
|
||||
columnList.Add("date");
|
||||
columnList.Add("createTime");
|
||||
columnList.Add("modifyTime");
|
||||
|
||||
listColumnControlsType["columnList"] = columnList;
|
||||
|
||||
return listColumnControlsType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user