| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <template>
- <FlexRow justify="space-between" align="flex-start" :gap="gap" :padding="[margin??0,0]">
- <FlexRow :width="titleWidth">
- <Text v-bind="titleProps" :color="titleColor" :text="title" />
- </FlexRow>
- <template v-if="valueType === 'text'">
- <FlexCol v-if="Array.isArray(value)">
- <Text
- v-for="(item,k) in value"
- :key="k"
- v-bind="valueProps"
- :color="valueColor"
- :text="item"
- />
- </FlexCol>
- <Text v-else v-bind="valueProps" :color="valueColor" :text="value || emptyText" />
- </template>
-
- <template v-else-if="valueType === 'image'">
- <FlexRow v-if="Array.isArray(value)" wrap>
- <Image
- v-for="(item,k) in value"
- :key="k"
- :width="100"
- :height="100"
- :radius="12"
- round
- v-bind="(valueProps as ImageProps)"
- :src="item"
- clickPreview
- />
- </FlexRow>
- <Image
- v-else
- :width="100"
- :height="100"
- :radius="12"
- round
- v-bind="(valueProps as ImageProps)"
- :src="value"
- clickPreview
- />
- </template>
- </FlexRow>
- </template>
- <script setup lang="ts">
- import FlexRow from '../layout/FlexRow.vue';
- import Text,{ type TextProps } from '../basic/Text.vue';
- import FlexCol from '../layout/FlexCol.vue';
- import Image, { type ImageProps } from '../basic/Image.vue';
- export type PreviewItemType = 'text' | 'image';
- const props = withDefaults(defineProps<{
- title?: string,
- titleColor?: string,
- titleWidth?: string|number,
- titleProps?: TextProps,
- value?: string | string[],
- valueColor?: string,
- valueType?: PreviewItemType,
- valueProps?: TextProps|ImageProps,
- emptyText?: string,
- gap?: number,
- margin?: number,
- }>(), {
- emptyText: '空',
- valueType: 'text',
- });
- </script>
|