Exemple #1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="schema"></param>
 public el_inputAttribute(EnumComponentSchema schema)
     : base(schema, EnumComponentType.el_input)
 {
     this.type      = "text";
     this.clearable = false;
     this.disabled  = false;
     this.rows      = 2;
     this.autosize  = false;
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="componentSchema"></param>
 /// <param name="componentType"></param>
 public AbstractPropertyComponentAttribute(EnumComponentSchema componentSchema,
                                           EnumComponentType componentType
                                           )
 {
     this.componentSchema    = componentSchema;
     this.componentType      = componentType;
     this.serial             = Int32.MaxValue - 100;
     this.showConditionValue = true;
     this.allowEdit          = true;
 }
Exemple #3
0
        /// <summary>
        /// 获取类上可访问的属性以及VueComponent标注;
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="filterPropertyAndComponentFunc"></param>
        /// <param name="schema"></param>
        /// <returns></returns>
        private static List <PropertyAndVuecompontAttribute> GetPropertyAndVueComponentList(Type entityType,
                                                                                            EnumComponentSchema schema,
                                                                                            Func <ILimitAttribute, bool> filterPropertyAndComponentFunc)
        {
            var propDefaultListAndEdit = GetPropertyDefaultCanAccess(entityType);
            List <PropertyAndVuecompontAttribute> propertyComponentAttributeEnum = new List <PropertyAndVuecompontAttribute>();

            if (propDefaultListAndEdit.DefaultPropertyEntityOperate == EnumClassPropertyEntityOperate.AllowEditAndList)
            //属性未定义 PropertyDenyListAttribute 和 PropertyDenyListAndEditAttribute 标注时,即显示在列表中
            {
                entityType.GetProperties()
                .Where(a => (schema == EnumComponentSchema.List || a.CanWrite) &&
                       a.GetCustomAttribute <PropertyDenyListAttribute>() == null &&
                       a.GetCustomAttribute <PropertyDenyListAndEditAttribute>() == null)
                .ForEach(prop =>
                {
                    var props = getPropertyWithAttributeFunc(prop, schema, filterPropertyAndComponentFunc);
                    propertyComponentAttributeEnum.AddRange(props);
                });
            }
            else
            {
                //属性必须要定义有 componentSchema=EnumComponentSchema.List 的标注时, 显示在列表中
                entityType.GetProperties().ForEach(a =>
                {
                    var enums = getPropertyWithAttributeFunc(a, schema, filterPropertyAndComponentFunc);
                    propertyComponentAttributeEnum.AddRange(enums.Where(b => b.VueComponentAttribute != null));
                });
            }

            return(propertyComponentAttributeEnum);
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_childentity_admin(EnumComponentSchema schema, Type childEntityType) : base(schema, Enums.EnumComponentType.ehay_childentity_admin)
 {
     this.childEntityType = childEntityType;
 }
Exemple #5
0
        /// <summary>
        /// 判断给定 property 是否存在 AbstractPropertyComponentAttribute标注且标注中 componentSchema为 给定schema 的 标注,
        /// 如果存在此标注,还判断权限是否包含给定标注的权限,如果包含,则返回此标注;
        /// 如果存在多个符合的标注,则返回匹配  componentSchema为 给定schema 的所有标注;
        /// 否则,返回 null;
        /// </summary>
        static IEnumerable <PropertyAndVuecompontAttribute> getPropertyWithAttributeFunc(PropertyInfo prop,
                                                                                         EnumComponentSchema schema,
                                                                                         Func <ILimitAttribute, bool> filterPropertyAndComponentFunc)
        {
            if (filterPropertyAndComponentFunc == null)
            {
                filterPropertyAndComponentFunc = (c) => true;
            }
            Func <AbstractPropertyComponentAttribute, bool> filterFunc = (c) =>
                                                                         (c.componentSchema == EnumComponentSchema.FilterAndEditAndList || c.componentSchema == schema || ((c.componentSchema & schema) > 0)) &&
                                                                         filterPropertyAndComponentFunc(c);
            var propAttributes = prop.GetCustomAttributes <AbstractPropertyComponentAttribute>(true).ToList();  //


            // 获取到的标注中,如果子类和父类对同一个属性同时定义有标注,子类定义的标注在前,父类定义的标注在后;
            //麻烦的是 如果获取 父类中定义的 标注,则可能获取到多个标注; (例如, Name 同时在 OA_Role 和 父类: IdAndNameAndCreateDatetimeEntity 中定义了标注)
            //如果不获取父类中定义的标注,则某一个属性在子类中未定义标注时,标注就无法获取到;( OA_User 无法获取到 父类父类: IdAndNameAndCreateDatetimeEntity 中定义的标注)
            //另外,可能对于同一个属性会定有多个标注;
            var result = propAttributes.Where(filterFunc)
                         .OrderBy(c => c.componentSchema == schema ? 0 : 1)
                         .Select(attr => new PropertyAndVuecompontAttribute(prop, attr)).ToList();

            IListExtension.ReverseForEach(result, (item, index) =>
            {
                //移走相同属性的,
                var sameItemIndex = result.FindIndex((xitem) =>
                                                     item.VueComponentAttribute.propertyPath == xitem.VueComponentAttribute.propertyPath);
                if (sameItemIndex < index)
                {
                    propAttributes.RemoveAt(index);
                }
            });
            return(result);
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="componentType"></param>
 public AbstractFormElementAttribute(EnumComponentSchema schema, EnumComponentType componentType) : base(schema, componentType)
 {
 }
Exemple #7
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_media_preview(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_media_preview)
 {
 }
Exemple #8
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="componentSchema"></param>
 /// <param name="componentType"></param>
 public ehay_entity(EnumComponentSchema componentSchema,
                    EnumComponentType componentType
                    ) : base(componentSchema, componentType)
 {
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_chooseserverimage_orupload(EnumComponentSchema schema)
     : this(schema, null)
 {
 }
Exemple #10
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_span(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_span)
 {
     this.hideLabel = true;
 }
Exemple #11
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="componentSchema"></param>
 /// <param name="enumComponentType"></param>
 protected ehay_entity_checkboxGroup(EnumComponentSchema componentSchema,
                                     EnumComponentType enumComponentType
                                     ) : base(componentSchema, enumComponentType)
 {
 }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 public el_date_picker(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.el_date_picker)
 {
     this.valueFormat = "yyyy-MM-dd";
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_wechat_scandevicename(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_wechat_scandevicename)
 {
 }
Exemple #14
0
 public ELRadioGroup(EnumComponentSchema schema) : base(schema, EnumComponentType.el_radio_group)
 {
 }
Exemple #15
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_daterange_picker(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_daterange_picker)
 {
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_chooseserverimage_orupload(EnumComponentSchema schema, object howToGetServerFile)
     : base(schema, EnumComponentType.ehay_file_chooseserverfile_orupload)
 {
     this.howToGetServerFile = howToGetServerFile;
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_bool_checkboxgroup(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_boolean_checkboxgroup)
 {
 }
Exemple #18
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="componentSchema"></param>
 public ehay_entity_decode(EnumComponentSchema componentSchema
                           ) : base(componentSchema, EnumComponentType.ehay_entity_decode)
 {
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_enum_radiogroup(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_enum_radiogroup)
 {
 }
Exemple #20
0
 public ELAutocomplete(EnumComponentSchema schema) : base(schema, EnumComponentType.el_autocomplete)
 {
 }
Exemple #21
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="componentSchema"></param>
 public ehay_entity_checkboxGroup_collapse(EnumComponentSchema componentSchema
                                           ) : base(componentSchema, EnumComponentType.ehay_entity_checkboxGroup_collapse)
 {
 }
Exemple #22
0
 public ELButton(EnumComponentSchema schema) : base(schema, EnumComponentType.el_button)
 {
 }
Exemple #23
0
 public ElDateRangePicker(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.auto)
 {
 }
Exemple #24
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public el_checkbox(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.el_checkbox)
 {
 }
Exemple #25
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_bool_show(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_boolean_show)
 {
 }
Exemple #26
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="componentSchema"></param>
 /// <param name="componentId">一个用来表示组件的Id,客户端必须注册此Id对应的组件</param>
 public ehay_dialog_forcomponent(EnumComponentSchema componentSchema,
                                 int componentId
                                 ) : base(componentSchema, EnumComponentType.ehay_dialog_forcomponent)
 {
     this.componentId = componentId;
 }
Exemple #27
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ehay_wechat_selectimage(EnumComponentSchema schema) : base(schema, Enums.EnumComponentType.ehay_wechat_selectimage)
 {
 }
Exemple #28
0
 /// <summary>
 /// 根据 Type, IEnumerable&lt;(Property, AbstractPropertyComponentAttribut)&gt; 进行如下操作:
 /// a. 填充 AbstractPropertyComponentAttribut.label
 /// b. 当 componentAttr.componentType == EnumComponentType.Auto 时,需要根据 PropertyInfo 转换为 客户端Vue组件类型;
 /// 返回转换后的 客户端Vue组件列表
 /// </summary>
 /// <param name="entityType"></param>
 /// <param name="propertyComponentAttrEnum"></param>
 /// <param name="schema"></param>
 /// <returns></returns>
 private static List <AbstractPropertyComponentAttribute> ConvertToClientVueComponentAttribute(Type entityType,
                                                                                               IEnumerable <PropertyAndVuecompontAttribute> propertyComponentAttrEnum,
                                                                                               EnumComponentSchema schema)
 {
     return(propertyComponentAttrEnum
            .Select(a => ConvertToClientVueComponentAttribute(entityType, a.Property, a.VueComponentAttribute, schema))
            .Where(a => a != null)
            .OrderBy(a => a.serial)
            .ToList());
 }
Exemple #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="schema"></param>
 public ELCheckboxGroup(EnumComponentSchema schema) : base(schema, EnumComponentType.el_checkbox_group)
 {
 }
Exemple #30
0
        /// <summary>
        /// 根据 Type, Property, AbstractPropertyComponentAttribut 进行如下操作:
        /// a. 填充 AbstractPropertyComponentAttribut.label
        /// b. 当 componentAttr.componentType == EnumComponentType.Auto 时,需要根据 PropertyInfo 转换为具体的 组件类型;
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="property"></param>
        /// <param name="componentAttr"> 为null时表示自动构建  </param>
        /// <param name="schema"></param>
        /// <returns></returns>
        private static AbstractPropertyComponentAttribute ConvertToClientVueComponentAttribute(Type entityType,
                                                                                               PropertyInfo property,
                                                                                               AbstractPropertyComponentAttribute componentAttr,
                                                                                               EnumComponentSchema schema)
        {
            var inputComponentAttr = componentAttr;

            componentAttr.property = property;
            if (componentAttr == null || componentAttr.componentType == EnumComponentType.auto)  //为空或者自动
            {
                var name = property.Name;

                if (name == "Id" || name == "Xid" || name == "Guid" || name == "LastModifyDateTime")   //这些列不可编辑,不可过滤,也不会显示在列表中;
                {
                    return(null);
                }
                if (schema == EnumComponentSchema.Edit &&
                    (name == "CreateDateTime" || name == "LastModifyDateTime"))
                {
                    return(null);
                }

                var  propertyType = property.PropertyType;
                Type innerType    = propertyType;
                if (propertyType.IsGenericType)
                {
                    innerType = propertyType.GenericTypeArguments[0];
                }
                AbstractConvertable convertible = null;
                if (propertyType == typeof(string))
                {
                    convertible = new StringConvertable(entityType, property);
                }
                else if (propertyType == typeof(DateTime) || innerType == typeof(DateTime))
                {
                    convertible = new DatetimeConvertable(entityType, property);
                }
                else if (propertyType.IsEnum || innerType.IsEnum)
                {
                    convertible = new EnumConvertable(entityType, property);
                }
                else if (propertyType == typeof(Int32) || innerType == typeof(Int32))
                {
                    convertible = new IntConvertable(entityType, property);
                }
                else if (propertyType == typeof(Int64) || innerType == typeof(Int64))
                {
                    convertible = new Int64Convertable(entityType, property);
                }
                else if (propertyType == typeof(decimal) || innerType == typeof(decimal))
                {
                    convertible = new DecimalConvertable(entityType, property);
                }
                else if (propertyType == typeof(Boolean) || innerType == typeof(Boolean))
                {
                    convertible = new BoolConvertable(entityType, property);
                }
                else
                {
                    convertible = new StringConvertable(entityType, property);   //默认使用字符串转换类型;
                }

                /*{
                 *  throw new Exception("不支持的类型转换: (");
                 * }*/
                if (componentAttr != null)
                {
                    if (property.Name == "CreateUserId")
                    {
                        componentAttr.width = "80";
                    }
                    if (property.Name == "CreateDateTime")
                    {
                        componentAttr.width = "160";
                    }
                    if (property.Name == "Name")
                    {
                        componentAttr.width = "180";
                    }
                }
                if (schema == EnumComponentSchema.Filter)
                {
                    componentAttr = convertible.ConvertToFilterVueComponentAttribute(entityType, property);
                }
                else if (schema == EnumComponentSchema.Edit)
                {
                    componentAttr = convertible.ConvertToClientEditVueComponentAttribute(entityType, property);
                }
                else if (schema == EnumComponentSchema.List)
                {
                    componentAttr = convertible.ConvertToClientTableColumnVueComponentAttribute(entityType, property);
                }
            }
            if (componentAttr != null)
            {
                if (property.Name == "CreateUserId" && componentAttr.serial == 0)
                {
                    componentAttr.serial = 999;
                }
                if (property.Name == "CreateDateTime" && componentAttr.serial == 0)
                {
                    componentAttr.serial = 1000;
                }
                if (property.Name == "Name" && componentAttr.serial == 0)
                {
                    componentAttr.serial = -1;
                }
                CopyPropertyInAttributeDefine(componentAttr, inputComponentAttr);
            }
            return(componentAttr);
        }