cityEmergencyEvent.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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 } 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 = `http://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 rowDetail = ref({
  233. address: '',
  234. event_type: '',
  235. event_time: '',
  236. injuries: '',
  237. deaths: ''
  238. });
  239. const handleRowClick = (row) => {
  240. setTimeout(() => {
  241. showDetailPop.value = true;
  242. rowDetail.value = row;
  243. }, 10)
  244. };
  245. const initData = () => {
  246. getActiveEventList().then(res => {
  247. if (res.data.event_id != '') {
  248. noticeBarState.value = [{
  249. event_id: res.data.event_id,
  250. time: res.data.event_time,
  251. event_title: res.data.event_description
  252. }];
  253. }
  254. });
  255. // noticeBarState.value = [
  256. // {
  257. // event_id: "",
  258. // time: "2024-03-01 12:12:12",
  259. // event_title: "茂名市茂南区xxx高速路口发生交通事故,今日凌晨三点在xx高速路口,由于突降暴雨路面湿滑,导致路面积水严重,不少路过车辆都减速慢行…"
  260. // }
  261. // ];
  262. // 趋势统计
  263. option1.value.xAxis[0].data = [
  264. "2024-01",
  265. "2024-02",
  266. "2024-03",
  267. "2024-04",
  268. "2024-05",
  269. "2024-06"
  270. ];
  271. option1.value.series[0].data = [
  272. 502.84, 205.97, 332.79, 281.55, 398.35, 214.02
  273. ];
  274. option1.value.series[1].data = [
  275. 281.55, 398.35, 214.02, 179.55, 289.57, 356.14
  276. ];
  277. // 事件列表
  278. getList()
  279. };
  280. </script>
  281. <style lang="scss" scoped>
  282. .container {
  283. .map {
  284. width: 100%;
  285. height: 250px;
  286. }
  287. .event-box {
  288. position: relative;
  289. width: 375px;
  290. height: 117px;
  291. background: url("@/assets/images/disasterRiskMonitor/cityEmergencyEvent/box1.png") no-repeat;
  292. background-size: 100% 100%;
  293. box-shadow: 0 2px 4px 0 rgba(228, 240, 255, 1);
  294. .box-header {
  295. display: flex;
  296. justify-content: space-between;
  297. align-items: center;
  298. padding: 0 6px;
  299. .more {
  300. font-size: 12px;
  301. color: #2c81ff;
  302. }
  303. }
  304. .title-box {
  305. height: 30px;
  306. background-color: #ffffff; /* 背景颜色 */
  307. transform: skewX(-20deg); /* 斜切变形 */
  308. box-shadow: 0 2px 4px 0 rgba(250, 217, 97, 0.18);
  309. padding: 0 10px;
  310. display: flex;
  311. align-items: center;
  312. border-radius: 2px;
  313. &::after {
  314. content: "";
  315. position: absolute;
  316. top: 0;
  317. right: -6px;
  318. transform: skewX(20deg);
  319. width: 11px;
  320. height: 27px;
  321. background: url("@/assets/images/disasterRiskMonitor/riverMonitor/thickness.png") no-repeat;
  322. background-size: 100% 100%;
  323. }
  324. .title {
  325. font-size: 14px;
  326. color: #ffaf00;
  327. transform: skewX(20deg);
  328. display: flex;
  329. align-items: center;
  330. .icon-speaker {
  331. display: inline-block;
  332. width: 16px;
  333. height: 16px;
  334. background: url("@/assets/images/disasterRiskMonitor/riverMonitor/speaker.png") no-repeat;
  335. background-size: 100% 100%;
  336. margin-right: 5px;
  337. }
  338. }
  339. }
  340. .event-content {
  341. padding: 0 10px;
  342. }
  343. .text1 {
  344. display: -webkit-box;
  345. -webkit-line-clamp: 3;
  346. -webkit-box-orient: vertical;
  347. overflow: hidden;
  348. text-overflow: ellipsis;
  349. font-size: 14px;
  350. color: #414f64;
  351. }
  352. .text2 {
  353. font-size: 12px;
  354. color: rgba(0, 0, 0, 0.45);
  355. text-align: right;
  356. }
  357. }
  358. }
  359. .search-box {
  360. position: relative;
  361. padding: 16px 16px 10px;
  362. }
  363. .search-list {
  364. position: absolute;
  365. top: 55px;
  366. left: 0;
  367. z-index: 9;
  368. width: 100%;
  369. height: calc(100vh - 400px);
  370. overflow-y: auto;
  371. background-color: #ffffff;
  372. border-top: 1px solid #eeeeee;
  373. .item {
  374. padding: 8px 15px;
  375. border-bottom: 1px solid #eeeeee;
  376. }
  377. }
  378. .common-search {
  379. border: 1px solid #dce0ee;
  380. border-radius: 2px;
  381. padding: 0;
  382. :deep(.van-field__control) {
  383. &::placeholder {
  384. color: #c9cfd9;
  385. }
  386. }
  387. :deep(.van-search__content) {
  388. background-color: #ffffff;
  389. border: none !important;
  390. }
  391. :deep(.van-field__left-icon) {
  392. .van-icon__image {
  393. width: 12px;
  394. height: 12px;
  395. }
  396. }
  397. :deep(.van-field__right-icon) {
  398. width: 30px;
  399. height: 30px;
  400. padding: 0;
  401. .van-icon__image {
  402. width: 30px;
  403. height: 30px;
  404. }
  405. }
  406. .search-btn {
  407. font-size: 14px;
  408. color: #2c81ff;
  409. }
  410. }
  411. .card {
  412. background-color: #ffffff;
  413. border: 1px solid #eaedf7;
  414. border-radius: 4px;
  415. padding: 2px;
  416. margin-top: 16px;
  417. &:first-child {
  418. margin-top: 0;
  419. }
  420. .card-header {
  421. font-size: 16px;
  422. color: #414f64;
  423. font-weight: bold;
  424. line-height: 26px;
  425. padding: 11px 10px;
  426. display: flex;
  427. align-items: center;
  428. border-top-left-radius: 4px;
  429. border-top-right-radius: 4px;
  430. background-image: linear-gradient(180deg, #f3f7fd 0%, #ffffff 100%);
  431. .icon-line {
  432. display: inline-block;
  433. width: 6px;
  434. height: 16px;
  435. background: url("@/assets/images/line.jpg") no-repeat;
  436. background-size: 100% 100%;
  437. margin-right: 3px;
  438. }
  439. }
  440. }
  441. .content {
  442. padding: 0 16px;
  443. margin-top: 16px;
  444. }
  445. .select-box {
  446. display: flex;
  447. justify-content: flex-end;
  448. align-items: center;
  449. margin-bottom: 10px;
  450. padding-right: 20px;
  451. .text1 {
  452. font-size: 14px;
  453. color: #414f64;
  454. margin-right: 5px;
  455. }
  456. .select-item {
  457. background-color: #f4f7fc;
  458. padding: 5px;
  459. min-width: 92px;
  460. height: 32px;
  461. border-raduis: 4px;
  462. font-size: 14px;
  463. color: #414f64;
  464. display: flex;
  465. align-items: center;
  466. .label {
  467. flex: 1;
  468. }
  469. .icon-down {
  470. flex-shrink: 0;
  471. display: inline-block;
  472. width: 14px;
  473. height: 14px;
  474. background: url("@/assets/images/down.png") no-repeat;
  475. background-size: 100% 100%;
  476. margin-left: 5px;
  477. }
  478. }
  479. }
  480. /* 移除表单容器背景 */
  481. :deep(.van-cell-group) {
  482. background: transparent !important;
  483. }
  484. /* 移除每个表单项的背景 */
  485. :deep(.van-cell) {
  486. background: transparent !important;
  487. }
  488. /* 移除内嵌容器的边距和阴影 */
  489. :deep(.van-cell-group--inset) {
  490. margin: 0;
  491. box-shadow: none;
  492. &::after {
  493. border: none !important;
  494. }
  495. }
  496. :deep(.van-field--disabled) {
  497. .van-field__label,
  498. .van-field__control {
  499. color: rgba(12, 12, 12, 0.93) !important;
  500. -webkit-text-fill-color: #4a4848 !important;
  501. }
  502. /* 移除禁用蒙层 */
  503. .van-field__disabled-mask {
  504. display: none !important;
  505. }
  506. }
  507. .title {
  508. font-size: 18px;
  509. font-weight: bold;
  510. line-height: 32px;
  511. width: 100%;
  512. text-align: center;
  513. margin-bottom: 8px;
  514. margin-top: 8px;
  515. }
  516. .unit-box {
  517. display: flex;
  518. background-color: #ffffff;
  519. min-height: 35px;
  520. width: 100%;
  521. border-bottom: 1px solid #f4f5f7;
  522. padding: 10px 15px;
  523. }
  524. .text {
  525. color: grey;
  526. width: 64px;
  527. flex-shrink: 0;
  528. margin-right: 10px;
  529. }
  530. .info-content {
  531. word-break: break-all;
  532. }
  533. </style>