예제 #1
0
        public async Task <IActionResult> Edit(UrlParameter param)
        {
            ViewBag.ImportTypeList = new SelectList(Enum.GetValues(typeof(TableImportType)).Cast <TableImportType>());
            var module = (await _tableListService.GetByIdAsync(param.id)).data;

            return(View(module));
        }
예제 #2
0
        public async Task <IActionResult> Index(UrlParameter param)
        {
            ViewBag.queryString = Request.QueryString.Value;
            var model = new ViewListModel();

            model.Table = (await _tableListService.GetByIdAsync(param.id)).data;
            var result = await _tableColumnService.GetListAsync(item => item.TableId == param.id && item.ListVisible == 1);

            model.TableColumn = result.data.OrderBy(c => c.ListOrder).ToList();
            ViewBag.TableName = model.Table.Description;

            var viewEditWidthHeight =
                string.IsNullOrEmpty(model.Table.ViewEditWidthHeight) ||
                model.Table.ViewEditWidthHeight.Split("|").Length != 2
                ? "90%,90%|90%,90%".Split("|") : model.Table.ViewEditWidthHeight.Split("|");
            //example: width,height|width,height
            var viewWidth     = viewEditWidthHeight[0].Split(',')[0];
            var viewHeight    = viewEditWidthHeight[0].Split(',')[1];
            var addEditWidth  = viewEditWidthHeight[1].Split(',')[0];
            var addEditHeight = viewEditWidthHeight[1].Split(',')[1];

            ViewBag.viewWidth     = viewWidth.Contains("px") || viewWidth.Contains("%") ? viewWidth : "90%";
            ViewBag.viewHeight    = viewHeight.Contains("px") || viewHeight.Contains("%") ? viewHeight : "90%";
            ViewBag.addEditWidth  = addEditWidth.Contains("px") || addEditWidth.Contains("%") ? addEditWidth : "90%";
            ViewBag.addEditHeight = addEditHeight.Contains("px") || addEditHeight.Contains("%") ? addEditHeight : "90%";

            var showBtnModel = new ShowButtonModel
            {
                ShowAddBtn    = model.Table.AllowAdd == 1,
                ShowEditBtn   = model.Table.AllowEdit == 1,
                ShowDelBtn    = model.Table.AllowDelete == 1,
                ShowImportBtn = model.Table.AllowImport == 1,
                ShowExportBtn = model.Table.AllowExport == 1,
                ShowDetailBtn = model.Table.AllowDetail == 1,

                TopExtendFunction = model.Table.TopExtendFunction,
            };

            ViewBag.ShowButton = showBtnModel;

            foreach (var column in model.TableColumn)
            {
                if (column.DataType == ColumnType.Out || column.DataType == ColumnType.MultiSelect_Out)
                {
                    var outSqlModel = new OutSqlModel(column.OutSql);
                    var queryResult = await SysService.GetOutData(outSqlModel);

                    var items = new List <SelectListItem>();
                    foreach (var row in queryResult)
                    {
                        items.Add(new SelectListItem
                        {
                            Value = row[outSqlModel.PrimaryKey].ToString(),
                            Text  = row[outSqlModel.TextKey].ToString(),
                        });
                    }
                    ViewData[column.Name] = new SelectList(items, "Value", "Text");
                }
                else if (column.DataType == ColumnType.Enum)
                {
                    var enumStr = column.EnumRange.Split(','); //value,value
                    var items   = new List <SelectListItem>();
                    for (int i = 0; i < enumStr.Length; i++)
                    {
                        items.Add(new SelectListItem
                        {
                            Value = enumStr[i],
                            Text  = enumStr[i]
                        });
                    }
                    ViewData[column.Name] = new SelectList(items, "Value", "Text");
                }
                else if (column.DataType == ColumnType.MultiSelect)
                {
                    var checkStr = column.SelectRange.Split('|'); //值,选项1|2,选项2
                    var items    = new List <SelectListItem>();
                    for (int i = 0; i < checkStr.Length; i++)
                    {
                        items.Add(new SelectListItem
                        {
                            Value = checkStr[i].Split(',')[0],
                            Text  = checkStr[i].Split(',')[1],
                        });
                    }
                    ViewData[column.Name] = new SelectList(items, "Value", "Text");
                }
            }

            return(View(model));
        }