securityFacilitiesErrList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <van-nav-bar
  3. title="安防设施异常"
  4. left-text=""
  5. right-text="上报"
  6. left-arrow
  7. @click-left="onClickLeft"
  8. @click-right="onClickRight"
  9. />
  10. <van-search v-model="value" shape="round" placeholder="请输入搜索关键词" />
  11. <van-tabs
  12. v-model:active="active"
  13. title-inactive-color="#bdbdbd"
  14. title-active-color="#36a7f3"
  15. @click-tab="onClickTab"
  16. >
  17. <van-tab title="未审核" name="0">
  18. <van-list
  19. v-model:loading="loading"
  20. :finished="finished"
  21. finished-text="没有更多了"
  22. @load="onLoad"
  23. >
  24. <van-swipe-cell
  25. v-for="item in list"
  26. :key="item"
  27. :before-close="beforeClose"
  28. >
  29. <div class="list_item" @click="goInfo(item.id)">
  30. <div class="item-left">
  31. <p style="color: #c4c4c4">{{ item.updateDate }}</p>
  32. <p style="color: red">待审核</p>
  33. </div>
  34. <van-cell is-link v-if="item.facilityType==0">
  35. <template #title >
  36. {{ item.siteName.name }}({{ item.videoAudioPoint.name }})
  37. </template>
  38. <template #label>
  39. {{ item.position }}
  40. </template>
  41. </van-cell>
  42. <van-cell is-link v-if="item.facilityType==1">
  43. <template #title >
  44. {{ item.siteName.name }}({{ item.siteFireProtection.name }})
  45. </template>
  46. <template #label>
  47. {{ item.position }}
  48. </template>
  49. </van-cell>
  50. </div>
  51. <template #right>
  52. <van-button square type="danger" text="删除" class="button" />
  53. <van-button
  54. square
  55. type="primary"
  56. text="修改"
  57. class="button"
  58. @click="updateItem(item)"
  59. />
  60. </template>
  61. </van-swipe-cell>
  62. </van-list>
  63. </van-tab>
  64. <van-tab title="已审核" name="1">
  65. <van-list
  66. v-model:loading="loading"
  67. :finished="finished"
  68. finished-text="没有更多了"
  69. @load="onLoad"
  70. >
  71. <van-swipe-cell
  72. v-for="item in list"
  73. :key="item"
  74. :before-close="beforeClose"
  75. >
  76. <div class="list_item" @click="goInfo(item.id)">
  77. <div class="item-left">
  78. <p style="color: #c4c4c4">{{ item.updateDate }}</p>
  79. <p style="color: gray">已审核</p>
  80. </div>
  81. <van-cell is-link v-if="item.facilityType==0">
  82. <template #title >
  83. {{ item.siteName.name }}({{ item.videoAudioPoint.name }})
  84. </template>
  85. <template #label>
  86. {{ item.position }}
  87. </template>
  88. </van-cell>
  89. <van-cell is-link v-if="item.facilityType==1">
  90. <template #title >
  91. {{ item.siteName.name }}({{ item.siteFireProtection.name }})
  92. </template>
  93. <template #label>
  94. {{ item.position }}
  95. </template>
  96. </van-cell>
  97. </div>
  98. </van-swipe-cell>
  99. </van-list>
  100. </van-tab>
  101. </van-tabs>
  102. </template>
  103. <script>
  104. import { ref } from "vue";
  105. import router from "@/router";
  106. import securityFacilitiesErrService from "@/api/securityFacilitiesErr/securityFacilitiesErrService";
  107. export default {
  108. name: "securityFacilitiesErrList",
  109. setup() {
  110. const onClickLeft = () => {
  111. history.back();
  112. };
  113. const onClickRight = () => {
  114. router.push("/securityFacilitiesErrView");
  115. };
  116. let tabIndex = ref(0);
  117. //tab切换
  118. let active = ref(0);
  119. const onClickTab = (val) => {
  120. // 清空列表数据
  121. finished.value = false;
  122. list.value = [];
  123. // 重新加载数据
  124. // 将 loading 设置为 true,表示处于加载状态
  125. loading.value = true;
  126. index = 0;
  127. if (val.name == 0) {
  128. onLoad(0);
  129. } else {
  130. onLoad(1);
  131. }
  132. };
  133. // 列表
  134. let list = ref([]);
  135. const loading = ref(false);
  136. const finished = ref(false);
  137. let index = 0;
  138. const onLoad = (val) => {
  139. // 异步更新数据
  140. console.log(val);
  141. new securityFacilitiesErrService()
  142. .list({
  143. current: index + 1,
  144. size: 10,
  145. assessment:val ? val : 0,
  146. })
  147. .then((res) => {
  148. list.value.push(...res.records) ;
  149. // 加载状态结束
  150. loading.value = false;
  151. // 数据全部加载完成
  152. if (res.records.length < 10) {
  153. finished.value = true;
  154. }
  155. index++;
  156. });
  157. };
  158. // 搜索
  159. let value = ref("");
  160. // 删除确认
  161. const beforeClose = ({ position }) => {
  162. switch (position) {
  163. case "left":
  164. case "cell":
  165. case "outside":
  166. return true;
  167. case "right":
  168. return new Promise((resolve) => {
  169. showConfirmDialog({
  170. title: "确定删除吗?",
  171. }).then(resolve);
  172. });
  173. }
  174. };
  175. // 详情跳转
  176. const goInfo = (val) => {
  177. router.push({
  178. path: "/securityFacilitiesErrInfo",
  179. query: { id: val },
  180. });
  181. };
  182. return {
  183. onClickLeft,
  184. onClickTab,
  185. list,
  186. onLoad,
  187. loading,
  188. finished,
  189. value,
  190. onClickRight,
  191. tabIndex,
  192. goInfo,
  193. beforeClose,
  194. };
  195. },
  196. };
  197. </script>
  198. <style>
  199. body {
  200. background: #f5f5f5;
  201. }
  202. .nav_tab {
  203. width: 100vw;
  204. display: flex;
  205. text-align: center;
  206. background: #fff;
  207. margin: 10px 0;
  208. }
  209. .tab {
  210. flex: 1;
  211. line-height: 40px;
  212. font-size: 14px;
  213. }
  214. .active {
  215. background: #36a7f3;
  216. color: #fff;
  217. }
  218. .van-list {
  219. height: 80%;
  220. margin-top: 5px;
  221. }
  222. .list_item {
  223. display: flex;
  224. background: #fff;
  225. }
  226. .item-left {
  227. text-align: center;
  228. width: 30%;
  229. font-size: 12px;
  230. border-right: 1px solid #eee;
  231. }
  232. .button {
  233. height: 100%;
  234. }
  235. </style>