<template>
  <!-- 修改原料仓库信息 -->
  <div id="contractDetails">
    <page-title>编辑</page-title>
    <div class="main">
    </div>
<!--     <div class="contractTitle">
      <div class="form-box">
        <div class="form-one">
          <dil-form :formId="355" v-model="form1"></dil-form>
        </div>
      </div>
    </div> -->

    <div class="shipperName">
    <label>托运人</label>
    <el-select v-model="shipperName" placeholder="请选择" @change="getValue">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
     </div>
  <div class="point">
    <label>装卸点</label>
  <el-input style="width: 220px;" v-model="warehouseName" placeholder="请输入内容"></el-input>
  </div>
  
    
         
    <div class="button-box">
      <el-button @click="onClickCancel">返回</el-button>
      <el-button type="primary" @click="onClickConfirm">确认</el-button>
    </div>
  </div>
</template>

<script>
import PageTitle from "@/components/Page/Title";

export default {
  components: { PageTitle },
  data() {
    return {
    warehouseName : '',
    shipperName: '',
    options: [{
          value: '',
          label: ''
        }],
    };
  },
  created(){
    this.getValue();
  },
  mounted() {
      console.log(this.$route)
    this.information();
  },
  methods: {
    information() {
      //编辑
      console.log("warehouseId",this.$route.params.warehouseId);
      this.axios
        .post(
          "/api/v1/rms/getWarehouseById/" +
            this.$route.params.warehouseId
        )
        .then((res) => {
            console.log("res",res)
            this.shipperName=res.data.data.shipperId;
            this.warehouseName=res.data.data.warehouseName;
            
        });
    },
    //单选下拉框
    getValue(){
       this.axios
        .get(
          "/api/v1/rms/getShipperId" 
           
        )
        .then((res) => {
            this.options = res.data.data;
        });
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {
     console.log("RmsWarehouse",RmsWarehouse)
       let RmsWarehouse={
      warehouseId:this.$route.params.warehouseId,
      warehouseName:this.warehouseName,
      shipperId:this.shipperName,
    };
   console.log("RmsWarehouse",RmsWarehouse)
        this.axios
          .post(
            "/api/v1/rms/updateWarehouse",
           RmsWarehouse 
          )
          .then((res) => {
            if (res.data.code == "200") {
              this.$router.go(-1);
            }
          });
    },
  },
};
</script>
<style lang='scss' scoped>
.form-box,
 .button-box{
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    .el-button{
      width: 80px;
      margin-right: 10px;
    }
  }
  .shipperName{
    display: flex;
    justify-content: center;
  }
  .point{
    display: flex;
    justify-content: center;
    margin-top: 1rem;
  }
</style>