<template>
  <el-col :span="span">
    <div class="descriptions-item">
      <div class="label" :style="labelStyle">
        {{ label }}:
      </div>
      <div class="content">
        <div v-if="value !== ''" style="display: inline-block">{{ value }}</div>
        <slot />
      </div>
    </div>
  </el-col>
</template>

<script>
export default {
  name: 'DescriptionsItem',
  props: {
    label: {
      type: String,
      default: ''
    },
    span: {
      type: Number,
      default: 8
    },
    // eslint-disable-next-line vue/require-default-prop
    value: [String, Number],
    // eslint-disable-next-line vue/require-default-prop
    labelWidth: String
  },
  computed: {
    labelStyle() {
      const ret = {}
      const labelWidth = this.labelWidth || this.parent().labelWidth
      if (labelWidth) {
        ret.width = labelWidth
      }
      return ret
    }
  },
  methods: {
    parent() {
      return this.$parent.$parent
    }
  }
}
</script>

<style scoped lang="scss">
  .descriptions-item{
    padding-bottom: 16px;
    display: flex;
    .label{
      width: 100px;
      color: rgba(0,0,0,.85);
      font-weight: 400;
      font-size: 14px;
      line-height: 1.5715;
      vertical-align: top;
      flex-grow: 0;
      flex-shrink: 0
    }
    .content{
      color: rgba(0,0,0,.65);
      font-size: 14px;
      line-height: 1.5715;
      padding-left: 12px;
      flex-grow: 1;
      text-align: left;
    }
  }

</style>
