| | |
| | | <script setup lang="tsx"> |
| | | import { ref, computed, watch } from 'vue' |
| | | import type { DataTableColumns } from 'naive-ui' |
| | | import { NTag } from 'naive-ui' |
| | | import { NTag, useMessage } from 'naive-ui' |
| | | import { fetchWhitelistPageList } from '@/service/api/whitelist' |
| | | |
| | | interface Props { |
| | |
| | | |
| | | interface Emits { |
| | | (e: 'update:show', value: boolean): void |
| | | (e: 'send-all'): void |
| | | (e: 'send-all', payload: { userCount: number }): void |
| | | (e: 'send-selected', rows: any[]): void |
| | | } |
| | | |
| | | const props = defineProps<Props>() |
| | | const emits = defineEmits<Emits>() |
| | | const message = useMessage() |
| | | |
| | | const showModal = computed({ |
| | | get: () => props.show, |
| | |
| | | const pageSize = ref(10) |
| | | const total = ref(0) |
| | | |
| | | const isNormalStatus = (status: unknown) => status === 1 || status === true |
| | | |
| | | const columns: DataTableColumns<any> = [ |
| | | { type: 'selection' }, |
| | | { title: '序号', key: 'id', width: 80, align: 'center', render: (_, index) => (currentPage.value - 1) * pageSize.value + index + 1 }, |
| | |
| | | key: 'status', |
| | | width: 100, |
| | | render(row) { |
| | | const isNormal = row.status === 1 || row.status === true |
| | | const isNormal = isNormalStatus(row.status) |
| | | return ( |
| | | <NTag type={isNormal ? 'info' : 'warning'} size="small" bordered={false} style={{ color: isNormal ? '#1890FF' : '#FAAD14', backgroundColor: isNormal ? '#E6F7FF' : '#FFFBE6' }}> |
| | | {isNormal ? '正常' : '冻结'} |
| | |
| | | } |
| | | |
| | | const handleSendAll = () => { |
| | | emits('send-all') |
| | | if (!isNormalStatus(searchModel.value.status)) { |
| | | message.warning('一键发放所有用户仅支持“冻结状态”筛选为“正常”') |
| | | return |
| | | } |
| | | emits('send-all', { userCount: total.value }) |
| | | showModal.value = false |
| | | } |
| | | |
| | | const handleSendSelected = () => { |
| | | const selectedRows = list.value.filter((item) => checkedRowKeys.value.includes(item.id)) |
| | | const hasFrozen = selectedRows.some(row => !isNormalStatus(row.status)) |
| | | if (hasFrozen) { |
| | | message.warning('选中用户包含冻结状态,请仅选择“正常”用户') |
| | | return |
| | | } |
| | | emits('send-selected', selectedRows) |
| | | showModal.value = false |
| | | } |