selectKh.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
  3. <view class="ht-qm-popup">
  4. <view class="phone-navBar-box">
  5. <view @click="goUpPage" class="nav-bar-icon"></view>
  6. <text class="nav-bar-title">选择客户</text>
  7. <uni-icons class="nav-bar-right-icon bar-ml10" type="search" size="20"
  8. @click="toggle('top')"></uni-icons>
  9. </view>
  10. <view>
  11. <search-dialog ref="searchDialogRef" shenfen="jz" @search-btn="dialogSearchBtn"
  12. @reset-search="dialogSearchReset"></search-dialog>
  13. </view>
  14. <view class="jz-new-btn-box">
  15. <button type="default" class="phone-green-btn" @click="handleAddKehu">新增客户</button>
  16. </view>
  17. <!-- 无限滚动容器 -->
  18. <view>
  19. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  20. :refresher-threshold="50" @scrolltolower="onScrolltolower" refresher-background="transparent"
  21. @refresherrefresh="onRefresh" class="jz-scroll-view">
  22. <uni-list class="admin-list-box">
  23. <radio-group @change="radioChange">
  24. <uni-list-item v-for="item in data.list" class="jz-list-item-box">
  25. <template v-slot:body>
  26. <view>
  27. <view>{{item.realName}}</view>
  28. <view>
  29. <radio :value="item.value" :checked="index === current" />
  30. </view>
  31. </view>
  32. </template>
  33. </uni-list-item>
  34. </radio-group>
  35. <uni-load-more :status="data.state" @click="getMore(0)"
  36. :contentText="data.contentText"></uni-load-more>
  37. </uni-list>
  38. </scroll-view>
  39. </view>
  40. <view>
  41. <button @click="handleSelect">选择此家政阿姨</button>
  42. </view>
  43. </view>
  44. </uni-popup>
  45. </template>
  46. <script setup>
  47. import {
  48. ref,
  49. reactive,
  50. nextTick
  51. } from "vue";
  52. import {
  53. onLoad
  54. } from "@dcloudio/uni-app";
  55. import * as httpApi from "@/api/sanfang.js"
  56. import searchDialog from "./components/search.vue";
  57. const emits = defineEmits(['select'])
  58. function goback2() {}
  59. const searchDialogRef = ref(null);
  60. const popupRef = ref(null)
  61. const data = reactive({
  62. status: 0,
  63. statusText: '待签字',
  64. state: 'more',
  65. list: [], // 考试列表
  66. loading: false,
  67. realName: '',
  68. page: 0,
  69. size: 10,
  70. activeData: null
  71. })
  72. function toggle() {
  73. searchDialogRef.value.handleShow();
  74. }
  75. function dialogSearchBtn(opt, searchInput) {
  76. data.realName = searchInput
  77. onRefresh()
  78. }
  79. function dialogSearchReset() {
  80. data.realName = '';
  81. }
  82. function onScrolltolower() {
  83. getMore()
  84. }
  85. function onRefresh() {
  86. if (data.loading) return;
  87. data.page = 0;
  88. data.list = [];
  89. data.loading = true;
  90. refreshData();
  91. }
  92. function refreshData() {
  93. const opt = {
  94. realName: data.realName,
  95. page: data.page,
  96. size: data.size,
  97. status: data.status
  98. }
  99. data.list = [];
  100. // 数学
  101. data.state = 'loading';
  102. data.page++;
  103. opt.page = data.page;
  104. httpApi.getKehuList(opt).then(res => {
  105. data.list = data.list.concat(res.data.data);
  106. data.loading = false;
  107. if (res.data.total > data.list.length) {
  108. data.state = 'more';
  109. } else {
  110. data.state = 'no-more';
  111. }
  112. }).catch(err => {
  113. data.state = 'more';
  114. }).finally(() => {
  115. data.loading = false;
  116. })
  117. }
  118. function getMore() {
  119. const opt = {
  120. realName: data.realName,
  121. page: data.page,
  122. size: data.size,
  123. status: data.status
  124. }
  125. if (data.state == 'no-more') return;
  126. data.state = 'loading';
  127. data.page++;
  128. opt.page = data.page;
  129. httpApi.getKehuList(opt).then(res => {
  130. data.list = data.list.concat(res.data.data);
  131. data.loading = false;
  132. if (res.data.total > data.list.length) {
  133. data.state = 'more';
  134. } else {
  135. data.state = 'no-more';
  136. }
  137. }).catch(err => {
  138. data.state = 'more';
  139. }).finally(() => {
  140. data.loading = false;
  141. })
  142. }
  143. function radioChange(opt) {
  144. data.activeData = opt.id
  145. }
  146. function handleAddKehu() {}
  147. function handleSelect() {
  148. emits('select', data.activeData)
  149. }
  150. function handleShow() {
  151. popupRef.value.open();
  152. onRefresh();
  153. }
  154. </script>
  155. <style>
  156. </style>