home.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view class="container">
  3. <!-- 头部筛选区域 -->
  4. <view class="search">
  5. <picker style="width: 50%" :value="typeIndex" :range="typeList" @change="bindTypeChange">
  6. <view class="search-left">
  7. {{ typeList[typeIndex] }}
  8. <view class="search-img">
  9. <img class="img" src="@/static/images/bottom2.png" />
  10. </view>
  11. </view>
  12. </picker>
  13. <picker style="width: 50%" mode="date" :value="date" @change="bindDateChange">
  14. <view class="search-right">
  15. {{ date }}
  16. <view class="search-img">
  17. <img class="img" src="@/static/images/bottom2.png" />
  18. </view>
  19. </view>
  20. </picker>
  21. </view>
  22. <!-- 每一个预警信息 -->
  23. <view class="container-item" v-for="item in listData" :key="item.id">
  24. <!-- 标题区域 -->
  25. <view class="item-title">
  26. <view class="title-info">{{ item.type }}</view>
  27. <view class="title-state" v-if="item.statu == 0">待处理</view>
  28. <view class="title-state color" v-else>已处理</view>
  29. </view>
  30. <!-- 告警时间区域 -->
  31. <view class="item-box">
  32. <view class="box-key">告警时间</view>
  33. <view class="box-value">{{ item.dateTime }}</view>
  34. </view>
  35. <!-- 姓名区域 -->
  36. <view class="item-box">
  37. <view class="box-key">姓名</view>
  38. <view class="box-value">{{ item.name ? item.name : '未知' }}</view>
  39. </view>
  40. <!-- 地点区域 -->
  41. <view class="item-box">
  42. <view class="box-key">地点</view>
  43. <view class="box-value">{{ item.location }}</view>
  44. </view>
  45. <!-- 图片区域 -->
  46. <view class="item-box2">
  47. <view class="box-key">图片</view>
  48. <view class="box-img" @click="previewImage(item.image)"><img mode="aspectFill" class="img" :src="item.image" /></view>
  49. </view>
  50. <!-- 按钮区域 -->
  51. <view class="item-button" v-if="item.statu == 0">
  52. <view class="button-finish" @click="handleFinish(item.id)">处理完成</view>
  53. <view class="button-err" @click="handleErr(item.id)">误报</view>
  54. </view>
  55. </view>
  56. <!-- 无数据时展示的区域 -->
  57. <NoData v-if="!listData.length" />
  58. </view>
  59. </template>
  60. <script setup>
  61. import { ref } from 'vue'
  62. import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  63. // 导入时间相关函数
  64. import { time_format, getNowDate } from '@/utils/formatTime.js'
  65. import { myRequest } from '@/utils/api.js'
  66. import NoData from '@/components/noData.vue'
  67. import { previewImage } from '@/utils/previewImage.js'
  68. import { decryptDes } from '@/utils/des.js'
  69. // 状态筛选框数组当前索引
  70. const typeIndex = ref(0)
  71. // 状态筛选框数组
  72. const typeList = ref([])
  73. // 状态筛选框改变数据时的回调
  74. const bindTypeChange = (e) => {
  75. typeIndex.value = e.detail.value
  76. listData.value = []
  77. currentPage.value = 1
  78. getData()
  79. }
  80. // 日期筛选框绑定日期
  81. const date = ref(getNowDate())
  82. // 日期筛选框改变数据时的回调
  83. const bindDateChange = (e) => {
  84. date.value = e.detail.value
  85. listData.value = []
  86. currentPage.value = 1
  87. getData()
  88. }
  89. // 当前页
  90. const currentPage = ref(1)
  91. // 总条数
  92. const total = ref(null)
  93. // 预警列表数据
  94. const listData = ref([])
  95. onLoad(() => {
  96. getTypeList()
  97. getData()
  98. })
  99. // 页面上拉到最底部时触发的回调
  100. onReachBottom(() => {
  101. if (total.value > listData.value.length) {
  102. currentPage.value++
  103. getData()
  104. } else {
  105. uni.showToast({
  106. title: '没有更多数据了',
  107. icon: 'none'
  108. })
  109. }
  110. })
  111. // 获取筛选框数组
  112. const getTypeList = async () => {
  113. const res = await myRequest({
  114. url: '/wanzai/api/smartWarning/warningType'
  115. })
  116. // console.log(res)
  117. const result = JSON.parse(decryptDes(res.data))
  118. typeList.value = result.reverse()
  119. }
  120. // 获取预警列表数据
  121. const getData = async () => {
  122. const res = await myRequest({
  123. url: '/wanzai/api/smartWarning/pageWarning',
  124. data: {
  125. currentPage: currentPage.value,
  126. pageCount: 6,
  127. type: typeList.value[typeIndex.value] || '全部',
  128. dateTime: date.value
  129. }
  130. })
  131. // console.log(res)
  132. if (res.code == 200) {
  133. const result = JSON.parse(decryptDes(res.data))
  134. listData.value = [...listData.value, ...result.list]
  135. total.value = result.totalCount
  136. }
  137. }
  138. // 处理完成按钮回调
  139. const handleFinish = (id) => {
  140. uni.showModal({
  141. title: '提示',
  142. editable: true,
  143. placeholderText: '请输入处理情况备注',
  144. success: (res) => {
  145. if (res.confirm) {
  146. handleOperation(id, res.content)
  147. }
  148. }
  149. })
  150. }
  151. // 误报按钮回调
  152. const handleErr = (id) => {
  153. uni.showModal({
  154. title: '提示',
  155. content: '确定是误报吗?',
  156. success: (res) => {
  157. if (res.confirm) {
  158. handleOperation(id)
  159. }
  160. }
  161. })
  162. }
  163. // 处理请求
  164. const handleOperation = async (id, remark) => {
  165. const res = await myRequest({
  166. url: '/wanzai/api/smartWarning/operation',
  167. method: 'post',
  168. data: {
  169. id,
  170. remark
  171. }
  172. })
  173. // console.log(res)
  174. uni.showToast({
  175. title: res.message,
  176. icon: 'success',
  177. duration: 2000
  178. })
  179. setTimeout(() => {
  180. listData.value = []
  181. currentPage.value = 1
  182. getData()
  183. }, 2000)
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .container {
  188. min-height: 100vh;
  189. background-color: #f2f2f2;
  190. .search {
  191. margin-bottom: 20rpx;
  192. display: flex;
  193. align-items: center;
  194. height: 100rpx;
  195. background-color: #fff;
  196. .search-left {
  197. display: flex;
  198. justify-content: center;
  199. border-right: 1rpx solid #ccc;
  200. .search-img {
  201. margin-left: 27rpx;
  202. margin-top: -5rpx;
  203. width: 17rpx;
  204. height: 12rpx;
  205. .img {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. }
  210. }
  211. .search-right {
  212. display: flex;
  213. justify-content: center;
  214. .search-img {
  215. margin-left: 27rpx;
  216. margin-top: -5rpx;
  217. width: 17rpx;
  218. height: 12rpx;
  219. .img {
  220. width: 100%;
  221. height: 100%;
  222. }
  223. }
  224. }
  225. }
  226. .container-item {
  227. padding: 0 30rpx 20rpx 30rpx;
  228. margin-bottom: 20rpx;
  229. background-color: #fff;
  230. .item-title {
  231. display: flex;
  232. justify-content: space-between;
  233. align-items: center;
  234. height: 92rpx;
  235. border-bottom: 1rpx solid #e6e6e6;
  236. .title-info {
  237. font-size: 34rpx;
  238. font-weight: bold;
  239. }
  240. .title-state {
  241. font-size: 28rpx;
  242. color: #d43030;
  243. }
  244. .color {
  245. color: #5a61f4;
  246. }
  247. }
  248. .item-box {
  249. display: flex;
  250. align-items: center;
  251. height: 80rpx;
  252. font-size: 28rpx;
  253. .box-key {
  254. margin-right: 60rpx;
  255. width: 120rpx;
  256. color: #999999;
  257. text-align-last: justify;
  258. }
  259. .box-value {
  260. }
  261. }
  262. .item-box2 {
  263. display: flex;
  264. align-items: center;
  265. font-size: 28rpx;
  266. .box-key {
  267. margin-right: 60rpx;
  268. width: 120rpx;
  269. color: #999999;
  270. text-align-last: justify;
  271. }
  272. .box-img {
  273. flex: 1;
  274. height: 100%;
  275. .img {
  276. width: 320rpx;
  277. height: 180rpx;
  278. }
  279. }
  280. }
  281. .item-button {
  282. display: flex;
  283. justify-content: flex-end;
  284. align-items: center;
  285. height: 170rpx;
  286. .button-finish {
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. width: 170rpx;
  291. height: 70rpx;
  292. color: #fff;
  293. font-size: 32rpx;
  294. border-radius: 15rpx;
  295. background: linear-gradient(180deg, #8684ff 0%, #3c50e8 100%);
  296. }
  297. .button-err {
  298. margin-left: 30rpx;
  299. display: flex;
  300. justify-content: center;
  301. align-items: center;
  302. width: 170rpx;
  303. height: 70rpx;
  304. color: #d43030;
  305. font-size: 32rpx;
  306. border-radius: 15rpx;
  307. background-color: #e6e6e6;
  308. }
  309. }
  310. }
  311. }
  312. </style>