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;
|
||||
|
||||
Reference in New Issue
Block a user