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;
}
///
///
/// "id,name" "1:name,3:displayName" "1:name|name2,3:displayName"
/// "id,name,name2,displayName"
///
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;
}
}
///
/// 目标字段
///
public string[] TargetFields { get; set; }
///
/// 有此值会覆盖模板的默认值。正常为空!
///
public string OriginField { get; set; }
///
/// 配合Ajax-Select 的赋值使用,
///
public string AjaxSelectNameField { get; set; }
public string SearchBindFun { get; set; }
///
/// filed AND selectOption
///
public Dictionary[] 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[] dic)
{
SelectStrDic = dic;
return this;
}
///
/// 0:SubmitEventName(默认),1:ItemClickEventName,2:ItemDbClickEventName
///
///
///
///
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;
}
}