ManageList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 list3"
  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 list3 = ref([]);
  37. const loading = ref(false);
  38. const finished = ref(false);
  39. let index = 0;
  40. let zjList = 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. // 数据全部加载完成
  54. if (records.length < 10) {
  55. finished.value = true;
  56. }
  57. });
  58. let placeAddress = "";
  59. placeAddress = props.placeAddress.split("/");
  60. let mechanism1 = ref([]); //宗教
  61. new placeRegister().treeDate2().then((res) => {
  62. mechanism1.value.push(res[0]);
  63. Getzj(mechanism1.value);
  64. let listone = [];
  65. let itemId = [];
  66. zjList.value.forEach((item1) => {
  67. if (item1.regionLevel5 == placeAddress[2]) {
  68. itemId.push(item1.id);
  69. }
  70. });
  71. itemId.forEach((ID) => {
  72. list.value.forEach((item2) => {
  73. if (ID == item2.officeDTO.id) {
  74. listone.push(item2);
  75. }
  76. });
  77. });
  78. list3.value = listone;
  79. });
  80. };
  81. //获取宗教部门数组
  82. function Getzj(list) {
  83. list.forEach((item) => {
  84. zjList.value.push(item);
  85. if (item.children) {
  86. Getzj(item.children);
  87. }
  88. });
  89. }
  90. //获取公安部门数组
  91. // function Getga(list) {
  92. // list.forEach((item) => {
  93. // gaList.value.push(item);
  94. // if (item.children) {
  95. // Getga(item.children);
  96. // }
  97. // });
  98. // }
  99. // 选择人员
  100. const checked = ref([]);
  101. const checkboxRefs = ref([]);
  102. const checkboxGroup = ref(null);
  103. const toggle = (index) => {
  104. checkboxRefs.value[index].toggle();
  105. emit("selected", checked.value, 1);
  106. };
  107. // 全选
  108. const checkAll = () => {
  109. checkboxGroup.value.toggleAll(true);
  110. emit("selected", checked.value, 1);
  111. };
  112. const selectes = (val) => {
  113. checked.value = val;
  114. emit("selected", checked.value, 0);
  115. };
  116. // let placeAddress = "";
  117. // watch(
  118. // () => props.placeAddress,
  119. // (val) => {
  120. // placeAddress = val.split("/");
  121. // let mechanism1 = ref([]); //宗教
  122. // new placeRegister().treeDate2().then((res) => {
  123. // mechanism1.value.push(res[0]);
  124. // Getzj(mechanism1.value);
  125. // let listone = [];
  126. // zjList.value.forEach((item1) => {
  127. // let itemId = '';
  128. // if (item1.regionLevel5 == placeAddress[2]) {
  129. // itemId = item1.id;
  130. // list.value.forEach((item2) => {
  131. // if (itemId == item2.officeDTO.id) {
  132. // listone.push(item2);
  133. // }
  134. // });
  135. // list3.value = listone;
  136. // }
  137. // });
  138. // });
  139. // },
  140. // {
  141. // //如果加了这个参数,值为true的话,就消除了惰性,watch会在创建后立即执行一次
  142. // //那么首次执行,val为默认值,preVal为undefined
  143. // immediate: true,
  144. // //这个参数代表监听对象时,可以监听深度嵌套的对象属性
  145. // //比如message是一个对象的话,可以监听到message.a.b.c,也就是message下的所有属性
  146. // deep: true,
  147. // }
  148. // );
  149. return {
  150. // 人员
  151. onLoad,
  152. loading,
  153. finished,
  154. // 全选
  155. checkAll,
  156. toggle,
  157. checked,
  158. checkboxRefs,
  159. checkboxGroup,
  160. // 单选
  161. selectes,
  162. list3,
  163. };
  164. },
  165. };
  166. </script>
  167. <style scoped>
  168. .personList {
  169. height: 65vh;
  170. overflow: auto;
  171. margin: 10px;
  172. }
  173. .van-button {
  174. top: -5px;
  175. }
  176. .search {
  177. height: 40px;
  178. line-height: 40px;
  179. }
  180. .van-list {
  181. height: 80%;
  182. margin-top: 5px;
  183. }
  184. .keyword {
  185. width: 70%;
  186. height: 25px;
  187. border-radius: 25px;
  188. border: 1px solid;
  189. padding-left: 15px;
  190. }
  191. </style>