funReport.vue 6.4 KB

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