<template>
  <!-- 新增请作业页面 -->
  <div id="contractDetails">
    <page-title>返回</page-title>
    <div class="form">
      <div class="form_box">
        <dil-form :formId="122" v-model="form1"></dil-form>
      </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: {},
    };
  },
  mounted() {
    // this.unit();
  },
  methods: {
    handleCheckedCitiesChange(value) {
      console.log(value);
    },

    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    // 确认
    onClickConfirm() {
      let tmstrainPleaseApproveResult = {
        resultPlanDate: sjTime(this.form1.resultPlanDate),
        resultCategory: this.form1.resultCategory,
        shipperId: this.form1.shipperId,
        sendStationId: this.form1.sendStationId,
        toTheStationId: this.form1.toTheStationId,
        resultPleaseNumber: this.form1.resultPleaseNumber,
        resultType: 3,
      };
      function isNumber() {
        var value = tmstrainPleaseApproveResult.resultPleaseNumber;
        //验证是否为数字
        var patrn = /^(-)?\d+(\.\d+)?$/;
        if (patrn.exec(value) == null || value == "") {
          return false;
        } else {
          return true;
        }
      }
      var val = this.value;
      if (
        tmstrainPleaseApproveResult.resultPlanDate == null ||
        tmstrainPleaseApproveResult.resultCategory == null ||
        tmstrainPleaseApproveResult.shipperId == null ||
        tmstrainPleaseApproveResult.sendStationId == null ||
        tmstrainPleaseApproveResult.toTheStationId == null ||
        tmstrainPleaseApproveResult.resultPleaseNumber == null
      )
        this.$message.error("存在空值！");
      else if (!isNumber(val)) this.$message.error("请车数量必须是数字！");
      else
        this.axios
          .post("/api/v1/tms/addWagonPlease", tmstrainPleaseApproveResult)
          .then(() => {
            this.$message({
              type: "success",
              message: "新增成功!",
            });
            this.$router.go(-1);
          });
    },
  },
};
</script>
<style lang="scss" scoped>
#contractDetails{
  .form {
    display: flex;
    .form_box {
      width: 240px;
      margin-left: 35%;
      margin-top: 30px;
      margin-right: 22px;
      .el-form {
        .preview-group {
     }
    }
  }          .el-form-item {
            .el-form-item__label {
              display: inline-block;
              width: 70px !important;    
              padding-right: 200px;
              margin-bottom: 0px;
            }
            .el-form-item__content {
              .el-select {
                width: 230px;
              }
              .el-input {
                width: 160px;
                margin-left: -300px;
                padding-bottom: 0%;
               
              }
            }
          }
        }
 
  .button-box{
    margin-top: 50px;
    margin-left: 550px;
    
  }
}
</style>