fireRun.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="uni-container uni-container-bg">
  3. <view class="top">
  4. <view>
  5. <view class="search-time">
  6. <text class="time-item">事件时间:</text>
  7. <uni-datetime-picker class="time-item-check" type="date" v-model="startSingle"
  8. @maskClick="startMaskClick" />
  9. </view>
  10. <view class="search-time">
  11. <text class="time-item">结束时间:</text>
  12. <uni-datetime-picker class="time-item-check" type="date" v-model="endSingle"
  13. @maskClick="endMaskClick" />
  14. </view>
  15. </view>
  16. <view class="search-icon">
  17. <u-icon name="search" color="#4CB2B6" size="40" @click="handleQuery"></u-icon>
  18. </view>
  19. </view>
  20. <view class="main">
  21. <view v-for="(item, index) in list" :key="index">
  22. <uni-card v-if="list.length>0">
  23. <view class="main-item">
  24. <rich-text :nodes="`事件内容: ${item.eventContent}`" class="font-16 uni-ellipsis-set"></rich-text>
  25. </view>
  26. <view class="main-item">
  27. <text style="width: 140rpx;">事件日期:</text>
  28. <text class="conts">{{ item.eventTime}}</text>
  29. </view>
  30. <view class="">
  31. <view class="an-niu" @click.native="delClick(item.id)" link style="margin-left:3px">
  32. <text class="deletes">删除事件</text>
  33. </view>
  34. <view class="an-niu" @click.native="detailClick(item.id)" link style="margin-left:3px;">
  35. <text class="bianji details">查看详情</text>
  36. </view>
  37. <view class="an-niu" @click.native="editClick(item.id)" link style="margin-left:3px;">
  38. <text class="bianji">编辑事件</text>
  39. </view>
  40. </view>
  41. </uni-card>
  42. <view v-else style="text-align:center">
  43. 暂无数据
  44. </view>
  45. </view>
  46. </view>
  47. <view>
  48. <image :src="Group" @click="addClick" class="tiantupian"></image>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import config from '@/config'
  54. import {
  55. getStationEvent,
  56. delMicrostation
  57. } from '@/api/fire_station/index';
  58. const baseUrlImg = config.baseUrlImg
  59. export default {
  60. data() {
  61. return {
  62. Group: `${baseUrlImg}/checkActive/Group.png`,
  63. endSingle: '', //结束时间
  64. startSingle: '', //开始时间
  65. list: [],
  66. queryParams: {
  67. pageNo: 1,
  68. pageSize: 5,
  69. eventTime: [],
  70. eventContent: null,
  71. microstationid:''
  72. },
  73. eventTimeString: '',
  74. // 总条数
  75. total: 0,
  76. runId:""
  77. }
  78. },
  79. onShow() {
  80. this.list = []
  81. this.getData()
  82. },
  83. onLoad: function(option) {
  84. this.runId=option.runId
  85. this.queryParams.microstationid=option.runId
  86. },
  87. methods: {
  88. getData() {
  89. if (this.queryParams.pageNo != 1) {
  90. this.queryParams.eventTime.push(this.startSingle, this.endSingle)
  91. }
  92. getStationEvent(this.queryParams).then(response => {
  93. console.log(response, 'responseresponse');
  94. this.list = [...this.list, ...response.data.list]
  95. this.total = response.data.total;
  96. this.queryParams.eventTime = []
  97. })
  98. },
  99. delClick(val) {
  100. let that = this
  101. uni.showModal({
  102. title: '确认删除',
  103. content: `是否确认删除?`,
  104. success: function(res) {
  105. console.log(res, 'res');
  106. if (res.confirm) {
  107. delMicrostation({
  108. id: val
  109. }).then(delres => {
  110. that.$modal.msg('删除成功')
  111. that.queryParams.pageNo = 1;
  112. that.list=[]
  113. that.getData()
  114. that.$forceUpdate()
  115. })
  116. // delRole(ids);
  117. } else if (res.cancel) {
  118. console.log('用户点击取消');
  119. }
  120. }
  121. });
  122. },
  123. /** 搜索按钮操作 */
  124. handleQuery() {
  125. const end = new Date(this.endSingle).getTime()
  126. const start = new Date(this.startSingle).getTime()
  127. if (!this.endSingle && !this.startSingle) {
  128. this.queryParams.pageNo = 1;
  129. this.list = []
  130. this.getData();
  131. } else if (this.endSingle && this.startSingle && start <= end) {
  132. // } else{
  133. this.queryParams.pageNo = 1;
  134. this.queryParams.eventTime.push(this.startSingle, this.endSingle)
  135. this.list = []
  136. this.getData();
  137. } else if (start > end) {
  138. this.$modal.msgError('结束时间不能小于事件时间')
  139. } else {
  140. this.$modal.msgError('请选择事件时间和结束时间')
  141. }
  142. },
  143. startMaskClick(e) {
  144. console.log('maskClick事件:', e);
  145. },
  146. endMaskClick(e) {
  147. console.log('maskClick事件:', e);
  148. },
  149. addClick() {
  150. uni.navigateTo({
  151. url: `/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent?runId=${this.runId}`
  152. });
  153. },
  154. detailClick(val){
  155. uni.navigateTo({
  156. url: `/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent?id=${val}&runId=${this.runId}&isview=isview`
  157. });
  158. },
  159. editClick(val) {
  160. uni.navigateTo({
  161. url: `/pagesA/fire/add_fireRun/add_fireEvent/add_fireEvent?id=${val}&runId=${this.runId}`
  162. });
  163. }
  164. },
  165. // 触底的事件
  166. onReachBottom() {
  167. // 判断是否还有下一页数据
  168. if (this.queryParams.pageNo * this.queryParams.pageSize >= this.total)
  169. return uni.showToast({
  170. title: `数据加载完毕`
  171. });
  172. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  173. if (this.loading) return;
  174. this.queryParams.pageNo += 1;
  175. this.getData();
  176. },
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. body {
  181. background-color: #f5f7f9;
  182. }
  183. page {
  184. background-color: #f5f7f9 !important;
  185. }
  186. .uni-container {
  187. height: 100vh;
  188. }
  189. .top {
  190. display: flex;
  191. align-items: center;
  192. width: 90%;
  193. margin-left: 5%;
  194. justify-content: space-between;
  195. .search-time {
  196. display: flex;
  197. align-items: center;
  198. margin-top: 40rpx;
  199. margin-bottom: 20rpx;
  200. .time-item {
  201. margin-right: 20rpx;
  202. }
  203. .time-item-check {}
  204. }
  205. .search-icon {}
  206. }
  207. .tiantupian {
  208. width: 110rpx;
  209. height: 110rpx;
  210. position: fixed;
  211. right: 15px;
  212. bottom: 40rpx;
  213. }
  214. /deep/.uni-card {
  215. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  216. border-radius: 30rpx;
  217. }
  218. .main {
  219. margin-left: 5%;
  220. margin-top: 30rpx;
  221. width: 90%;
  222. .main-item {
  223. display: flex;
  224. // justify-content: start;
  225. // justify-content: space-between;
  226. margin-bottom: 15rpx;
  227. color: #728f90;
  228. }
  229. }
  230. .an-niu {
  231. float: right;
  232. font-size: 10px;
  233. text-align: center;
  234. display: flex;
  235. color: #fff;
  236. .deletes,
  237. .bianji {
  238. width: 72px;
  239. height: 60rpx;
  240. border-radius: 30px;
  241. background-color: red;
  242. margin-right: 20rpx;
  243. margin-bottom: 20rpx;
  244. text-align: center;
  245. line-height: 60rpx;
  246. }
  247. .bianji {
  248. background-color: #4CB2B6
  249. }
  250. .details{
  251. background-color: #F7C41E
  252. }
  253. }
  254. /deep/.u-button--primary {
  255. border: 1px solid #fff;
  256. background-color: #fff !important;
  257. }
  258. </style>