selectKh.vue 4.6 KB

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