chooseShelf.vue 5.7 KB

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