commonDes.vue 1.6 KB

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