<template>
  <!-- 新增装船作业 -->
  <div style="width:100%">
    <page-title>返回</page-title>
    <!-- 第一部分 -->
    <el-form style="width:500px;margin-left:35%;margin-top:50px">
        <el-form-item style="display:inline" label="未轧规格">
            <el-select filterable  v-model="spectionsModel" style="width:300px">
                    <el-option v-for="item in models" :value="item.materialId" :key="item.materialId" :label="item.materialName"></el-option>
            </el-select>
        </el-form-item>
        <el-button type="primary" @click="makeSure" style="margin:20px;margin-left:100px">新增</el-button>
    </el-form>
  </div>
</template>
<script>
import PageTitle from "@/components/Page/Title";
import { sjTime } from "@/utils/sharedJsFile";
import { getCookie } from "@/utils/util.js";
export default {
  components: { PageTitle },
  data() {
    return{
        models:[],
        spectionsModel:null,
    };
  },
  mounted() {
    this.getAllModel();
  },
  methods: {
    getAllModel(){
      this.axios
            .get("/api/v1/qms/getAllModel")
            .then((res) => {
                this.models=res.data.data;
        });
    },
    // 新增
    makeSure() {
        if(!this.spectionsModel || this.spectionsModel==''){
          this.$message.warning("请输入正确的规格！");
          return;
        }
        let map={
            spectionsModel:this.spectionsModel
        }
        console.log(map);
        this.axios
            .post("/api/v1/qms/addModel",map)
            .then((res) => {
              if(res.data.code=="200"){
                this.$message.success("新增成功!");
                this.$router.go(-1);
              }else{
                this.$message.success("新增失败!");
              }
        });
    },
  },
};
</script>
<style lang="scss">

</style>
