chooseCustomer.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="chooseCustomer-content">
  3. <view class="search">
  4. <view class="flex justify_between align_center search-title" v-if="backPage!='shelfSeting'">
  5. <text class="search-label">客户名称</text>
  6. <view class="search-btn" v-if="backPage != 'salesRecord'">
  7. <text>没有搜索到?</text>
  8. <text>点击</text>
  9. <text @click="addCustomer">新增客户</text>
  10. </view>
  11. </view>
  12. <view v-else>
  13. <view class="shelfName">{{shelfName}}</view>
  14. <view class="flex justify_between align_center search-title">
  15. <view class="search-btn">
  16. <text>请先设置此货架的关联客户。没有搜索到?</text>
  17. <text>点击</text>
  18. <text @click="addCustomer">新增客户</text>
  19. </view>
  20. </view>
  21. </view>
  22. <u-search
  23. placeholder="请输入客户名称搜索"
  24. v-model="queryWord"
  25. height="90"
  26. @input="searchBrand"
  27. @blur="searchBrand"
  28. @search="searchBrand"
  29. @clear="clearSearch"
  30. :showAction="false">
  31. </u-search>
  32. </view>
  33. <scroll-view class="picker-content flex_1" scroll-y >
  34. <view class="picker-main">
  35. <view class="picker-main-item" v-for="(item, index) in listData" :key="item.id" @click="chooseItem(item)">
  36. <view class="item-name">{{item.customerName}}</view>
  37. </view>
  38. <view v-if="listData&&listData.length>=20" style="color:#999;font-size: 26upx;text-align: center;padding: 10upx;">最多显示前20条匹配客户,请尝试输入更多内容</view>
  39. <view v-if="listData && listData.length == 0">
  40. <u-empty text="暂无匹配客户" mode="list" :img-width="200" :margin-top="60"></u-empty>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. </view>
  45. </template>
  46. <script>
  47. import {customerList} from '@/api/customer.js'
  48. export default{
  49. data(){
  50. return{
  51. listData:[],
  52. queryWord:'',
  53. pageSize:20,
  54. pageNo:1,
  55. scrollH:300,
  56. backPage:'',
  57. shelfName: ''
  58. }
  59. },
  60. onLoad(opts) {
  61. uni.$on('clear',this.clearSearch)
  62. this.backPage = opts.backPage
  63. let title = '选择客户'
  64. if(opts.backPage == 'shelfSeting'){
  65. title = '关联客户'
  66. }
  67. if(opts.backPage == 'shelfEdit'){
  68. title = '修改关联客户'
  69. }
  70. uni.setNavigationBarTitle({
  71. title: title
  72. })
  73. this.shelfName = opts.shelfName
  74. },
  75. onShow() {
  76. this.init()
  77. },
  78. onUnload() {
  79. uni.$off('clear',this.clearSearch)
  80. },
  81. methods:{
  82. // 初始数据
  83. init(){
  84. this.listData=[]
  85. this.queryWord=''
  86. this.pageSize=20
  87. this.pageNo=1
  88. },
  89. // 新增客户
  90. addCustomer(){
  91. uni.navigateTo({
  92. url:'/pages/sales/addCustomer?backPage='+this.backPage
  93. })
  94. },
  95. getData(){
  96. console.log('调用')
  97. uni.showLoading({title:'加载中...',mask:true})
  98. customerList({queryWord:this.queryWord,pageNo:this.pageNo,pageSize:this.pageSize}).then(res => {
  99. if(res.status == 200 && res.data){
  100. uni.hideLoading({})
  101. this.listData = res.data.list
  102. }else{
  103. this.listData = []
  104. }
  105. })
  106. },
  107. // 搜索品牌
  108. searchBrand(){
  109. if(this.queryWord != ''){
  110. this.getData()
  111. }
  112. },
  113. clearSearch(){
  114. this.queryWord = ''
  115. this.listData = []
  116. },
  117. chooseItem(item){
  118. console.log(item)
  119. this.queryWord=item.customerName
  120. // 新增销售单
  121. if(this.backPage == 'addSales'){
  122. uni.navigateTo({
  123. url:'/pages/sales/addSales?pageType=edit&nowId='+item.id
  124. })
  125. }
  126. // 销售记录
  127. if(this.backPage == 'salesRecord'){
  128. uni.$emit("searchSalesRecord",item)
  129. uni.navigateBack()
  130. }
  131. // 门店审核通过
  132. if(this.backPage == 'authPass'){
  133. uni.$emit("addCustome",item)
  134. uni.navigateBack()
  135. }
  136. // 货架设置关联客户
  137. if(this.backPage == 'shelfSeting'){
  138. uni.$emit("setCustome",item)
  139. uni.navigateBack()
  140. }
  141. if(this.backPage == 'shelfEdit'){
  142. uni.$emit("editCustome",item)
  143. uni.navigateBack()
  144. }
  145. }
  146. },
  147. }
  148. </script>
  149. <style lang="scss">
  150. .chooseCustomer-content{
  151. width: 100%;
  152. height: 100vh;
  153. background-color: #fff;
  154. padding:0 30upx;
  155. display: flex;
  156. flex-direction: column;
  157. .search{
  158. .shelfName{
  159. font-weight: bold;
  160. }
  161. .search-title{
  162. padding: 20upx 0;
  163. .search-label{
  164. font-size: 30upx;
  165. font-weight: 600;
  166. }
  167. .search-btn{
  168. font-size: 24upx;
  169. color: #999;
  170. text:last-child{
  171. display: inline-block;
  172. padding-left: 10upx;
  173. color:#007AFF
  174. }
  175. }
  176. }
  177. }
  178. .picker-content{
  179. padding: 6upx 0 20upx;
  180. width: 100%;
  181. height: calc(100vh-144upx);
  182. flex: 1;
  183. overflow-y: scroll;
  184. .picker-main{
  185. width: 100%;
  186. .picker-main-item{
  187. padding: 0 20upx;
  188. .item-name{
  189. padding: 30upx 0;
  190. border-bottom: 1rpx solid #e5e6eb;
  191. }
  192. .item-name:not(:last-child){
  193. border-bottom:none
  194. }
  195. }
  196. }
  197. }
  198. }
  199. </style>