<template>
  <view class="sh-content" style="padding: 50rpx 50rpx;">
    
    <view class="task">
    	<span>AGV起始点位:</span>
    	<u-input v-model="begin" border type="select" placeholder="请选择起始点位" prop="wareHouse" class="u-input"
    		placeholder-style="color:#000000" @click="show = true" />
    	<u-select v-model="show" :list="showList" @confirm="confirm" mode="single-column" ></u-select>
    </view>
    <view class="" style="text-align: center;">
      <img src="/static/down.png" alt="" srcset="" style="width: 400rpx;">
    </view>
    <view class="task" >
    	<span>AGV目标点位:</span>
    	<u-input v-model="end" border type="select" placeholder="请选择目标点位" prop="wareHouse" class="u-input"
    		placeholder-style="color:#000000" @click="showTwo = true" />
    	<u-select v-model="showTwo" :list="showList" @confirm="confirmTwo" mode="single-column"></u-select>
    </view>
    <view class="footer" style="position: absolute;bottom:8%;left: 50%;transform: translateX(-50%);">
    	<u-button type="success" @click="checkOutPick()" style="width: 400rpx;">呼叫搬运</u-button>
    </view>
  </view>
</template>

<script>
  export default{
    data(){
      return {
          show: false,
          showTwo:false,
          begin:'',
          end:'',
          list:[],
          showList:[],
      }
    },
    onLoad(){
   // this.getDic()
      this.getList()
      
    },
    methods:{
      //呼叫搬运
      checkOutPick(){
        this.$u.api.AvgCarry.moveByAGV({fromLocation:this.begin,toLocation:this.end}).then(res=>{
          this.$u.toast(res.msg)
          if(res.code==200){
            this.begin=''
            this.end=''
            this.judge()
          }
        }).catch(err=>console.log(err))
      },
    //获取点位
    async  getList(){
        this.list = [];
      await  this.$u.api.getCarry().then(res => {
          if (res.code === 200) {
            let dataArry = res.data;
            for (var i = 0; i < dataArry.length; i++) {
            	var obj = {
            		value: dataArry[i].dictValue,
            		label: dataArry[i].dictLabel,
            	};
            	this.list.push(obj);
            }
          } else {
          	this.$u.toast(res.msg);
          }
          });
        this.showList = [...this.list]
       // console.log(this.list)
      },
      //过滤数组
      judge(e){
        this.showList = this.list.filter(item=>item.value != this.beginValue && item.value != this.endValue)
      },
      confirm(e) {
      	this.begin = e[0].label
      	this.beginValue = e[0].value
        this.judge(e)
      },
      confirmTwo(e) {
      	this.end = e[0].label
      	this.endValue = e[0].value
         this.judge(e)
      },
    }
  }
</script>

<style lang="scss">
  @import "index.scss";
</style>