warningSituation.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div class="container">
  3. <van-image :src="detailsData.img" />
  4. <el-table :data="detailsData.dataList" border table-layout="auto">
  5. <el-table-column prop="type" align="center">
  6. <template #header>
  7. <div class="table-line" @click="showTypePicker = true">
  8. <div>{{ labelData.type ? labelData.type : "类型" }}</div>
  9. <i class="icon-down" />
  10. </div>
  11. </template>
  12. <template #default="scope">
  13. <img
  14. v-if="scope.row.level === '1'"
  15. :src="'src/assets/images/disasterRiskMonitor/warningSituation/icon5.png'"
  16. alt="blue alert"
  17. class="alert-icon"
  18. />
  19. <img
  20. v-else-if="scope.row.level === '2'"
  21. :src="'src/assets/images/disasterRiskMonitor/warningSituation/icon2.png'"
  22. alt="yellow alert"
  23. class="alert-icon"
  24. />
  25. <img
  26. v-else-if="scope.row.level === '3'"
  27. :src="'src/assets/images/disasterRiskMonitor/warningSituation/icon3.png'"
  28. alt="orange alert"
  29. class="alert-icon"
  30. />
  31. <img
  32. v-else-if="scope.row.level === '4'"
  33. :src="'src/assets/images/disasterRiskMonitor/warningSituation/icon4.png'"
  34. alt="red alert"
  35. class="alert-icon"
  36. />
  37. <span v-else>无预警</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column prop="level" align="center">
  41. <template #header>
  42. <div class="table-line" @click="showLevelPicker = true">
  43. <div>{{ labelData.level ? labelData.level : "等级" }}</div>
  44. <i class="icon-down" />
  45. </div>
  46. </template>
  47. <template #default="scope">
  48. <div :class="getClass(scope.row.level)">
  49. {{ getLabel(scope.row.level) }}
  50. </div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="地区" prop="area" align="center" />
  54. <el-table-column label="发布时间" prop="publicTime" align="center" />
  55. </el-table>
  56. <van-popup v-model:show="showTypePicker" round position="bottom">
  57. <van-picker
  58. :columns="typeColumns"
  59. @cancel="showTypePicker = false"
  60. @confirm="onSelectTypeConfirm"
  61. />
  62. </van-popup>
  63. <van-popup v-model:show="showLevelPicker" round position="bottom">
  64. <van-picker
  65. :columns="levelColumns"
  66. @cancel="showLevelPicker = false"
  67. @confirm="onSelectLevelConfirm"
  68. />
  69. </van-popup>
  70. </div>
  71. </template>
  72. <script lang="ts" setup name="warningSituation">
  73. import { onMounted, reactive, ref } from "vue";
  74. import { ElTable, ElTableColumn } from "element-plus";
  75. const labelData = reactive({
  76. type: "",
  77. level: "",
  78. area: ""
  79. });
  80. const queryParams = reactive({
  81. type: "",
  82. level: "",
  83. area: ""
  84. });
  85. const detailsData = ref({
  86. img: "",
  87. dataList: []
  88. });
  89. const getClass = (data: string) => {
  90. let res = "text";
  91. if (data === "1") {
  92. res = "text text-blue";
  93. } else if (data === "2") {
  94. res = "text text-yellow";
  95. } else if (data === "3") {
  96. res = "text text-orange";
  97. } else if (data === "4") {
  98. res = "text text-red";
  99. }
  100. return res;
  101. };
  102. const getLabel = (data: string) => {
  103. let res = "无预警";
  104. if (data === "1") {
  105. res = "蓝色";
  106. } else if (data === "2") {
  107. res = "黄色";
  108. } else if (data === "3") {
  109. res = "橙色";
  110. } else if (data === "4") {
  111. res = "红色";
  112. }
  113. return res;
  114. };
  115. const initData = () => {
  116. detailsData.value = {
  117. img: "src/assets/images/disasterRiskMonitor/warningSituation/icon1.png",
  118. dataList: [
  119. {
  120. area: "电白",
  121. type: "1",
  122. level: "2",
  123. publicTime: "2024-10-28 13:32:01"
  124. },
  125. {
  126. area: "高新",
  127. type: "1",
  128. level: "2",
  129. publicTime: "2024-10-28 14:42:21"
  130. },
  131. {
  132. area: "茂南",
  133. type: "1",
  134. level: "0",
  135. publicTime: "2024-10-28 15:13:13"
  136. },
  137. {
  138. area: "滨海",
  139. type: "1",
  140. level: "2",
  141. publicTime: "2024-10-28 16:27:21"
  142. },
  143. {
  144. area: "化州",
  145. type: "1",
  146. level: "1",
  147. publicTime: "2024-10-28 17:31:55"
  148. },
  149. {
  150. area: "高州",
  151. type: "1",
  152. level: "3",
  153. publicTime: "2024-10-28 17:49:01"
  154. },
  155. { area: "信宜", type: "1", level: "3", publicTime: "2024-10-28 18:09:11" }
  156. ]
  157. };
  158. };
  159. // 获取类型标签
  160. const getTypeLabel = (typeCode: string) => {
  161. const typeItem = typeColumns.value.find(item => item.value === typeCode);
  162. return typeItem ? typeItem.text : "未知类型";
  163. };
  164. const typeColumns = ref([
  165. { text: "全部", value: "" },
  166. { text: "森林火险", value: "1" }
  167. ]);
  168. let showTypePicker = ref(false);
  169. const onSelectTypeConfirm = ({ selectedOptions }) => {
  170. showTypePicker.value = false;
  171. labelData.type = selectedOptions[0].text;
  172. queryParams.type = selectedOptions[0].value;
  173. initData();
  174. };
  175. const levelColumns = ref([
  176. { text: "全部", value: "" },
  177. { text: "无预警", value: "0" },
  178. { text: "蓝色", value: "1" },
  179. { text: "黄色", value: "2" },
  180. { text: "橘色", value: "3" },
  181. { text: "红色", value: "4" }
  182. ]);
  183. let showLevelPicker = ref(false);
  184. const onSelectLevelConfirm = ({ selectedOptions }) => {
  185. showLevelPicker.value = false;
  186. labelData.level = selectedOptions[0].text;
  187. queryParams.level = selectedOptions[0].value;
  188. initData();
  189. };
  190. onMounted(() => {
  191. initData();
  192. });
  193. </script>
  194. <style lang="scss" scoped>
  195. .container {
  196. height: 100vh;
  197. padding: 0;
  198. .table-line {
  199. display: flex;
  200. align-items: center;
  201. font-size: 14px;
  202. .icon-down {
  203. margin-left: 3px;
  204. display: inline-block;
  205. flex-shrink: 0;
  206. width: 14px;
  207. height: 14px;
  208. background: url("@/assets/images/down.png") no-repeat;
  209. background-size: 100% 100%;
  210. }
  211. }
  212. .text {
  213. font-size: 14px;
  214. color: #a3a7ad;
  215. }
  216. .text-blue {
  217. color: #2c81ff;
  218. }
  219. .text-yellow {
  220. color: #ffd700;
  221. }
  222. .text-orange {
  223. color: #ffaf00;
  224. }
  225. .text-red {
  226. color: #ec2734;
  227. }
  228. }
  229. .alert-icon {
  230. width: 36px;
  231. height: 24px;
  232. }
  233. </style>