index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div class="left-section">
  3. <div class="weather-card">
  4. <div class="weather-item">
  5. <div class="gradient-text weatherBox1" style="margin-left: 95px">天气</div>
  6. <div class="weatherBox2">
  7. <div class="sunnyIcon"></div>
  8. </div>
  9. </div>
  10. <div class="weather-item">
  11. <div class="gradient-text weatherBox1" style="margin-left: 70px">温度</div>
  12. <div class="weatherBox2">
  13. <div class="temperatureIcon"></div>
  14. <div class="text">{{ temperature }}<span class="text1">℃</span></div>
  15. </div>
  16. </div>
  17. <div class="weather-item">
  18. <div class="gradient-text weatherBox1" style="margin-left: 110px">湿度</div>
  19. <div class="weatherBox2">
  20. <div class="humidityIcon"></div>
  21. <div class="text">{{ humidity }}<span class="text1">%</span></div>
  22. </div>
  23. </div>
  24. <div class="weather-item">
  25. <div class="gradient-text weatherBox1" style="margin-left: 18px">风力</div>
  26. <div class="weatherBox2">
  27. <div class="windPowerIcon"></div>
  28. <div class="text">{{ windDirection }} {{ windLevel }}级</div>
  29. </div>
  30. </div>
  31. <div class="weather-item">
  32. <div class="gradient-text weatherBox1" style="margin-left: 58px">降雨量</div>
  33. <div class="weatherBox2">
  34. <div class="rainfall"></div>
  35. <div class="text">{{ rainfall }}<span class="text1">mm</span></div>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="event-card">
  40. <div class="title gradient-text">灾害信息</div>
  41. <div class="card-content">
  42. <div class="event-box">
  43. <div class="event-item">
  44. <div class="event-icon1"></div>
  45. <div class="text-box">
  46. <div class="text1">灾害事件</div>
  47. <div class="text2">{{ eventData.event_title }}</div>
  48. </div>
  49. </div>
  50. <div class="event-item">
  51. <div class="event-icon2"></div>
  52. <div class="text-box">
  53. <div class="text1">灾害级别</div>
  54. <div class="text2"><dict-tag :options="mm_event_level" :value="eventData.event_level" /></div>
  55. </div>
  56. </div>
  57. <div class="event-item">
  58. <div class="event-icon3"></div>
  59. <div class="text-box">
  60. <div class="text1">灾害地点</div>
  61. <div class="text2">{{ eventData.address }}</div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="eventBox1">
  66. <div class="duration-box">
  67. <div class="icon1"></div>
  68. <div class="duration-item">
  69. <div class="gradient-text duration-text">持续时长</div>
  70. <div class="time-box">
  71. <span class="time-text">{{ duration.days }}</span>
  72. <span>天</span>
  73. <span class="time-text">{{ duration.hours }}</span>
  74. <span>小时</span>
  75. <span class="time-text">{{ duration.minutes }}</span>
  76. <span>分</span>
  77. <span class="time-text">{{ duration.seconds }}</span>
  78. <span>秒</span>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="finish-btn" @click="closeCommand">
  83. <div class="finish-icon"></div>
  84. <div class="finish-text">结束处置</div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <VideoMonitor />
  90. <CloseCommand
  91. v-model="closeCommandState.show"
  92. :title="closeCommandState.title"
  93. :flag="flag"
  94. :event-id="eventId"
  95. @update:model-value="fetchEventDetail"
  96. />
  97. </div>
  98. </template>
  99. <script lang="ts" setup name="LeftSection">
  100. import { getEventDetail, getWeather } from '@/api/duty/eventing';
  101. import VideoMonitor from '@/views/emergencyCommandMap/LeftSection/VideoMonitor.vue';
  102. import { ref, onMounted, onUnmounted, computed } from 'vue';
  103. import CloseCommand from './CloseCommand.vue';
  104. const route = useRoute();
  105. const router = useRouter();
  106. const eventId = ref('');
  107. // 天气相关数据
  108. const weatherDescription = ref('');
  109. const temperature = ref('');
  110. const humidity = ref('');
  111. const windDirection = ref('');
  112. const windLevel = ref('');
  113. const rainfall = ref('');
  114. // 灾害事件数据
  115. const eventData = ref({
  116. event_title: '',
  117. event_type: '',
  118. event_level: '',
  119. address: '',
  120. event_status: '',
  121. event_source: '',
  122. event_time: '',
  123. report_time: ''
  124. });
  125. // 灾害信息卡片中的持续时间
  126. const duration = computed(() => {
  127. if (isNaN(elapsedTime.value) || elapsedTime.value < 0) {
  128. return { days: 0, hours: 0, minutes: 0, seconds: 0 };
  129. }
  130. const totalSeconds = Math.floor(elapsedTime.value / 1000);
  131. const days = Math.floor(totalSeconds / (24 * 3600));
  132. const hours = Math.floor((totalSeconds % (24 * 3600)) / 3600);
  133. const minutes = Math.floor((totalSeconds % 3600) / 60);
  134. const seconds = totalSeconds % 60;
  135. return { days, hours, minutes, seconds };
  136. });
  137. const closeCommandState = reactive({
  138. show: false,
  139. title: '',
  140. flag: false, // 默认为 false
  141. eventId: ''
  142. });
  143. const elapsedTime = ref(0);
  144. let intervalId = null;
  145. // 获取天气数据
  146. async function fetchWeatherData() {
  147. try {
  148. const response = await getWeather({});
  149. if (response && response.rows && response.rows.length > 0) {
  150. const weatherData = response.rows[0];
  151. weatherDescription.value = weatherData.sk_s;
  152. temperature.value = weatherData.sk_t;
  153. humidity.value = weatherData.sk_h;
  154. windDirection.value = getWindDirection(weatherData.sk_wd);
  155. windLevel.value = weatherData.sk_wp_level;
  156. rainfall.value = weatherData.sk_r1h;
  157. }
  158. } catch (error) {
  159. console.error('Failed to fetch weather data:', error);
  160. }
  161. }
  162. // 根据风向角度获取风向名称
  163. function getWindDirection(angle) {
  164. const directions = [
  165. '北',
  166. '北偏北',
  167. '北偏东北',
  168. '东北',
  169. '东偏东北',
  170. '东偏东',
  171. '东',
  172. '东偏东南',
  173. '东南',
  174. '南偏东南',
  175. '南偏南',
  176. '南',
  177. '南偏西南',
  178. '西南',
  179. '西偏西南',
  180. '西偏西',
  181. '西',
  182. '西偏西北',
  183. '西北',
  184. '北偏西北'
  185. ];
  186. const index = Math.floor(((angle + 11.25) % 360) / 22.5);
  187. return directions[index];
  188. }
  189. const fetchEventDetail = (id: string) => {
  190. console.log('fetchEventDetail');
  191. if (id && id !== eventData.value.event_id) {
  192. // 如果有 id,则正常获取事件详情
  193. getEventDetail({ event_id: id }).then((res) => {
  194. eventData.value = res.data;
  195. // 初始化响应时间
  196. updateTime();
  197. });
  198. }
  199. };
  200. const closeCommand = () => {
  201. console.log('CloseCommand');
  202. closeCommandState.title = '结束指挥';
  203. closeCommandState.eventId = eventId.value;
  204. closeCommandState.show = true;
  205. };
  206. // 当关闭对话框时,不重置 eventId
  207. watch(closeCommandState.show, (newVal) => {
  208. if (!newVal) {
  209. // 对话框关闭时,保持 eventId 的状态
  210. eventId.value = closeCommandState.eventId;
  211. // 保持 eventData 的状态
  212. fetchEventDetail(eventId.value);
  213. }
  214. });
  215. const updateTime = () => {
  216. if (eventData.value.event_time && typeof eventData.value.event_time === 'string') {
  217. const eventTime = new Date(eventData.value.event_time);
  218. if (!isNaN(eventTime.getTime())) {
  219. elapsedTime.value = Date.now() - eventTime.getTime();
  220. } else {
  221. console.error('Invalid date format:', eventData.value.event_time);
  222. }
  223. } else {
  224. // 如果没有 event_time,则重置响应时间为 0
  225. elapsedTime.value = 0;
  226. }
  227. };
  228. onMounted(() => {
  229. // 从 URL 参数中获取 tempEventId 或 event_id
  230. const flag = !!route.query.event_id;
  231. eventId.value = flag ? route.query.event_id : route.query.tempEventId;
  232. closeCommandState.flag = flag; // 将 flag 赋值给 closeCommandState
  233. fetchEventDetail(eventId.value);
  234. fetchWeatherData();
  235. intervalId = setInterval(updateTime, 1000);
  236. });
  237. onUnmounted(() => {
  238. if (intervalId) {
  239. clearInterval(intervalId);
  240. }
  241. });
  242. </script>
  243. <style lang="scss" scoped>
  244. .left-section {
  245. width: 1965px;
  246. height: 100%;
  247. display: flex;
  248. flex-direction: column;
  249. font-size: 74px;
  250. .weather-card {
  251. width: 1922px;
  252. height: 230px;
  253. background: url('@/assets/images/emergencyCommandMap/weather/weatherBg.png') no-repeat;
  254. background-size: 100% 100%;
  255. display: flex;
  256. align-items: center;
  257. margin-top: 35px;
  258. color: #fff;
  259. .weather-item {
  260. width: 390px;
  261. font-size: 48px;
  262. margin-left: 2px;
  263. &:first-child {
  264. width: 295px;
  265. margin-left: 0;
  266. padding-left: 15px;
  267. }
  268. &:nth-child(3) {
  269. width: 435px;
  270. }
  271. .weatherBox1 {
  272. position: relative;
  273. height: 60px;
  274. }
  275. .weatherBox2 {
  276. display: flex;
  277. justify-content: center;
  278. align-items: center;
  279. height: 82px;
  280. margin-top: 10px;
  281. .text {
  282. margin-left: 20px;
  283. display: flex;
  284. align-items: flex-end;
  285. .text1 {
  286. font-size: 32px;
  287. }
  288. }
  289. }
  290. .sunnyIcon {
  291. width: 135px;
  292. height: 105px;
  293. background: url('@/assets/images/emergencyCommandMap/weather/sunny.png') no-repeat;
  294. }
  295. .temperatureIcon {
  296. width: 135px;
  297. height: 105px;
  298. background: url('@/assets/images/emergencyCommandMap/weather/temperature.png') no-repeat;
  299. }
  300. .humidityIcon {
  301. width: 135px;
  302. height: 109px;
  303. background: url('@/assets/images/emergencyCommandMap/weather/humidity.png') no-repeat;
  304. }
  305. .windPowerIcon {
  306. width: 135px;
  307. height: 116px;
  308. background: url('@/assets/images/emergencyCommandMap/weather/windPower.png') no-repeat;
  309. }
  310. .rainfall {
  311. width: 135px;
  312. height: 109px;
  313. background: url('@/assets/images/emergencyCommandMap/weather/rainfall.png') no-repeat;
  314. }
  315. }
  316. }
  317. .event-card {
  318. width: 1965px;
  319. height: 422px;
  320. background: url('@/assets/images/emergencyCommandMap/disasterInfo/disasterInfoBg.png') no-repeat;
  321. background-size: 100% 100%;
  322. margin-top: 20px;
  323. display: flex;
  324. justify-content: center;
  325. align-items: center;
  326. position: relative;
  327. .title {
  328. position: absolute;
  329. top: 12px;
  330. left: 130px;
  331. font-size: 60px;
  332. }
  333. .card-content {
  334. margin-top: 60px;
  335. width: 1904px;
  336. height: 260px;
  337. background: url('@/assets/images/emergencyCommandMap/disasterInfo/contentBg.png') no-repeat;
  338. background-size: 100% 100%;
  339. padding-left: 120px;
  340. padding-right: 20px;
  341. display: flex;
  342. }
  343. .eventBox1 {
  344. display: flex;
  345. justify-content: right;
  346. align-items: center;
  347. font-family: 'BEBAS-1';
  348. font-size: 38px;
  349. color: #00e8ff;
  350. margin-top: -20px;
  351. .icon1 {
  352. width: 138px;
  353. height: 156px;
  354. background: url('@/assets/images/emergencyCommandMap/disasterInfo/time.png') no-repeat;
  355. margin-top: -50px;
  356. }
  357. }
  358. .event-box {
  359. display: flex;
  360. align-items: flex-start;
  361. color: #fff;
  362. flex-wrap: wrap;
  363. width: 578px;
  364. .event-item {
  365. font-size: 38px;
  366. margin-top: -20px;
  367. display: flex;
  368. width: 317px;
  369. position: relative;
  370. padding-left: 120px;
  371. margin-left: -30px;
  372. &:last-child {
  373. width: 574px;
  374. }
  375. .event-icon1,
  376. .event-icon2,
  377. .event-icon3 {
  378. position: absolute;
  379. top: 0;
  380. left: 0;
  381. flex-shrink: 0;
  382. width: 149px;
  383. height: 149px;
  384. }
  385. .event-icon1 {
  386. background: url('@/assets/images/emergencyCommandMap/disasterInfo/icon1.png');
  387. }
  388. .event-icon2 {
  389. height: 150px;
  390. background: url('@/assets/images/emergencyCommandMap/disasterInfo/icon2.png');
  391. }
  392. .event-icon3 {
  393. background: url('@/assets/images/emergencyCommandMap/disasterInfo/icon3.png');
  394. }
  395. .text-box {
  396. margin-top: 35px;
  397. .text1 {
  398. font-size: 32px;
  399. color: #a7ccdf;
  400. }
  401. .text2 {
  402. font-size: 36px;
  403. color: #ffffff;
  404. }
  405. }
  406. }
  407. }
  408. }
  409. .duration-box {
  410. width: 893px;
  411. height: 224px;
  412. margin-top: 160px;
  413. margin-left: 22px;
  414. background: url('@/assets/images/emergencyCommandMap/disasterInfo/durationBg.png');
  415. display: flex;
  416. .text {
  417. font-size: 44px;
  418. }
  419. .duration-item {
  420. margin-top: -22px;
  421. margin-left: 10px;
  422. }
  423. .time-box {
  424. font-size: 30px;
  425. color: #ffffff;
  426. margin-top: -10px;
  427. .time-text {
  428. /* 设置字体透明 */
  429. color: transparent;
  430. /* 设置线性渐变,从红色渐变到蓝色 */
  431. background-image: linear-gradient(to bottom, #fff 20%, #f6d6a7 50%, #e48406 100%);
  432. /* 使用 -webkit-background-clip 属性将背景剪裁至文本形状 */
  433. -webkit-background-clip: text;
  434. /* 非Webkit内核浏览器需要使用标准前缀 */
  435. background-clip: text;
  436. /* 把当前元素设置为行内块,以便能够应用背景 */
  437. display: inline-block;
  438. font-family: 'BEBAS-1';
  439. font-size: 50px;
  440. width: 150px;
  441. text-align: center;
  442. &:first-child {
  443. width: 70px;
  444. text-align: left;
  445. }
  446. }
  447. }
  448. }
  449. .finish-btn {
  450. display: flex;
  451. flex-direction: column;
  452. margin-top: -160px;
  453. justify-content: center;
  454. cursor: pointer;
  455. margin-top: 35px;
  456. margin-left: 80px;
  457. .finish-icon {
  458. width: 97px;
  459. height: 107px;
  460. background: url('@/assets/images/emergencyCommandMap/disasterInfo/finishBtn.png');
  461. }
  462. .finish-text {
  463. font-size: 30.58px;
  464. /* 设置字体透明 */
  465. color: transparent;
  466. /* 设置线性渐变,从红色渐变到蓝色 */
  467. background-image: linear-gradient(to bottom, #fff 20%, #ff2f3c 50%, #ff2f3c 100%);
  468. /* 使用 -webkit-background-clip 属性将背景剪裁至文本形状 */
  469. -webkit-background-clip: text;
  470. /* 非Webkit内核浏览器需要使用标准前缀 */
  471. background-clip: text;
  472. /* 把当前元素设置为行内块,以便能够应用背景 */
  473. display: inline-block;
  474. font-family: 'YouSheBiaoTiHei';
  475. }
  476. }
  477. }
  478. @keyframes slide {
  479. 0% {
  480. transform: translateX(-80%);
  481. }
  482. 80% {
  483. transform: translateX(92px);
  484. }
  485. 80% {
  486. transform: translateX(0);
  487. }
  488. }
  489. </style>