home.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. if (res.code == 200) {
  131. listData.value = [...listData.value, ...res.data.list]
  132. total.value = res.data.totalCount
  133. }
  134. }
  135. // 处理完成按钮回调
  136. const handleFinish = (id) => {
  137. uni.showModal({
  138. title: '提示',
  139. editable: true,
  140. placeholderText: '请输入处理情况备注',
  141. success: (res) => {
  142. if (res.confirm) {
  143. handleOperation(id, res.content)
  144. }
  145. }
  146. })
  147. }
  148. // 误报按钮回调
  149. const handleErr = (id) => {
  150. uni.showModal({
  151. title: '提示',
  152. content: '确定是误报吗?',
  153. success: (res) => {
  154. if (res.confirm) {
  155. handleOperation(id)
  156. }
  157. }
  158. })
  159. }
  160. // 处理请求
  161. const handleOperation = async (id, remark) => {
  162. const res = await myRequest({
  163. url: '/wanzai/api/smartWarning/operation',
  164. method: 'post',
  165. data: {
  166. id,
  167. remark
  168. }
  169. })
  170. // console.log(res)
  171. uni.showToast({
  172. title: res.message,
  173. icon: 'success',
  174. duration: 2000
  175. })
  176. setTimeout(() => {
  177. listData.value = []
  178. currentPage.value = 1
  179. getData()
  180. }, 2000)
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .container {
  185. min-height: 100vh;
  186. background-color: #f2f2f2;
  187. .search {
  188. margin-bottom: 20rpx;
  189. display: flex;
  190. align-items: center;
  191. height: 100rpx;
  192. background-color: #fff;
  193. .search-left {
  194. display: flex;
  195. justify-content: center;
  196. border-right: 1rpx solid #ccc;
  197. .search-img {
  198. margin-left: 27rpx;
  199. margin-top: -5rpx;
  200. width: 17rpx;
  201. height: 12rpx;
  202. .img {
  203. width: 100%;
  204. height: 100%;
  205. }
  206. }
  207. }
  208. .search-right {
  209. display: flex;
  210. justify-content: center;
  211. .search-img {
  212. margin-left: 27rpx;
  213. margin-top: -5rpx;
  214. width: 17rpx;
  215. height: 12rpx;
  216. .img {
  217. width: 100%;
  218. height: 100%;
  219. }
  220. }
  221. }
  222. }
  223. .container-item {
  224. padding: 0 30rpx 20rpx 30rpx;
  225. margin-bottom: 20rpx;
  226. background-color: #fff;
  227. .item-title {
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. height: 92rpx;
  232. border-bottom: 1rpx solid #e6e6e6;
  233. .title-info {
  234. font-size: 34rpx;
  235. font-weight: bold;
  236. }
  237. .title-state {
  238. font-size: 28rpx;
  239. color: #d43030;
  240. }
  241. .color {
  242. color: #5a61f4;
  243. }
  244. }
  245. .item-box {
  246. display: flex;
  247. align-items: center;
  248. height: 80rpx;
  249. font-size: 28rpx;
  250. .box-key {
  251. margin-right: 60rpx;
  252. width: 120rpx;
  253. color: #999999;
  254. text-align-last: justify;
  255. }
  256. .box-value {
  257. }
  258. }
  259. .item-box2 {
  260. display: flex;
  261. align-items: center;
  262. font-size: 28rpx;
  263. .box-key {
  264. margin-right: 60rpx;
  265. width: 120rpx;
  266. color: #999999;
  267. text-align-last: justify;
  268. }
  269. .box-img {
  270. flex: 1;
  271. height: 100%;
  272. .img {
  273. width: 320rpx;
  274. height: 180rpx;
  275. }
  276. }
  277. }
  278. .item-button {
  279. display: flex;
  280. justify-content: flex-end;
  281. align-items: center;
  282. height: 170rpx;
  283. .button-finish {
  284. display: flex;
  285. justify-content: center;
  286. align-items: center;
  287. width: 170rpx;
  288. height: 70rpx;
  289. color: #fff;
  290. font-size: 32rpx;
  291. border-radius: 15rpx;
  292. background: linear-gradient(180deg, #8684ff 0%, #3c50e8 100%);
  293. }
  294. .button-err {
  295. margin-left: 30rpx;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. width: 170rpx;
  300. height: 70rpx;
  301. color: #d43030;
  302. font-size: 32rpx;
  303. border-radius: 15rpx;
  304. background-color: #e6e6e6;
  305. }
  306. }
  307. }
  308. }
  309. </style>