Nozzle.razor 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. @using EasyTemplate.Service
  2. <div class="card-container">
  3. <div class="icon-section">
  4. <img src=@IconUrl alt="功能图标" />
  5. </div>
  6. <div class="text-section">
  7. <div class="bottom-text">@BottomText</div>
  8. </div>
  9. <div class="right-section">
  10. <div class="right-line-one">@NozNo 号枪</div>
  11. <div class="right-line-two">@VLR</div>
  12. <div class="right-line-three">@OilName</div>
  13. </div>
  14. </div>
  15. @code {
  16. public string IconUrl { get; set; } = "img/nozzle.png";
  17. //[Parameter] public string IconAltText { get; set; } = "功能图标";
  18. //[Parameter] public string TopText { get; set; } = "默认标题";
  19. [Parameter] public int warnstate { get; set; } = 0;
  20. [Parameter] public int nozzlestate { get; set; } = 0;
  21. [Parameter] public string BottomText { get; set; } = "";
  22. [Parameter] public string NozNo { get; set; } = "行1";
  23. [Parameter] public string VLR { get; set; } = "行2";
  24. [Parameter] public string OilName { get; set; } = "行3";
  25. protected override void OnParametersSet()
  26. {
  27. RecalculateInternalValues();
  28. }
  29. private void RecalculateInternalValues()
  30. {
  31. if (nozzlestate == Tool.NozzleState_Offline)
  32. {
  33. IconUrl = "img/nozzle-offline.png";
  34. }
  35. else if (nozzlestate == Tool.NozzleState_Idle)
  36. {
  37. IconUrl = "img/nozzle-idle.png";
  38. }
  39. else if (nozzlestate == Tool.NozzleState_Filling)
  40. {
  41. IconUrl = "img/nozzle-filling.png";
  42. }
  43. else
  44. {
  45. IconUrl = "img/nozzle-offline.png";
  46. }
  47. }
  48. }
  49. <style>
  50. .card-container {
  51. width: 90px;
  52. height: 65px;
  53. position: relative;
  54. /* border: 1px solid #e0e0e0; */
  55. border-radius: 6px;
  56. box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  57. font-family: Arial, sans-serif;
  58. }
  59. .icon-section {
  60. position: absolute;
  61. top: 0;
  62. left: 0;
  63. width: 54px;
  64. height: 54px;
  65. display: flex;
  66. align-items: center;
  67. justify-content: center;
  68. }
  69. .icon-section img {
  70. width: 100%;
  71. height: 100%;
  72. object-fit: cover;
  73. border-top-left-radius: 6px;
  74. }
  75. .text-section {
  76. position: absolute;
  77. bottom: 0;
  78. left: 0;
  79. padding: 4px;
  80. }
  81. .bottom-text {
  82. font-size: 10px;
  83. color: #666;
  84. white-space: nowrap;
  85. overflow: hidden;
  86. text-overflow: ellipsis;
  87. }
  88. .right-section {
  89. position: absolute;
  90. top: 0;
  91. right: 0;
  92. padding: 2px 4px;
  93. text-align: right;
  94. width: calc(100% - 32px);
  95. }
  96. .right-line-one,
  97. .right-line-two,
  98. .right-line-three {
  99. font-size: 10px;
  100. color: #444;
  101. line-height: 1.3;
  102. white-space: nowrap;
  103. overflow: hidden;
  104. text-overflow: ellipsis;
  105. }
  106. </style>