index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <view class="page">
  3. <view class="header" style="height: 70rpx;">
  4. <picker mode="selector" :range="timeTypes" :value="selectedTimeType" @change="onTimeTypeChange">
  5. <view class="time-type-picker" :class="processTimeTypes(timeTypes[selectedTimeType])">
  6. <text>{{ selectedTimeType === -1? '全部' : timeTypes[selectedTimeType] }}</text>
  7. <uni-icons type="arrowdown" size="20" color="#333" />
  8. </view>
  9. </picker>
  10. </view>
  11. <scroll-view scroll-y class="event-list" @refresherrefresh="onRefresh" :refresher-triggered="isRefreshing"
  12. refresher-enabled>
  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 {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. const eventList = ref<EventItem[]>([]);
  74. const timeTypes = ['严重', '一般', '轻微'] as const;
  75. const selectedTimeType = ref(-1);
  76. const processTimeTypes = (type : typeof timeTypes[number]) => {
  77. if (type === '严重') {
  78. return "urgent"
  79. } else if (type === '轻微') {
  80. return "normal"
  81. } else if (type === '一般') {
  82. return "important"
  83. } else {
  84. return "";
  85. }
  86. }
  87. const filteredEventList = computed(() => {
  88. if (selectedTimeType.value === -1) {
  89. return eventList.value;
  90. }
  91. const selectedType = timeTypes[selectedTimeType.value];
  92. return eventList.value.filter(item => item.level === selectedType);
  93. });
  94. const handleEmergency = (item : EventItem) => {
  95. uni.showActionSheet({
  96. itemList: ['拨打110', '拨打119', '拨打120'],
  97. success: function (res) {
  98. const phoneNumbers = ['110', '119', '120'];
  99. uni.makePhoneCall({
  100. phoneNumber: phoneNumbers[res.tapIndex]
  101. });
  102. }
  103. });
  104. };
  105. const notifySecurity = (item : EventItem) => {
  106. uni.showToast({
  107. title: '已通知保安',
  108. icon: 'success'
  109. });
  110. };
  111. const notifyVisitor = (item : EventItem) => {
  112. uni.showToast({
  113. title: '已发送通知',
  114. icon: 'success'
  115. });
  116. };
  117. const viewDetail = (item : EventItem) => {
  118. uni.setStorageSync("eventDetail", item);
  119. uni.navigateTo({
  120. url: "/pages/eventDetail/index"
  121. })
  122. };
  123. const isRefreshing = ref(false);
  124. const onRefresh = async () => {
  125. isRefreshing.value = true;
  126. await getEventList();
  127. isRefreshing.value = false;
  128. uni.showToast({
  129. title: '刷新成功',
  130. icon: 'success'
  131. });
  132. };
  133. const onTimeTypeChange = (e : any) => {
  134. selectedTimeType.value = e.detail.value;
  135. };
  136. const currentPage = ref(1);
  137. const pageSize = ref(10);
  138. const total = ref(0);
  139. const getEventList = async () => {
  140. const res = await clientPostWithQueryParams("/visualization/fireFighting/queryEventStatisticsPage", {
  141. pageNum: currentPage.value,
  142. pageSize: pageSize.value,
  143. sortType: 'DESC'
  144. })
  145. if (res.code !== 200) {
  146. uni.showToast({
  147. title: "请求数据失败",
  148. duration: 2000
  149. })
  150. }
  151. const res2 = await clientPostWithQueryParams('/visualization/fireFighting/queryEventStatistics')
  152. if (res2.code !== 200) {
  153. uni.showToast({
  154. title: "请求数据失败",
  155. duration: 2000
  156. })
  157. }
  158. total.value = res2.data.value;
  159. console.log(res);
  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. console.log(processEventList);
  180. }
  181. onShow(() => {
  182. getEventList();
  183. })
  184. </script>
  185. <style>
  186. page {
  187. height: 100%;
  188. }
  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. .time-type-picker {
  204. display: flex;
  205. align-items: center;
  206. gap: 10rpx;
  207. background-color: #F8F9FB;
  208. padding: 10rpx 20rpx;
  209. border-radius: 10rpx;
  210. font-size: 28rpx;
  211. color: #666;
  212. }
  213. .event-list {
  214. flex: 1;
  215. overflow: auto;
  216. padding: 20rpx;
  217. }
  218. .event-card {
  219. width: 650rpx;
  220. background-color: #fff;
  221. border-radius: 12px;
  222. padding: 30rpx;
  223. margin-bottom: 20rpx;
  224. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  225. }
  226. .event-header {
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. margin-bottom: 20rpx;
  231. }
  232. .status-tag {
  233. padding: 4rpx 16rpx;
  234. border-radius: 4px;
  235. font-size: 12px;
  236. }
  237. .pending {
  238. background-color: #ff4d4f;
  239. color: #fff;
  240. }
  241. .processing {
  242. background-color: #faad14;
  243. color: #fff;
  244. }
  245. .completed {
  246. background-color: #52c41a;
  247. color: #fff;
  248. }
  249. .mistake {
  250. background-color: #55aa7f;
  251. color: #fff;
  252. }
  253. .ignore {
  254. background-color: #55ffff;
  255. color: #fff;
  256. }
  257. .time {
  258. font-size: 14px;
  259. color: #999;
  260. }
  261. .event-info {
  262. margin-bottom: 30rpx;
  263. }
  264. .location {
  265. display: flex;
  266. align-items: center;
  267. margin-bottom: 16rpx;
  268. }
  269. .location-text {
  270. margin-left: 8rpx;
  271. font-size: 14px;
  272. color: #666;
  273. }
  274. .type-level {
  275. display: flex;
  276. align-items: center;
  277. margin-bottom: 16rpx;
  278. }
  279. .level-tag {
  280. padding: 4rpx 16rpx;
  281. border-radius: 4px;
  282. font-size: 12px;
  283. margin-right: 16rpx;
  284. }
  285. .urgent {
  286. background-color: #ff4d4f;
  287. color: #fff;
  288. }
  289. .important {
  290. background-color: #faad14;
  291. color: #fff;
  292. }
  293. .normal {
  294. background-color: #1890ff;
  295. color: #fff;
  296. }
  297. .type {
  298. font-size: 14px;
  299. color: #666;
  300. }
  301. .description {
  302. font-size: 14px;
  303. color: #333;
  304. margin-bottom: 16rpx;
  305. line-height: 1.5;
  306. }
  307. .person-info {
  308. font-size: 14px;
  309. color: #666;
  310. }
  311. .label {
  312. color: #999;
  313. }
  314. .action-buttons {
  315. display: flex;
  316. justify-content: space-between;
  317. }
  318. .button-content text {
  319. margin-left: 8rpx;
  320. font-size: 12px;
  321. }
  322. .uni-button {
  323. margin: 0;
  324. flex: 1;
  325. margin-right: 16rpx;
  326. }
  327. .uni-button:last-child {
  328. margin-right: 0;
  329. }
  330. .pagination-container {
  331. width: 80vw;
  332. margin: auto;
  333. }
  334. .no-data {
  335. text-align: center;
  336. color: #999;
  337. font-size: 14px;
  338. padding: 20rpx;
  339. }
  340. .message-box {
  341. padding: 16rpx 24rpx;
  342. background-color: #f8f9fb;
  343. border-radius: 8rpx;
  344. font-size: 24rpx;
  345. color: #666;
  346. line-height: 1.6;
  347. margin-top: 20rpx;
  348. border: 1px solid #eee;
  349. }
  350. /* 扩展不同状态的消息样式(可选) */
  351. .message-box.processing { background-color: #fff3d6; border-color: #ffe5b4; }
  352. .message-box.completed { background-color: #e8f9eb; border-color: #c8e6c9; }
  353. .message-box.mistake { background-color: #e0f2f1; border-color: #b2dfdb; }
  354. .message-box.ignore { background-color: #fff3b0; border-color: #fff9c4; }
  355. </style>