import { RefreshCw as ActionRefreshCw } from '@/components/common/icons/ActionIcons'; import TableEmpty from '../../components/common/table/TableEmpty'; import TableToolbar from '../../components/common/table/TableToolbar'; import React, { useCallback, useEffect, useState } from 'react'; import { Banner, Button, Card, Descriptions, Modal, Table, Tag, Typography, } from '@/components/ui'; import { useTranslation } from 'react-i18next'; import { API, showError, showSuccess } from '../../helpers'; const { Text } = Typography; const uToYuan = (u) => u === undefined || u === null ? '-' : (u / 1e6).toFixed(2); /** 我的提成(内部销售自助对账,v2.0 六章:次月对账、3 工作日申诉期) */ export default function MyCommission() { const { t } = useTranslation(); const [bills, setBills] = useState([]); const [detail, setDetail] = useState(null); const [loading, setLoading] = useState(false); const load = useCallback(async () => { setLoading(true); try { const res = await API.get('/api/sales/commission/bills'); if (res.data.success) setBills(res.data.data || []); else showError(res.data.message); } catch (error) { showError(error.message); } finally { setLoading(false); } }, []); useEffect(() => { load(); }, [load]); const openDetail = async (bill) => { const res = await API.get(`/api/sales/commission/bills/${bill.id}/items`); if (res.data.success) setDetail(res.data.data); else showError(res.data.message); }; const confirm = async (billId) => { const res = await API.post(`/api/sales/commission/bills/${billId}/confirm`); if (res.data.success) { showSuccess(t('对账单已确认')); setDetail(null); load(); } else showError(res.data.message); }; return ( // mt-[60px]:顶栏 fixed 定位需自行让位(跑马灯由 PageLayout 占位补偿)
( {r.holdback_yuan}{' '} {r.holdback_released && ( {t('已释放')} )} ), }, { title: t('状态'), dataIndex: 'status', render: (v) => ( {v === 'pending_confirm' ? t('待确认') : t('已确认')} ), }, { title: '', render: (r) => ( {r.status === 'pending_confirm' && ( )} ), }, ]} dataSource={bills} rowKey='id' pagination={false} scroll={{ x: 'max-content' }} empty={} /> setDetail(null)} width={760} footer={null} > {detail && ( <>
r.is_stock ? ( {t('存量(续费叠加)')} ) : r.is_new_first ? ( {t('新客首月')} ) : ( '-' ), }, { title: t('续费提成(元)'), dataIndex: 'renewal_uyuan', render: uToYuan, }, ]} dataSource={detail.items} rowKey='id' pagination={false} size='small' /> {t( '毛利 = 净消耗 − 底层成本(v2.0 二章口径);提成按实际毛利据实计算', )} )} ); }