chooseShelf.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入客户名称搜索"
  6. v-model="customerName"
  7. :show-action="isGobleSearch"
  8. @input="change"
  9. @focus="isGobleSearch=true"
  10. @blur="isGobleSearch=false"
  11. @custom="search"
  12. @search="search"
  13. @clear="$delayDel(clearSearch)"
  14. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
  15. </u-search>
  16. </view>
  17. <view class="moreShelfPart-body">
  18. <scroll-view
  19. class="nav-right"
  20. scroll-y
  21. @scrolltolower="onreachBottom">
  22. <view class="nav-right-item" v-for="(item, index) in shelfList" :key="item.id" @click="viewDetail(item)">
  23. <view class="item-info uni-col-10">
  24. <view class="item-name">
  25. <text>{{item.customerName}}</text>
  26. </view>
  27. </view>
  28. <view class="arrow" v-if="item.customerSn == checkedSn">
  29. <u-icon name="checkbox-mark" color="#3dc50b" size="28"></u-icon>
  30. </view>
  31. </view>
  32. <view v-if="shelfList&&shelfList.length==0">
  33. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  34. </view>
  35. <view style="padding: 20upx;" v-else>
  36. <u-loadmore :status="status" />
  37. </view>
  38. </scroll-view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import { customerList } from '@/api/customer.js'
  44. export default {
  45. data() {
  46. return {
  47. customerName: '',
  48. isGobleSearch: false,
  49. shelfList: [],
  50. pageNo:1,
  51. pageSize: 30,
  52. total: 0, // 列表总数
  53. noDataText: '暂无客户',
  54. status: 'loading',
  55. vinstatus: 'loading',
  56. checkedSn: null
  57. }
  58. },
  59. onLoad(opts) {
  60. this.checkedSn = opts.customerSn
  61. this.getShelfList()
  62. },
  63. methods: {
  64. clearSearch(){
  65. this.customerName = ''
  66. this.search()
  67. },
  68. change(v){
  69. if(v==''){
  70. this.clearSearch()
  71. }
  72. },
  73. search(){
  74. this.pageNo = 1
  75. this.shelfList = []
  76. this.getShelfList()
  77. },
  78. // 获取客户列表
  79. getShelfList(){
  80. const _this = this
  81. let params = {
  82. pageNo: this.pageNo,
  83. pageSize: this.pageSize,
  84. customerName: this.customerName,
  85. dealerFlag: 0,
  86. enabledFlag : 1 //1启用客户 0 禁用用户
  87. }
  88. _this.status = 'loading'
  89. customerList(params).then(res => {
  90. uni.hideLoading()
  91. if(res.status == 200){
  92. let list = res.data.list
  93. if (list && list.length){
  94. // 分页 拼接数据
  95. if(_this.pageNo>1){
  96. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  97. }else{
  98. _this.shelfList = res.data.list || []
  99. _this.shelfList.unshift({
  100. customerSn: '',
  101. customerName: '全部客户'
  102. })
  103. }
  104. _this.total = res.data.count
  105. if (_this.shelfList.length == res.data.count) {
  106. _this.status = 'nomore'
  107. } else {
  108. _this.status = 'loadmore'
  109. }
  110. } else {
  111. _this.shelfList = list || []
  112. _this.total = 0
  113. _this.status = 'nomore'
  114. }
  115. _this.noDataText = '暂无客户'
  116. }else{
  117. _this.status = 'loadmore'
  118. _this.shelfList = []
  119. _this.total = 0
  120. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  121. }
  122. })
  123. },
  124. // 加载更多
  125. onreachBottom () {
  126. if(this.shelfList.length < this.total ){
  127. if(this.isGobleSearch&&this.customerName==''){
  128. return
  129. }
  130. this.pageNo++
  131. this.getShelfList()
  132. }else{
  133. this.status = "nomore"
  134. }
  135. },
  136. viewDetail(item){
  137. console.log('111111',item)
  138. uni.$emit('chooseShelfOk',item)
  139. uni.navigateBack()
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="less">
  145. .moreShelfPart{
  146. width: 100%;
  147. height: 100vh;
  148. padding: 0;
  149. .moreShelfPart-search{
  150. padding: 20rpx;
  151. background-color: #FFFFFF;
  152. }
  153. .moreShelfPart-body{
  154. flex-grow: 1;
  155. background-color: #fff;
  156. }
  157. .nav-right{
  158. padding: 0 0;
  159. height: calc(100vh - 110rpx);
  160. box-sizing: border-box;
  161. .nav-right-item{
  162. padding:20upx;
  163. border-bottom: 2rpx solid #f5f5f5;
  164. display: flex;
  165. align-items: center;
  166. &:active{
  167. background: #f8f8f8;
  168. }
  169. .arrow{
  170. text-align: right;
  171. padding-left: 20rpx;
  172. }
  173. .item-info{
  174. .item-name{
  175. font-size: 30upx;
  176. display: flex;
  177. align-items: center;
  178. }
  179. .item-detail{
  180. margin-top: 10rpx;
  181. .item-detail-text{
  182. font-size: 30upx;
  183. color: #9DA8B5;
  184. word-break: break-all;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. </style>