commonDes.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <a-descriptions :column="column"
  3. :bordered="bordered"
  4. class="commom-des">
  5. <a-descriptions-item v-for="(item, i) in list"
  6. :key="i + 'des'"
  7. :label="item.label">
  8. <span :class="item.className ? item.className : 'white'"
  9. @click="onClick(item)">{{item.value}}</span>
  10. </a-descriptions-item>
  11. <a-descriptions-item v-if="slotDesName"
  12. :label="slotDesName">
  13. <slot></slot>
  14. </a-descriptions-item>
  15. </a-descriptions>
  16. </template>
  17. <script lang="ts">
  18. import { defineComponent, PropType } from 'vue';
  19. import { DescriptionsList } from './interface';
  20. export default defineComponent({
  21. name: 'des-list',
  22. components: {},
  23. props: {
  24. column: {
  25. // 一行的 DescriptionItems 数量
  26. type: Number,
  27. default: 2,
  28. },
  29. bordered: {
  30. // 是否展示边框
  31. type: Boolean,
  32. default: false,
  33. },
  34. slotDesName: {
  35. // 使用插槽的时候,DescriptionItems 的内容描述
  36. type: String,
  37. default: '',
  38. },
  39. list: {
  40. type: Array as PropType<DescriptionsList[]>,
  41. default: [],
  42. },
  43. },
  44. setup(props, context) {
  45. function onClick(value: DescriptionsList) {
  46. context.emit('onClick', value);
  47. }
  48. return { onClick };
  49. },
  50. });
  51. </script>
  52. <style lang="less">
  53. .commom-des {
  54. .ant-descriptions-item-label {
  55. display: inline-block;
  56. width: 130px;
  57. line-height: 30px;
  58. padding-left: 16px;
  59. color: @m-grey1;
  60. &::after {
  61. content: '';
  62. }
  63. }
  64. .ant-descriptions-item-content {
  65. width: calc(100% - 146px);
  66. color: @m-grey1;
  67. }
  68. }
  69. </style>;