index.vue 2.26 KB
<template>
  <div class="el-descriptions">
    <div class="el-descriptions__body">
      <table class="el-descriptions__table is-bordered">
        <tbody v-for="(item, index) in tableModel" :key="index">
          <tr class="el-descriptions-row">
            <template v-for="(trTtem, idx) in item.colList">
              <th :key="idx" :colspan="trTtem.thColspan" class="el-descriptions-item__cell el-descriptions-item__label is-bordered-label">{{ trTtem.label }}</th>

              <td :key="idx" :colspan="trTtem.tdColspan" class="el-descriptions-item__cell el-descriptions-item__content" :style="{ color: trTtem.color }">
                <slot v-if="trTtem.addHtml" :name="trTtem.addHtml" :scope="list"></slot>
                <span v-else>
                    {{ list[trTtem.name] ? list[trTtem.name] : ' — ' }}
                </span>
              
              </td>
            </template>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ylDescriptions',
  props: {
    tableModel: {
      type: Array,
      default: () => []
    },
    showData: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    list() {
      return this.showData
    }
  }
}
</script>

<style lang="scss" scoped>
.el-descriptions .is-bordered {
  table-layout: auto;
}
.el-descriptions__body .el-descriptions__table {
  border-collapse: collapse;
  table-layout: fixed;
}
.el-descriptions :not(.is-bordered) .el-descriptions-item__cell {
  padding-bottom: 12px;
}
.el-descriptions .is-bordered .el-descriptions-item__cell {
  border: 1px solid #ebeef5;
  padding: 12px 10px;
}
.el-descriptions-item__label.is-bordered-label {
  font-weight: 700;
  color: #333333;
  background: #f4f6fc;
}
.el-descriptions :not(.is-bordered) .el-descriptions-item__cell {
  padding-bottom: 12px;
}
.el-descriptions .is-bordered .el-descriptions-item__cell {
  border: 1px solid #e8e8ea;
  padding: 7px 10px;
}
.el-descriptions__body .el-descriptions__table .el-descriptions-item__cell {
  box-sizing: border-box;
  text-align: left;
  font-weight: 400;
  line-height: 1.5;
  width: 118px;
  vertical-align: middle;
  font-size: 14px;
}
.el-descriptions-item__content {
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 238px;
}
</style>