parent
97b91aaf7c
commit
8f9215ffad
@ -1 +1,2 @@
|
||||
export { default as OptionsTag } from './src/options-tag.vue';
|
||||
export { default as TableSwitch } from './src/table-switch.vue';
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
<script setup lang="tsx">
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { Tag } from 'ant-design-vue';
|
||||
|
||||
defineOptions({ name: 'OptionsTag' });
|
||||
|
||||
const props = defineProps<{
|
||||
options: { color?: string; label: string; value: number | string }[];
|
||||
value: number | string;
|
||||
}>();
|
||||
|
||||
const found = computed(() =>
|
||||
props.options.find((item) => item.value === props.value),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Tag v-if="found" :color="found.color">{{ found.label }}</Tag>
|
||||
<span v-else>未知</span>
|
||||
</template>
|
||||
@ -0,0 +1,35 @@
|
||||
import { optionsToEnum } from '@vben/utils';
|
||||
|
||||
export const activityStatusOptions = [
|
||||
{
|
||||
label: '激活',
|
||||
value: 1,
|
||||
color: 'success',
|
||||
enumName: 'Active',
|
||||
},
|
||||
{
|
||||
label: '挂起',
|
||||
value: 0,
|
||||
color: 'error',
|
||||
enumName: 'Suspended',
|
||||
},
|
||||
] as const;
|
||||
|
||||
export const ActivityStatusEnum = optionsToEnum(activityStatusOptions);
|
||||
|
||||
export const publishStatusOptions = [
|
||||
{
|
||||
label: '已发布',
|
||||
value: 1,
|
||||
color: 'success',
|
||||
enumName: 'Published',
|
||||
},
|
||||
{
|
||||
label: '未发布',
|
||||
value: 0,
|
||||
color: 'error',
|
||||
enumName: 'Unpublished',
|
||||
},
|
||||
] as const;
|
||||
|
||||
export const PublishStatusEnum = optionsToEnum(publishStatusOptions);
|
||||
Loading…
Reference in new issue