selectCustomer.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view>
  3. <view style="padding: 20rpx;">
  4. <u-search placeholder="请输入客户名称" v-model="name" @custom="custom"></u-search>
  5. </view>
  6. <view class="dataBox">
  7. <view class="forDataBox" v-for="(item,index) of dataList" :key="item.id" @click="choice(item,index)" >
  8. <view>{{item.cname}}</view>
  9. <view>{{item.tel}}</view>
  10. </view>
  11. </view>
  12. <!-- <u-index-list :indexList="indexList" v-if="!loading">
  13. <template v-for="(item, index) in itemArr">
  14. #ifdef APP-NVUE
  15. <u-index-anchor :text="indexList[index]" :key="index" v-if="item.length>0"></u-index-anchor>
  16. #endif
  17. <u-index-item :key="index">
  18. #ifndef APP-NVUE
  19. <u-index-anchor :text="indexList[index]" v-if="item.length>0"></u-index-anchor>
  20. #endif
  21. <view class="list" v-for="(item1, index1) in item" :key="index1">
  22. <view class="list__item" @click="choice(item1,index1)">
  23. <text class="list__item__user-name">{{item1.cname}}</text>
  24. <text class="list__item__user-tel">{{item1.tel}}</text>
  25. </view>
  26. <u-line></u-line>
  27. </view>
  28. </u-index-item>
  29. </template>
  30. </u-index-list> -->
  31. <!-- <u-loading-page loading-mode="spinner" :loading="loading"></u-loading-page> -->
  32. <u-loadmore v-if="total !== 0 && dataList.length != 0" :status="status" />
  33. <u-modal :show="show" :content="'是否确认选择:'+ form.cname" @confirm="confirm" @cancel="show = false"
  34. :showCancelButton="true" style="text-align: center;"></u-modal>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. queryAllCustomer,
  40. } from '@/api/views/sale/index.js'
  41. import {
  42. queryList,
  43. } from '@/api/views/customer/index.js'
  44. const indexList = () => {
  45. const indexList = []
  46. const charCodeOfA = 'A'.charCodeAt(0)
  47. for (let i = 0; i < 26; i++) {
  48. indexList.push(String.fromCharCode(charCodeOfA + i))
  49. }
  50. indexList.push('#')
  51. return indexList
  52. }
  53. export default {
  54. data() {
  55. return {
  56. name:'',
  57. indexList: indexList(),
  58. itemArrTwo: [],
  59. loading: true,
  60. show: false,
  61. form: {},
  62. params:{},
  63. page: {
  64. current: 1,
  65. size: 30,
  66. },
  67. total:0,
  68. dataList:[],
  69. status:'loadmore',
  70. }
  71. },
  72. onLoad(params) {
  73. this.params = {
  74. ...params,
  75. adminProfiles: uni.getStorageSync('userInfo').user_id
  76. }
  77. this.queryListfun()
  78. // queryAllCustomer(this.params).then(res=>{
  79. // this.itemArrTwo = res.data
  80. // this.loading = false
  81. // })
  82. },
  83. onReachBottom() {
  84. this.status = 'loading'
  85. if (this.dataList.length < this.total) {
  86. this.page.current++
  87. this.queryListfun()
  88. } else {
  89. this.status = 'nomore'
  90. }
  91. },
  92. computed: {
  93. itemArr() {
  94. return this.indexList.map((item,index) => {
  95. return this.itemArrTwo[index]
  96. })
  97. }
  98. },
  99. onNavigationBarButtonTap(e) {
  100. uni.$u.route('/pages/views/customer/customerDetails');
  101. },
  102. methods: {
  103. // 新的列表数据
  104. queryListfun() {
  105. uni.showLoading({
  106. title: '加载中',
  107. mask: true
  108. });
  109. queryList({
  110. ...this.page,
  111. cname:this.name,
  112. corpType: 'KH'
  113. }).then(res => {
  114. if (res.data.records) {
  115. this.dataList = this.dataList.concat(res.data.records)
  116. }
  117. this.total = res.data.total || 0
  118. uni.hideLoading();
  119. if (this.total < 10) {
  120. this.status = 'nomore'
  121. }
  122. })
  123. },
  124. // 搜索
  125. custom(){
  126. // this.loading = true
  127. this.dataList = []
  128. this.queryListfun()
  129. // queryAllCustomer({
  130. // ...this.params,
  131. // cname:this.name
  132. // }).then(res=>{
  133. // this.itemArrTwo = res.data
  134. // this.loading = false
  135. // })
  136. },
  137. // 点击调起弹窗
  138. choice(item1, index1) {
  139. this.form = item1
  140. this.show = true
  141. },
  142. // 把数据抛给父级
  143. confirm() {
  144. let pages = getCurrentPages() // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  145. let prevPage = pages[pages.length - 2] //上一页页面实例
  146. prevPage.$vm.otherFun(this.form)
  147. uni.navigateBack()
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .dataBox {
  154. // width: 96%;
  155. // margin: 0 auto;
  156. }
  157. .forDataBox {
  158. font-size: 32rpx;
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. padding: 15rpx 30rpx;
  163. box-sizing: border-box;
  164. border-bottom: 2rpx solid #e5e5e6;
  165. }
  166. .list {
  167. &__item {
  168. @include flex;
  169. padding: 6px 12px;
  170. align-items: center;
  171. justify-content: space-between;
  172. &__user-name {
  173. font-size: 32rpx;
  174. color: $u-main-color;
  175. }
  176. &__user-tel {
  177. font-size: 32rpx;
  178. margin-right: 20rpx;
  179. color: $u-main-color;
  180. }
  181. }
  182. &__footer {
  183. color: $u-tips-color;
  184. font-size: 14px;
  185. text-align: center;
  186. margin: 15px 0;
  187. }
  188. }
  189. </style>