chooseShelf.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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="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="index" @click="viewDetail(item)">
  23. <view class="item-info uni-col-10">
  24. <view class="item-name" v-if="item.customer">
  25. <text>{{item.customer.customerName}}</text>
  26. </view>
  27. </view>
  28. <view class="arrow" v-if="item.targetSn == 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. import { queryCustomerPage } from '@/api/verify.js';
  45. export default {
  46. data() {
  47. return {
  48. customerName: '',
  49. isGobleSearch: false,
  50. shelfList: [],
  51. pageNo:1,
  52. pageSize: 30,
  53. total: 0, // 列表总数
  54. noDataText: '暂无客户',
  55. status: 'loading',
  56. vinstatus: 'loading',
  57. checkedSn: null,
  58. customer:{
  59. queryWord:''
  60. }
  61. }
  62. },
  63. onLoad(opts) {
  64. this.checkedSn = opts.customerSn
  65. this.getShelfList()
  66. },
  67. methods: {
  68. clearSearch(){
  69. this.customerName = ''
  70. this.search()
  71. },
  72. change(v){
  73. if(v==''){
  74. this.clearSearch()
  75. }
  76. },
  77. search(){
  78. this.pageNo = 1
  79. this.shelfList = []
  80. this.customer.queryWord = this.customerName;
  81. this.getShelfList()
  82. },
  83. // 获取客户列表
  84. getShelfList(){
  85. const _this = this
  86. let params = {
  87. pageNo: this.pageNo,
  88. pageSize: this.pageSize,
  89. allCustomerFlag: 1
  90. }
  91. params.customer = _this.customer
  92. _this.status = 'loading'
  93. queryCustomerPage(params).then(res => {
  94. uni.hideLoading()
  95. if(res.status == 200){
  96. let list = res.data.list
  97. if (list && list.length){
  98. // 分页 拼接数据
  99. if(_this.pageNo>1){
  100. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  101. }else{
  102. _this.shelfList = res.data.list || []
  103. let obj={}
  104. obj.targetSn = ''
  105. obj.customer={
  106. customerSn: '',
  107. customerName: '全部客户'
  108. }
  109. _this.shelfList.unshift(obj)
  110. }
  111. _this.total = res.data.count
  112. if (_this.shelfList.length == res.data.count) {
  113. _this.status = 'nomore'
  114. } else {
  115. _this.status = 'loadmore'
  116. }
  117. } else {
  118. _this.shelfList = list || []
  119. _this.total = 0
  120. _this.status = 'nomore'
  121. }
  122. _this.noDataText = '暂无客户'
  123. }else{
  124. _this.status = 'loadmore'
  125. _this.shelfList = []
  126. _this.total = 0
  127. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  128. }
  129. })
  130. },
  131. // 加载更多
  132. onreachBottom () {
  133. if(this.shelfList.length < this.total ){
  134. if(this.isGobleSearch&&this.customerName==''){
  135. return
  136. }
  137. this.pageNo++
  138. this.getShelfList()
  139. }else{
  140. this.status = "nomore"
  141. }
  142. },
  143. viewDetail(item){
  144. uni.$emit('chooseShelfOk',item.customer)
  145. uni.navigateBack()
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="less">
  151. .moreShelfPart{
  152. width: 100%;
  153. height: 100vh;
  154. padding: 0;
  155. .moreShelfPart-search{
  156. padding: 20rpx;
  157. background-color: #FFFFFF;
  158. }
  159. .moreShelfPart-body{
  160. flex-grow: 1;
  161. background-color: #fff;
  162. }
  163. .nav-right{
  164. padding: 0 0;
  165. height: calc(100vh - 110rpx);
  166. box-sizing: border-box;
  167. .nav-right-item{
  168. padding:20upx;
  169. border-bottom: 2rpx solid #f5f5f5;
  170. display: flex;
  171. align-items: center;
  172. &:active{
  173. background: #f8f8f8;
  174. }
  175. .arrow{
  176. text-align: right;
  177. padding-left: 20rpx;
  178. }
  179. .item-info{
  180. .item-name{
  181. font-size: 30upx;
  182. display: flex;
  183. align-items: center;
  184. }
  185. .item-detail{
  186. margin-top: 10rpx;
  187. .item-detail-text{
  188. font-size: 30upx;
  189. color: #9DA8B5;
  190. word-break: break-all;
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. </style>