/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
For commercial licensing, please contact support@quantumnous.com
*/
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 { RefreshCw } from 'lucide-react';
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 占位补偿)