<template>
  <!-- 修改运输预约页面 -->
  <div id="contractDetails">
    <page-title>运输预约</page-title>
    <div class="main">
      <span class="text">修改运输预约</span>
      <span class="a"></span>
    </div>
    <div class="contractTitle">
      <div class="form-box">
        <div class="form-one">
          <dil-form :formId="258" v-model="form1"></dil-form>
          <div>
            <div v-if="form1.orderMaterialNumber">
              <span>物资件数：</span>
              <el-input placeholder="请输入内容" v-model="orderMaterialNumber" clearable>
              </el-input>
            </div>
             <div v-if="form1.orderMaterialWeight">
              <span>物资重量：</span>
              <el-input placeholder="请输入内容" v-model="orderMaterialWeight" clearable>
              </el-input>
            </div>
          </div>
        </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: {},
      orderMaterialNumber:'',
      orderMaterialWeight:'',
    };
  },
  mounted() {
    this.information();
  },
  methods: {
    information() {
      this.$axios
        .post("/api/v1/oms/selectOrderByOrderId/" + this.$route.params.orderId)
        .then((res) => {
          res.data.data.forEach((e) => {
            this.form1 = e;
            if(e.orderMaterialNumber){
              this.orderMaterialNumber = e.orderMaterialNumber;
            }else if(e.orderMaterialWeight){
              this.orderMaterialWeight = e.orderMaterialWeight;
            }
          });
        });
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {
      let obj = {
        orderId: this.$route.params.orderId,
        orderMaterialNumber: this.form1.orderMaterialNumber,
        orderEntryTime: sjTime(this.form1.orderEntryTime),
        unloadPointId: this.form1.unloadPointId,
        orderType: 5,
      };

      if (
        obj.orderId == null ||
        obj.orderMaterialNumber == null ||
        obj.orderEntryTime == null ||
        obj.unloadPointId == null
      )
        this.$message.error("存在空值！");
      else
        this.$axios.post("/api/v1/oms/updateOrder", obj).then(() => {
          this.$message({
            type: "success",
            message: "修改成功!",
          });
          this.$router.go(-1);
        });
    },
  },
};
</script>
<style lang="scss" scoped>
</style>  