selectKh.vue 4.0 KB

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