index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <view class="page">
  3. <view class="header" style="height: 70rpx;">
  4. <!-- 四个按钮 -->
  5. <view class="button-group">
  6. <button :class="{ 'active': selectedTimeType === -1 }" @click="selectTimeType(-1)">全部</button>
  7. <button :class="{ 'active': selectedTimeType === 0 }" @click="selectTimeType(0)">严重</button>
  8. <button :class="{ 'active': selectedTimeType === 1 }" @click="selectTimeType(1)">一般</button>
  9. <button :class="{ 'active': selectedTimeType === 2 }" @click="selectTimeType(2)">轻微</button>
  10. </view>
  11. </view>
  12. <scroll-view scroll-y class="event-list" @refresherrefresh="onRefresh" :refresher-triggered="isRefreshing"
  13. refresher-enabled>
  14. <view v-if="filteredEventList.length > 0">
  15. <view v-for="(item, index) in filteredEventList" :key="index" class="event-card">
  16. <view class="event-header">
  17. <view :class="['status-tag', item.status]">{{ item.statusText }}</view>
  18. <text class="time">{{ item.time }}</text>
  19. </view>
  20. <view class="event-info">
  21. <view class="location">
  22. <uni-icons type="location" size="16" color="#666" />
  23. <text class="location-text">{{ item.location }}</text>
  24. </view>
  25. <view class="type-level">
  26. <text :class="['level-tag', item.levelClass]">{{ item.level }}</text>
  27. <text class="type">{{ item.type }}</text>
  28. </view>
  29. <view class="description">{{ item.description }}</view>
  30. <view :class="['message-box', item.status]" v-if="item.status !== 'pending'">{{ item.message }}</view>
  31. </view>
  32. <view class="action-buttons">
  33. <uni-button size="mini" type="warn" @click="handleEmergency(item)">
  34. <view class="button-content">
  35. <uni-icons type="phone-filled" size="16" color="#fff" />
  36. <text>一键报警</text>
  37. </view>
  38. </uni-button>
  39. <uni-button size="mini" type="default" @click="viewDetail(item)">
  40. <view class="button-content">
  41. <uni-icons type="more-filled" size="16" color="#666" />
  42. <text>查看详情</text>
  43. </view>
  44. </uni-button>
  45. </view>
  46. </view>
  47. <view class="pagination-container">
  48. <uni-pagination :show-icon="true" :total="total" v-model="currentPage" :pageSize="pageSize" title="标题文字"
  49. @change="getEventList" />
  50. </view>
  51. </view>
  52. <view v-else class="no-data">无数据</view>
  53. </scroll-view>
  54. </view>
  55. </template>
  56. <script lang="ts" setup>
  57. import {computed, ref} from 'vue';
  58. import {clientPostWithQueryParams} from '../../utils/request';
  59. import {alarmGradeClassMap, alarmGradeMap, alarmTypeMap} from './eventMap';
  60. import {onShow} from '@dcloudio/uni-app';
  61. interface EventItem {
  62. id: number;
  63. status: "ignore" | "mistake" | "completed" | "processing" | "pending";
  64. statusText: string;
  65. time: string;
  66. location: string;
  67. level: string;
  68. levelClass: string;
  69. type: string;
  70. description: string;
  71. person: string;
  72. message: string;
  73. }
  74. const eventList = ref<EventItem[]>([]);
  75. const timeTypes = ['严重', '一般', '轻微'] as const;
  76. const selectedTimeType = ref(-1);
  77. const processTimeTypes = (type: typeof timeTypes[number]) => {
  78. if (type === '严重') {
  79. return "urgent"
  80. } else if (type === '轻微') {
  81. return "normal"
  82. } else if (type === '一般') {
  83. return "important"
  84. } else {
  85. return "";
  86. }
  87. }
  88. const filteredEventList = computed(() => {
  89. if (selectedTimeType.value === -1) {
  90. return eventList.value;
  91. }
  92. const selectedType = timeTypes[selectedTimeType.value];
  93. return eventList.value.filter(item => item.level === selectedType);
  94. });
  95. const handleEmergency = (item: EventItem) => {
  96. uni.showActionSheet({
  97. itemList: ['拨打110', '拨打119', '拨打120'],
  98. success: function (res) {
  99. const phoneNumbers = ['110', '119', '120'];
  100. uni.makePhoneCall({
  101. phoneNumber: phoneNumbers[res.tapIndex]
  102. });
  103. }
  104. });
  105. };
  106. const notifySecurity = (item: EventItem) => {
  107. uni.showToast({
  108. title: '已通知保安',
  109. icon: 'success'
  110. });
  111. };
  112. const notifyVisitor = (item: EventItem) => {
  113. uni.showToast({
  114. title: '已发送通知',
  115. icon: 'success'
  116. });
  117. };
  118. const viewDetail = (item: EventItem) => {
  119. uni.setStorageSync("eventDetail", item);
  120. uni.navigateTo({
  121. url: "/pages/eventDetail/index"
  122. })
  123. };
  124. const isRefreshing = ref(false);
  125. const onRefresh = async () => {
  126. isRefreshing.value = true;
  127. await getEventList();
  128. isRefreshing.value = false;
  129. uni.showToast({
  130. title: '刷新成功',
  131. icon: 'success'
  132. });
  133. };
  134. const selectTimeType = (index: number) => {
  135. selectedTimeType.value = index;
  136. };
  137. const currentPage = ref(1);
  138. const pageSize = ref(10);
  139. const total = ref(0);
  140. const getEventList = async () => {
  141. const res = await clientPostWithQueryParams("/visualization/fireFighting/queryEventStatisticsPage", {
  142. pageNum: currentPage.value,
  143. pageSize: pageSize.value,
  144. sortType: 'DESC'
  145. })
  146. if (res.code !== 200) {
  147. uni.showToast({
  148. title: "请求数据失败",
  149. duration: 2000
  150. })
  151. }
  152. const res2 = await clientPostWithQueryParams('/visualization/fireFighting/queryEventStatistics')
  153. if (res2.code !== 200) {
  154. uni.showToast({
  155. title: "请求数据失败",
  156. duration: 2000
  157. })
  158. }
  159. total.value = res2.data.value;
  160. const processEventList: EventItem[] = res.data.pageData.map(q => {
  161. const statusArr: EventItem['status'][] = ["pending", "processing", "completed", "mistake", "ignore"]
  162. const statusArrText: string[] = ["未处理", "处理中", "处理完成", "误报", "忽略"]
  163. const r: EventItem = {
  164. id: q.alarmCode,
  165. location: q.alarmPosition,
  166. status: statusArr[q.handleStat],
  167. statusText: statusArrText[q.handleStat],
  168. time: q.alarmDate,
  169. level: alarmGradeMap.get(q.alarmGrade),
  170. levelClass: alarmGradeClassMap.get(q.alarmGrade),
  171. type: q.orgName,
  172. description: alarmTypeMap.get(q.alarmType),
  173. person: 'string',
  174. message: q.handleMessage
  175. }
  176. return r;
  177. })
  178. eventList.value = processEventList
  179. };
  180. onShow(() => {
  181. getEventList();
  182. })
  183. </script>
  184. <style scoped>
  185. .page {
  186. display: flex;
  187. flex-direction: column;
  188. height: 100%;
  189. background-color: #f5f5f5;
  190. }
  191. .header {
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. padding: 20rpx 30rpx;
  196. background-color: #fff;
  197. border-bottom: 1px solid #eee;
  198. }
  199. .button-group {
  200. display: flex;
  201. justify-content: space-around;
  202. width: 100%;
  203. }
  204. .button-group button {
  205. padding: 10rpx 20rpx;
  206. border: none;
  207. border-radius: 10rpx;
  208. background-color: #F8F9FB;
  209. color: #666;
  210. font-size: 28rpx;
  211. }
  212. .button-group button.active {
  213. background-color: #1890ff;
  214. color: white;
  215. }
  216. .event-list {
  217. flex: 1;
  218. overflow: auto;
  219. padding: 20rpx;
  220. }
  221. .event-card {
  222. width: 650rpx;
  223. background-color: #fff;
  224. border-radius: 12px;
  225. padding: 30rpx;
  226. margin-bottom: 20rpx;
  227. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  228. }
  229. .event-header {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. margin-bottom: 20rpx;
  234. }
  235. .status-tag {
  236. padding: 4rpx 16rpx;
  237. border-radius: 4px;
  238. font-size: 12px;
  239. }
  240. .pending {
  241. background-color: #ff4d4f;
  242. color: #fff;
  243. }
  244. .processing {
  245. background-color: #faad14;
  246. color: #fff;
  247. }
  248. .completed {
  249. background-color: #52c41a;
  250. color: #fff;
  251. }
  252. .mistake {
  253. background-color: #55aa7f;
  254. color: #fff;
  255. }
  256. .ignore {
  257. background-color: #55ffff;
  258. color: #fff;
  259. }
  260. .time {
  261. font-size: 14px;
  262. color: #999;
  263. }
  264. .event-info {
  265. margin-bottom: 30rpx;
  266. }
  267. .location {
  268. display: flex;
  269. align-items: center;
  270. margin-bottom: 16rpx;
  271. }
  272. .location-text {
  273. margin-left: 8rpx;
  274. font-size: 14px;
  275. color: #666;
  276. }
  277. .type-level {
  278. display: flex;
  279. align-items: center;
  280. margin-bottom: 16rpx;
  281. }
  282. .level-tag {
  283. padding: 4rpx 16rpx;
  284. border-radius: 4px;
  285. font-size: 12px;
  286. margin-right: 16rpx;
  287. }
  288. .urgent {
  289. background-color: #ff4d4f;
  290. color: #fff;
  291. }
  292. .important {
  293. background-color: #faad14;
  294. color: #fff;
  295. }
  296. .normal {
  297. background-color: #1890ff;
  298. color: #fff;
  299. }
  300. .type {
  301. font-size: 14px;
  302. color: #666;
  303. }
  304. .description {
  305. font-size: 14px;
  306. color: #333;
  307. margin-bottom: 16rpx;
  308. line-height: 1.5;
  309. }
  310. .person-info {
  311. font-size: 14px;
  312. color: #666;
  313. }
  314. .label {
  315. color: #999;
  316. }
  317. .action-buttons {
  318. display: flex;
  319. justify-content: space-between;
  320. }
  321. .button-content text {
  322. margin-left: 8rpx;
  323. font-size: 12px;
  324. }
  325. .uni-button {
  326. margin: 0;
  327. flex: 1;
  328. margin-right: 16rpx;
  329. }
  330. .uni-button:last-child {
  331. margin-right: 0;
  332. }
  333. .pagination-container {
  334. width: 80vw;
  335. margin: auto;
  336. }
  337. .no-data {
  338. text-align: center;
  339. color: #999;
  340. font-size: 14px;
  341. padding: 20rpx;
  342. }
  343. .message-box {
  344. padding: 16rpx 24rpx;
  345. background-color: #f8f9fb;
  346. border-radius: 8rpx;
  347. font-size: 24rpx;
  348. color: #666;
  349. line-height: 1.6;
  350. margin-top: 20rpx;
  351. border: 1px solid #eee;
  352. }
  353. /* 扩展不同状态的消息样式(可选) */
  354. .message-box.processing {
  355. background-color: #fff3d6;
  356. border-color: #ffe5b4;
  357. }
  358. .message-box.completed {
  359. background-color: #e8f9eb;
  360. border-color: #c8e6c9;
  361. }
  362. .message-box.mistake {
  363. background-color: #e0f2f1;
  364. border-color: #b2dfdb;
  365. }
  366. .message-box.ignore {
  367. background-color: #fff3b0;
  368. border-color: #fff9c4;
  369. }
  370. </style>