selectKh.vue 4.6 KB

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