//修改倒垛作业
<template>
    <div class="steel_restackEdit">
        <div class="search">
            <div class="warehouse">
                <span>仓库名称：</span>
                <el-select v-model="value1" placeholder="请选择" @change="onchange1()">
                    <el-option
                    v-for="(item,i) in options1"
                    :key="i"
                    :label="item.label"
                    :value="item.value"
                    >
                    </el-option>
                </el-select>
            </div>
            <div class="stack">
                <span>垛位：</span>
                <el-select v-model="value2" placeholder="请选择" @change ="onchange2()">
                    <el-option
                        v-for="(item,i) in options2"
                        :key="i"
                        :label="item.label"
                        :value="item.value"
                    >
                    </el-option>
                </el-select>
            </div>
            <div class="gradationnumber">
                <span>层次：</span>
                <el-select v-model="value3" placeholder="请选择" @change="onchange3()">
                    <el-option
                    v-for="(item,i) in options3"
                    :key="i"
                    :label="item.label"
                    :value="item.value">
                    </el-option>
                </el-select>
            </div>
        </div>
        <div class="table" >
            <dilTable v-bind.sync="options11"  @selection-change="selectionChange"></diltable>
        </div>
            <div class="search">
            <div class="warehouse">
                <span>仓库名称：</span>
                <el-select v-model="value4" disabled  placeholder="请选择" @change="onchange4()">
                    <el-option
                    v-for="(item,i) in options4"
                    :key="i"
                    :label="item.label"
                    :value="item.value"
                    >
                    </el-option>
                </el-select>
            </div>
            <div class="stack">
                <span>垛位：</span>
                <el-select v-model="value5" placeholder="请选择" @change ="onchange5()">
                    <el-option
                        v-for="(item,i) in options5"
                        :key="i"
                        :label="item.label"
                        :value="item.value"
                    >
                    </el-option>
                </el-select>
            </div>
     
        </div>
         <div class="table">
            <dilTable v-bind.sync="options" ></diltable>
        </div>
        <div class="button_box">
            <el-button @click="cancel">取消</el-button>
            <el-button type="primary" @click="onClickConfirm">确定</el-button>
        </div>
    </div>  
</template>

<script>
// import PageTitle from "@/components/Page/Title";
export default {
  data(){
    return{
      form1:{},
      inputText:"",
        options11:{
        // first请求数据的地址
      requestUrl: "/api/v1/wms/getWmspRestackMakeResultList?apiId=106",
      selectionType: "select",
      },
      options:{
        // first请求数据的地址
      requestUrl: "/api/v1/wms/getWmspRestackMakeResultList?apiId=106",
      },
        //仓库
        options1:[],
        // 选中的仓库
        value1:'',
        // 垛位
        options2:[],
        // 选中垛位
        value2:'',
        // 层次
        options3:[],
        // 选中的层次
        value3:'',
        // 新增下拉框
        //仓库
        options4:[],
        // // 选中的仓库
        value4:'',
        // 垛位
        options5:[],
        // 选中垛位
        value5:'',
        inf: {}
    }
  },
    mounted(){
        this.initialization();
        this.information();
    },
     methods: {

   information() {
      this.axios
        .post("/api/v1/wms/selectAfterstackingByResultId/" + this.$route.params.resultId)
        .then((res) => {
          console.log(res.data.data);

        });
    },
     initialization(){
         this.axios.get('/api/v1/wms/selectWarehouse').then((res)=>{
             this.options1 = res.data.data
         })
     },
     onchange1(){
            console.log(1);
            //  查询选中的仓库垛位
             this.axios.get('/api/v1/wms/selectStackingId?warehouseid='+this.value1).then((res)=>{
             this.options2 = res.data.data;
             this.options5=res.data.data;
             this.axios.post('/api/v1/wms/getWmspRestackMakeResultList?apiId=106&warehouseid='+this.value1)
             
         })
     },
     onchange2(){
        if(this.value1 == ''){
            this.$message({
                message: '请选择仓库之后！再选择',
                type: 'warning'
            });
            this.value2 = ''
        }else{
            this.axios.post('/api/v1/wms/getWmspRestackMakeResultList?apiId=106'+this.value1)
        }   
            //选择仓库层次号
            this.axios.get('/api/v1/wms/selectGardationNumber?warehouseid='+this.value1+'&stackingId='+this.value2).then((res)=>{
             this.options3 = res.data.data;
            this.axios.post('/api/v1/wms/getWmspRestackMakeResultList?apiId=106&warehouseid='+this.value1+'&stackingId=')
         })
    },
    onchange3(){
        if(this.value2 == ''||this.value1==''){
            this.$message({
                message: '请选择仓库和垛位之后！再选择',
                type: 'warning'
            });
            this.value3 = ''

        }else{
            this.axios.post('/api/v1/wms/getWmspRestackMakeResultList?apiId=106'+this.value1 +this.value2 )
        }
    },
  
         onchange4(){
         console.log(1);
        //  查询选中的仓库垛位
             this.axios.get('/api/v1/wms/selectStackingId?warehouseid='+this.value1).then((res)=>{
              console.log( this.options5 = res.data.data)
             this.axios.post('/api/v1/wms/getWmspRestackMakeResultList?apiId=106&warehouseid='+this.value1)
         })
     },
     onchange5(){     
             this.axios.post('/api/v1/wms/getWmspRestackMakeResultList?apiId=106'+this.value1)
            //选择仓库层次号
             this.axios.get('/api/v1/wms/selectGardationNumber?warehouseid='+this.value1+'&stackingId='+this.value5).then((res)=>{
             this.options6 = res.data.data;
             this.axios.post('/api/v1/wms/getWmspRestackMakeResultList?apiId=106&warehouseid='+this.value1 +'&stackingId=')
         })
    },

     onclick(){
      console.log("点击事件");
     },
       // 确认
      onClickConfirm() { 
        console.log(this.inf,"inf");
       let wmspRestackMakeResult = {
       //倒垛后的垛位id    
       afterStackingId:this.value5,
       //倒垛后的层次id
       afterWarehouseId:this.value1, 
       //实绩id
       resultId:this.inf[0].resultId,
      };
       console.log(wmspRestackMakeResult,"aaaa");
       this.axios
        .post("/api/v1/wms/editRestackMakeResult/", wmspRestackMakeResult)
         .then(() => {
         this.$message({
            type: "success",  
         message: "修改成功!",
           });
          this.$router.go(-1);
        });
    },
    selectionChange(row) {
      console.log("当前选中行的数据：");
      console.log(row);
      this.inf = row;
      console.log(this.inf);
    },
    
    // 取消
    cancel() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang="scss" scode>
.steel_restackEdit{
    .search{
        height: 5rem;
        display: flex;
        align-items:center;
        padding-left:0.625rem;
        .warehouse,.stack,.gradationnumber{
            margin-left: 1.25rem;
        }
    }
    .form{
        display: inline;
        justify-content: center;
        margin-left: 1.25rem;
        
    }
    .button_box{
        width: 90%;
        position: fixed;
        bottom: 1.25rem;
        display: flex;
        justify-content: center;
    }
}
</style>