VmInputNumberDialer.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using VberZero.Tools.StringModel;
  2. namespace VberAdmin.Web.Models.Input;
  3. public class VmInputNumberDialer : VmInputBase
  4. {
  5. public VmInputNumberDialer(string name, string displayName) : base(name, displayName, VmInputType.Dialer)
  6. {
  7. Step = 1;
  8. Prefix = "";
  9. Suffix = "";
  10. Decimals = 0;
  11. DefaultClass = "form-control form-control-sm form-control-solid border-0 ps-12";
  12. }
  13. /// <summary>
  14. /// 步长
  15. /// </summary>
  16. public decimal Step { get; set; }
  17. /// <summary>
  18. /// 前缀
  19. /// </summary>
  20. public string Prefix { get; set; }
  21. /// <summary>
  22. /// 后缀
  23. /// </summary>
  24. public string Suffix { get; set; }
  25. /// <summary>
  26. /// 小数位数
  27. /// </summary>
  28. public int Decimals { get; set; }
  29. public string ControlDataStr => $"data-kt-dialer=\"true\" data-kt-dialer-step=\"{Step}\" {(Min != null ? $"data-kt-dialer-min=\"{Min}\"" : "")} {(Max is > 0 ? $"data-kt-dialer-max=\"{Max}\"" : "")} {(Decimals > 0 ? $"data-kt-dialer-decimals=\"{Decimals}\"" : "")} {(Prefix.Empty() ? "" : $"data-kt-dialer-prefix=\"{Prefix}\"")} {(Suffix.Empty() ? "" : $"data-kt-dialer-suffix=\"{Suffix}\"")} ";
  30. public override string Other
  31. {
  32. get => $"{base.Other ?? ""} data-kt-dialer-control=\"input\"";
  33. set => _other = value;
  34. }
  35. public VmInputNumberDialer WithDialerFix(string prefix = "", string suffix = "")
  36. {
  37. Prefix = prefix;
  38. Suffix = suffix;
  39. return this;
  40. }
  41. public VmInputNumberDialer WithDecimals(int count)
  42. {
  43. Decimals = count;
  44. return this;
  45. }
  46. public VmInputNumberDialer WithStep(decimal step)
  47. {
  48. if (step <= 0)
  49. {
  50. return this;
  51. }
  52. Step = step;
  53. return this;
  54. }
  55. public VmInputNumberDialer WithDialer(int? min = null, int? max = null)
  56. {
  57. Min = min;
  58. Max = max;
  59. DefaultValue = Min + "";
  60. return this;
  61. }
  62. }