index.vue 1.81 KB
<template>
  <div>
    <template v-for="(list, id) in tableData">
      <div class="layout-wrap" :key="id">
        <el-row :gutter="30">
          <template v-for="(params, index) in layoutParams">
            <el-col :span="12" :key="index">
              <div class="label-wrap">
                <label>{{ params.label }}</label>
                <span>{{ list[params.prop] ? list[params.prop] : '--' }}</span>
              </div>
            </el-col>
          </template>
        </el-row>
      </div>
    </template>
  </div>
</template>
<script>
export default {
  name: 'layout-row',
  props: {
    //获取的数据
    layoutData: {
      type: Array,
      default: () => []
    },
    layoutParams: {
      type: Array,
      default: () => []
    },
    isHidden: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    tableData() {
      return this.isHidden ? this.layoutData : this.layoutData.slice(0, 1)
    }
  },
  created() {}
}
</script>
<style scoped lang="scss">
.layout-wrap {
  padding: 20px 0;
  box-sizing: border-box;
  background: #f5f5f5;
  margin-bottom: 10px;
  .el-row {
    &:last-child {
      margin-bottom: -20px;
    }
    .el-col {
      margin-bottom: 16px;
    }
    .label-wrap {
      display: flex;
      align-items: center;
      margin: 0 10%;
      min-width: 80%;
      label {
        font-size: 14px;
        font-weight: 400;
        color: #666666;
        line-height: 20px;
        text-align: right;
        min-width: 30%;
        display: inline-block;
      }
      span {
        font-size: 14px;
        font-weight: 400;
        color: #333333;
        line-height: 20px;
        text-align: left;
        min-width: 260px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
      }
    }
  }
}
</style>