<template>
  <div>
    <el-form :model="formData" style="width: 100%;" ref="dataForm" :rules="formRules"
             label-width="auto"
    >
      <el-row :gutter="24">
        <el-col :span="12" class="el-col">
          <el-form-item label="货架编码:" prop="code" class="query-form-item">
            <el-input
              v-model="formData.freightCode" style="width: 80%"
              auto-complete="off"
              disabled
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" class="el-col">
          <el-form-item label="货架名称:"  class="query-form-item"  prop="name" placeholder="请输入名称">
            <el-input
              v-model="freightData.name" style="width: 80%"
              auto-complete="off"
              disabled
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24">
        <!--<el-col :span="12" class="el-col" v-if="titleName == 'add'">-->
          <!--<el-form-item label="货位层级:" prop="layer" class="query-form-item" placeholder="请输入货位格数">-->
          <!--  <el-input-->
          <!--    v-model="formData.layer" style="width: 80%"-->
          <!--    type="Number"-->
          <!--    auto-complete="off"-->
          <!--  ></el-input>-->
            <!--<el-select-->
            <!--  v-model="formData.layer"-->
            <!--  filterable-->
            <!--  remote-->
            <!--  style="width: 80%"-->
            <!--  placeholder="请选择层级"-->
            <!--&gt;-->
            <!--  <el-option-->
            <!--    v-for="item in layers"-->
            <!--    :key="item.code"-->
            <!--    :label="item.label"-->
            <!--    :value="item.code"-->
            <!--  />-->
            <!--</el-select>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
        <!--<el-col :span="12" class="el-col" v-if="titleName == 'edit'">-->
        <!--  <el-form-item label="货位层级:" prop="layer" class="query-form-item" placeholder="请输入货位格数">-->
        <!--    <el-select-->
        <!--      v-model="formData.layer"-->
        <!--      filterable-->
        <!--      remote-->
        <!--      style="width: 80%"-->
        <!--      placeholder="请选择层级"-->
        <!--    >-->
        <!--      <el-option-->
        <!--        v-for="item in layers"-->
        <!--        :key="item.code"-->
        <!--        :label="item.label"-->
        <!--        :value="item.code"-->
        <!--      />-->
        <!--    </el-select>-->
        <!--  </el-form-item>-->
        <!--</el-col>-->
        <el-col :span="12" class="el-col">
          <el-form-item label="货位格数:" prop="code" class="query-form-item" placeholder="请输入货位格数">
            <el-input
              v-model="formData.grids" style="width: 80%"
              type="Number"
              auto-complete="off"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <!--<el-row :gutter="24">-->
      <!--  <el-col :span="12" class="el-col">-->
      <!--    <el-form-item label="备注:" prop="remake" class="query-form-item">-->
      <!--      <el-input-->
      <!--        v-model="formData.remark" style="width: 80%"-->
      <!--        auto-complete="off"-->
      <!--      ></el-input>-->
      <!--    </el-form-item>-->
      <!--  </el-col>-->
      <!--</el-row>-->
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click.native="hideForm">取消</el-button>
      <el-button
        type="primary"
        @click.native="formSubmit()"
      >提交
      </el-button
      >
    </div>
  </div>
</template>

<script>


import { addLayer } from '@/api/basic/workPlace/SysWorkplaceQueue'

export default {
  props: {
    closeDialog: {
      type: Function,
      required: true
    },
    freightData: {
      type: Object,
      required: true
    },
    titleName: {
      type: String,
      required: true
    },

  },
  data() {
    return {
      formData: {
        freightCode: "",
        grids: null,
      },
      layers:[]

    }
  },
  methods: {
    hideForm(){
      this.closeDialog()
    },
    formSubmit(){
      addLayer(this.formData).then(res => {
        if (res.code == 20000){
          this.$message.success("增加成功")
          this.closeDialog()
        }else {
          this.$message.error("增加失败")
        }
      })
    }

  },
  created() {
    if (this.freightData != null){
      this.formData.freightCode = this.freightData.code
    }
  }
}
</script>

<style scoped>

</style>
