This commit is contained in:
guochunsi
2025-12-31 17:40:01 +08:00
parent 6d94e91b70
commit 74c06bb8a0
713 changed files with 115034 additions and 46 deletions

View File

@@ -0,0 +1,58 @@
<template>
<el-tag
v-if="currentOption"
:type="currentOption.type"
:class="{ 'audit-state-tag': showIcon && currentOption.icon }"
>
<i v-if="showIcon && currentOption.icon" :class="currentOption.icon" style="margin-right: 4px;"></i>
{{ currentOption.label }}
</el-tag>
<span v-else>{{ emptyText }}</span>
</template>
<script setup lang="ts">
import { computed } from 'vue'
export interface StateOption {
value: string | number;
label: string;
type: 'success' | 'danger' | 'warning' | 'info' | '';
icon?: string;
}
interface Props {
state?: string | number;
options?: StateOption[];
showIcon?: boolean;
emptyText?: string;
}
const props = withDefaults(defineProps<Props>(), {
state: '',
options: () => [
{ value: '1', label: '通过', type: 'success', icon: 'fa-solid fa-circle-check' },
{ value: '-2', label: '驳回', type: 'danger', icon: 'fa-solid fa-circle-xmark' },
{ value: '0', label: '待审核', type: 'warning', icon: 'fa-regular fa-clock' }
],
showIcon: true,
emptyText: '-'
})
// 根据 state 值查找对应的配置
const currentOption = computed(() => {
if (!props.state && props.state !== 0 && props.state !== '0') {
return null
}
return props.options.find(option => {
return String(option.value) === String(props.state)
}) || null
})
</script>
<style scoped>
.audit-state-tag {
display: inline-flex;
align-items: center;
}
</style>