chooseCustomer.vue 3.3 KB

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