SensorDetailModal - 复制.razor 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 
  2. <div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
  3. <div class="bg-white rounded-2xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden">
  4. <!-- 模态框头部 -->
  5. <div class="bg-gradient-to-r from-blue-500 to-indigo-600 p-6 flex justify-between items-center">
  6. <h2 class="text-2xl font-bold text-white">传感器详细信息</h2>
  7. <button @onclick="OnClose"
  8. class="text-white hover:text-gray-200 focus:outline-none focus:ring-2 focus:ring-white rounded-full p-2 transition-colors">
  9. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  10. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
  11. </svg>
  12. </button>
  13. </div>
  14. <!-- 模态框内容 -->
  15. <div class="overflow-y-auto max-h-[70vh]">
  16. <table class="min-w-full divide-y divide-gray-200">
  17. <thead class="bg-gray-50">
  18. <tr>
  19. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">传感器</th>
  20. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">数值</th>
  21. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">当天预报警状态</th>
  22. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">预报警信息</th>
  23. </tr>
  24. </thead>
  25. <tbody class="bg-white divide-y divide-gray-200">
  26. @if (SensorData != null)
  27. {
  28. @foreach (var record in SensorData)
  29. {
  30. <tr class="hover:bg-gray-50">
  31. <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">@record.Sensor</td>
  32. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">@record.Value</td>
  33. <td class="px-6 py-4 whitespace-nowrap text-sm font-medium
  34. @(record.Status == 0 ? "text-gray-900" :
  35. record.Status == 1 ? "text-yellow-600" : "text-red-600")">
  36. @(record.Status == 0 ? "正常" :
  37. record.Status == 1 ? "警告" : "严重")
  38. </td>
  39. <td class="px-6 py-4 text-sm
  40. @(record.Status == 0 ? "text-gray-500" :
  41. record.Status == 1 ? "text-yellow-600" : "text-red-600")">
  42. @record.Message
  43. </td>
  44. </tr>
  45. }
  46. }
  47. else
  48. {
  49. <tr>
  50. <td colspan="4" class="px-6 py-4 text-center text-sm text-gray-500">暂无数据</td>
  51. </tr>
  52. }
  53. </tbody>
  54. </table>
  55. </div>
  56. <!-- 模态框底部 -->
  57. <div class="bg-gray-50 px-6 py-4 flex justify-end">
  58. <button @onclick="OnClose"
  59. class="px-6 py-2 bg-gradient-to-r from-blue-500 to-indigo-600 text-white font-medium rounded-lg hover:from-blue-600 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-all">
  60. 关闭
  61. </button>
  62. </div>
  63. </div>
  64. </div>
  65. @code {
  66. [Parameter]
  67. public string SensorType { get; set; }
  68. [Parameter]
  69. public List<Home.SensorRecord> SensorData { get; set; }
  70. [Parameter]
  71. public EventCallback OnClose { get; set; }
  72. }