chooseShelf.vue 5.9 KB

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