<template>
  <div>
    <avue-crud :option="handleOption(outputJson)"></avue-crud>
  </div>
</template>
<script>
import { ft } from '../../../lib/utils.js';

const LABELS = {
  noData: ft('i18n_common_no_data', '暂无数据'),
  staticResourcePlaceholder: ft('i18n_common_static_resource_placeholder', '静态资源占位符')
};

// 属性信息展示卡 - 单条模式
export default {
  name: 'item-block',
  props: {
    item: {
      type: Object,
      default: function () {
        return {
          content: `<p>${LABELS.staticResourcePlaceholder}</p>`,
          label: 'label',
          type: 'list',
          position: 'left',
          slug: '',
          outputJson: {}
        };
      }
    }
  },

  methods: {
    handleOption(option) {
      option.emptyText = this.labels.noData;

      const columns = option.column;

      for (const column of columns) {
        if (column.i18nKey) {
          column.label = ft(column.i18nKey, column.displayName || column.label || '');
        }
      }

      return option;
    }
  }
};
</script>

<style lang="scss" scoped>
.label__top {
  span.label {
    display: block;
  }
  span.showdata {
    display: block;
    margin-left: 10px;
  }
}
.label__left {
  span.label {
    display: inline-block;
    width: 120px;
  }
  span.showdata {
    display: inline-block;
    margin-left: 10px;
  }
}

span.showdata a {
  text-decoration: underline;
}
</style>
