index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view class="content">
  3. <view class="msg-box">
  4. <view style="margin-bottom:10rpx;position:relative" v-for="item in msgList" :key="item.id">
  5. <view class="msg-item">
  6. <view class="msg-row">
  7. <image src="@/static/image/bj1.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
  8. alt="">
  9. <view class="msg-content">
  10. 名称 :{{item.itemReadName}}
  11. </view>
  12. </view>
  13. <view class="msg-row">
  14. <image src="@/static/image/bj3.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
  15. alt="">
  16. <view class="msg-content">
  17. 类型 :{{item.alarmType}}
  18. </view>
  19. </view>
  20. <view class="msg-row">
  21. <image src="@/static/image/bj4.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
  22. alt="">
  23. <view class="msg-content">
  24. 时间 :{{item.alarmTime}}
  25. </view>
  26. </view>
  27. <view class="msg-row">
  28. <image src="@/static/image/bj2.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
  29. alt="">
  30. <view class="msg-content">
  31. 报警描述 :<text style="font-weight: normal;">{{item.alarmText}}</text>
  32. </view>
  33. </view>
  34. <view class="msg-row">
  35. <u-button type="primary" size="small" class="cl" @click="handleMsg(item)">查看详情</u-button>
  36. </view>
  37. </view>
  38. <!-- <view class="msg-btn">
  39. <u-button type="primary" size="small" class="cl" @click="handleMsg(item.id)">查看详情</u-button>
  40. </view> -->
  41. <!-- <view class="emergent" v-if="item.readState!==0">
  42. <image src="@/static/image/jjbq.png" alt="" style="width:95rpx;height:80rpx">
  43. </view> -->
  44. </view>
  45. <view v-if="queryForm" class="query-screen">
  46. <view>
  47. 关键字
  48. </view>
  49. <div style="margin: 20px 0;">
  50. <input v-model="queryParams.queryKey" placeholder="请输入点位名称查询"/>
  51. </div>
  52. <view>
  53. 报警类型
  54. </view>
  55. <div style="margin: 20px 0;">
  56. <uni-data-select v-model="queryParams.alarmType" :localdata="alarmTypeList"></uni-data-select>
  57. </div>
  58. <view>
  59. 报警时间
  60. </view>
  61. <uni-datetime-picker v-model="range" type="datetimerange" start-placeholder="起始时间"
  62. end-placeholder="终止时间" @change="handelDate" return-type="timestamp" />
  63. <view class="month-btn">
  64. <u-button class="reset" style="width:200rpx" @click="reset">重置</u-button>
  65. <u-button type="primary" style="width:200rpx" @click="handelQuery">确认</u-button>
  66. </view>
  67. </view>
  68. </view>
  69. <u-empty v-if="!msgList.length" class="empty" icon="../../static/data.png" text="暂无数据">
  70. </u-empty>
  71. </view>
  72. </template>
  73. <script>
  74. import {
  75. getDayTime,
  76. timeToDate
  77. } from '@/utils/date.js'
  78. export default {
  79. data() {
  80. return {
  81. queryForm:false,
  82. // 日期选择
  83. range: [],
  84. //报警类型
  85. alarmTypeList:[
  86. {
  87. text:'数据源报警',
  88. value:'数据源',
  89. },
  90. {
  91. text:'点位报警',
  92. value:'点位'
  93. }
  94. ],
  95. // 查询参数
  96. queryParams: {
  97. queryKey:null,
  98. startDate:null,
  99. endDate:null,
  100. alarmType:null,
  101. page: 1,
  102. limit: 20
  103. },
  104. // 列表数据
  105. msgList: []
  106. };
  107. },
  108. onShow() {
  109. this.queryParams.limit = 20
  110. this.getMsgList()
  111. uni.pageScrollTo({
  112. scrollTop: 0,
  113. duration: 0
  114. })
  115. },
  116. onPullDownRefresh() {
  117. this.queryParams.limit = 20
  118. this.getMsgList()
  119. },
  120. onReachBottom() {
  121. this.queryParams.limit += 10
  122. this.getMsgList()
  123. },
  124. methods: {
  125. // 获取消息数据
  126. getMsgList() {
  127. if((this.queryParams.startDate==null) || (this.queryParams.endDate==null)){
  128. let dDate = getDayTime();
  129. this.queryParams.startDate = timeToDate(dDate[0])
  130. this.queryParams.endDate = timeToDate(dDate[1])
  131. }
  132. console.log(this.queryForm)
  133. uni.$http.get('/mobileAlarm/queryAllAlarmData', this.queryParams).then(res => {
  134. const data = res.data
  135. if (data.code === 200) {
  136. this.msgList = data.data
  137. uni.stopPullDownRefresh()
  138. }
  139. })
  140. },
  141. //立即处理
  142. handleMsg(item) {
  143. uni.navigateTo({
  144. url: "/pages/message/msg-detail/index?data=" + JSON.stringify(item),
  145. })
  146. },
  147. onNavigationBarButtonTap(e){
  148. this.queryForm = !this.queryForm;
  149. if(this.queryForm){
  150. this.range = getDayTime()
  151. this.handelDate(this.range)
  152. }
  153. },
  154. resolvingDate(date) {
  155. if (!date) {
  156. return;
  157. }
  158. //date是传入的时间
  159. let d = new Date(date);
  160. let month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
  161. let day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();
  162. let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
  163. let min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
  164. let sec = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
  165. let times;
  166. times = d.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + sec;
  167. return times
  168. },
  169. //选择日期
  170. handelDate(date) {
  171. this.queryParams.startDate = this.resolvingDate(date[0])
  172. this.queryParams.endDate = this.resolvingDate(date[1])
  173. },
  174. //重置按钮
  175. reset() {
  176. this.queryParams = {
  177. queryKey:null,
  178. startDate:null,
  179. endDate:null,
  180. alarmType:null,
  181. page: 1,
  182. limit: 20
  183. }
  184. },
  185. //确认按钮查询
  186. handelQuery() {
  187. //如果没有选择时间,默认当天的起止时间
  188. this.queryForm = false;
  189. this.getMsgList();
  190. },
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .content {
  196. //padding: 20rpx 45rpx 20rpx 45rpx;
  197. background: #EEEDF2;
  198. }
  199. .empty {
  200. width: 400rpx;
  201. height: 400rpx;
  202. position: absolute;
  203. top: 50%;
  204. left: 50%;
  205. margin-top: -280rpx !important;
  206. margin-left: -200rpx;
  207. }
  208. .msg-box {
  209. .msg-item {
  210. background: #ffffff;
  211. padding: 25rpx;
  212. margin-bottom: 4rpx;
  213. .msg-row {
  214. display: flex;
  215. align-items: center;
  216. margin-bottom: 20rpx;
  217. .msg-content {
  218. width: 500rpx;
  219. white-space: nowrap;
  220. text-overflow: ellipsis;
  221. overflow: hidden;
  222. }
  223. }
  224. }
  225. .msg-btn {
  226. background: #ffffff;
  227. padding: 25rpx;
  228. .cl {
  229. width: 180rpx;
  230. margin-right: 0
  231. }
  232. }
  233. .emergent {
  234. position: absolute;
  235. right: 30rpx;
  236. top: 0;
  237. }
  238. .query-screen {
  239. width: 96vw;
  240. padding: 0 20rpx;
  241. background: #ffffff;
  242. position: absolute;
  243. top: 0;
  244. z-index: 999;
  245. .month {
  246. display: flex;
  247. justify-content: space-between;
  248. align-items: center;
  249. font-size: 32rpx;
  250. margin: 40rpx 0;
  251. .month-item {
  252. padding: 10rpx 20rpx;
  253. background: #ECECEC;
  254. color: #000000;
  255. border-radius: 12rpx;
  256. }
  257. .month-select {
  258. padding: 10rpx 20rpx;
  259. border-radius: 12rpx;
  260. background: #289BFF;
  261. color: #ffffff;
  262. }
  263. }
  264. .month-btn {
  265. display: flex;
  266. justify-content: space-around;
  267. margin-top: 40rpx;
  268. margin-bottom: 40rpx;
  269. .reset {
  270. background: #EAF4FF;
  271. color: #469DED;
  272. border: 1px solid #A3B8CB;
  273. }
  274. }
  275. }
  276. }
  277. </style>