home.vue 7.3 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. </view>
  14. <view class="search">
  15. <uni-datetime-picker v-model="datetimerangeValue" type="datetimerange" rangeSeparator="至" :clear-icon="false" @change="bindDateChange" />
  16. </view>
  17. <!-- 每一个预警信息 -->
  18. <view class="container-item" v-for="item in listData" :key="item.id">
  19. <!-- 标题区域 -->
  20. <view class="item-title">
  21. <view class="title-info">{{ item.type }}</view>
  22. <view class="title-state" v-if="item.statu == 0">待处理</view>
  23. <view class="title-state color" v-else>已处理</view>
  24. </view>
  25. <!-- 告警时间区域 -->
  26. <view class="item-box">
  27. <view class="box-key">告警时间</view>
  28. <view class="box-value">{{ item.dateTime }}</view>
  29. </view>
  30. <!-- 姓名区域 -->
  31. <view class="item-box">
  32. <view class="box-key">姓名</view>
  33. <view class="box-value">{{ item.name ? item.name : '未知' }}</view>
  34. </view>
  35. <!-- 地点区域 -->
  36. <view class="item-box">
  37. <view class="box-key">地点</view>
  38. <view class="box-value">{{ item.location }}</view>
  39. </view>
  40. <!-- 图片区域 -->
  41. <view class="item-box2">
  42. <view class="box-key">图片</view>
  43. <view class="box-img" @click="previewImage(item.image)"><img mode="aspectFill" class="img" :src="item.image" /></view>
  44. </view>
  45. <!-- 按钮区域 -->
  46. <view class="item-button" v-if="item.statu == 0">
  47. <view class="button-finish" @click="handleFinish(item.id)">处理完成</view>
  48. <view class="button-err" @click="handleErr(item.id)">误报</view>
  49. </view>
  50. </view>
  51. <!-- 无数据时展示的区域 -->
  52. <NoData v-if="!listData.length" />
  53. </view>
  54. </template>
  55. <script setup>
  56. import { ref } from 'vue'
  57. import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  58. // 导入时间相关函数
  59. import { time_format } from '@/utils/formatTime.js'
  60. import { myRequest } from '@/utils/api.js'
  61. import NoData from '@/components/noData.vue'
  62. import { previewImage } from '@/utils/previewImage.js'
  63. import { decryptDes } from '@/utils/des.js'
  64. import dayjs from 'dayjs'
  65. // 状态筛选框数组当前索引
  66. const typeIndex = ref(0)
  67. // 状态筛选框数组
  68. const typeList = ref([])
  69. // 状态筛选框改变数据时的回调
  70. const bindTypeChange = (e) => {
  71. typeIndex.value = e.detail.value
  72. listData.value = []
  73. currentPage.value = 1
  74. getData()
  75. }
  76. // 日期筛选框改变数据时的回调
  77. const bindDateChange = (e) => {
  78. if (e.length) {
  79. listData.value = []
  80. currentPage.value = 1
  81. getData()
  82. }
  83. }
  84. // 当前页
  85. const currentPage = ref(1)
  86. // 总条数
  87. const total = ref(null)
  88. // 预警列表数据
  89. const listData = ref([])
  90. const datetimerangeValue = ref()
  91. onLoad(() => {
  92. datetimerangeValue.value = [dayjs(Date.now()).format('YYYY-MM-DD') + ' 00:00:00', dayjs(Date.now()).format('YYYY-MM-DD') + ' 23:59:59']
  93. getTypeList()
  94. getData()
  95. })
  96. // 页面上拉到最底部时触发的回调
  97. onReachBottom(() => {
  98. if (total.value > listData.value.length) {
  99. currentPage.value++
  100. getData()
  101. } else {
  102. uni.showToast({
  103. title: '没有更多数据了',
  104. icon: 'none'
  105. })
  106. }
  107. })
  108. // 获取筛选框数组
  109. const getTypeList = async () => {
  110. const res = await myRequest({
  111. url: '/wanzai/api/smartWarning/warningType'
  112. })
  113. // console.log(res)
  114. const result = JSON.parse(decryptDes(res.data))
  115. // console.log(result)
  116. typeList.value = result.reverse()
  117. }
  118. // 获取预警列表数据
  119. const getData = async () => {
  120. const res = await myRequest({
  121. url: '/wanzai/api/smartWarning/pageWarning',
  122. data: {
  123. currentPage: currentPage.value,
  124. pageCount: 6,
  125. type: typeList.value[typeIndex.value] || '全部',
  126. startTime: datetimerangeValue.value[0],
  127. endTime: datetimerangeValue.value[1]
  128. }
  129. })
  130. // console.log(res)
  131. if (res.code == 200) {
  132. const result = JSON.parse(decryptDes(res.data))
  133. listData.value = [...listData.value, ...result.list]
  134. total.value = result.totalCount
  135. }
  136. }
  137. // 处理完成按钮回调
  138. const handleFinish = (id) => {
  139. uni.showModal({
  140. title: '提示',
  141. editable: true,
  142. placeholderText: '请输入处理情况备注',
  143. success: (res) => {
  144. if (res.confirm) {
  145. handleOperation(id, res.content)
  146. }
  147. }
  148. })
  149. }
  150. // 误报按钮回调
  151. const handleErr = (id) => {
  152. uni.showModal({
  153. title: '提示',
  154. content: '确定是误报吗?',
  155. success: (res) => {
  156. if (res.confirm) {
  157. handleOperation(id)
  158. }
  159. }
  160. })
  161. }
  162. // 处理请求
  163. const handleOperation = async (id, remark) => {
  164. const res = await myRequest({
  165. url: '/wanzai/api/smartWarning/operation',
  166. method: 'post',
  167. data: {
  168. id,
  169. remark
  170. }
  171. })
  172. // console.log(res)
  173. uni.showToast({
  174. title: res.message,
  175. icon: 'success',
  176. duration: 2000
  177. })
  178. setTimeout(() => {
  179. listData.value = []
  180. currentPage.value = 1
  181. getData()
  182. }, 2000)
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .container {
  187. min-height: 100vh;
  188. background-color: #f2f2f2;
  189. .search {
  190. // margin-bottom: 20rpx;
  191. display: flex;
  192. align-items: center;
  193. height: 100rpx;
  194. // border-bottom: 2rpx solid #ccc;
  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>