cityEmergencyEvent.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <template>
  2. <div class="container">
  3. <div class="event-box">
  4. <div class="box-header">
  5. <div class="title-box">
  6. <div class="title"><i class="icon-speaker"/>重大事件信息</div>
  7. </div>
  8. </div>
  9. <div class="event-content">
  10. <div class="text1">{{ noticeBarState[0]?.event_title }}</div>
  11. <div class="text2">{{ noticeBarState[0]?.time }}</div>
  12. </div>
  13. </div>
  14. <div ref="searchBoxRef" class="search-box">
  15. <van-search
  16. v-model="keywords"
  17. placeholder="请输入位置信息"
  18. class="common-search"
  19. :left-icon="searchImg"
  20. show-action
  21. @search="onSearchKeyword"
  22. >
  23. <template #action>
  24. <div class="search-btn" @click="onSearchKeyword">搜索</div>
  25. </template>
  26. </van-search>
  27. <div v-show="showSearch" class="search-list">
  28. <div
  29. v-for="(item, index) in searchList"
  30. :key="index"
  31. class="item"
  32. @click="handleClickItem(item)"
  33. >
  34. {{ item.name }}
  35. </div>
  36. </div>
  37. </div>
  38. <div class="content" style="margin-top: 0">
  39. <Map
  40. ref="mapRef"
  41. class="map"
  42. active-map="satellite"
  43. customMarker
  44. @onLoadCompleted="initData"
  45. @onMarkerClick="handleRowClick"
  46. />
  47. </div>
  48. <div class="content">
  49. <div class="card">
  50. <div class="card-header">
  51. <i class="icon-line"/>
  52. <div class="text">趋势统计</div>
  53. </div>
  54. <Chart :option="option1" style="height: 200px"/>
  55. </div>
  56. </div>
  57. <div class="content">
  58. <div class="card">
  59. <div class="card-header">
  60. <i class="icon-line"/>
  61. <div class="text">事件列表</div>
  62. </div>
  63. <div class="select-box" @click="showPicker = true">
  64. <div class="text1">年度</div>
  65. <div class="select-item">
  66. <div class="label">{{ yearLabel ? yearLabel : "请选择" }}</div>
  67. <i class="icon-down"/>
  68. </div>
  69. </div>
  70. <el-table
  71. :data="dataList"
  72. border
  73. table-layout="auto"
  74. @row-click="handleRowClick"
  75. >
  76. <el-table-column label="类别" prop="event_type" align="center">
  77. <template #default="scope">
  78. <dict-tag :options="mm_event_type" :value="scope.row.event_type"/>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="位置" prop="address" align="center"/>
  82. <el-table-column label="发生时间" prop="event_time" align="center"/>
  83. <el-table-column label="受伤人数" prop="injuries" align="center"/>
  84. <el-table-column label="死亡人数" prop="deaths" align="center"/>
  85. </el-table>
  86. </div>
  87. </div>
  88. <van-popup v-model:show="showPicker" round position="bottom">
  89. <van-picker
  90. :columns="columns"
  91. @cancel="showPicker = false"
  92. @confirm="onPickerConfirm"
  93. />
  94. </van-popup>
  95. <van-popup v-model:show="showDetailPop" position="bottom">
  96. <div class="title">事件详情</div>
  97. <div class="unit-box">
  98. <div class="text">位置</div>
  99. <div class="info-content">{{ rowDetail.address }}</div>
  100. </div>
  101. <div class="unit-box">
  102. <div class="text">灾害类型</div>
  103. <div class="info-content">
  104. <dict-tag :options="mm_event_type" :value="rowDetail.event_type"/>
  105. </div>
  106. </div>
  107. <div class="unit-box">
  108. <div class="text">发生时间</div>
  109. <div class="info-content">{{ rowDetail.event_time }}</div>
  110. </div>
  111. <div class="unit-box">
  112. <div class="text">受伤人数</div>
  113. <div class="info-content">{{ rowDetail.injuries }}</div>
  114. </div>
  115. <div class="unit-box">
  116. <div class="text">死亡人数</div>
  117. <div class="info-content">{{ rowDetail.deaths }}</div>
  118. </div>
  119. </van-popup>
  120. </div>
  121. </template>
  122. <script lang="ts" setup name="cityEmergencyEvent">
  123. import {ElTable, ElTableColumn} from "element-plus";
  124. import Map from '@/components/Map/index2.vue';
  125. import {getEvent} from "@/api/duty/eventing";
  126. import {chartOption1} from "@/views/disasterRiskMonitor/chartOptions";
  127. import searchImg from "@/assets/images/search.png";
  128. import { iconList } from '@/components/Map/mapData';
  129. import { getActiveEventList, getEventCompletedTrend } from "@/api/event";
  130. const proxy = getCurrentInstance()?.proxy;
  131. const {mm_event_type} = toRefs<any>(
  132. proxy?.useDict('mm_event_type')
  133. );
  134. let mapRef = ref();
  135. const noticeBarState = ref([]);
  136. // 搜索
  137. const searchBoxRef = ref();
  138. const keywords = ref('');
  139. let searchList = ref([]);
  140. let showSearch = ref(false);
  141. let yearLabel = ref("");
  142. onClickOutside(searchBoxRef, event => {
  143. showSearch.value = false;
  144. });
  145. const onSearchKeyword = () => {
  146. searchList.value = []
  147. getSearch();
  148. };
  149. const handleClickItem = (row) => {
  150. showSearch.value = false;
  151. const dom = mapRef.value;
  152. const map = dom.getMap();
  153. const mapUtils = dom.getMapUtils();
  154. const center = row.lonlat.split(",").map(Number);
  155. const item = iconList['common'];
  156. mapUtils.addSearchMarker({
  157. icon: item.image,
  158. image: item.image,
  159. imageHover: item.image,
  160. size: item.size,
  161. lnglat: center
  162. });
  163. map.setCenter(center);
  164. map.setZoom(16);
  165. };
  166. const getSearch = async() => {
  167. const url = `https://api.tianditu.gov.cn/v2/search?postStr=${encodeURIComponent(JSON.stringify({
  168. keyWord: keywords.value,
  169. level: '18',
  170. mapBound: "73.33,8.33,135.08,53.55",
  171. queryType: '1',
  172. start: 0,
  173. count: 10
  174. }))}&tk=a8df87f1695d224d2679aa805c1268d9&type=query`
  175. const res = await fetch(url);
  176. if (res.status === 200) {
  177. const data = await res.json();
  178. searchList.value = data.pois
  179. }
  180. showSearch.value = true;
  181. }
  182. let dataList = ref([]);
  183. const option1 = ref(chartOption1);
  184. const queryParams = reactive({
  185. page: 1,
  186. page_size: 10,
  187. year: ''
  188. });
  189. let loading = ref(false);
  190. let showPicker = ref(false);
  191. const showDetailPop = ref(false);
  192. let columns = reactive([
  193. {text: "2025年", value: "2025"},
  194. {text: "2024年", value: "2024"},
  195. {text: "2023年", value: "2023"},
  196. {text: "2022年", value: "2022"},
  197. {text: "2021年", value: "2021"}
  198. ]);
  199. const getImageUrl = name => {
  200. return new URL(
  201. `../../assets/images/dotIcon/${name}`,
  202. import.meta.url
  203. ).href;
  204. };
  205. const onPickerConfirm = ({selectedOptions}) => {
  206. showPicker.value = false;
  207. yearLabel.value = selectedOptions[0].text;
  208. queryParams.year = selectedOptions[0].value;
  209. getList()
  210. };
  211. const getList = () => {
  212. loading.value = true;
  213. getEvent(queryParams).then(res => {
  214. dataList.value = res.data;
  215. dataList.value.forEach(item => {
  216. const icon = {
  217. image: getImageUrl("address.png"),
  218. size: [30, 32]
  219. }
  220. item.icon = icon.image;
  221. item.image = icon.image;
  222. item.imageHover = icon.image;
  223. item.size = icon.size;
  224. item.lnglat = [item.longitude, item.latitude];
  225. });
  226. const dom = mapRef.value;
  227. dom.addMarker(dataList.value);
  228. }).finally(() => {
  229. loading.value = false;
  230. });
  231. };
  232. const getCompletedTrend = async() => {
  233. getEventCompletedTrend().then((res) => {
  234. option1.value.xAxis[0].data = res.data.xAxis;
  235. res.data.series.forEach((n, i)=>{
  236. option1.value.series[i].data = n;
  237. });
  238. })
  239. };
  240. const rowDetail = ref({
  241. address: '',
  242. event_type: '',
  243. event_time: '',
  244. injuries: '',
  245. deaths: ''
  246. });
  247. const handleRowClick = (row) => {
  248. setTimeout(() => {
  249. showDetailPop.value = true;
  250. rowDetail.value = row;
  251. }, 10)
  252. };
  253. const initData = () => {
  254. getActiveEventList().then(res => {
  255. if (res.data.event_id != '') {
  256. noticeBarState.value = [{
  257. event_id: res.data.event_id,
  258. time: res.data.event_time,
  259. event_title: res.data.event_description
  260. }];
  261. }
  262. });
  263. // noticeBarState.value = [
  264. // {
  265. // event_id: "",
  266. // time: "2024-03-01 12:12:12",
  267. // event_title: "茂名市茂南区xxx高速路口发生交通事故,今日凌晨三点在xx高速路口,由于突降暴雨路面湿滑,导致路面积水严重,不少路过车辆都减速慢行…"
  268. // }
  269. // ];
  270. // 趋势统计
  271. // option1.value.xAxis[0].data = [
  272. // "2024-01",
  273. // "2024-02",
  274. // "2024-03",
  275. // "2024-04",
  276. // "2024-05",
  277. // "2024-06"
  278. // ];
  279. // option1.value.series[0].data = [
  280. // 502.84, 205.97, 332.79, 281.55, 398.35, 214.02
  281. // ];
  282. // option1.value.series[1].data = [
  283. // 281.55, 398.35, 214.02, 179.55, 289.57, 356.14
  284. // ];
  285. // 事件列表
  286. getList();
  287. getCompletedTrend();
  288. };
  289. </script>
  290. <style lang="scss" scoped>
  291. .container {
  292. .map {
  293. width: 100%;
  294. height: 250px;
  295. }
  296. .event-box {
  297. position: relative;
  298. width: 375px;
  299. height: 117px;
  300. background: url("@/assets/images/disasterRiskMonitor/cityEmergencyEvent/box1.png") no-repeat;
  301. background-size: 100% 100%;
  302. box-shadow: 0 2px 4px 0 rgba(228, 240, 255, 1);
  303. .box-header {
  304. display: flex;
  305. justify-content: space-between;
  306. align-items: center;
  307. padding: 0 6px;
  308. .more {
  309. font-size: 12px;
  310. color: #2c81ff;
  311. }
  312. }
  313. .title-box {
  314. height: 30px;
  315. background-color: #ffffff; /* 背景颜色 */
  316. transform: skewX(-20deg); /* 斜切变形 */
  317. box-shadow: 0 2px 4px 0 rgba(250, 217, 97, 0.18);
  318. padding: 0 10px;
  319. display: flex;
  320. align-items: center;
  321. border-radius: 2px;
  322. &::after {
  323. content: "";
  324. position: absolute;
  325. top: 0;
  326. right: -6px;
  327. transform: skewX(20deg);
  328. width: 11px;
  329. height: 27px;
  330. background: url("@/assets/images/disasterRiskMonitor/riverMonitor/thickness.png") no-repeat;
  331. background-size: 100% 100%;
  332. }
  333. .title {
  334. font-size: 14px;
  335. color: #ffaf00;
  336. transform: skewX(20deg);
  337. display: flex;
  338. align-items: center;
  339. .icon-speaker {
  340. display: inline-block;
  341. width: 16px;
  342. height: 16px;
  343. background: url("@/assets/images/disasterRiskMonitor/riverMonitor/speaker.png") no-repeat;
  344. background-size: 100% 100%;
  345. margin-right: 5px;
  346. }
  347. }
  348. }
  349. .event-content {
  350. padding: 0 10px;
  351. }
  352. .text1 {
  353. display: -webkit-box;
  354. -webkit-line-clamp: 3;
  355. -webkit-box-orient: vertical;
  356. overflow: hidden;
  357. text-overflow: ellipsis;
  358. font-size: 14px;
  359. color: #414f64;
  360. }
  361. .text2 {
  362. font-size: 12px;
  363. color: rgba(0, 0, 0, 0.45);
  364. text-align: right;
  365. }
  366. }
  367. }
  368. .search-box {
  369. position: relative;
  370. padding: 16px 16px 10px;
  371. }
  372. .search-list {
  373. position: absolute;
  374. top: 55px;
  375. left: 0;
  376. z-index: 9;
  377. width: 100%;
  378. height: calc(100vh - 400px);
  379. overflow-y: auto;
  380. background-color: #ffffff;
  381. border-top: 1px solid #eeeeee;
  382. .item {
  383. padding: 8px 15px;
  384. border-bottom: 1px solid #eeeeee;
  385. }
  386. }
  387. .common-search {
  388. border: 1px solid #dce0ee;
  389. border-radius: 2px;
  390. padding: 0;
  391. :deep(.van-field__control) {
  392. &::placeholder {
  393. color: #c9cfd9;
  394. }
  395. }
  396. :deep(.van-search__content) {
  397. background-color: #ffffff;
  398. border: none !important;
  399. }
  400. :deep(.van-field__left-icon) {
  401. .van-icon__image {
  402. width: 12px;
  403. height: 12px;
  404. }
  405. }
  406. :deep(.van-field__right-icon) {
  407. width: 30px;
  408. height: 30px;
  409. padding: 0;
  410. .van-icon__image {
  411. width: 30px;
  412. height: 30px;
  413. }
  414. }
  415. .search-btn {
  416. font-size: 14px;
  417. color: #2c81ff;
  418. }
  419. }
  420. .card {
  421. background-color: #ffffff;
  422. border: 1px solid #eaedf7;
  423. border-radius: 4px;
  424. padding: 2px;
  425. margin-top: 16px;
  426. &:first-child {
  427. margin-top: 0;
  428. }
  429. .card-header {
  430. font-size: 16px;
  431. color: #414f64;
  432. font-weight: bold;
  433. line-height: 26px;
  434. padding: 11px 10px;
  435. display: flex;
  436. align-items: center;
  437. border-top-left-radius: 4px;
  438. border-top-right-radius: 4px;
  439. background-image: linear-gradient(180deg, #f3f7fd 0%, #ffffff 100%);
  440. .icon-line {
  441. display: inline-block;
  442. width: 6px;
  443. height: 16px;
  444. background: url("@/assets/images/line.jpg") no-repeat;
  445. background-size: 100% 100%;
  446. margin-right: 3px;
  447. }
  448. }
  449. }
  450. .content {
  451. padding: 0 16px;
  452. margin-top: 16px;
  453. }
  454. .select-box {
  455. display: flex;
  456. justify-content: flex-end;
  457. align-items: center;
  458. margin-bottom: 10px;
  459. padding-right: 20px;
  460. .text1 {
  461. font-size: 14px;
  462. color: #414f64;
  463. margin-right: 5px;
  464. }
  465. .select-item {
  466. background-color: #f4f7fc;
  467. padding: 5px;
  468. min-width: 92px;
  469. height: 32px;
  470. border-radius: 4px;
  471. font-size: 14px;
  472. color: #414f64;
  473. display: flex;
  474. align-items: center;
  475. .label {
  476. flex: 1;
  477. }
  478. .icon-down {
  479. flex-shrink: 0;
  480. display: inline-block;
  481. width: 14px;
  482. height: 14px;
  483. background: url("@/assets/images/down.png") no-repeat;
  484. background-size: 100% 100%;
  485. margin-left: 5px;
  486. }
  487. }
  488. }
  489. /* 移除表单容器背景 */
  490. :deep(.van-cell-group) {
  491. background: transparent !important;
  492. }
  493. /* 移除每个表单项的背景 */
  494. :deep(.van-cell) {
  495. background: transparent !important;
  496. }
  497. /* 移除内嵌容器的边距和阴影 */
  498. :deep(.van-cell-group--inset) {
  499. margin: 0;
  500. box-shadow: none;
  501. &::after {
  502. border: none !important;
  503. }
  504. }
  505. :deep(.van-field--disabled) {
  506. .van-field__label,
  507. .van-field__control {
  508. color: rgba(12, 12, 12, 0.93) !important;
  509. -webkit-text-fill-color: #4a4848 !important;
  510. }
  511. /* 移除禁用蒙层 */
  512. .van-field__disabled-mask {
  513. display: none !important;
  514. }
  515. }
  516. .title {
  517. font-size: 18px;
  518. font-weight: bold;
  519. line-height: 32px;
  520. width: 100%;
  521. text-align: center;
  522. margin-bottom: 8px;
  523. margin-top: 8px;
  524. }
  525. .unit-box {
  526. display: flex;
  527. background-color: #ffffff;
  528. min-height: 35px;
  529. width: 100%;
  530. border-bottom: 1px solid #f4f5f7;
  531. padding: 10px 15px;
  532. }
  533. .text {
  534. color: grey;
  535. width: 64px;
  536. flex-shrink: 0;
  537. margin-right: 10px;
  538. }
  539. .info-content {
  540. word-break: break-all;
  541. }
  542. </style>