// 新增焦炭发运日计划
<template>
  <div id="endMaintenance">
    <page-title>新增焦炭发运日计划</page-title>
    <div class="main">
      <span class="text">新增</span>
      <span class="a"></span>
    </div>
    <div class="contractTitle">
      <div class="from1 f1">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="物资">
            <el-input v-model="materialName" disabled> </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="drawer = true">浏览</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="form-box">
        <div class="form-one">
          <dil-form :formId="252" v-model="form1" @change="onChange"></dil-form>
        </div>
      </div>
    </div>
    <el-drawer
      :visible.sync="drawer"
      :direction="direction"
      :before-close="handleClose"
      size="30%"
    >
      <el-input
        placeholder="请输入内容"
        v-model="input"
        style="margin-top: 10px; margin-left: 20px;width: 200px"
        clearable
      >
      </el-input>
      <el-button
        type="primary"
        class="btn"
        @click="onclick()"
        style="margin-bottom: 15px"
      >
        <i class="el-icon-search"></i>查询
      </el-button>
      <dilTable
        v-bind.sync="frist"
        @radio-change="currentRadioChange1"
      ></dilTable>
    </el-drawer>
    <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 {
      form1: {},
      materialName: "",
      materialId: null,
      drawer: false,
      direction: "rtl",
      input: "",
      frist: {
        requestUrl: "/api/v1/uc/queryMaterialByLike?apiId=244&index=焦",
        selectionType: "radio",
        mapList: [],
      },
    };
  },
  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) => {
          console.log(res);
          if (res.data.code == "200") {
            this.$message({
              type: "success",
              message: "新增成功!",
            });
            this.$router.go(-1);
          } else {
            this.$message.error("新增失败！");
          }
        });
      } else {
        this.$message({
          type: "warning",
          message: "电话号码输入不对!",
        });
      }
    },
    // 返回
    cancel() {
      this.$router.go(-1);
    },
     onclick() {
      this.frist.requestUrl =
        "/api/v1/uc/queryMaterialByLike?apiId=244&index=" + this.input;
    },
    ondrawer() {
      this.drawer = true;
    },
      currentRadioChange1(selection) {
      (this.mapList = selection),
        (this.materialName = this.mapList.materialName);
    },
  },
};
</script>

<style lang="scss" scoped>
.f1{
  margin-left: 26.5rem;
}
.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>
