chooseCustomer.vue 3.3 KB

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