index.vue 15 KB

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