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/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/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. alert(1)
  137. this.isLoadMore = true
  138. this.loadStatus = 'nomore'
  139. } else {
  140. this.isLoadMore = false
  141. }
  142. } else {
  143. this.isLoadMore = true
  144. this.loadStatus = 'nomore'
  145. }
  146. },
  147. //编辑
  148. editItem(item) {
  149. uni.redirectTo({
  150. url: '/pages/setting/funReport/funcAdd/funcAdd?id=' + item.id + '',
  151. });
  152. },
  153. //删除
  154. deleteItem(item) {
  155. let deleteT=0;
  156. this.deleteStatus=true
  157. uni.showModal({
  158. title: '确认删除吗?',
  159. content: '',
  160. success: function (result) {
  161. if (result.confirm) {
  162. this.deleteAlarm({
  163. "id": item.id
  164. });
  165. } else if (result.cancel) {
  166. console.log('用户点击取消');
  167. }
  168. }.bind(this)
  169. });
  170. },
  171. // 删除请求接口
  172. async deleteAlarm(ming = {}) {
  173. let res = await this.$myRequest({
  174. url: 'AlarmReport/del ',
  175. data: ming
  176. })
  177. if (!res.data.flag) {
  178. alert('删除失败');
  179. return;
  180. }
  181. this.getDeviceList({'company_code':uni.getStorageSync('selectedCode')})
  182. return res;
  183. },
  184. // 新增
  185. goAddPage(type) {
  186. uni.redirectTo({
  187. url: '/pages/setting/funReport/funcAdd/funcAdd',
  188. success: res => {},
  189. fail: () => {},
  190. complete: () => {}
  191. });
  192. },
  193. // ListTouch触摸开始
  194. ListTouchStart(e) {
  195. this.listTouchStart = e.touches[0].pageX
  196. },
  197. // ListTouch计算方向
  198. ListTouchMove(e) {
  199. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  200. },
  201. // ListTouch计算滚动
  202. ListTouchEnd(e) {
  203. if (this.listTouchDirection == 'left') {
  204. this.modalName = e.currentTarget.dataset.target
  205. } else {
  206. this.modalName = null
  207. }
  208. this.listTouchDirection = null
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss">
  214. .cu-item {
  215. height: 180rpx !important
  216. }
  217. .plus {
  218. position: fixed;
  219. bottom: 3px;
  220. right: 3px;
  221. }
  222. </style>