<template>
  <div>
    <el-card class="box-card" shadow="always">
      <div slot="header" class="clearfix">
        <span>{{ title }}</span>
        <el-button-group style="float: right;">
          <el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
        </el-button-group>
      </div>
      <div :style="classCardbody">
        <el-form ref="form" :model="form" label-width="80px" disabled>
          <el-form-item label="字段名称" prop="columnName">
            <el-input v-model="form.columnName" />
          </el-form-item>
          <el-form-item label="字段注释" prop="columnComment">
            <el-input v-model="form.columnComment" />
          </el-form-item>
          <el-form-item label="是否主键" prop="columnKey">
            <el-input v-model="form.columnKey" />
          </el-form-item>
          <el-form-item label="是否允许为空" prop="columnNullable">
            <el-input v-model="form.columnNullable" />
          </el-form-item>
          <el-form-item label="数据类型" prop="dataType">
            <el-input v-model="form.dataType" />
          </el-form-item>
          <el-form-item label="数据长度" prop="dataLength">
            <el-input v-model="form.dataLength" />
          </el-form-item>
          <el-form-item label="数据精度" prop="dataPrecision">
            <el-input v-model="form.dataPrecision" />
          </el-form-item>
          <el-form-item label="数据小数位" prop="dataScale">
            <el-input v-model="form.dataScale" />
          </el-form-item>
          <el-form-item label="数据默认值" prop="dataDefault">
            <el-input v-model="form.dataDefault" />
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
import { getDataColumn } from '@/api/metadata/datacolumn'

export default {
  name: 'DataColumnDetail',
  props: {
    data: {
      type: Object,
      default: function () {
        return {}
      }
    }
  },
  data () {
    return {
      classCardbody: {
        overflow: 'auto',
        height: document.body.offsetHeight - 240 + 'px'
      },
      title: '元数据详情',
      // 展示切换
      showOptions: {
        data: {},
        showList: true,
        showDetail: false
      },
      // 表单参数
      form: {}
    }
  },
  created () {
    console.log('id:' + this.data.id)
  },
  mounted () {
    this.getDataColumn(this.data.id)
  },
  methods: {
    showCard () {
      this.$emit('showCard', this.showOptions)
    },
    /** 获取详情 */
    getDataColumn: function (id) {
      getDataColumn(id).then(response => {
        if (response.success) {
          this.form = response.data
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
