<template>
  <el-form
    ref="form"
    :model="form"
    :disabled="disabled"
    size="mini"
    label-width="100px"
  >
    <el-row :gutter="20">
      <el-col :span="12">
        <el-form-item label="材料名称" prop="name" required>
          <el-input v-model="form.name"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="原材料编号" required>
          <el-input v-model="form.name1"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="规格" required>
          <el-input v-model="form.name2"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="入库数量" required>
          <el-input v-model="form.name3"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="保质期" required>
          <el-input v-model="form.name4"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="单位" required>
          <el-input v-model="form.name5"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="采购期数" required>
          <el-input v-model="form.name6"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="商品类别" required>
          <el-input v-model="form.name7"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="材料图片" required>
          <ImageUpload :isShowTip="false" :limit="1" />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
<script>
import ImageUpload from "@/components/ImageUpload";
export default {
  name: "FormUI",
  props: {
    form: {
      type: Object,
      default: () => ({}),
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  components: { ImageUpload },
  data() {
    return {};
  },
  methods: {
    validate() {
      return new Promise((resolve, reject) => {
        this.$refs.form.validate((valid) => {
          if (valid) {
            resolve();
          } else {
            reject();
          }
        });
      });
    },
  },
};
</script>
