<template>
  <view class="sh-content">
    <view class="sh-search">
      <u-form labelPosition="left" :model="dataForm" class="sh-form">

        <u-form-item  prop="barCode">
			<select-lay style="width: 100%;"   :zindex="200"  smoldName="model" smodel="moldName" name="name3" slabel="label" svalue="value" 
				:options="nextDataList"  @selectitem="queryList" >
			</select-lay>

        </u-form-item>
      </u-form>
 
    </view>
	<view class='recommend'>
	  <text class='recommend-title'></text>
	</view>
    <!-- {{dataList}} -->
	<view class="all-card">
		<view class="sh-card" v-for="(item, index) in dataList" :key="item.id" :index="item.id" v-if="dataList.length > 0"
		       style="border-radius: 20rpx;">
		<view  :class="isActive===index? 'sh-card-title-two':'sh-card-title'" @click="btn(index,item)"  style="border-radius: 20rpx;"><!--:class="{'borderBottom':!item.businInShelfDVoList.length}"-->
		      <view class="card-content">
		        <view class="card-content-item" >
		          <text class="item-title" ></text>
		          <text class="item-value"></text>
		        </view>
		      </view>
		      <view class="card-content">
		        <view class="card-content-item">
		          <text class="item-title">托盘编号:</text>
		          <text class="item-value">{{item.containerName}}</text>
		        </view>
		      </view>
		      <view class="card-content">
		        <view class="card-content-item">
		          <text class="item-title">使用状态:</text>
		          <text class="item-value">{{item.status == '0'? statusList[0].dictLabel:statusList[1].dictLabel}}</text>
		        </view>
		      </view> 
			  <view class="card-content">
		        <view class="card-content-item">
		          <text class="item-title">容器类型:</text>
		          <text class="item-value">{{item.containerType == '0'? typeList[0].dictLabel:typeList[1].dictLabel}}</text>
		        </view>
		      </view>
				


		    </view>
		     </view>
	</view>

    
  </view>
</template>

<script>
  export default {
    data() {
      return {
        showDiv:false,
        queryFlag: '',
        dataForm: {
          pageNum: 1,
          pageSize: 10
        },
		pickUpObj:{
			pointNo:'',
			taskCode:'',
			taskId:'',
			containerCode:'',
		},
		statusList:[],
		typeList:[],
        dataList:[],
		nextDataList:[],
        query: {
          current: 1,
          size: 20
        },
		isActive:0,
        loadStatus: 'loadmore',
		timer:0,
      }
    },
    onLoad() {
      // this.getDic(); //获取字典
      this.$u.api.containerStatus().then(res=>{
		 this.statusList = res.data
	  })  
	  this.$u.api.containerContainerType().then(res=>{
		 this.typeList = res.data
	  })
	  // this.loadList();
	  this.$u.api.getContainerList({...this.dataForm,pageSize: 9999}).then(res=>{
	  	this.nextDataList=[]
	  	if(res.code == '200'){
	  		// this.dataList = res.rows
	  		let dataArry = res.rows;
	  		for (var i = 0; i < dataArry.length; i++) {
	  			var obj = {
	  				value: dataArry[i].containerCode,
	  				label: dataArry[i].containerCode,
	  			};
	  			this.nextDataList.push(obj);
	  		}
	  	}
	  	
	  })
	  
    },
    //上拉刷新(当数据距离底部100时触发，距离在pages.json配置)
    onReachBottom() {
      this.loadStatus = "loading";
      setTimeout(() => {
        this.dataForm.pageNum += 1;
        this.loadList();
      }, 100);
    },
	 onPullDownRefresh () {
	    this.list = []
	    //调用获取数据方法
	    setTimeout(() => {
	        //结束下拉刷新
	      uni.stopPullDownRefresh ();
	    }, 1000);
	},
    methods: {
		//点击变色
		btn(index,item){
		this.isActive = index
		},
      /**搜索框查询*/
      queryList(row,item) {
		  this.dataForm.containerCode=item['value']
          this.loadList()
      },
      loadList() {
		  //防抖
		  this.timer =setTimeout(()=>{
		  	//节流
		  	let flag = true
		  	if(flag===false) return
			// if (this.dataForm.containerCode == '' || this.dataForm.containerCode == null || this.dataForm.containerCode ==
			//   undefined) {
			//   return
			// }
			this.$u.api.getContainerList(this.dataForm).then(res=>{
				if(res.code == '200'){
					this.dataList = res.rows
				}
				
			})
			
		  	flag=false
		  	setTimeout(()=>{
		  		flag = true
			}
			,500)
			
		  },400)
      },
	  pickUp(){
	  },
      // 任务查看
      searchClick() {
        this.dataList = [];
        this.dataForm.pageNum = 1;
        this.loadList();
      },
    }
  }
</script>

<style lang="scss">
  @import "index.scss";
  .footer {
    display: flex;
    padding: 20rpx 0;
  }
</style>
