<template>
  <!-- 修改司机信息 -->
  <div id="contractDetails">
    <page-title>编辑</page-title>
    <div class="main">
    </div>
    <div class="contractTitle">
      <div class="form_box">
          <dil-form :formId="340" v-model="form1"></dil-form>
      </div>
    </div>
     <div class="form-box f1">
          <el-form :inline="true" :model="formInline" class="demo-form-inline">
<div class="disableBox">
  <el-form-item>
    <el-input v-model="carrierName" disabled>  
    </el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="drawer = true">所属承运商</el-button>
  </el-form-item>
  </div>
   </el-form>
    </div>
  <el-drawer
      :visible.sync="drawer"
      :direction="direction"
      :before-close="handleClose">
        <el-input
            placeholder="请输入内容"
            v-model="inputText"
            clearable>
          </el-input>
          <el-button type="primary" class="btn" @click="onclick">
            <i class="el-icon-search"></i>查询
          </el-button>
            <div><dilTable v-bind.sync="options" @radio-change="currentRadioChange" ></dilTable></div>
</el-drawer>
    <div class="button_box">
      <el-button type="primary" @click="onClickConfirm">确认</el-button>
    </div>
  </div>
</template>

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

export default {
  components: { PageTitle },
  data() {
    return {
      drawer: false,
      direction: 'rtl',
      inputText:"",
      form1: {},
     carrierName:"",
 options:{
        requestUrl:"/api/v1/rms/getCarrierList?apiId=417",
        selectionType:"radio",
        mapList:[]
      }
    };
  },
  mounted() {
      console.log(this.$route)
    this.information();
  },
  methods: {
    currentRadioChange(selection){
      this.mapList=selection,
      console.log(this.mapList)
      this.carrierName=this.mapList.carrierName
    },
    onclick(){
      this.options.requestUrl="/api/v1/rms/getCarrierList?apiId=417&con=" +this.inputText;
    },
    information() {
      //编辑
      this.axios
        .post(
          "/api/v1/rms/getCarDriverById/" +
            this.$route.params.driverId
        )
        .then((res) => {
            console.log(res)
          res.data.data.forEach((e) => {
            this.form1 = e;
            console.log(e);
            console.log(this.form1);
            console.log(this.$route.params.driverId);
          });
        });
    this.axios
        .post(
          "/api/v1/rms/getCarrierNameByDriverId/" +
          this.$route.params.driverId
        )
        .then((res) => {
          this.carrierName=res.data.data.carrierName
          console.log("carrierName",this.carrierName);
        }); 
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {
      console.log(this.form1)
        let RmsCarDriver = {
       driverId:this.form1.driverId,
       driverName:this.form1.driverName,
       driverSex:this.form1.driverSex,
       driverAge:this.form1.driverAge,
       driverIdentityCard:this.form1.driverIdentityCard,
       driverPhone:this.form1.driverPhone,
       transportTypeId:this.form1.transportTypeId,
       carrierId:this.mapList.carrierId,
       driverPermitNo:this.form1.driverPermitNo,
       driverLicence:this.form1.driverLicence,
       driverLicence:this.form1.driverLicence,
       driverLicence:this.form1.driverLicence,
      };
      if(
        RmsCarDriver.driverName==null ||
        RmsCarDriver.driverSex==null ||
        RmsCarDriver.driverAge==null ||
        RmsCarDriver.driverIdentityCard==null ||
        RmsCarDriver.driverPhone==null ||
        RmsCarDriver.transportTypeId==null ||
        RmsCarDriver.carrierId==null 
    )this.$message.error("存在空值！");
        this.axios
          .post(
            "/api/v1/rms/updateCarDriver",
            RmsCarDriver
          )
          .then((res) => {
            if (res.data.code == "200") {
              this.$router.go(-1);
            }
          });
    },
  },
};
</script>
<style lang='scss' scoped>
  .form_box {
    width: 100%;
    margin-top: 30px;
    display: flex;
    justify-content: center;
    .el-form-item{
      display: flex;
      justify-content: center;
      .el-form-item__label{
        display: flex;
        align-items: center;
      }
      .el-form-item__content{
         .el-select{
            width: 250px;
          }
          .el-input{
            width: 250px;
          }
      }
    }
  }
  .inputBox{
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    .text{
      text-align: right;
      display: flex;
      align-items: center;
      margin-right: 5px;
    }
    .input{
      width: 250px;
    }
  }
.button_box{
    display: flex;
    justify-content: center;
    .el-button{
      width: 80px;
      margin-right: 10px;
    }
  }
  .disableBox{
  display: flex;
  text-align: center;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
  margin-bottom: 1.25rem;
}
</style>