// 新增水渣发运日计划
<template>
  <div id="endMaintenance">
    <page-title>新增水渣发运日计划</page-title>
    <div class="main">
      <span class="text">新增</span>
      <span class="a"></span>
    </div>
    <div>
      <div class="form-box" style="margin-left: 5rem">
        <dil-form :formId="298" v-model="form"></dil-form>
        
      </div>
    </div>
    <div class="button-box">
      <el-button type="primary" @click="makeSure">确认新增</el-button>
      <el-button type="primary" @click="cancel">返回</el-button>
    </div>
  </div>
</template>

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

export default {
  components: { PageTitle },
  data() {
    return {
      form: {},
    };
  },
  methods: {
    // 新增
    makeSure() {
     if (this.form.shipperId && sjTime(this.form.dayplanDeliveryDate) && this.form.dayplanTruckNumber
      && this.form.dayplanReceiveUnit && this.form.materialId && this.form.dayplanMaterialWeight) {
        let mes = {
          shipmentUnitId: this.form.shipperId,
          dayplanDeliveryDate: sjTime(this.form.dayplanDeliveryDate),
          dayplanTruckNumber: this.form.dayplanTruckNumber,
          dayplanReceiveUnit: this.form.dayplanReceiveUnit,
          materialId: this.form.materialId,
          dayplanMaterialWeight: parseInt(this.form.dayplanMaterialWeight),
          insertUpdateRemark: this.form.insertUpdateRemark
        };
      this.axios
        .post(
          "/api/v1/ams/addTruckRailDayPlan",
          mes
        )
        .then((res) => {
          if (res.data.code == '200') {
            this.$message({
              type: "success",
              message: "新增成功!",
            });            
            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>
