index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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">
  37. <!-- 静态的预警信息 -->
  38. <div class="notice-item">
  39. <div class="notice-header">
  40. <div class="notice-label-box">
  41. <div class="notice-label">预警信息</div>
  42. </div>
  43. <!-- 查看更多的链接 -->
  44. <div class="notice-more" @click="goToInformationReception">查看更多 >></div>
  45. </div>
  46. <div class="notice-content">
  47. 这里是静态的预警信息内容,不需要从变量中获取。
  48. </div>
  49. <div class="notice-time">2023-10-10 10:00:00</div>
  50. </div>
  51. </div>
  52. <div class="container-content">
  53. <div class="padding-content">
  54. <van-grid :column-num="2">
  55. <van-grid-item
  56. v-for="(item, index) in menu"
  57. :key="index"
  58. @click="handleClickMenu(item.url)"
  59. >
  60. <div class="card">
  61. <div :class="item.icon" />
  62. <van-badge :content="item.num" max="99" :show-zero="false">
  63. <div class="card-title">{{ item.name }}</div>
  64. </van-badge>
  65. </div>
  66. </van-grid-item>
  67. </van-grid>
  68. <div class="app_panel">
  69. <div class="app_panel_title">综合应用</div>
  70. <div v-for="(item, index) in menu2" :key="index" class="box">
  71. <div class="box-title">{{ item.name }}</div>
  72. <div class="box-content">
  73. <div
  74. v-for="(item2, index2) in item.children"
  75. :key="index2"
  76. class="box-item"
  77. @click="handleClickMenu(item2.url)"
  78. >
  79. <img class="icon" :src="getImageUrl(item2.icon)" alt="" />
  80. <span>{{ item2.name }}</span>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <OnlineRollCall />
  88. </div>
  89. </template>
  90. <script lang="ts" setup>
  91. import { onClickOutside } from "@vueuse/core";
  92. import { onMounted, reactive, ref } from "vue";
  93. import { selectTask } from "@/api/emergencyCommandMap/JointDuty";
  94. import searchImg from "@/assets/images/search.png";
  95. import { useRouter } from "vue-router";
  96. import closeImg from "@/assets/images/close.png";
  97. import { getPointInfoComprehensiveSearch } from "@/api/globalMap";
  98. import OnlineRollCall from "@/components/OnlineRollCall/index.vue";
  99. const router = useRouter();
  100. const noticeBarState = reactive({
  101. show: false,
  102. latestMessages: []
  103. });
  104. const goToInformationReception = () => {
  105. router.push({ name: "InformationReception" });
  106. };
  107. // 菜单数据
  108. const menu = ref([
  109. { name: "巡查工作", icon: "icon1", num: 0, url: "inspectionWork" },
  110. { name: "风险防控", icon: "icon2", num: 0, url: "riskManagement" },
  111. { name: "数据管理", icon: "icon3", num: 0, url: "" },
  112. { name: "在线点名", icon: "icon4", num: 0, url: "rollCallRecord2" }
  113. ]);
  114. // 综合应用菜单
  115. const menu2 = ref([
  116. {
  117. name: "自然灾害风险监测",
  118. children: [
  119. { name: '预警态势', icon: 'monitor', url: 'WarningSituation' },
  120. { name: '大风灾害', icon: 'wind', url: 'GaleDisaster' },
  121. { name: '森林火灾', icon: 'forestFire', url: 'ForestFireWarn' },
  122. { name: '台风实况', icon: 'typhoon', url: 'TyphoonPath' },
  123. { name: '水文监测', icon: 'hydrology', url: 'HydrologicalMonitor' },
  124. ]
  125. },
  126. {
  127. name: "应急事件场景专题",
  128. children: [
  129. { name: "自然灾害", icon: "nature", url: "" },
  130. { name: "事故灾害", icon: "accident", url: "" },
  131. { name: "城市应急事件专题", icon: "city", url: "CityEmergencyEvent" }
  132. ]
  133. }
  134. ]);
  135. const handleClickMenu = url => {
  136. if (!url) return;
  137. router.push({ name: url });
  138. };
  139. const getImageUrl = name => {
  140. return new URL(`../../assets/images/index/${name}.png`, import.meta.url).href;
  141. };
  142. // 请求数据
  143. const initData = async () => {
  144. try {
  145. const sortOrder = "desc";
  146. const sortBy = "creation_time";
  147. const event_code = "YJSJ0000000001";
  148. console.log("请求任务数据:", event_code);
  149. const res = await selectTask({
  150. sortOrder: sortOrder,
  151. sortBy: sortBy,
  152. event_code: event_code
  153. });
  154. if (res && res.data) {
  155. noticeBarState.latestMessages = res.data.slice(0, 3).map(msg => ({
  156. event_title: msg.event_title,
  157. event_time: msg.event_time
  158. }));
  159. noticeBarState.show = true;
  160. } else {
  161. console.error("API response data is empty or invalid");
  162. }
  163. } catch (error) {
  164. console.error("请求任务数据失败:", error);
  165. noticeBarState.show = false; // 如果请求失败,不显示通知栏
  166. }
  167. };
  168. // 搜索
  169. const searchBoxRef = ref();
  170. let showSearch = ref();
  171. const total = ref(0);
  172. let loading = ref(false);
  173. let error = ref(false);
  174. let finished = ref(false);
  175. const queryParams = reactive({
  176. page: 0,
  177. page_size: 15,
  178. keywords: ""
  179. });
  180. const searchList = ref([]);
  181. onClickOutside(searchBoxRef, event => {
  182. showSearch.value = false;
  183. });
  184. const getSearchList = () => {
  185. if (!queryParams.keywords) {
  186. return (loading.value = false);
  187. }
  188. queryParams.page++;
  189. getPointInfoComprehensiveSearch(queryParams)
  190. .then(res => {
  191. const items = res.data.list || [];
  192. total.value = res.data.total;
  193. if (queryParams.page == 1) {
  194. searchList.value = [];
  195. }
  196. items.forEach(val => {
  197. searchList.value.push(val);
  198. });
  199. finished.value = queryParams.page_size * queryParams.page >= total.value;
  200. showSearch.value = true;
  201. })
  202. .catch(() => {
  203. error.value = true;
  204. finished.value = false;
  205. })
  206. .finally(() => {
  207. loading.value = false;
  208. });
  209. };
  210. const on_search_keyword = val => {
  211. queryParams.keywords = val;
  212. queryParams.page = 0;
  213. getSearchList();
  214. };
  215. const on_search_cancel = () => {
  216. showSearch.value = false;
  217. queryParams.keywords = "";
  218. queryParams.page = 0;
  219. finished.value = false;
  220. searchList.value = [];
  221. };
  222. const handleClickItem = item => {
  223. showSearch.value = false;
  224. queryParams.keywords = "";
  225. queryParams.page = 0;
  226. finished.value = false;
  227. searchList.value = [];
  228. };
  229. onMounted(() => {
  230. initData();
  231. });
  232. </script>
  233. <style lang="scss" scoped>
  234. .container {
  235. display: block;
  236. width: 100%;
  237. height: 100%;
  238. padding-bottom: 20px;
  239. }
  240. .container-header {
  241. width: 100%;
  242. height: 370px;
  243. background: url("@/assets/images/index/banner.png") no-repeat;
  244. background-size: 100% 100%;
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: flex-end;
  248. align-items: center;
  249. padding-bottom: 70px;
  250. .search-box {
  251. width: 100%;
  252. position: relative;
  253. }
  254. .van-search {
  255. width: 100%;
  256. }
  257. }
  258. .container-content {
  259. .padding-content {
  260. padding: 0 16px;
  261. }
  262. .van-hairline--top:after {
  263. border-top-width: 0 !important;
  264. }
  265. :deep(.van-grid) {
  266. .van-grid-item {
  267. &:nth-child(1) {
  268. padding-right: 12px;
  269. padding-bottom: 12px;
  270. }
  271. &:nth-child(2) {
  272. padding-bottom: 12px;
  273. }
  274. &:nth-child(3) {
  275. padding-right: 12px;
  276. }
  277. .card {
  278. width: 100%;
  279. height: 89px;
  280. display: flex;
  281. justify-content: space-between;
  282. align-items: center;
  283. padding: 9px 15px 9px 0;
  284. font-size: 14px;
  285. background: url(@/assets/images/index/cardBg1.png) no-repeat;
  286. background-size: 100% 100%;
  287. &:nth-child(2) {
  288. background: url(@/assets/images/index/cardBg2.png) no-repeat;
  289. background-size: 100% 100%;
  290. }
  291. &:nth-child(3) {
  292. background: url(@/assets/images/index/cardBg3.png) no-repeat;
  293. background-size: 100% 100%;
  294. }
  295. &:nth-child(4) {
  296. background: url(@/assets/images/index/cardBg4.png) no-repeat;
  297. background-size: 100% 100%;
  298. }
  299. .card-title {
  300. font-size: 14px;
  301. color: #414f64;
  302. }
  303. }
  304. .icon1 {
  305. background: url(@/assets/images/index/icon1.png) no-repeat;
  306. }
  307. .icon2 {
  308. background: url(@/assets/images/index/icon2.png) no-repeat;
  309. }
  310. .icon3 {
  311. background: url(@/assets/images/index/icon3.png) no-repeat;
  312. }
  313. .icon4 {
  314. background: url(@/assets/images/index/icon4.png) no-repeat;
  315. }
  316. .icon1,
  317. .icon2,
  318. .icon3,
  319. .icon4 {
  320. width: 67px;
  321. height: 67px;
  322. background-size: 100% 100%;
  323. }
  324. }
  325. .van-grid-item__content {
  326. padding: 0;
  327. background: transparent;
  328. &::after {
  329. border: none;
  330. }
  331. }
  332. }
  333. }
  334. .app_panel {
  335. padding-top: 12px;
  336. .app_panel_title {
  337. height: 26px;
  338. font-weight: bold;
  339. font-size: 18px;
  340. color: #414f64;
  341. letter-spacing: 0;
  342. margin-bottom: 4px;
  343. }
  344. .box {
  345. width: 100%;
  346. height: 72px;
  347. background: url("@/assets/images/index/boxBg.png") no-repeat;
  348. background-size: 100% 100%;
  349. margin-bottom: 12px;
  350. &:last-child {
  351. margin-bottom: 0;
  352. }
  353. .box-title {
  354. font-size: 12px;
  355. color: #3687fe;
  356. padding: 0 10px;
  357. }
  358. .box-content {
  359. display: flex;
  360. flex-wrap: wrap;
  361. padding-top: 3px;
  362. .box-item {
  363. display: flex;
  364. flex-direction: column;
  365. justify-content: center;
  366. align-items: center;
  367. min-width: 20%;
  368. font-size: 12px;
  369. .icon {
  370. width: 32px;
  371. height: 34px;
  372. }
  373. }
  374. }
  375. }
  376. }
  377. .search-list {
  378. position: absolute;
  379. top: 50px;
  380. left: 0;
  381. z-index: 9;
  382. width: 100%;
  383. height: calc(100vh - 400px);
  384. overflow-y: auto;
  385. background-color: #ffffff;
  386. border-top: 1px solid #eeeeee;
  387. .item {
  388. padding: 8px 15px;
  389. border-bottom: 1px solid #eeeeee;
  390. }
  391. }
  392. .common-search {
  393. :deep(.van-field__left-icon) {
  394. .van-icon__image {
  395. width: 12px;
  396. height: 12px;
  397. }
  398. }
  399. :deep(.van-field__right-icon) {
  400. width: 30px;
  401. height: 30px;
  402. padding: 0;
  403. .van-icon__image {
  404. width: 30px;
  405. height: 30px;
  406. }
  407. }
  408. }
  409. .notice-bar {
  410. width: 100%;
  411. background-color: #f4f8ff;
  412. padding: 0 10px 10px;
  413. border-radius: 5px;
  414. margin-bottom: 10px;
  415. margin-top: -60px;
  416. border: 1px solid #EEEEEE;
  417. }
  418. .notice-item {
  419. margin-bottom: 10px;
  420. &:last-child {
  421. margin-bottom: 0;
  422. }
  423. .notice-header {
  424. display: flex;
  425. justify-content: flex-end;
  426. align-items: center;
  427. position: relative;
  428. margin-bottom: 10px;
  429. }
  430. }
  431. .notice-label-box {
  432. position: absolute;
  433. top: -3px;
  434. left: 0;
  435. background-color: #ffffff;
  436. padding: 5px;
  437. transform: skewX(-20deg); /* 斜切变形 */
  438. .notice-label {
  439. color: #FFAF00;
  440. font-size: 14px;
  441. transform: skewX(20deg);
  442. }
  443. }
  444. .notice-content {
  445. color: #414F64;
  446. font-size: 14px;
  447. line-height: 22px;
  448. overflow: hidden;
  449. text-overflow: ellipsis;
  450. display: -webkit-box;
  451. -webkit-line-clamp: 3;
  452. -webkit-box-orient: vertical;
  453. }
  454. .notice-time {
  455. font-size: 12px;
  456. color: rgba(0, 0, 0, 0.45);
  457. width: 100%;
  458. text-align: right;
  459. line-height: 22px;
  460. }
  461. .notice-more {
  462. font-size: 14px;
  463. color: #2C81FF;
  464. cursor: pointer;
  465. }
  466. </style>