selectKh.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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="goback2" class="nav-bar-icon"></view>
  6. <text>选择客户</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="kh" @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>{{item.idCard}}</view>
  29. <view>{{item.tel}}</view>
  30. <view>
  31. <radio :value="item.value" :checked="index === current" />
  32. </view>
  33. </view>
  34. </template>
  35. </uni-list-item>
  36. </radio-group>
  37. <uni-load-more :status="data.state" @click="getMore(0)"
  38. :contentText="data.contentText"></uni-load-more>
  39. </uni-list>
  40. </scroll-view>
  41. </view>
  42. <view>
  43. <button @click="handleSelect">选择此客户</button>
  44. </view>
  45. </view>
  46. </uni-popup>
  47. </template>
  48. <script setup>
  49. import {
  50. ref,
  51. reactive,
  52. nextTick
  53. } from "vue";
  54. import {
  55. onLoad
  56. } from "@dcloudio/uni-app";
  57. import * as httpApi from "@/api/sanfang.js"
  58. import searchDialog from "./search.vue";
  59. const emits = defineEmits(['select'])
  60. function goback2() {
  61. popupRef.value.close();
  62. }
  63. const searchDialogRef = ref(null);
  64. const popupRef = ref(null)
  65. const data = reactive({
  66. status: 0,
  67. statusText: '待签字',
  68. state: 'more',
  69. list: [], // 考试列表
  70. loading: false,
  71. realName: '',
  72. page: 0,
  73. size: 10,
  74. activeData: null
  75. })
  76. function toggle() {
  77. searchDialogRef.value.handleShow();
  78. }
  79. function dialogSearchBtn(opt, searchInput) {
  80. data.realName = searchInput
  81. onRefresh()
  82. }
  83. function dialogSearchReset() {
  84. data.realName = '';
  85. }
  86. function onScrolltolower() {
  87. getMore()
  88. }
  89. function onRefresh() {
  90. if (data.loading) return;
  91. data.page = 0;
  92. data.list = [];
  93. data.loading = true;
  94. refreshData();
  95. }
  96. function refreshData() {
  97. const opt = {
  98. realName: data.realName,
  99. page: data.page,
  100. size: data.size,
  101. status: data.status
  102. }
  103. data.list = [];
  104. // 数学
  105. data.state = 'loading';
  106. data.page++;
  107. opt.page = data.page;
  108. httpApi.getKehuList(opt).then(res => {
  109. data.list = data.list.concat(res.data.data);
  110. data.loading = false;
  111. if (res.data.total > data.list.length) {
  112. data.state = 'more';
  113. } else {
  114. data.state = 'no-more';
  115. }
  116. }).catch(err => {
  117. data.state = 'more';
  118. }).finally(() => {
  119. data.loading = false;
  120. })
  121. }
  122. function getMore() {
  123. const opt = {
  124. realName: data.realName,
  125. page: data.page,
  126. size: data.size,
  127. status: data.status
  128. }
  129. if (data.state == 'no-more') return;
  130. data.state = 'loading';
  131. data.page++;
  132. opt.page = data.page;
  133. httpApi.getKehuList(opt).then(res => {
  134. data.list = data.list.concat(res.data.data);
  135. data.loading = false;
  136. if (res.data.total > data.list.length) {
  137. data.state = 'more';
  138. } else {
  139. data.state = 'no-more';
  140. }
  141. }).catch(err => {
  142. data.state = 'more';
  143. }).finally(() => {
  144. data.loading = false;
  145. })
  146. }
  147. function radioChange(opt) {
  148. data.activeData = opt.id
  149. }
  150. function handleAddKehu() {}
  151. function handleSelect() {
  152. emits('select', data.activeData)
  153. }
  154. function handleShow() {
  155. data.realName = '';
  156. popupRef.value.open();
  157. onRefresh();
  158. }
  159. defineExpose({
  160. handleShow
  161. })
  162. </script>
  163. <style>
  164. </style>