chooseCustomer.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. scrollH:300,
  44. }
  45. },
  46. onLoad() {
  47. uni.$on('clear',this.clearSearch)
  48. },
  49. onShow() {
  50. this.init()
  51. },
  52. onUnload() {
  53. uni.$off('clear',this.clearSearch)
  54. },
  55. methods:{
  56. // 初始数据
  57. init(){
  58. this.listData=[]
  59. this.queryWord=''
  60. this.pageSize=20
  61. this.pageNo=1
  62. },
  63. // 新增客户
  64. addCustomer(){
  65. uni.navigateTo({
  66. url:'/pages/sales/addCustomer'
  67. })
  68. },
  69. getData(){
  70. console.log('调用')
  71. customerList({queryWord:this.queryWord,pageNo:this.pageNo,pageSize:this.pageSize}).then(res => {
  72. if(res.status == 200 && res.data){
  73. this.listData = res.data.list
  74. }else{
  75. this.listData = []
  76. }
  77. })
  78. },
  79. // 搜索品牌
  80. searchBrand(){
  81. if(this.queryWord != ''){
  82. this.getData()
  83. }
  84. },
  85. clearSearch(){
  86. this.queryWord = ''
  87. this.listData = []
  88. },
  89. chooseItem(val){
  90. console.log(val)
  91. this.queryWord=this.listData[val].customerName
  92. uni.navigateTo({
  93. url:'/pages/sales/addSales?pageType=edit&nowId='+this.listData[val].id
  94. })
  95. }
  96. },
  97. }
  98. </script>
  99. <style lang="scss">
  100. .chooseCustomer-content{
  101. width: 100%;
  102. height: 100vh;
  103. background-color: #fff;
  104. padding:0 30upx;
  105. display: flex;
  106. flex-direction: column;
  107. .search{
  108. .search-title{
  109. padding: 20upx 0;
  110. .search-label{
  111. font-size: 30upx;
  112. font-weight: 600;
  113. }
  114. .search-btn{
  115. font-size: 28upx;
  116. color: #999;
  117. text:last-child{
  118. display: inline-block;
  119. padding-left: 10upx;
  120. color:#007AFF
  121. }
  122. }
  123. }
  124. }
  125. .picker-content{
  126. padding: 6upx 0 20upx;
  127. width: 100%;
  128. height: calc(100vh-144upx);
  129. flex: 1;
  130. overflow-y: scroll;
  131. .picker-main{
  132. width: 100%;
  133. .picker-main-item{
  134. padding: 0 20upx;
  135. .item-name{
  136. padding: 14upx 0;
  137. border-bottom: 1rpx solid #e5e6eb;
  138. }
  139. .item-name:not(:last-child){
  140. border-bottom:none
  141. }
  142. }
  143. }
  144. }
  145. }
  146. </style>