| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.Collections.Generic;
- using System.Web.Mvc;
- using WeOnlineApp.Views.Shared.SearchForm;
- namespace WeOnlineApp.Views.Shared.Query
- {
- public class QueryItem
- {
- public QueryItem(string key, string name, bool isSearch = false, bool isDisabled = false, bool isHidden = false, FieldType fieldType = FieldType.S,
- ExpType expType = ExpType.Contains, string formatter = "")
- {
- Key = key;
- Name = name;
- IsSearch = isSearch;
- IsDisabled = isDisabled;
- IsHidden = isHidden;
- FieldType = fieldType;
- ExpType = expType;
- Formatter = formatter;
- }
- public string Key { get; set; }
- public string Name { get; set; }
- public string Formatter { get; set; }
- public bool IsSearch { get; set; }
- public bool IsHidden { get; set; }
- public string HiddenStr => IsHidden ? "display:none;" : "";
- public bool IsDisabled { get; set; }
- public string DisabledStr => IsDisabled ? "disable" : "";
- public FieldType FieldType { get; set; }
- public ExpType ExpType { get; set; }
- public bool IsSelectTree { get; set; }
- public string SelectTreeClass => IsSelectTree ? " select2tree" : "";
- public string SelectStr { get; set; }
- public QueryItem SetHidden()
- {
- IsHidden = true;
- return this;
- }
- public QueryItem SetDisabled()
- {
- IsDisabled = true;
- return this;
- }
- public QueryItem SetSelectStr(string str, bool isSelectTree = false)
- {
- IsSelectTree = isSelectTree;
- SelectStr = str;
- return this;
- }
- public QueryItem SetSelectStr(List<SelectListItem> list, bool isSelectTree = false)
- {
- IsSelectTree = isSelectTree;
- var str = "";
- foreach (var item in list)
- {
- str += $"<option value=\"{item.Value}\">{item.Text}</option>";
- }
- SelectStr = str;
- return this;
- }
- public QueryItem SetSelectStr(Dictionary<string, string> dic, bool isSelectTree = false)
- {
- IsSelectTree = isSelectTree;
- if (dic.ContainsKey(Key))
- {
- SelectStr = dic[Key];
- }
- return this;
- }
- }
- }
|