funReport.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="">
  3. <!-- 筛选框start -->
  4. <view style="height:98rpx"></view>
  5. <view class="ding">
  6. <!-- <calendar></calendar> -->
  7. <view class="example-body">
  8. <uni-datetime-picker v-model="datetimerange" type="daterange" start-placeholder="请选择开始时间"
  9. end-placeholder="请选择结束时间" start="2000-3-20 12:00:00" end="2025-10-20 20:00:00" rangeSeparator="至" />
  10. </view>
  11. </view>
  12. <!-- 筛选框end -->
  13. <view class="site-items" style="margin-top:0;height: calc(100vh - 286rpx)">
  14. <view class="cu-list menu-avatar" >
  15. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  16. v-for="(item,index) in funcReport" :key="index"
  17. @touchstart="ListTouchStart"
  18. @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index"
  19. >
  20. <view class="cu-avatar round lg">
  21. <image class="image-bg" src="@/static/images/setting/funcList.png"/>
  22. </view>
  23. <view class="content">
  24. <view class="pro-title">
  25. <view class="cut">{{item.report_name}}</view>
  26. </view>
  27. <view class="pro-des ">
  28. <view class="text-cut">
  29. {{item.remarks }}
  30. </view>
  31. </view>
  32. <view class="pro-date ">{{item.add_time}}</view>
  33. </view>
  34. <view class="nav-right num">
  35. <view class="text-grey">
  36. <text class="icon iconfont margin-right-sm margin-left-lg">&#xe629;</text>
  37. </view>
  38. </view>
  39. <view class="move">
  40. <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
  41. <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view v-if="!funcReport.length&&authListRes==1" class="text-center margin-top"> 暂无数据</view>
  46. <view v-show="isLoadMore&&this.pages>1" style="padding-bottom:60px">
  47. <uni-load-more :status="loadStatus"></uni-load-more>
  48. </view>
  49. <view style="padding-bottom:60px"></view>
  50. </view>
  51. <!-- 新增按钮start -->
  52. <view style="width: 100%;
  53. position: fixed;
  54. bottom: 0px;
  55. right: 0px;
  56. height: 64px;
  57. background: #fff;">
  58. <view class="plus">
  59. <image src="@/static/images/setting/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
  60. </view>
  61. </view>
  62. <!-- 新增按钮end -->
  63. </view>
  64. </template>
  65. <script>
  66. import json from '../../../data/json.js';
  67. export default {
  68. data() {
  69. return {
  70. funcReport: [],
  71. modalName: null,
  72. getData:[],
  73. dwtype:0,
  74. datetimerange: ['', ''],
  75. listTouchStart: 0,
  76. listTouchDirection: null,
  77. flag:false,
  78. authListRes:0,
  79. pages: 1,
  80. size: 12,
  81. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  82. isLoadMore: false, //是否加载中
  83. deleteStatus:false,
  84. };
  85. },
  86. onReachBottom() { //上拉触底函数
  87. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  88. this.isLoadMore = true
  89. this.pages += 1;
  90. this.loadData()
  91. }
  92. },
  93. onLoad: function(option) {
  94. this.dwtype=option.dwtype
  95. this.loadData()
  96. },
  97. onNavigationBarButtonTap(e) {
  98. console.log(e)
  99. uni.navigateTo({
  100. url: './export/export?dwtype='+this.dwtype,
  101. });
  102. },
  103. watch: {
  104. datetimerange:function(){
  105. this.funcReport=[];
  106. this.pages = 1;
  107. this.authListRes=[]
  108. this.loadData()
  109. },
  110. },
  111. methods: {
  112. loadData(){
  113. this.getDeviceList({
  114. 'company_code':uni.getStorageSync('selectedCode'),
  115. 'start_time':this.datetimerange[0],
  116. 'end_time':this.datetimerange[1],
  117. 'pages': this.pages,
  118. 'size': this.size
  119. })
  120. },
  121. // 设备类型数据请求
  122. async getDeviceList(params = {}) {
  123. const res = await this.$myRequest({
  124. url: 'AlarmReport/index',
  125. data:params,
  126. showLoading: true
  127. })
  128. if(this.deleteStatus){
  129. this.funcReport=[];
  130. this.deleteStatus=false;
  131. }
  132. this.authListRes = 1;
  133. if (res.data.totalcount) {
  134. this.funcReport = this.funcReport.concat(res.data.data)
  135. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  136. this.isLoadMore = true
  137. this.loadStatus = 'nomore'
  138. } else {
  139. this.isLoadMore = false
  140. }
  141. } else {
  142. this.isLoadMore = true
  143. this.loadStatus = 'nomore'
  144. }
  145. },
  146. //编辑
  147. editItem(item) {
  148. uni.redirectTo({
  149. url: '/pages/setting/funReport/funcAdd/funcAdd?id=' + item.id + '',
  150. });
  151. },
  152. //删除
  153. deleteItem(item) {
  154. let deleteT=0;
  155. this.deleteStatus=true
  156. uni.showModal({
  157. title: '确认删除吗?',
  158. content: '',
  159. success: function (result) {
  160. if (result.confirm) {
  161. this.deleteAlarm({
  162. "id": item.id
  163. });
  164. } else if (result.cancel) {
  165. console.log('用户点击取消');
  166. }
  167. }.bind(this)
  168. });
  169. },
  170. // 删除请求接口
  171. async deleteAlarm(ming = {}) {
  172. let res = await this.$myRequest({
  173. url: 'AlarmReport/del ',
  174. data: ming
  175. })
  176. if (!res.data.flag) {
  177. alert('删除失败');
  178. return;
  179. }
  180. this.getDeviceList({'company_code':uni.getStorageSync('selectedCode')})
  181. return res;
  182. },
  183. // 新增
  184. goAddPage(type) {
  185. uni.redirectTo({
  186. url: '/pages/setting/funReport/funcAdd/funcAdd',
  187. success: res => {},
  188. fail: () => {},
  189. complete: () => {}
  190. });
  191. },
  192. // ListTouch触摸开始
  193. ListTouchStart(e) {
  194. this.listTouchStart = e.touches[0].pageX
  195. },
  196. // ListTouch计算方向
  197. ListTouchMove(e) {
  198. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  199. },
  200. // ListTouch计算滚动
  201. ListTouchEnd(e) {
  202. if (this.listTouchDirection == 'left') {
  203. this.modalName = e.currentTarget.dataset.target
  204. } else {
  205. this.modalName = null
  206. }
  207. this.listTouchDirection = null
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss">
  213. .cu-item {
  214. height: 180rpx !important
  215. }
  216. .plus {
  217. position: fixed;
  218. bottom: 3px;
  219. right: 3px;
  220. }
  221. </style>