// 编辑水渣发运日计划
<template>
  <div id="endMaintenance">
    <page-title>修改汽车发运水渣日计划</page-title>
    <div>
      <div class="form-box">
        <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: {},
      dayPlanId:0,
    };
  },
  created(){
    this.information();
  },
  methods: {
     information() {
       console.log(1111);
      //编辑运输计划
      this.axios
        .post("/api/v1/ams/getDayPlanByDayPlanId/" + this.$route.params.dayPlanId)
        .then((res) => {
          res.data.data.forEach((e) => {
            this.form = e;
          });
        });
        console.log(this.form);
    },
    // 编辑
    makeSure() {
      if (this.form.shipperId && sjTime(this.form.dayplanDeliveryDate) && this.form.dayplanTruckNumber
      && this.form.dayplanReceiveUnit && this.form.materialId && this.form.dayplanMaterialWeight) {
        let mes = {
          dayplanId: this.$route.params.dayPlanId,
          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
        };
        console.log(mes);
        this.axios
        .post(
          "/api/v1/ams/updateDayPlan", mes
        )
        .then((res) => {
            console.log(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>
