<template>
  <div class="baseInfo">
    <el-form ref="form" :model="dataInfo">
      <el-col :span="4" label-width="80px">
        <el-form-item label="类型:" prop="type">
          {{
            dataInfo.bomType == 1
              ? 'PBOM'
              : dataInfo.bomType == 2
              ? 'MBOM'
              : dataInfo.bomType == 3
              ? 'ABOM'
              : dataInfo.bomType == 4
              ? 'EBOM'
              : ''
          }}
        </el-form-item>
      </el-col>

      <el-row>
        <el-col :span="5" label-width="78px">
          <el-form-item label="BOM编码:" prop="type">
            {{ dataInfo.code }}
          </el-form-item>
        </el-col>
        <el-col :span="5" label-width="78px">
          <el-form-item label="BOM名称:" prop="type">
            {{ dataInfo.name }}
          </el-form-item>
        </el-col>
        <el-col :span="4" label-width="78px">
          <el-form-item label="版本号:" prop="type">
            {{ dataInfo.versions }}
          </el-form-item>
        </el-col>
        <el-col :span="4" label-width="80px">
          <el-form-item label="状态:" prop="type">
            <el-select
              size="mini"
              style="width: 120px"
              disabled
              v-model="dataInfo.status"
              placeholder="请选择"
            >
              <el-option
                v-for="item in statusOptions"
                :label="item.label"
                :value="item.value"
                :key="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="2" label-width="78px">
          <el-button
            type="text"
            @click="handleEdit"
            v-if="dataInfo.status != 1"
          >
            编辑</el-button
          >
        </el-col>
      </el-row>
    </el-form>

    <baseInfoSave
      v-if="baseInfoShow"
      @close="baseClose"
      :categoryObj="dataInfo"
      :isEdit="true"
    ></baseInfoSave>
  </div>
</template>

<script>
  import baseInfoSave from './baseInfoSave.vue';
  export default {
    components: {
      baseInfoSave
    },
    data() {
      return {
        baseInfoShow: false,
        statusOptions: [
          {
            label: '已停用',
            value: '2'
          },
          {
            label: '已发布',
            value: '1'
          },

          {
            label: '草稿',
            value: '0'
          }
        ]
      };
    },
    props: {
      dataInfo: {
        type: Object,
        default() {
          return {};
        }
      }
    },
    methods: {
      handleEdit() {
        this.baseInfoShow = true;
      },

      baseClose() {
        this.baseInfoShow = false;
      }
    }
  };
</script>

<style lang="scss" scoped>
  .baseInfo {
    padding: 2px;
    box-sizing: border-box;
    border: 1px solid #f1f2f2;
  }
  .el-form-item {
    margin-bottom: 2px;
  }
</style>
