selectKh.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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="list-new-btn-box">
  16. <button type="default" class="phone-green-btn" @click="handleAddKehu">新增客户</button>
  17. </view>
  18. <!-- 无限滚动容器 -->
  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">
  22. <uni-list class="kh-scroll-view">
  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 class="select-kh-btn-box">
  43. <button @click="handleSelect" type="default" class="phone-green-btn">选择此客户</button>
  44. </view>
  45. </view>
  46. </uni-popup>
  47. <addKh ref="addKhRef" @success="onSuccess"></addKh>
  48. </view>
  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 onSuccess() {
  81. onRefresh()
  82. }
  83. function toggle() {
  84. searchDialogRef.value.handleShow();
  85. }
  86. function dialogSearchBtn(opt, searchInput) {
  87. data.realName = searchInput
  88. onRefresh()
  89. }
  90. function dialogSearchReset() {
  91. data.realName = '';
  92. }
  93. function onScrolltolower() {
  94. getMore()
  95. }
  96. function onRefresh() {
  97. if (data.loading) return;
  98. data.page = 0;
  99. data.list = [];
  100. data.loading = true;
  101. refreshData();
  102. }
  103. function refreshData() {
  104. const opt = {
  105. realName: data.realName,
  106. page: data.page,
  107. size: data.size,
  108. status: data.status
  109. }
  110. data.list = [];
  111. // 数学
  112. data.state = 'loading';
  113. data.page++;
  114. opt.page = data.page;
  115. httpApi.getKehuList(opt).then(res => {
  116. data.list = data.list.concat(res.data.data);
  117. data.loading = false;
  118. if (res.data.total > data.list.length) {
  119. data.state = 'more';
  120. } else {
  121. data.state = 'no-more';
  122. }
  123. }).catch(err => {
  124. data.state = 'more';
  125. }).finally(() => {
  126. data.loading = false;
  127. })
  128. }
  129. function getMore() {
  130. const opt = {
  131. realName: data.realName,
  132. page: data.page,
  133. size: data.size,
  134. status: data.status
  135. }
  136. if (data.state == 'no-more') return;
  137. data.state = 'loading';
  138. data.page++;
  139. opt.page = data.page;
  140. httpApi.getKehuList(opt).then(res => {
  141. data.list = data.list.concat(res.data.data);
  142. data.loading = false;
  143. if (res.data.total > data.list.length) {
  144. data.state = 'more';
  145. } else {
  146. data.state = 'no-more';
  147. }
  148. }).catch(err => {
  149. data.state = 'more';
  150. }).finally(() => {
  151. data.loading = false;
  152. })
  153. }
  154. function radioChange(opt) {
  155. data.activeData = data.list.find(item => item.id == opt.detail.value)
  156. }
  157. function handleAddKehu() {
  158. addKhRef.value.handleShow()
  159. }
  160. function handleSelect() {
  161. emits('select', data.activeData)
  162. popupRef.value.close();
  163. }
  164. function handleShow() {
  165. data.realName = '';
  166. popupRef.value.open();
  167. onRefresh();
  168. }
  169. defineExpose({
  170. handleShow
  171. })
  172. </script>
  173. <style>
  174. </style>