<template>
  <!-- 新增批车作业页面 -->
  <div id="trainTransport">
    <!-- <page-title>批车作业</page-title>
    <div class="main">
      <span class="text">选择已下发请车作业</span>
      <span class="a"></span>
    </div>
    <div>
      <dilTable
        v-bind.sync="option"
        v-model="table1"
        @change="handleCheckedCitiesChange"
        ref="table"
        @radio-change="currentRadioChange"
      >
      </dilTable>
    </div>
    <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="105" v-model="form1"></dil-form>
        </div>
      </div>
    </div>
    <div class="button-box">
      <el-button @click="onClickCancel">返回</el-button>
      <el-button type="primary" @click="onClickConfirm">确认</el-button>
    </div> -->
    <page-title>返回</page-title>
    <!-- 第一部分 -->
      <div class="top">
        <el-input placeholder="请输入内容" v-model="input" clearable> </el-input> 
        <el-button type="primary" class="btn" @click="onclick()">
          <i class="el-icon-search"></i>查询
        </el-button>   
      </div>
      <dilTable v-bind.sync="option" v-model="table1" @change="handleCheckedCitiesChange" 
      ref="table" @radio-change="currentRadioChange">
      </dilTable>
    <div class="form">
      <!-- 第二部分 -->
      <div class="form_box">
          <dil-form :formId="105" 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";
import { sjTime, isNumber } from "@/utils/sharedJsFile";
export default {
  components: { PageTitle },
  data() {
    return {
      option: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/tms/getAllWagonPlease?apiId=57&status=1&resultType=1",
        // 控制显示当选列
        selectionType: "radio",
      },
      // 表单
      form1: {},
      // 表格
      table1: {},
      contractId: "",
      inf: {},
    };
  },
  mounted() {
    // this.unit();
  },
  methods: {
    onclick(){

    },
    handleCheckedCitiesChange(value) {
      console.log(value);
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    currentRadioChange(row) {
      this.inf = row;
    },
    // 确认
    onClickConfirm() {
      let approveWagonPlease = {
        resultId: this.inf.resultId,
        resultApproveDate: sjTime(this.form1.resultApproveDate),
        resultApproveNumber: this.form1.resultApproveNumber,
      };
      function isNumber() {
        var value = approveWagonPlease.resultApproveNumber;
        //验证是否为数字
        var patrn = /^(-)?\d+(\.\d+)?$/;
        if (patrn.exec(value) == null || value == "") {
          return false;
        } else {
          return true;
        }
      }
      var val = this.value;
      if (
        approveWagonPlease.resultId == null ||
        approveWagonPlease.resultApproveDate == null ||
        approveWagonPlease.resultApproveNumber == null
      )
        this.$message.error("存在空值！");
      else if (!isNumber(val)) this.$message.error("请车数量必须是数字！");
      else console.log(approveWagonPlease);
      this.axios
        .post("/api/v1/tms/addApproveWagonPlease", approveWagonPlease)
        .then(() => {
          this.$message({
            type: "success",
            message: "新增成功!",
          });
          this.$router.go(-1);
        });
    },
  },
};
</script>
<style lang="scss">
.shipTransport{
  .form{
    display: flex;
    .form_box{
      width: 320px;
      margin-left: 35%;
      margin-top: 30px;
      margin-right: 20px;
      .el-form{
        .preview-group{
          .el-form-item{
            .el-form-item__label{
              display: inline-block;
              width: 70px !important;
            }
            .el-form-item__content{
              .el-select{
                width: 250px;
              }
              .el-input{
                width: 250px;
              }
            }
          }
        }
      }
    }
  }
  .top {
    padding: 1.25rem 0.375rem;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
  .button_box{
    margin-left: 45%;
  }
}
</style>