selectKh.vue 4.2 KB

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