chooseShelf.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. stateSet: [ 'ENABLE', 'SUSPEND', 'DISABLED' ]
  112. }
  113. params.customer = _this.customer
  114. _this.status = 'loading'
  115. queryCustomerPage(params).then(res => {
  116. uni.hideLoading()
  117. if(res.status == 200){
  118. let list = res.data.list
  119. if (list && list.length){
  120. // 分页 拼接数据
  121. if(_this.pageNo>1){
  122. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  123. }else{
  124. _this.shelfList = res.data.list || []
  125. let obj={}
  126. obj.targetSn = ''
  127. obj.customer={
  128. customerSn: '',
  129. customerName: '全部客户'
  130. }
  131. _this.shelfList.unshift(obj)
  132. }
  133. _this.total = res.data.count
  134. if (_this.shelfList.length == res.data.count) {
  135. _this.status = 'nomore'
  136. } else {
  137. _this.status = 'loadmore'
  138. }
  139. } else {
  140. _this.shelfList = list || []
  141. _this.total = 0
  142. _this.status = 'nomore'
  143. }
  144. _this.noDataText = '暂无客户'
  145. }else{
  146. _this.status = 'loadmore'
  147. _this.shelfList = []
  148. _this.total = 0
  149. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  150. }
  151. })
  152. },
  153. // 加载更多
  154. onreachBottom () {
  155. if(this.shelfList.length < this.total ){
  156. if(this.isGobleSearch&&this.customerName==''){
  157. return
  158. }
  159. this.pageNo++
  160. this.getShelfList()
  161. }else{
  162. this.status = "nomore"
  163. }
  164. },
  165. viewDetail(item){
  166. uni.$emit('chooseShelfOk',item.customer)
  167. uni.navigateBack()
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="less">
  173. .moreShelfPart{
  174. width: 100%;
  175. height: 100vh;
  176. padding: 0;
  177. background-color: #fff;
  178. .search_box{
  179. padding: 12rpx 20rpx;
  180. box-sizing: border-box;
  181. width: 100%;
  182. .moreShelfPart-search{
  183. padding: 12rpx 20rpx;
  184. border-radius: 40rpx;
  185. background-color: rgb(242, 242, 242);
  186. input{
  187. width: 80%;
  188. font-size: 30rpx;
  189. }
  190. }
  191. }
  192. .moreShelfPart-body{
  193. flex-grow: 1;
  194. background-color: #fff;
  195. }
  196. .nav-right{
  197. padding: 0 0;
  198. height: calc(100vh - 110rpx);
  199. box-sizing: border-box;
  200. .nav-right-item{
  201. padding:20upx;
  202. border-bottom: 2rpx solid #f5f5f5;
  203. display: flex;
  204. align-items: center;
  205. &:active{
  206. background: #f8f8f8;
  207. }
  208. .arrow{
  209. text-align: right;
  210. padding-left: 20rpx;
  211. }
  212. .item-info{
  213. .item-name{
  214. font-size: 30upx;
  215. display: flex;
  216. align-items: center;
  217. }
  218. .item-detail{
  219. margin-top: 10rpx;
  220. .item-detail-text{
  221. font-size: 30upx;
  222. color: #9DA8B5;
  223. word-break: break-all;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. </style>