home.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. // 状态筛选框数组当前索引
  69. const typeIndex = ref(0)
  70. // 状态筛选框数组
  71. const typeList = ref([])
  72. // 状态筛选框改变数据时的回调
  73. const bindTypeChange = (e) => {
  74. typeIndex.value = e.detail.value
  75. listData.value = []
  76. currentPage.value = 1
  77. getData()
  78. }
  79. // 日期筛选框绑定日期
  80. const date = ref(getNowDate())
  81. // 日期筛选框改变数据时的回调
  82. const bindDateChange = (e) => {
  83. date.value = e.detail.value
  84. listData.value = []
  85. currentPage.value = 1
  86. getData()
  87. }
  88. // 当前页
  89. const currentPage = ref(1)
  90. // 总条数
  91. const total = ref(null)
  92. // 预警列表数据
  93. const listData = ref([])
  94. onLoad(() => {
  95. getTypeList()
  96. getData()
  97. })
  98. // 页面上拉到最底部时触发的回调
  99. onReachBottom(() => {
  100. if (total.value > listData.value.length) {
  101. currentPage.value++
  102. getData()
  103. } else {
  104. uni.showToast({
  105. title: '没有更多数据了',
  106. icon: 'none'
  107. })
  108. }
  109. })
  110. // 获取筛选框数组
  111. const getTypeList = async () => {
  112. const res = await myRequest({
  113. url: '/wanzai/api/smartWarning/warningType'
  114. })
  115. // console.log(res)
  116. typeList.value = res.data.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. dateTime: date.value
  127. }
  128. })
  129. // console.log(res)
  130. listData.value = [...listData.value, ...res.data.list]
  131. total.value = res.data.totalCount
  132. }
  133. // 处理完成按钮回调
  134. const handleFinish = (id) => {
  135. uni.showModal({
  136. title: '提示',
  137. editable: true,
  138. placeholderText: '请输入处理情况备注',
  139. success: (res) => {
  140. if (res.confirm) {
  141. handleOperation(id, res.content)
  142. }
  143. }
  144. })
  145. }
  146. // 误报按钮回调
  147. const handleErr = (id) => {
  148. uni.showModal({
  149. title: '提示',
  150. content: '确定是误报吗?',
  151. success: (res) => {
  152. if (res.confirm) {
  153. handleOperation(id)
  154. }
  155. }
  156. })
  157. }
  158. // 处理请求
  159. const handleOperation = async (id, remark) => {
  160. const res = await myRequest({
  161. url: '/wanzai/api/smartWarning/operation',
  162. method: 'post',
  163. data: {
  164. id,
  165. remark
  166. }
  167. })
  168. // console.log(res)
  169. uni.showToast({
  170. title: res.message,
  171. icon: 'success',
  172. duration: 2000
  173. })
  174. setTimeout(() => {
  175. listData.value = []
  176. currentPage.value = 1
  177. getData()
  178. }, 2000)
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .container {
  183. min-height: 100vh;
  184. background-color: #f2f2f2;
  185. .search {
  186. margin-bottom: 20rpx;
  187. display: flex;
  188. align-items: center;
  189. height: 100rpx;
  190. background-color: #fff;
  191. .search-left {
  192. display: flex;
  193. justify-content: center;
  194. border-right: 1rpx solid #ccc;
  195. .search-img {
  196. margin-left: 27rpx;
  197. margin-top: -5rpx;
  198. width: 17rpx;
  199. height: 12rpx;
  200. .img {
  201. width: 100%;
  202. height: 100%;
  203. }
  204. }
  205. }
  206. .search-right {
  207. display: flex;
  208. justify-content: center;
  209. .search-img {
  210. margin-left: 27rpx;
  211. margin-top: -5rpx;
  212. width: 17rpx;
  213. height: 12rpx;
  214. .img {
  215. width: 100%;
  216. height: 100%;
  217. }
  218. }
  219. }
  220. }
  221. .container-item {
  222. padding: 0 30rpx 20rpx 30rpx;
  223. margin-bottom: 20rpx;
  224. background-color: #fff;
  225. .item-title {
  226. display: flex;
  227. justify-content: space-between;
  228. align-items: center;
  229. height: 92rpx;
  230. border-bottom: 1rpx solid #e6e6e6;
  231. .title-info {
  232. font-size: 34rpx;
  233. font-weight: bold;
  234. }
  235. .title-state {
  236. font-size: 28rpx;
  237. color: #d43030;
  238. }
  239. .color {
  240. color: #5a61f4;
  241. }
  242. }
  243. .item-box {
  244. display: flex;
  245. align-items: center;
  246. height: 80rpx;
  247. font-size: 28rpx;
  248. .box-key {
  249. margin-right: 60rpx;
  250. width: 120rpx;
  251. color: #999999;
  252. text-align-last: justify;
  253. }
  254. .box-value {
  255. }
  256. }
  257. .item-box2 {
  258. display: flex;
  259. align-items: center;
  260. font-size: 28rpx;
  261. .box-key {
  262. margin-right: 60rpx;
  263. width: 120rpx;
  264. color: #999999;
  265. text-align-last: justify;
  266. }
  267. .box-img {
  268. flex: 1;
  269. height: 100%;
  270. .img {
  271. width: 320rpx;
  272. height: 180rpx;
  273. }
  274. }
  275. }
  276. .item-button {
  277. display: flex;
  278. justify-content: flex-end;
  279. align-items: center;
  280. height: 170rpx;
  281. .button-finish {
  282. display: flex;
  283. justify-content: center;
  284. align-items: center;
  285. width: 170rpx;
  286. height: 70rpx;
  287. color: #fff;
  288. font-size: 32rpx;
  289. border-radius: 15rpx;
  290. background: linear-gradient(180deg, #8684ff 0%, #3c50e8 100%);
  291. }
  292. .button-err {
  293. margin-left: 30rpx;
  294. display: flex;
  295. justify-content: center;
  296. align-items: center;
  297. width: 170rpx;
  298. height: 70rpx;
  299. color: #d43030;
  300. font-size: 32rpx;
  301. border-radius: 15rpx;
  302. background-color: #e6e6e6;
  303. }
  304. }
  305. }
  306. }
  307. </style>