index.vue 9.1 KB

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