<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="322" v-model="form1"></dil-form>
        </div>
      </div>
    </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 {
      form1: {},
      shipperName:"四川达钢",
      shipperAbbreviation:"四川达钢"
    };
  },
 
  mounted() {
    this.form1.shipperName = this.shipperName;
    this.form1.shipperAbbreviation = this.shipperAbbreviation;
    this.information();
  },
  methods: {
    information() {
      //编辑
      this.axios
        .post(
          "/api/v1/rms/getShipperById/" +
            this.$route.params.shipperId
        )
        .then((res) => {
        
          res.data.data.forEach((e) => {
            this.form1 = e;
      
          });
        });
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {
      console.log(this.form1)
       let RmsShipper={
        shipperId:this.form1.shipperId,
        shipperName: this.form1.shipperName,
        shipperAbbreviation: this.form1.shipperAbbreviation,
        shipperCompanyBranch:this.form1.shipperCompanyBranch,
        shipperBranchFactory:this.form1.shipperBranchFactory
      };
      if(
        RmsShipper.shipperName==null ||
        RmsShipper.shipperAbbreviation ==null ||
        RmsShipper.shipperCompanyBranch ==null ||
        RmsShipper.shipperBranchFactory ==null
      )this.$message.error("存在空值！");
        this.axios
          .post(
            "/api/v1/rms/updateShipper",
            RmsShipper
          )
          .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;
    .el-button{
      width: 80px;
      margin-right: 10px;
    }
  }
.button-box{
  display: flex;
  justify-items: center;
  margin-left: 0rem;
}
</style>