123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <view class="search-box">
- <u-search
- placeholder="请输入客户名称搜索"
- v-model="queryWord"
- @input="searchBrand"
- @search="searchBrand"
- @clear="clearSearch"
- :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': $config('primaryColor'), 'border-radius': '6upx', 'padding': '12upx 0'}">
- </u-search>
- <scroll-view class="picker-content flex_1" scroll-y v-if="isShow">
- <view class="picker-main">
- <view class="picker-main-item" v-for="(item, index) in listData" :key="item.id" @click="chooseItem(index)">
- <view class="item-name">{{item.customerName}}</view>
- </view>
- <view v-if="listData&&listData.length>=20" style="color:#999;font-size: 26upx;">最多显示前20条匹配客户,请尝试输入更多内容</view>
- <view v-if="listData && listData.length == 0">
- <u-empty text="暂无匹配客户" mode="list" :img-width="200" :margin-top="60"></u-empty>
- </view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import {customerList} from '@/api/customer.js'
- export default{
- data(){
- return{
- listData:[],
- queryWord:'',
- pageSize:20,
- pageNo:1,
- isShow:true
- }
- },
- onLoad() {
- this.queryWord=''
- this.listData=[]
- },
- onShow() {
- this.queryWord=''
- this.listData=[]
- },
- methods:{
- getData(){
- customerList({queryWord:this.queryWord,pageNo:this.pageNo,pageSize:this.pageSize}).then(res => {
- if(res.status == 200 && res.data){
- this.listData = res.data.list
- }else{
- this.listData = []
- }
- })
- },
- // 搜索品牌
- searchBrand(){
- if(this.queryWord != ''){
- this.getData()
- }
- },
- clearSearch(){
- this.queryWord = ''
- this.listData = []
- // this.getData()
- },
- chooseItem(val){
- console.log(val)
- this.queryWord=this.listData[val].customerName
- // uni.navigateTo({
- // url:'/pages/sales/addSales'
- // })
- uni.navigateTo({
- url:'/pages/sales/addSales?pageType=edit&nowId='+this.listData[val].id
- })
-
- }
- }
- }
- </script>
- <style lang="scss">
- .search-box{
- width: 100%;
- display: flex;
- flex-direction: column;
- // flex: 1;
- .picker-content{
- padding: 6upx 0 20upx;
- flex: 1;
- .picker-main{
- width: 100%;
- .picker-main-item{
- padding: 0 20upx;
- .item-name{
- padding: 14upx 0;
- border-bottom: 1rpx solid #e5e6eb;
- }
- .item-name:not(:last-child){
- border-bottom:none
- }
- }
-
- }
- }
- }
-
- </style>
|