| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- namespace VberAdmin.Web.Models.Modals;
- public class VmQuerySearch
- {
- public readonly string _targetField;
- public VmQuerySearch()
- {
- ModalWidth = 900;
- IsSingle = true;
- }
- public VmQuerySearch(string modalId) : this()
- {
- ModalId = modalId;
- }
- /// <summary>
- /// <param name="modalId"></param>
- /// <param name="targetField">"id,name" "1:name,3:displayName" "1:name|name2,3:displayName"</param>
- /// <param name="originField">"id,name,name2,displayName"</param>
- /// </summary>
- public VmQuerySearch(string modalId, string targetField, string originField = null) : this(modalId)
- {
- _targetField = targetField;
- OriginField = originField;
- }
- public string ModalId { get; set; }
- public string ModalName { get; set; }
- public int ModalWidth { get; set; }
- public string TargetField
- {
- get
- {
- if (TargetFields is { Length: > 0 }) return string.Join(",", TargetFields);
- return _targetField;
- }
- }
- /// <summary>
- /// 目标字段
- /// </summary>
- public string[] TargetFields { get; set; }
- /// <summary>
- /// 有此值会覆盖模板的默认值。正常为空!
- /// </summary>
- public string OriginField { get; set; }
- /// <summary>
- /// 配合Ajax-Select 的赋值使用,
- /// </summary>
- public string AjaxSelectNameField { get; set; }
- public string SearchBindFun { get; set; }
- /// <summary>
- /// filed AND selectOption
- /// </summary>
- public Dictionary<string, string>[] SelectStrDic { get; set; }
- public VmQueryTreeSearch VmQueryTreeSearch { get; set; }
- public string SubmitEventName { get; set; }
- public string ItemClickEventName { get; set; }
- public string ItemDbClickEventName { get; set; }
- public bool IsSingle { get; set; }
- public VmQuerySearch SetModal(string modalId, string modalName = "", int width = 900)
- {
- if (!string.IsNullOrEmpty(modalId)) ModalId = modalId;
- ModalName = modalName;
- ModalWidth = width;
- return this;
- }
- public VmQuerySearch SetMultiple()
- {
- IsSingle = false;
- return this;
- }
- public VmQuerySearch SetTargetFields(params string[] targets)
- {
- TargetFields = targets;
- return this;
- }
- public VmQuerySearch SetAjaxSelectWithTarget(string selectName, params string[] targets)
- {
- AjaxSelectNameField = selectName;
- TargetFields = targets;
- return this;
- }
- public VmQuerySearch SetOriginField(params string[] originFields)
- {
- OriginField = string.Join(",", originFields);
- return this;
- }
- public VmQuerySearch SetAjaxSelectName(string name)
- {
- AjaxSelectNameField = name;
- return this;
- }
- public VmQuerySearch SetSearchFun(string funName)
- {
- SearchBindFun = funName;
- return this;
- }
- public VmQuerySearch SetSelectStrDic(params Dictionary<string, string>[] dic)
- {
- SelectStrDic = dic;
- return this;
- }
- /// <summary>
- /// 0:SubmitEventName(默认),1:ItemClickEventName,2:ItemDbClickEventName
- /// </summary>
- /// <param name="name"></param>
- /// <param name="type"></param>
- /// <returns></returns>
- public VmQuerySearch SetEventName(string name, int type = 0)
- {
- switch (type)
- {
- case 0:
- SubmitEventName = name;
- break;
- case 1:
- ItemClickEventName = name;
- break;
- case 2:
- ItemDbClickEventName = name;
- break;
- }
- return this;
- }
- }
|