enum-table-column.vue 941 Bytes
<script setup lang="ts">
import { Options } from '@/types/global';
import { eq, get } from 'lodash';
import TableColumn from '@/components/filter/table-column.vue';

const props = defineProps<{ title?: string; dataIndex?: string; option: Options[]; darkValue?: string | number }>();

const getValue = (record: object) => {
  return get(record, props.dataIndex || '', '');
};
</script>

<template>
  <TableColumn v-bind="$attrs" :title="title" :data-index="dataIndex">
    <template #default="{ record }">
      <template v-if="darkValue !== undefined && eq(getValue(record), darkValue)">
        <span style="color: rgba(44, 44, 44, 0.5)"> {{ option.find((item) => item.value === getValue(record))?.label || '未知' }}</span>
      </template>
      <template v-else> {{ option.find((item) => item.value === getValue(record))?.label || '未知' }}</template>
    </template>
  </TableColumn>
</template>

<style scoped lang="less"></style>