index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div>
  3. <van-nav-bar
  4. title="检测计划"
  5. left-text="返回"
  6. left-arrow
  7. @click-left="onClickLeft"
  8. />
  9. <div class="body">
  10. <van-dropdown-menu>
  11. <van-dropdown-item v-model="value1" :options="option1" />
  12. <van-dropdown-item v-model="value2" :options="option2" />
  13. </van-dropdown-menu>
  14. <div class="listcontent" :style="`height:${bodyheight}px`">
  15. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  16. <van-list
  17. v-model:loading="loading"
  18. :finished="finished"
  19. finished-text="没有更多了"
  20. @load="onLoad"
  21. >
  22. <div
  23. style="padding: 10px 10px; padding-bottom: 0"
  24. v-for="item in detectionlist"
  25. >
  26. <div class="item">
  27. <div>
  28. <div class="header">
  29. <div>
  30. 计划名称:{{
  31. alldevices.filter((i) => i.id === item.facilitiesId)[0]
  32. ?.roadName ?? "-"
  33. }}检测计划
  34. </div>
  35. <div class="time">{{ item.detectionTime }}</div>
  36. </div>
  37. <div class="body">
  38. <div class="status">
  39. {{
  40. detection_status.filter(
  41. (i) =>
  42. i.value.toString() ===
  43. (item.status ?? "").toString()
  44. )[0]?.label ?? "-"
  45. }}
  46. </div>
  47. <van-row>
  48. <van-col span="24"
  49. ><div>
  50. 检测类型:{{
  51. detection_type.filter(
  52. (i) =>
  53. i.value.toString() ===
  54. item.detectionType.toString()
  55. )[0]?.label ?? "-"
  56. }}
  57. </div></van-col
  58. >
  59. <van-col span="8"> <div>计划年:{{item.detectionYear}}</div></van-col>
  60. <van-col span="8"><div>计划月:{{item.detectionMonth}}</div></van-col>
  61. <van-col span="8"><div>计划周:{{item.detectionWeek}}</div></van-col>
  62. <van-col span="24"
  63. ><div>
  64. 设施起止点:
  65. {{
  66. alldevices.filter(
  67. (i) => i.id === item.facilitiesId
  68. )[0]?.addrFrom
  69. }}
  70. -
  71. {{
  72. alldevices.filter(
  73. (i) => i.id === item.facilitiesId
  74. )[0]?.addrEnd
  75. }}
  76. </div></van-col
  77. >
  78. </van-row>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </van-list>
  84. </van-pull-refresh>
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. <script setup>
  90. import { defineComponent, ref, onMounted, watch, computed } from "vue";
  91. import { useDict } from "@/utils/dict";
  92. import router from "../../../router";
  93. import { listFacilities } from "@/api/system/facilities";
  94. import {
  95. listDetection,
  96. getDetection,
  97. delDetection,
  98. addDetection,
  99. updateDetection,
  100. } from "@/api/system/detection";
  101. const detectionlist = ref([]);
  102. const loading = ref(false);
  103. const finished = ref(false);
  104. const refreshing = ref(false);
  105. const { detection_status, detection_type } = useDict(
  106. "detection_status",
  107. "detection_type"
  108. );
  109. const bodyheight = ref(0);
  110. bodyheight.value = document.body.clientHeight - 48 - 46;
  111. const value1 = ref(0);
  112. const value2 = ref("0");
  113. const option1 = [
  114. { text: "我的", value: 0 },
  115. { text: "全部", value: 1 },
  116. ];
  117. const option2 = computed(() => {
  118. return [{ text: "全部", value: "0" }].concat(
  119. detection_status.value.map((i) => {
  120. return { text: i.label, value: i.value };
  121. })
  122. );
  123. });
  124. const alldevices = ref([]);
  125. listFacilities().then((res) => {
  126. alldevices.value = res.rows;
  127. });
  128. const pagec = ref(1);
  129. const onLoad = () => {
  130. if (refreshing.value) {
  131. detectionlist.value = [];
  132. refreshing.value = false;
  133. pagec.value = 1;
  134. }
  135. listDetection({ pageSize: 10, pageNum: pagec.value++ }).then((res) => {
  136. // finished.value = true;
  137. loading.value = false;
  138. detectionlist.value = detectionlist.value.concat(res.rows);
  139. if (res.total <= detectionlist.value.length) {
  140. finished.value = true;
  141. }
  142. });
  143. console.log("----");
  144. };
  145. const onRefresh = () => {
  146. // 清空列表数据
  147. finished.value = false;
  148. loading.value = true;
  149. refreshing.value = true;
  150. onLoad();
  151. };
  152. const onClickLeft = () => {
  153. router.back();
  154. };
  155. </script>
  156. <style lang="scss">
  157. body {
  158. position: fixed;
  159. width: 100%;
  160. top: -1px;
  161. }
  162. .listcontent {
  163. overflow-y: auto;
  164. .item {
  165. background: #fff;
  166. border: 1px solid rgba(209, 217, 221,0.4);
  167. padding: 10px 15px;
  168. font-size: 10px;
  169. border-radius: 5px;
  170. .header {
  171. color: #3d6dc5;
  172. font-weight: bold;
  173. position: relative;
  174. padding-bottom: 8px;
  175. border-bottom: 1px solid rgba(209, 217, 221,0.4);
  176. .time {
  177. position: absolute;
  178. right: 0;
  179. top: 0;
  180. color: #283247;
  181. opacity: 0.7;
  182. font-weight: 400;
  183. }
  184. }
  185. .body {
  186. padding-top: 10px;
  187. padding-bottom: 10px;
  188. position: relative;
  189. color: #283247;
  190. opacity: 0.8;
  191. .status {
  192. position: absolute;
  193. top: 10px;
  194. color: #dc2828;
  195. right: 0px;
  196. font-weight: bold;
  197. }
  198. .van-col {
  199. margin: 3px 0;
  200. }
  201. }
  202. }
  203. }
  204. </style>