index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="description">
  3. <div class="d-title" @click="handleClkHeader">
  4. <span>{{ title }}</span>
  5. <div>
  6. <DownOutlined style="font-size:12px; color: #979797" v-if="foldState" />
  7. <UpOutlined style="font-size:12px; color: #979797" size="10px" v-if="!foldState" />
  8. </div>
  9. </div>
  10. <div v-show="foldState">
  11. <div class="default_slot" v-if="slots.default">
  12. <slot></slot>
  13. </div>
  14. <a-descriptions v-if="!isEmpty(items)" :bordered="false">
  15. <a-descriptions-item v-for="(item, index) in items" :key="index" v-bind="item.extraProps">
  16. <template #label>
  17. <slot v-if="item.labelSlot" :name="item.labelSlot"></slot>
  18. <span v-else class="dsc-label">{{ item.label }}</span>
  19. </template>
  20. <template v-if="item.valueSlot">
  21. <slot :name="item.valueSlot"></slot>
  22. </template>
  23. <template v-if="!item.valueSlot">
  24. <div class="dsc-value">
  25. {{ item.value }}
  26. </div>
  27. </template>
  28. </a-descriptions-item>
  29. </a-descriptions>
  30. </div>
  31. </div>
  32. </template>
  33. <script setup>
  34. import { isEmpty } from 'lodash';
  35. import {ref, useSlots} from 'vue';
  36. const props = defineProps({
  37. title: {
  38. required: true,
  39. default: '',
  40. },
  41. items: {
  42. required: false,
  43. default: [],
  44. },
  45. isFolded: {
  46. required: false,
  47. default: false,
  48. },
  49. });
  50. const foldState = ref(true);
  51. const emits = defineEmits(['update:isFolded']);
  52. const slots = useSlots();
  53. const handleClkHeader = () => {
  54. foldState.value = !foldState.value;
  55. };
  56. </script>
  57. <style lang="scss" scoped>
  58. .description {
  59. width: 100%;
  60. .d-title {
  61. font-size: 16px;
  62. font-weight: 600;
  63. padding: 10px 0 10px 10px;
  64. border-bottom: 1px solid #e4e7ed;
  65. cursor: pointer;
  66. position: relative;
  67. display: flex;
  68. align-items: center;
  69. gap: 10px;
  70. &:hover {
  71. background: rgba(#000, .1);
  72. border-radius: 8px;
  73. }
  74. &::before {
  75. width: 4px;
  76. height: 18px;
  77. background: var(--webchat-toolbar-background-color);
  78. position: absolute;
  79. left: 0;
  80. top: 50%;
  81. transform: translateY(-50%);
  82. content: '';
  83. border-radius: 4px;
  84. }
  85. }
  86. .dsc-label {
  87. font-size: 14px;
  88. color: #6c6c6c;
  89. }
  90. .dsc-value {
  91. font-size: 14px;
  92. color: #000;
  93. font-weight: 500;
  94. }
  95. :deep(.ant-descriptions-header) {
  96. margin: 0 0 10px 0;
  97. }
  98. :deep(.ant-descriptions-item) {
  99. margin: 0;
  100. padding: 10px 0 0 0;
  101. }
  102. .default_slot {
  103. padding: 10px 0;
  104. }
  105. }
  106. </style>