<template>
  <!-- 修改汽运单价 -->
  <div id="contractDetails">
    <page-title>编辑</page-title>
    <div class="main">
      <span class="text">汽运单价</span>
    </div>
    <div class="contractTitle">
      <div class="form-box">
        <div class="form-one">
          <dil-form :formId="288" v-model="form1"></dil-form>
        </div>
      </div>
    </div>
    <div class="button-box">
      <el-button type="primary" @click="onClickConfirm">确认</el-button>
      <el-button @click="onClickCancel">返回</el-button>
    </div>
  </div>
</template>

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

export default {
  components: { PageTitle },
  data() {
    return {
      form1: {},
    };
  },
  mounted() {
    this.information();
  },
  methods: {
    information() {
      //编辑
      this.axios
        .post(
          "/api/v1/ams/getAmsContractTransportPriceByPriceId1?priceId=" +
            this.$route.params.priceId
        )
        .then((res) => {
          res.data.data.forEach((e) => {
            this.form1 = e;
            console.log(e);
            console.log(this.form1);
            console.log(this.$route.params.resultId);
          });
        });
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {
      let amsContractTransportPrice = {
        priceId: this.$route.params.priceId,
        shipperId: this.form1.shipperId,
        carrierId: this.form1.carrierId,
        lineId: this.form1.lineId,
        capacityId: this.form1.capacityId,
        materialId: this.form1.materialId,
        addressId: this.form1.addressId,
        priceValue: this.form1.priceValue,
        priceDate: sjTime(this.form1.priceDate),
      };
      if (
        amsContractTransportPrice.shipperId == null ||
        amsContractTransportPrice.carrierId == null ||
        amsContractTransportPrice.lineId == null ||
        amsContractTransportPrice.capacityId == null ||
        amsContractTransportPrice.materialId == null ||
        amsContractTransportPrice.addressId == null ||
        amsContractTransportPrice.priceValue == null ||
        amsContractTransportPrice.priceDate == null
      )
        this.$message.error("必填项存在空值！");
      else
        this.axios
          .post(
            "/api/v1/ams/updateAmsContractTransportPrice1",
            amsContractTransportPrice
          )
          .then((res) => {
            if (res.data.code == "200") {
              this.$router.go(-1);
            }
          });
    },
  },
};
</script>
<style lang="scss" scoped>
.form-box,
.from {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 5px;
  margin-bottom: 20px;
}
.table_form {
  margin-left: -16rem;
}
.button-box{
  display: flex;
  text-align: center;
  align-items: center;
  justify-content: center;
  margin-top: 0.3125rem;
  margin-bottom: 1.25rem;
}
</style>