chooseCustomer.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="chooseCustomer-content">
  3. <view class="search">
  4. <view class="flex justify_between align_center search-title">
  5. <text class="search-label">客户名称</text>
  6. <view class="search-btn">
  7. <text>没有搜索到?</text>
  8. <text>点击</text>
  9. <text @click="addCustomer">新增客户</text>
  10. </view>
  11. </view>
  12. <u-search
  13. placeholder="请输入客户名称搜索"
  14. v-model="queryWord"
  15. height="90"
  16. @input="searchBrand"
  17. @blur="searchBrand"
  18. @search="searchBrand"
  19. @clear="clearSearch"
  20. :showAction="false">
  21. </u-search>
  22. </view>
  23. <scroll-view class="picker-content flex_1" scroll-y >
  24. <view class="picker-main">
  25. <view class="picker-main-item" v-for="(item, index) in listData" :key="item.id" @click="chooseItem(index)">
  26. <view class="item-name">{{item.customerName}}</view>
  27. </view>
  28. <view v-if="listData&&listData.length>=20" style="color:#999;font-size: 26upx;text-align: center;padding: 10upx;">最多显示前20条匹配客户,请尝试输入更多内容</view>
  29. <view v-if="listData && listData.length == 0">
  30. <u-empty text="暂无匹配客户" mode="list" :img-width="200" :margin-top="60"></u-empty>
  31. </view>
  32. </view>
  33. </scroll-view>
  34. </view>
  35. </template>
  36. <script>
  37. import {customerList} from '@/api/customer.js'
  38. export default{
  39. data(){
  40. return{
  41. listData:[],
  42. queryWord:'',
  43. pageSize:20,
  44. pageNo:1,
  45. scrollH:300,
  46. }
  47. },
  48. onLoad() {
  49. uni.$on('clear',this.clearSearch)
  50. },
  51. onShow() {
  52. this.init()
  53. },
  54. onUnload() {
  55. uni.$off('clear',this.clearSearch)
  56. },
  57. methods:{
  58. // 初始数据
  59. init(){
  60. this.listData=[]
  61. this.queryWord=''
  62. this.pageSize=20
  63. this.pageNo=1
  64. },
  65. // 新增客户
  66. addCustomer(){
  67. uni.navigateTo({
  68. url:'/pages/sales/addCustomer'
  69. })
  70. },
  71. getData(){
  72. console.log('调用')
  73. uni.showLoading({title:'加载中...',mask:true})
  74. customerList({queryWord:this.queryWord,pageNo:this.pageNo,pageSize:this.pageSize}).then(res => {
  75. if(res.status == 200 && res.data){
  76. uni.hideLoading({})
  77. this.listData = res.data.list
  78. }else{
  79. this.listData = []
  80. }
  81. })
  82. },
  83. // 搜索品牌
  84. searchBrand(){
  85. if(this.queryWord != ''){
  86. this.getData()
  87. }
  88. },
  89. clearSearch(){
  90. this.queryWord = ''
  91. this.listData = []
  92. },
  93. chooseItem(val){
  94. console.log(val)
  95. this.queryWord=this.listData[val].customerName
  96. uni.navigateTo({
  97. url:'/pages/sales/addSales?pageType=edit&nowId='+this.listData[val].id
  98. })
  99. }
  100. },
  101. }
  102. </script>
  103. <style lang="scss">
  104. .chooseCustomer-content{
  105. width: 100%;
  106. height: 100vh;
  107. background-color: #fff;
  108. padding:0 30upx;
  109. display: flex;
  110. flex-direction: column;
  111. .search{
  112. .search-title{
  113. padding: 20upx 0;
  114. .search-label{
  115. font-size: 30upx;
  116. font-weight: 600;
  117. }
  118. .search-btn{
  119. font-size: 28upx;
  120. color: #999;
  121. text:last-child{
  122. display: inline-block;
  123. padding-left: 10upx;
  124. color:#007AFF
  125. }
  126. }
  127. }
  128. }
  129. .picker-content{
  130. padding: 6upx 0 20upx;
  131. width: 100%;
  132. height: calc(100vh-144upx);
  133. flex: 1;
  134. overflow-y: scroll;
  135. .picker-main{
  136. width: 100%;
  137. .picker-main-item{
  138. padding: 0 20upx;
  139. .item-name{
  140. padding: 30upx 0;
  141. border-bottom: 1rpx solid #e5e6eb;
  142. }
  143. .item-name:not(:last-child){
  144. border-bottom:none
  145. }
  146. }
  147. }
  148. }
  149. }
  150. </style>