Infotip.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <script setup lang="ts">
  2. import { PropType } from 'vue'
  3. import { Highlight } from '@//components/Highlight'
  4. import { useDesign } from '@/hooks/web/useDesign'
  5. import { propTypes } from '@/utils/propTypes'
  6. const { getPrefixCls } = useDesign()
  7. const prefixCls = getPrefixCls('infotip')
  8. defineProps({
  9. title: propTypes.string.def(''),
  10. schema: {
  11. type: Array as PropType<Array<string | TipSchema>>,
  12. required: true,
  13. default: () => []
  14. },
  15. showIndex: propTypes.bool.def(true),
  16. highlightColor: propTypes.string.def('var(--el-color-primary)')
  17. })
  18. const emit = defineEmits(['click'])
  19. const keyClick = (key: string) => {
  20. emit('click', key)
  21. }
  22. </script>
  23. <template>
  24. <div
  25. :class="[
  26. prefixCls,
  27. 'p-20px mb-20px border-1px border-solid border-[var(--el-color-primary)] bg-[var(--el-color-primary-light-9)]'
  28. ]"
  29. >
  30. <div v-if="title" :class="[`${prefixCls}__header`, 'flex items-center']">
  31. <Icon icon="bi:exclamation-circle-fill" :size="22" color="var(--el-color-primary)" />
  32. <span :class="[`${prefixCls}__title`, 'pl-5px text-14px font-bold']">{{ title }}</span>
  33. </div>
  34. <div :class="`${prefixCls}__content`">
  35. <p v-for="(item, $index) in schema" :key="$index" class="pl-8px text-14px mt-15px">
  36. <Highlight
  37. :keys="typeof item === 'string' ? [] : item.keys"
  38. :color="highlightColor"
  39. @click="keyClick"
  40. >
  41. {{ showIndex ? `${$index + 1}、` : '' }}{{ typeof item === 'string' ? item : item.label }}
  42. </Highlight>
  43. </p>
  44. </div>
  45. </div>
  46. </template>