<template>
  <!-- 修改承运商信息 -->
  <div id="contractDetails">
    <page-title>编辑</page-title>
    <div class="main">
    </div>
    <div class="contractTitle">
      <div class="form_box">
          <dil-form :formId="330" v-model="form1"></dil-form>
      </div>
    </div>

    <div class="form_box f1">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item>
    <el-button type="primary" @click="drawer = true">添加中标区域信息</el-button>
  </el-form-item>
    </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 @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 {
      form1: {},
      registerDate:"",
      mapValue:"",
      drawer: false,
      options:{
        // first请求数据的地址
        requestUrl: "/api/v1/rms/getCarrierBidAreaList?apiId=406",
        selectionType: "radio",
         mapList:[],
         registerDate:"",
         mapValue:""
      },
    };
  },
 
  mounted() {
      console.log(this.$route)
    this.information();
  },
  methods: {
    onclick(){
      this.options.requestUrl="/api/v1/rms/getCarrierBidAreaList?apiId=406&con=" +this.inputText;
    },
    currentRadioChange(selection){
      this.mapList=selection, 
      console.log(this.mapList) 
      this.bidArea=this.mapList.bidArea
     
    },
    information() {
      //编辑
      this.axios
        .post(
          "/api/v1/rms/getCarrierById/" +
            this.$route.params.carrierId
        )
        .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.carrierId);
          });
        });
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {  
       let RmsCarrier={
        carrierId:this.$route.params.carrierId,
        carrierName:this.form1.carrierName,
        carrierTransportCertificate:this.form1.carrierTransportCertificate,
        carrierBusinessLicense:this.form1.carrierBusinessLicense,
        carrierBusinessAblelicense:this.form1.carrierBusinessAblelicense,
        carrierAbbreviation:this.form1.carrierAbbreviation,
        carrierAddress:this.form1.carrierAddress,
        registerNo:this.form1.registerNo,
        carrierBidAreaId:this.mapList.bidAreaId,
        carrierLegalRepresentative:this.form1.carrierLegalRepresentative,
        registerCapital:this.form1.registerCapital,
        businessScope:this.form1.businessScope,
        annualDate:this.form1.annualDate,
        companyStatusDesc:this.form1.companyStatusDesc,
        companyTypeDesc:this.form1.companyTypeDesc,
        operationPeriod:this.form1.operationPeriod,
        registerOrganization:this.form1.registerOrganization,
        registerAptitudes:this.form1.registerAptitudes,
        contactsName:this.form1.contactsName,
        carrierContactNumber:this.form1.carrierContactNumber,
        carrierType:this.form1.carrierType,
        carrierTransportType:this.form1.carrierTransportType
      };
       let registerDate={
        registerDate: this.form1.registerDate,
      };
      let mapValue={
        RmsCarrier:RmsCarrier,
        registerDate:registerDate
      };
       if(
        RmsCarrier.carrierName ==null ||
       // RmsCarrier.carrierTransportCertificate ==null ||
       // RmsCarrier.carrierBusinessLicense ==null ||
       // RmsCarrier.carrierBusinessAblelicense ==null ||
        RmsCarrier.carrierAbbreviation ==null ||
        RmsCarrier.carrierAddress ==null ||
        RmsCarrier.registerNo ==null ||
        RmsCarrier.carrierBidAreaId ==null || 
        RmsCarrier.carrierLegalRepresentative ==null ||
        RmsCarrier.registerCapital ==null ||
        RmsCarrier.businessScope ==null ||
        RmsCarrier.annualDate ==null ||
        RmsCarrier.companyStatusDesc ==null ||
        RmsCarrier.companyTypeDesc ==null ||
        RmsCarrier.operationPeriod ==null ||
        registerDate.registerDate ==null ||
        RmsCarrier.registerOrganization ==null ||
        RmsCarrier.registerAptitudes ==null ||
        RmsCarrier.contactsName ==null ||
        RmsCarrier.carrierContactNumber ==null ||
        RmsCarrier.carrierType ==null ||
        RmsCarrier.carrierTransportType ==null 
      )this.$message.error("存在空值！");
        this.axios
          .post(
            "/api/v1/rms/updateCarrier",
            mapValue
          )
          .then((res) => {
            if (res.data.code == "200") {
              this.$router.go(-1);
            }
          });
    },
  },
};
</script>
<style lang='scss'>

  .form_box {
    display: flex;
    justify-content: center;
    margin-left: 170px;
    margin-top: 15px;
    .el-form-item {
      display: flex;
      justify-content: center;
      .el-form-item__label {
        display: flex;
        align-items: center;
      }
      .el-form-item__content {
        width: 250px;
        .el-radio-group {
          width: 500px;
        }
        .el-date-editor {
          width: 250px;
        }
        .el-input__inner {
          width: 250px;
        }
      }
    }
  }
.button-box{
    display: flex;
    justify-content: center;
    .el-button{
      width: 80px;
      margin-right: 10px;
    }
  }
</style>