Ejemplo n.º 1
0
        public AtawPageViewModel Create()
        {
            result = new AtawPageViewModel();
            //数据载入完毕
            result.Data = new DataSet();
            //result.Data.Tables.Add(DataSourceRegName.PlugIn<DataTable>());
            // result.Data.Aggregate(result.Data);
            var listDataTable = DataSourceRegName.CodePlugIn <IListDataTable>();

            foreach (DataFormConfig form in DataFormConfigs)
            {
                AtawFormConfigView formView = new AtawFormConfigView();
                formView.FormType  = FormType.Normal;
                formView.ShowKind  = ShowKind.Tile;
                formView.TableName = form.TableName;
                formView.Title     = form.Title;

                formView.Columns = new List <AtawColumnConfigView>();
                foreach (var column in form.Columns)
                {
                    AtawColumnConfigView to = new AtawColumnConfigView();
                    to.ControlType = column.ControlType;
                    to.DisplayName = column.DisplayName;
                    to.Prompt      = column.Prompt;
                    to.ValPrompt   = column.ValPrompt;
                    to.Name        = column.Name;

                    string _controlRegname = column.ControlType.ToString();
                    // to.Options
                    var _optionCreator = _controlRegname.CodePlugIn <AtawOptionCreator>();
                    //初始化
                    _optionCreator.Config = column;
                    // _optionCreator.FormData = result.Data[formView.TableName];
                    _optionCreator.FormView = formView;
                    //方法调用
                    to.Options = _optionCreator.Create();
                }
            }
            return(result);
        }
        protected virtual AtawColumnConfigView CreateColumn(AtawFormConfigView formView, ColumnConfig column)
        {
            AtawColumnConfigView colView = new AtawColumnConfigView();

            colView.ControlType = column.ControlType;
            colView.DisplayName = column.DisplayName;
            colView.Prompt      = column.Prompt;
            colView.ValPrompt   = column.ValPrompt;

            //if ((PageStyle == PageStyle.Update || PageStyle == PageStyle.Insert) && colView.ValPrompt != null && column.ShowType > 0)
            //{

            //    column.ShowType = column.ShowType >= 3?0:2;

            //}
            if (column.Changer != null)
            {
                colView.Changer               = new ChangerViewConfig();
                colView.Changer.Expression    = column.Changer.Expression;
                colView.Changer.DependColumns = column.Changer.DependColumns;
                colView.Changer.NotifyColumns = column.Changer.NotifyColumns;
            }

            if (column.ShowType == 0 ||
                column.ControlType == ControlType.AllImageShow ||
                column.ControlType == ControlType.Editor ||
                column.ControlType == ControlType.EditorDetail ||
                column.ControlType == ControlType.ImageDetail ||
                column.ControlType == ControlType.PCAS ||
                column.ControlType == ControlType.MultiSelector ||
                column.ControlType == ControlType.MultiImageUpload ||
                column.ControlType == ControlType.SingleImageUpload ||
                column.ControlType == ControlType.SingleFileUpload ||
                column.ControlType == ControlType.MultiFileUpload ||
                column.ControlType == ControlType.FormMultiSelector ||
                column.ControlType == ControlType.TextArea)
            {
                colView.ShowType = "ColShowType".AppKv <int>(4);
            }
            else
            {
                colView.ShowType = column.ShowType;
            }
            if (column.ControlType == ControlType.Hidden)
            {
                colView.ShowType = 0;
            }
            colView.Sortable       = column.Sortable;
            colView.IsDetailLink   = column.IsDetailLink;
            colView.Name           = column.Name;
            colView.Kind           = column.Kind;
            colView.NormalStyle    = column.NormalStyle;
            colView.TdStyle        = column.TdStyle;
            colView.IsHiddenCol    = column.IsHiddenCol;
            colView.Width          = column.Width;
            colView.LinkFormat     = column.LinkFormat;
            colView.ChangeEventFun = column.ChangeEventFun;
            colView.Report         = column.Report;
            colView.TreeConfig     = column.TreeConfig;
            colView.ShortCutName   = column.ShortCutName;
            colView.Amount         = column.Amount;
            if (column.ControlType == ControlType.Custom)
            {
                AtawDebug.AssertArgumentNull(column.CustomControl, "Custom控件类型需要配置CustomControl", column);
                AtawDebug.AssertArgumentNullOrEmpty(column.CustomControl.ControlType, "CustomControl中必须指定自定义控件类型", column);
            }

            colView.CustomControl = column.CustomControl;
            if (column.ControlType == ControlType.Editor)
            {
                colView.Editor = column.Editor;
            }

            if (!column.SourceName.IsEmpty())
            {
                colView.QingColumnName = column.Name;
            }

            string controlRegname = column.ControlType.ToString();
            // to.Options
            var optionCreator = controlRegname.CodePlugIn <AtawOptionCreator>();

            //初始化
            optionCreator.Initialize(BasePageView, formView, column, PageStyle);
            //方法调用
            colView.Options = optionCreator.Create();
            return(colView);
        }
        private void CreateSearchColumn(AtawFormConfigView formView, ColumnConfig column)
        {
            AtawColumnConfigView colView = new AtawColumnConfigView();

            if (column.IsReadOnly)
            {
                column.IsReadOnly = false;
            }

            if (column.ControlType == ControlType.TreeMultiSelector)
            {
                colView.ControlType = ControlType.TreeSingleSelector;
            }
            else if (column.ControlType == ControlType.Detail || column.ControlType == ControlType.TextArea || (column.Search != null && column.Search.IsLike == true))//添加如果islike为true
            {
                colView.ControlType = ControlType.Text;
            }
            //else if (column.Search.ControlType != ControlType.None)
            //{
            //    colView.ControlType = column.Search.ControlType;
            //}
            else if (column.ControlType == ControlType.SingleCheckBox)
            {
                colView.ControlType = ControlType.Combo;
                column.RegName      = "SingleCheckBoxIsOrNo";
            }
            else
            {
                colView.ControlType = column.ControlType;
            }
            //搜索区的控件类型当为搜索字段配置的控件类型
            if (column.Search.ControlType != ControlType.None)
            {
                colView.ControlType = column.Search.ControlType;
            }
            if (column.Search.DateSpan)
            {
                colView.DisplayName = column.DisplayName + "开始";
            }
            else
            {
                colView.DisplayName = column.DisplayName;
            }
            colView.DisplayName = column.DisplayName;
            colView.Name        = column.Name;

            string controlRegname = colView.ControlType.ToString();
            // to.Options
            var optionCreator = controlRegname.CodePlugIn <AtawOptionCreator>();

            //初始化
            optionCreator.Initialize(BasePageView, formView, column, PageStyle.None);
            //方法调用
            colView.Options = optionCreator.Create();

            if (!column.DetailRegName.IsEmpty())
            {
                colView.Options.RegName = column.DetailRegName;
            }
            if (column.Search != null && column.Search.IsOpenByDefault == true)
            {
                colView.Options.IsOpenByDefault = true;
            }
            colView.Options.DataValue = null;
            if (column.ControlType == ControlType.Text) //Text字段,模糊查询
            {
                colView.Options.PostSetting.ColumnName = colView.Name + "_LIKE";
            }
            //如果islike为true则
            if (column.Search != null && column.Search.IsLike == true)
            {
                colView.Options.PostSetting.ColumnName = colView.Name + "_LIKE";
                colView.Options.IsLike = true;
            }
            if (column.Search.IsExtension) //查询扩展
            {
                colView.Options.PostSetting.ColumnName = colView.Name + "_IN";
            }

            //查询区日期控件需要扩展成2个控件
            if (column.Search.DateSpan)
            {
                colView.DisplayName = column.DisplayName + "开始";
                formView.Columns.Add(colView);
                PageStyle = PageStyle.None;//避免创建选择器控件或多选控件的时候重复解码CodeTable
                var col = CreateColumn(formView, column);
                PageStyle             = PageStyle.List;
                col.DisplayName       = column.DisplayName + "结束";
                col.Name              = column.Name + "_END";
                col.ControlType       = colView.ControlType;
                col.Options.DataValue = null;
                col.Options.PostSetting.ColumnName = col.Name;
                formView.Columns.Add(col);
            }
            else
            {
                formView.Columns.Add(colView);
            }
        }
        protected virtual AtawNaviColumnConfigView CreateColumnNavigation(AtawColumnConfigView atawColumnConfigView, ColumnConfig columnConfig)
        {
            if (atawColumnConfigView == null || columnConfig == null)
            {
                return(null);
            }
            try
            {
                AtawColumnConfigView viewColumn = new AtawColumnConfigView();
                atawColumnConfigView.ObjectClone <AtawColumnConfigView>(viewColumn);
                // viewColumn = atawColumnConfigView.c
                // viewColumn = atawColumnConfigView;


                AtawNaviColumnConfigView naviViewColumn = new AtawNaviColumnConfigView();
                naviViewColumn.ChangeEventFun = viewColumn.ChangeEventFun;
                naviViewColumn.DisplayName    = viewColumn.DisplayName;
                naviViewColumn.Prompt         = viewColumn.Prompt;
                naviViewColumn.ValPrompt      = viewColumn.ValPrompt;
                naviViewColumn.Kind           = viewColumn.Kind;
                naviViewColumn.Name           = viewColumn.Name;
                naviViewColumn.ShowType       = viewColumn.ShowType;
                naviViewColumn.NormalStyle    = viewColumn.NormalStyle;
                naviViewColumn.Width          = viewColumn.Width;
                naviViewColumn.TdStyle        = viewColumn.TdStyle;
                naviViewColumn.IsHiddenCol    = viewColumn.IsHiddenCol;
                naviViewColumn.Sortable       = viewColumn.Sortable;
                naviViewColumn.Options        = new BaseOptions();
                viewColumn.Options.ObjectClone(naviViewColumn.Options);
                naviViewColumn.IsRefrech   = columnConfig.Navigation.IsRefrech;
                naviViewColumn.IsAvailable = columnConfig.Navigation.IsAvailable;
                naviViewColumn.IsExpand    = columnConfig.Navigation.IsExpand;
                if (!string.IsNullOrEmpty(columnConfig.Navigation.RegName))
                {
                    naviViewColumn.Options.RegName = columnConfig.Navigation.RegName;
                }
                ControlType controlType = columnConfig.Navigation.ControlType;
                if (controlType == ControlType.CheckBoxNavi ||
                    controlType == ControlType.RadioNavi ||
                    controlType == ControlType.TreeSingleNavi ||
                    controlType == ControlType.TreeMultiNavi ||
                    controlType == ControlType.SingleRadioNavi ||
                    controlType == ControlType.RadioNavi ||
                    controlType == ControlType.NaviFilter
                    )
                {
                    naviViewColumn.ControlType = controlType;
                }
                else
                {
                    switch (columnConfig.ControlType)
                    {
                    case ControlType.Combo:
                    case ControlType.Radio:
                        naviViewColumn.ControlType = ControlType.RadioNavi;
                        break;

                    case ControlType.CheckBox:
                        naviViewColumn.ControlType = ControlType.CheckBoxNavi;
                        break;

                    case ControlType.SingleCheckBox:
                        naviViewColumn.ControlType = ControlType.SingleRadioNavi;
                        break;

                    case ControlType.TreeSingleSelector:
                        naviViewColumn.ControlType = ControlType.TreeSingleNavi;
                        break;

                    case ControlType.TreeMultiSelector:
                        naviViewColumn.ControlType = ControlType.TreeMultiNavi;
                        break;

                    case ControlType.NaviFilter:
                        naviViewColumn.ControlType = ControlType.NaviFilter;
                        break;

                    default:
                        return(null);
                    }
                }
                return(naviViewColumn);
            }
            catch
            {
                return(null);
            }
        }