SensorDetailModal.razor 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
  2. <div class="bg-white rounded-2xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden">
  3. <!-- 模态框内容 -->
  4. <div class="overflow-y-auto max-h-[70vh]">
  5. <table class="min-w-full divide-y divide-gray-200">
  6. <thead class="bg-gray-50">
  7. <tr>
  8. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">传感器</th>
  9. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">数值</th>
  10. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">当天预报警状态</th>
  11. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">预报警信息</th>
  12. </tr>
  13. </thead>
  14. <tbody class="bg-white divide-y divide-gray-200">
  15. @if (SensorData != null)
  16. {
  17. @foreach (var record in SensorData)
  18. {
  19. <tr class="hover:bg-gray-50">
  20. <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">@record.Sensor</td>
  21. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">@record.Value</td>
  22. <td class="px-6 py-4 whitespace-nowrap text-sm font-medium
  23. @(record.Status == 0 ? "text-gray-900" :
  24. record.Status == 1 ? "text-yellow-600" : "text-red-600")">
  25. @(record.Status == 0 ? "正常" :
  26. record.Status == 1 ? "警告" : "严重")
  27. </td>
  28. <td class="px-6 py-4 text-sm
  29. @(record.Status == 0 ? "text-gray-500" :
  30. record.Status == 1 ? "text-yellow-600" : "text-red-600")">
  31. @record.Message
  32. </td>
  33. </tr>
  34. }
  35. }
  36. else
  37. {
  38. <tr>
  39. <td colspan="4" class="px-6 py-4 text-center text-sm text-gray-500">暂无数据</td>
  40. </tr>
  41. }
  42. </tbody>
  43. </table>
  44. </div>
  45. <!-- 模态框底部 -->
  46. <div class="bg-gray-50 px-6 py-4 flex justify-end">
  47. <button @onclick="OnClose"
  48. 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">
  49. 关闭
  50. </button>
  51. </div>
  52. </div>
  53. </div>
  54. @code {
  55. [Parameter]
  56. public string SensorType { get; set; }
  57. [Parameter]
  58. public List<Home.SensorRecord> SensorData { get; set; }
  59. [Parameter]
  60. public EventCallback OnClose { get; set; }
  61. }