ManageList2.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div class="personList">
  3. <van-list
  4. v-model:loading="loading"
  5. :finished="finished"
  6. finished-text="没有更多了"
  7. @load="onLoad"
  8. >
  9. <van-radio-group v-if="type == 0" v-model="checked">
  10. <van-cell-group inset>
  11. <van-cell
  12. v-for="item in list4"
  13. clickable
  14. :key="item"
  15. :title="item.name"
  16. @click="selectes(item)"
  17. >
  18. <template #right-icon>
  19. <van-radio :name="item" />
  20. </template>
  21. </van-cell>
  22. </van-cell-group>
  23. </van-radio-group>
  24. </van-list>
  25. </div>
  26. </template>
  27. <script>
  28. import { ref, watch } from "vue";
  29. import placeRegister from "@/api/placeRegister/placeRegister";
  30. export default {
  31. name: "personList",
  32. emits: ["selected"],
  33. props: ["type", "placeAddress"],
  34. setup(props, { emit }) {
  35. const list = ref([]);
  36. const list4 = ref([]);
  37. const loading = ref(false);
  38. const finished = ref(false);
  39. let index = 0;
  40. let gaList = ref([]);
  41. const onLoad = () => {
  42. // 异步更新数据
  43. new placeRegister()
  44. .list({
  45. current: index + 1,
  46. size: 10,
  47. })
  48. .then(({ records }) => {
  49. list.value.push(...records);
  50. // 加载状态结束
  51. loading.value = false;
  52. index++;
  53. // console.log(list.value);
  54. // 数据全部加载完成
  55. if (records.length < 10) {
  56. finished.value = true;
  57. }
  58. });
  59. let placeAddress = "";
  60. placeAddress = props.placeAddress.split("/");
  61. let mechanism2 = ref([]); //公安
  62. new placeRegister().treeDate2().then((res) => {
  63. mechanism2.value.push(res[1]);
  64. Getga(mechanism2.value);
  65. let listtwo = [];
  66. let itemId = [];
  67. gaList.value.forEach((item3) => {
  68. if (item3.regionLevel5 == placeAddress[2]) {
  69. itemId.push(item3.id);
  70. }
  71. });
  72. list.value.forEach((item2) => {
  73. itemId.forEach((ID) => {
  74. if (ID == item2.officeDTO.id) {
  75. listtwo.push(item2);
  76. }
  77. });
  78. list4.value = listtwo;
  79. });
  80. });
  81. };
  82. //获取公安部门数组
  83. function Getga(list) {
  84. list.forEach((item) => {
  85. gaList.value.push(item);
  86. if (item.children) {
  87. Getga(item.children);
  88. }
  89. });
  90. }
  91. //获取宗教部门数组
  92. // function Getzj(list) {
  93. // list.forEach((item) => {
  94. // zjList.value.push(item);
  95. // if (item.children) {
  96. // Getzj(item.children);
  97. // }
  98. // });
  99. // }
  100. // 选择人员
  101. const checked = ref([]);
  102. const checkboxRefs = ref([]);
  103. const checkboxGroup = ref(null);
  104. const toggle = (index) => {
  105. checkboxRefs.value[index].toggle();
  106. emit("selected", checked.value, 1);
  107. };
  108. // 全选
  109. const checkAll = () => {
  110. checkboxGroup.value.toggleAll(true);
  111. emit("selected", checked.value, 1);
  112. };
  113. const selectes = (val) => {
  114. checked.value = val;
  115. emit("selected", checked.value, 0);
  116. };
  117. // let placeAddress = "";
  118. // watch(
  119. // () => props.placeAddress,
  120. // (val) => {
  121. // placeAddress = val.split("/");
  122. // },
  123. // {
  124. // //如果加了这个参数,值为true的话,就消除了惰性,watch会在创建后立即执行一次
  125. // //那么首次执行,val为默认值,preVal为undefined
  126. // immediate: true,
  127. // //这个参数代表监听对象时,可以监听深度嵌套的对象属性
  128. // //比如message是一个对象的话,可以监听到message.a.b.c,也就是message下的所有属性
  129. // deep: true,
  130. // }
  131. // );
  132. return {
  133. // 人员
  134. onLoad,
  135. loading,
  136. finished,
  137. // 全选
  138. checkAll,
  139. toggle,
  140. checked,
  141. checkboxRefs,
  142. checkboxGroup,
  143. // 单选
  144. selectes,
  145. list4,
  146. };
  147. },
  148. };
  149. </script>
  150. <style scoped>
  151. .personList {
  152. height: 65vh;
  153. overflow: auto;
  154. margin: 10px;
  155. }
  156. .van-button {
  157. top: -5px;
  158. }
  159. .search {
  160. height: 40px;
  161. line-height: 40px;
  162. }
  163. .van-list {
  164. height: 80%;
  165. margin-top: 5px;
  166. }
  167. .keyword {
  168. width: 70%;
  169. height: 25px;
  170. border-radius: 25px;
  171. border: 1px solid;
  172. padding-left: 15px;
  173. }
  174. </style>