<template>
  <!-- 添加汽运单价 -->
  <div class="addSalePlan">
    <page-title>新增</page-title>
    <div class="form-box" style="margin-right: 10rem">
      <dil-form :formId="287" v-model="form1" ref="from1"></dil-form>
    </div>
    <div class="button-box">
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="makeSure">确定</el-button>
    </div>
  </div>
</template>

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

export default {
  components: { PageTitle },
  data() {
    return {
      form1: {},
      value: undefined,
    };
  },
  created(){
    this.form1.priceDate=new Date()
  },
  methods: {
    // 确定
    makeSure() {
      let amsContractTransportPrice = {
        shipperId: this.form1.shipperId,
        carrierId: this.form1.carrierId,
        lineId: this.form1.lineId,
        addressId: this.form1.addressId,
        priceValue: this.form1.priceValue,
        priceDate: sjTime(this.form1.priceDate),
      };
      if (
        amsContractTransportPrice.shipperId && 
        amsContractTransportPrice.carrierId && 
        amsContractTransportPrice.lineId && 
        amsContractTransportPrice.addressId && 
        amsContractTransportPrice.priceValue && 
        amsContractTransportPrice.priceDate
      ){
        this.axios
          .post(
            "/api/v1/ams/addAmsContractTransportUnitPrice1",
            amsContractTransportPrice
          )
          .then((res) => {
            console.log(res.data.data);
            if (res.data.code == "200") {
              this.$router.go(-1);
            }
          });
      }else {
        this.$message.error("必填项存在空值！");
      }
    },
    // 取消
    cancel() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang='scss' scoped>
.form-box{
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 5px;
  margin-bottom: 20px;
}
.button-box{
  display: flex;
  text-align: center;
  align-items: center;
  justify-content: center;
  margin-top: 0.3125rem;
  margin-bottom: 1.25rem;
}
</style>