index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <div class="container">
  3. <div class="container-header">
  4. <div ref="searchBoxRef" class="search-box">
  5. <van-search
  6. v-model="queryParams.keywords"
  7. class="common-search"
  8. :left-icon="searchImg"
  9. :right-icon="closeImg"
  10. placeholder="请输入搜索内容"
  11. @search="on_search_keyword"
  12. @click-right-icon.stop="on_search_cancel"
  13. />
  14. <div v-show="showSearch" class="search-list">
  15. <van-list
  16. v-model:loading="loading"
  17. v-model:error="error"
  18. error-text="请求失败,点击重新加载"
  19. :finished="finished"
  20. finished-text="没有更多了"
  21. :immediate-check="false"
  22. @load="getSearchList"
  23. >
  24. <div
  25. v-for="(item, index) in searchList"
  26. :key="index"
  27. class="item"
  28. @click="handleClickItem(item)"
  29. >
  30. {{ item.name }}
  31. </div>
  32. </van-list>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="notice-bar" v-if="noticeBarState.show">
  37. <!-- 静态的预警信息 -->
  38. <div class="notice-item">
  39. <div class="notice-header">
  40. <div class="notice-label-box">
  41. <div :class="['notice-label', get_info_type_color(noticeBarState.latestMessages.msg_type)]">
  42. {{ noticeBarState.latestMessages.msg_type }}
  43. </div>
  44. </div>
  45. <!-- 查看更多的链接 -->
  46. <div class="notice-more" @click="goToInformationReception">查看更多 >></div>
  47. </div>
  48. <div class="notice-content" @click="handleInfo(noticeBarState.latestMessages)">
  49. {{ noticeBarState.latestMessages.content }}
  50. </div>
  51. <div class="notice-time">{{ noticeBarState.latestMessages.recv_time }}</div>
  52. </div>
  53. </div>
  54. <div class="container-content">
  55. <div class="padding-content">
  56. <van-grid :column-num="2">
  57. <van-grid-item
  58. v-for="(item, index) in menu"
  59. :key="index"
  60. @click="handleClickMenu(item.url)"
  61. >
  62. <div class="card">
  63. <div :class="item.icon" />
  64. <van-badge :content="item.num" max="99" :show-zero="false">
  65. <div class="card-title">{{ item.name }}</div>
  66. </van-badge>
  67. </div>
  68. </van-grid-item>
  69. </van-grid>
  70. <div class="app_panel">
  71. <div class="app_panel_title">综合应用</div>
  72. <div v-for="(item, index) in menu2" :key="index" class="box">
  73. <div class="box-title">{{ item.name }}</div>
  74. <div class="box-content">
  75. <div
  76. v-for="(item2, index2) in item.children"
  77. :key="index2"
  78. class="box-item"
  79. @click="handleClickMenu(item2.url)"
  80. >
  81. <img class="icon" :src="getImageUrl(item2.icon)" alt="" />
  82. <span>{{ item2.name }}</span>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <OnlineRollCall />
  90. </div>
  91. </template>
  92. <script lang="ts" setup>
  93. import { onClickOutside } from "@vueuse/core";
  94. import { onMounted, onUnmounted, reactive, ref } from "vue";
  95. import { selectTask } from "@/api/emergencyCommandMap/JointDuty";
  96. import searchImg from "@/assets/images/search.png";
  97. import { useRouter } from "vue-router";
  98. import closeImg from "@/assets/images/close.png";
  99. import { getPointInfoComprehensiveSearch } from "@/api/globalMap";
  100. import OnlineRollCall from "@/components/OnlineRollCall/index.vue";
  101. import { MsgCenterList, getUnreadMsgCount } from "@/api/InformationReception/InformationReception";
  102. const router = useRouter();
  103. const noticeBarState = reactive({
  104. show: false,
  105. latestMessages: {
  106. msg_type: '',
  107. content: '',
  108. recv_time: ''
  109. }
  110. });
  111. const goToInformationReception = () => {
  112. router.push({ name: "InformationReception" });
  113. };
  114. const get_info_type_color = (val) => {
  115. if(val == "任务消息") {
  116. return "info_type_2"
  117. }
  118. else if(['预警信息', '灾情信息', '灾情信息', '指挥救援', '公众防范'].includes(val)) {
  119. return "info_type_3"
  120. }
  121. return "info_type_0"
  122. }
  123. // 菜单数据
  124. const menu = ref([
  125. { name: "巡查工作", icon: "icon1", num: 0, url: "inspectionWork" },
  126. { name: "风险防控", icon: "icon2", num: 0, url: "riskManagement" },
  127. { name: "数据管理", icon: "icon3", num: 0, url: "rescueManagement" },
  128. { name: "在线点名", icon: "icon4", num: 0, url: "rollCallRecord2" }
  129. ]);
  130. // 综合应用菜单
  131. const menu2 = ref([
  132. {
  133. name: "自然灾害风险监测",
  134. children: [
  135. { name: '预警态势', icon: 'monitor', url: 'WarningSituation' },
  136. { name: '大风灾害', icon: 'wind', url: 'GaleDisaster' },
  137. { name: '森林火灾', icon: 'forestFire', url: 'ForestFireWarn' },
  138. { name: '台风实况', icon: 'typhoon', url: 'TyphoonPath' },
  139. { name: '水库监测', icon: 'hydrology', url: 'ReservoirMonitor' },
  140. { name: '河道监测', icon: 'riverMonitor', url: 'RiverMonitor' }
  141. ]
  142. },
  143. {
  144. name: "应急事件场景专题",
  145. children: [
  146. { name: "防风防汛", icon: "accident", url: "WindAndFloodPrevention" },
  147. { name: "地质灾害", icon: "nature", url: "GeologicalDisaster" },
  148. { name: "森林防火", icon: "forestFire2", url: "ForestFirePrevention" },
  149. { name: "危化品事故", icon: "hazardousChemicals", url: "HazardousChemicals" },
  150. { name: "非煤矿山", icon: "nonCoalMine", url: "NonCoalMine" },
  151. { name: "城市应急", icon: "city", url: "CityEmergencyEvent" }
  152. ]
  153. }
  154. ]);
  155. const handleClickMenu = url => {
  156. if (!url) return;
  157. router.push({ name: url });
  158. };
  159. const getImageUrl = name => {
  160. return new URL(`../../assets/images/index/${name}.png`, import.meta.url).href;
  161. };
  162. // 请求数据
  163. const initData = async() => {
  164. let res = await MsgCenterList({})
  165. const data = res.data || [];
  166. if (data.length > 0) {
  167. noticeBarState.latestMessages = data[0]
  168. noticeBarState.show = true;
  169. }
  170. }
  171. const handleInfo = (item) => {
  172. router.push(item.detail.detail_url);
  173. //router.push("/infoDetails?id=" + item.id);
  174. }
  175. // 搜索
  176. const searchBoxRef = ref();
  177. let showSearch = ref();
  178. const total = ref(0);
  179. let loading = ref(false);
  180. let error = ref(false);
  181. let finished = ref(false);
  182. const queryParams = reactive({
  183. page: 0,
  184. page_size: 15,
  185. keywords: ""
  186. });
  187. const searchList = ref([]);
  188. onClickOutside(searchBoxRef, event => {
  189. showSearch.value = false;
  190. });
  191. const getSearchList = () => {
  192. if (!queryParams.keywords) {
  193. return (loading.value = false);
  194. }
  195. queryParams.page++;
  196. getPointInfoComprehensiveSearch(queryParams)
  197. .then(res => {
  198. const items = res.data.list || [];
  199. total.value = res.data.total;
  200. if (queryParams.page == 1) {
  201. searchList.value = [];
  202. }
  203. items.forEach(val => {
  204. searchList.value.push(val);
  205. });
  206. finished.value = queryParams.page_size * queryParams.page >= total.value;
  207. showSearch.value = true;
  208. })
  209. .catch(() => {
  210. error.value = true;
  211. finished.value = false;
  212. })
  213. .finally(() => {
  214. loading.value = false;
  215. });
  216. };
  217. const on_search_keyword = val => {
  218. queryParams.keywords = val;
  219. queryParams.page = 0;
  220. getSearchList();
  221. };
  222. const on_search_cancel = () => {
  223. showSearch.value = false;
  224. queryParams.keywords = "";
  225. queryParams.page = 0;
  226. finished.value = false;
  227. searchList.value = [];
  228. };
  229. const handleClickItem = item => {
  230. showSearch.value = false;
  231. queryParams.keywords = "";
  232. queryParams.page = 0;
  233. finished.value = false;
  234. searchList.value = [];
  235. };
  236. // 设置定时器,刷新统计数
  237. const fetchInterval = process.env.NODE_ENV === 'development' ? 60000 : 3000; // 每60秒刷新一次(刷新太频繁影响调试)
  238. let intervalId: any | null = null;
  239. const startFetchingData = () => {
  240. if (!intervalId) {
  241. intervalId = setInterval(() => {
  242. fetchData();
  243. }, fetchInterval);
  244. }
  245. };
  246. const stopFetchingData = () => {
  247. if (intervalId) {
  248. clearInterval(intervalId);
  249. intervalId = null;
  250. }
  251. };
  252. const fetchData = async () => {
  253. getUnreadMsgCount({"msg_types": "巡查工作,在线点名,风险防控,数据管理"}).then((res)=>{
  254. menu.value.forEach((v)=>{
  255. let obj = res.data.find(item=>item.name === v.name);
  256. if(obj) {
  257. v.num = obj.num;
  258. }
  259. })
  260. })
  261. }
  262. onMounted(() => {
  263. initData();
  264. // 统计数
  265. nextTick(()=>{
  266. fetchData();
  267. });
  268. startFetchingData();
  269. });
  270. onUnmounted(() => {
  271. stopFetchingData();
  272. });
  273. </script>
  274. <style lang="scss" scoped>
  275. .container {
  276. display: block;
  277. width: 100%;
  278. height: 100%;
  279. padding-bottom: 20px;
  280. }
  281. .container-header {
  282. width: 100%;
  283. height: 370px;
  284. background: url("@/assets/images/index/banner2.png") no-repeat;
  285. background-size: 100% 100%;
  286. display: flex;
  287. flex-direction: column;
  288. justify-content: flex-end;
  289. align-items: center;
  290. padding-bottom: 70px;
  291. .search-box {
  292. width: 100%;
  293. position: relative;
  294. }
  295. .van-search {
  296. width: 100%;
  297. }
  298. }
  299. .container-content {
  300. .padding-content {
  301. padding: 0 16px;
  302. }
  303. .van-hairline--top:after {
  304. border-top-width: 0 !important;
  305. }
  306. :deep(.van-grid) {
  307. .van-grid-item {
  308. &:nth-child(1) {
  309. padding-right: 12px;
  310. padding-bottom: 12px;
  311. }
  312. &:nth-child(2) {
  313. padding-bottom: 12px;
  314. }
  315. &:nth-child(3) {
  316. padding-right: 12px;
  317. }
  318. .card {
  319. width: 100%;
  320. height: 89px;
  321. display: flex;
  322. justify-content: space-between;
  323. align-items: center;
  324. padding: 9px 15px 9px 0;
  325. font-size: 14px;
  326. background: url(@/assets/images/index/cardBg1.png) no-repeat;
  327. background-size: 100% 100%;
  328. &:nth-child(2) {
  329. background: url(@/assets/images/index/cardBg2.png) no-repeat;
  330. background-size: 100% 100%;
  331. }
  332. &:nth-child(3) {
  333. background: url(@/assets/images/index/cardBg3.png) no-repeat;
  334. background-size: 100% 100%;
  335. }
  336. &:nth-child(4) {
  337. background: url(@/assets/images/index/cardBg4.png) no-repeat;
  338. background-size: 100% 100%;
  339. }
  340. .card-title {
  341. font-size: 14px;
  342. font-weight: bold;
  343. letter-spacing: 0.78px;
  344. color: #414f64;
  345. }
  346. }
  347. .icon1 {
  348. background: url(@/assets/images/index/icon5.png) no-repeat;
  349. }
  350. .icon2 {
  351. background: url(@/assets/images/index/icon6.png) no-repeat;
  352. }
  353. .icon3 {
  354. background: url(@/assets/images/index/icon7.png) no-repeat;
  355. }
  356. .icon4 {
  357. background: url(@/assets/images/index/icon8.png) no-repeat;
  358. }
  359. .icon1,
  360. .icon2,
  361. .icon3,
  362. .icon4 {
  363. width: 50px;
  364. height: 49px;
  365. background-size: 100% 100%;
  366. margin-left: 11px;
  367. }
  368. }
  369. .van-grid-item__content {
  370. padding: 0;
  371. background: transparent;
  372. &::after {
  373. border: none;
  374. }
  375. }
  376. }
  377. }
  378. .app_panel {
  379. padding-top: 12px;
  380. .app_panel_title {
  381. height: 26px;
  382. font-weight: bold;
  383. font-size: 18px;
  384. color: #414f64;
  385. letter-spacing: 0;
  386. margin-bottom: 4px;
  387. }
  388. .box {
  389. width: 100%;
  390. height: 152px;
  391. background: url("@/assets/images/index/boxBg.png") no-repeat;
  392. background-size: 100% 100%;
  393. margin-bottom: 12px;
  394. display: flex;
  395. flex-direction: column;
  396. &:last-child {
  397. margin-bottom: 0;
  398. }
  399. .box-title {
  400. font-size: 12px;
  401. color: #3687fe;
  402. padding: 3px 6px 0;
  403. }
  404. .box-content {
  405. flex: 1;
  406. display: flex;
  407. flex-wrap: wrap;
  408. padding-top: 3px;
  409. .box-item {
  410. display: flex;
  411. flex-direction: column;
  412. justify-content: center;
  413. align-items: center;
  414. min-width: 20%;
  415. font-size: 12px;
  416. .icon {
  417. width: 32px;
  418. height: 34px;
  419. }
  420. }
  421. }
  422. }
  423. }
  424. .search-list {
  425. position: absolute;
  426. top: 50px;
  427. left: 0;
  428. z-index: 9;
  429. width: 100%;
  430. height: calc(100vh - 400px);
  431. overflow-y: auto;
  432. background-color: #ffffff;
  433. border-top: 1px solid #eeeeee;
  434. .item {
  435. padding: 8px 15px;
  436. border-bottom: 1px solid #eeeeee;
  437. }
  438. }
  439. .common-search {
  440. :deep(.van-search__content) {
  441. border-radius: 15px;
  442. border: none !important;
  443. }
  444. :deep(.van-field__left-icon) {
  445. .van-icon__image {
  446. width: 12px;
  447. height: 12px;
  448. }
  449. }
  450. :deep(.van-field__right-icon) {
  451. width: 30px;
  452. height: 30px;
  453. padding: 0;
  454. .van-icon__image {
  455. width: 30px;
  456. height: 30px;
  457. }
  458. }
  459. }
  460. .notice-bar {
  461. width: 100%;
  462. background-color: #f4f8ff;
  463. padding: 0 10px 10px;
  464. border-radius: 5px;
  465. margin-bottom: 10px;
  466. margin-top: -60px;
  467. border: 1px solid #EEEEEE;
  468. }
  469. .notice-item {
  470. margin-bottom: 10px;
  471. &:last-child {
  472. margin-bottom: 0;
  473. }
  474. .notice-header {
  475. display: flex;
  476. justify-content: flex-end;
  477. align-items: center;
  478. position: relative;
  479. margin-bottom: 10px;
  480. }
  481. }
  482. .notice-label-box {
  483. position: absolute;
  484. top: -3px;
  485. left: 0;
  486. background-color: #ffffff;
  487. padding: 5px;
  488. transform: skewX(-20deg); /* 斜切变形 */
  489. .notice-label {
  490. font-size: 14px;
  491. transform: skewX(20deg);
  492. }
  493. .info_type_0 {
  494. color: #FFAF00;
  495. }
  496. .info_type_1 {
  497. color: #FF1818;
  498. }
  499. .info_type_2 {
  500. color: #2c81ff;
  501. }
  502. .info_type_3 {
  503. color: #FF9F9F;
  504. }
  505. .info_type_4 {
  506. color: #A4D3FF;
  507. }
  508. }
  509. .notice-content {
  510. color: #414F64;
  511. font-size: 14px;
  512. line-height: 22px;
  513. overflow: hidden;
  514. text-overflow: ellipsis;
  515. display: -webkit-box;
  516. -webkit-line-clamp: 3;
  517. -webkit-box-orient: vertical;
  518. }
  519. .notice-time {
  520. font-size: 12px;
  521. color: rgba(0, 0, 0, 0.45);
  522. width: 100%;
  523. text-align: right;
  524. line-height: 22px;
  525. }
  526. .notice-more {
  527. margin-top:4px;
  528. font-size: 14px;
  529. color: #2C81FF;
  530. cursor: pointer;
  531. }
  532. </style>