| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using VberZero.Tools.StringModel;
- namespace VberAdmin.Web.Models.Input;
- public class VmInputSelectAjax : VmInputBase
- {
- public VmInputSelectAjax(string name, string displayName) : base(name, displayName, VmInputType.AjaxSelect)
- {
- DefaultClass = "form-select form-select-sm form-control-sm form-select-solid ajax-select";
- }
- public VmInputSelectAjax(string name, string displayName, string codeKey, string modalId, string clear = "", int takeCount = 10) : this(name, displayName)
- {
- CodeKey = codeKey;
- TakeCount = takeCount;
- QueryModalId = modalId;
- if (clear.Empty())
- {
- WithQueryClear(Name);
- }
- else
- {
- WithQueryClear(clear, true);
- }
- }
- public string CodeKey { get; protected set; }
- public int TakeCount { get; protected set; }
- /// <summary>
- /// 展示模板函数
- /// </summary>
- public string FunResultTemplateName { get; protected set; }
- public string ControlDataStr =>
- "data-select-ajax=\"true\" " +
- $"data-dropdown-parent=\"#{ModalId}\" " +
- $"data-placeholder=\"{PlaceholderStr}\" " +
- $"data-param-key=\"{CodeKey}\" " +
- $"data-param-count=\"{TakeCount}\" " +
- $"{(FunResultTemplateName.Empty() ? "" : $"data-result-template-function=\"{FunResultTemplateName}\"")}";
- public VmInputSelectAjax WithCodeKey(string codeKey)
- {
- CodeKey = codeKey;
- return this;
- }
- public VmInputSelectAjax WithTakeCount(int takeCount)
- {
- TakeCount = takeCount;
- return this;
- }
- public VmInputSelectAjax WithResultTemplateName(string resultTemplateName)
- {
- FunResultTemplateName = resultTemplateName;
- return this;
- }
- }
|