|
|
@@ -34,6 +34,16 @@ import {
|
|
|
} from '@d8d/shared-ui-components/components/ui/select';
|
|
|
import { Badge } from '@d8d/shared-ui-components/components/ui/badge';
|
|
|
import { toast } from 'sonner';
|
|
|
+import {
|
|
|
+ AlertDialog,
|
|
|
+ AlertDialogAction,
|
|
|
+ AlertDialogCancel,
|
|
|
+ AlertDialogContent,
|
|
|
+ AlertDialogDescription,
|
|
|
+ AlertDialogFooter,
|
|
|
+ AlertDialogHeader,
|
|
|
+ AlertDialogTitle,
|
|
|
+} from '@d8d/shared-ui-components/components/ui/alert-dialog';
|
|
|
import {
|
|
|
Plus,
|
|
|
Search,
|
|
|
@@ -69,6 +79,12 @@ export const OrderManagement: React.FC = () => {
|
|
|
const [selectedOrderId, setSelectedOrderId] = useState<number | null>(null);
|
|
|
const [selectedPersonId, setSelectedPersonId] = useState<number | null>(null);
|
|
|
|
|
|
+ // 确认对话框状态
|
|
|
+ const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);
|
|
|
+ const [activateConfirmOpen, setActivateConfirmOpen] = useState(false);
|
|
|
+ const [closeConfirmOpen, setCloseConfirmOpen] = useState(false);
|
|
|
+ const [pendingOrderId, setPendingOrderId] = useState<number | null>(null);
|
|
|
+
|
|
|
// 查询订单列表
|
|
|
const { data: ordersData, isLoading, error } = useQuery({
|
|
|
queryKey: ['orders', searchParams],
|
|
|
@@ -162,22 +178,46 @@ export const OrderManagement: React.FC = () => {
|
|
|
|
|
|
// 处理删除订单
|
|
|
const handleDeleteOrder = (id: number) => {
|
|
|
- if (window.confirm('确定要删除这个订单吗?')) {
|
|
|
- deleteMutation.mutate(id);
|
|
|
- }
|
|
|
+ setPendingOrderId(id);
|
|
|
+ setDeleteConfirmOpen(true);
|
|
|
};
|
|
|
|
|
|
// 处理激活订单
|
|
|
const handleActivateOrder = (orderId: number) => {
|
|
|
- if (window.confirm('确定要激活这个订单吗?')) {
|
|
|
- activateMutation.mutate(orderId);
|
|
|
- }
|
|
|
+ setPendingOrderId(orderId);
|
|
|
+ setActivateConfirmOpen(true);
|
|
|
};
|
|
|
|
|
|
// 处理关闭订单
|
|
|
const handleCloseOrder = (orderId: number) => {
|
|
|
- if (window.confirm('确定要关闭这个订单吗?')) {
|
|
|
- closeMutation.mutate(orderId);
|
|
|
+ setPendingOrderId(orderId);
|
|
|
+ setCloseConfirmOpen(true);
|
|
|
+ };
|
|
|
+
|
|
|
+ // 确认删除订单
|
|
|
+ const confirmDeleteOrder = () => {
|
|
|
+ if (pendingOrderId) {
|
|
|
+ deleteMutation.mutate(pendingOrderId);
|
|
|
+ setDeleteConfirmOpen(false);
|
|
|
+ setPendingOrderId(null);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 确认激活订单
|
|
|
+ const confirmActivateOrder = () => {
|
|
|
+ if (pendingOrderId) {
|
|
|
+ activateMutation.mutate(pendingOrderId);
|
|
|
+ setActivateConfirmOpen(false);
|
|
|
+ setPendingOrderId(null);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 确认关闭订单
|
|
|
+ const confirmCloseOrder = () => {
|
|
|
+ if (pendingOrderId) {
|
|
|
+ closeMutation.mutate(pendingOrderId);
|
|
|
+ setCloseConfirmOpen(false);
|
|
|
+ setPendingOrderId(null);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -506,6 +546,70 @@ export const OrderManagement: React.FC = () => {
|
|
|
}}
|
|
|
/>
|
|
|
)}
|
|
|
+
|
|
|
+ {/* 删除订单确认对话框 */}
|
|
|
+ <AlertDialog open={deleteConfirmOpen} onOpenChange={setDeleteConfirmOpen}>
|
|
|
+ <AlertDialogContent data-testid="delete-confirm-dialog">
|
|
|
+ <AlertDialogHeader>
|
|
|
+ <AlertDialogTitle data-testid="delete-confirm-dialog-title">删除订单</AlertDialogTitle>
|
|
|
+ <AlertDialogDescription data-testid="delete-confirm-dialog-description">
|
|
|
+ 确定要删除这个订单吗?此操作不可撤销。
|
|
|
+ </AlertDialogDescription>
|
|
|
+ </AlertDialogHeader>
|
|
|
+ <AlertDialogFooter>
|
|
|
+ <AlertDialogCancel data-testid="delete-confirm-dialog-cancel">取消</AlertDialogCancel>
|
|
|
+ <AlertDialogAction
|
|
|
+ onClick={confirmDeleteOrder}
|
|
|
+ data-testid="delete-confirm-dialog-confirm"
|
|
|
+ className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </AlertDialogAction>
|
|
|
+ </AlertDialogFooter>
|
|
|
+ </AlertDialogContent>
|
|
|
+ </AlertDialog>
|
|
|
+
|
|
|
+ {/* 激活订单确认对话框 */}
|
|
|
+ <AlertDialog open={activateConfirmOpen} onOpenChange={setActivateConfirmOpen}>
|
|
|
+ <AlertDialogContent data-testid="activate-confirm-dialog">
|
|
|
+ <AlertDialogHeader>
|
|
|
+ <AlertDialogTitle data-testid="activate-confirm-dialog-title">激活订单</AlertDialogTitle>
|
|
|
+ <AlertDialogDescription data-testid="activate-confirm-dialog-description">
|
|
|
+ 确定要激活这个订单吗?订单激活后将进入进行中状态。
|
|
|
+ </AlertDialogDescription>
|
|
|
+ </AlertDialogHeader>
|
|
|
+ <AlertDialogFooter>
|
|
|
+ <AlertDialogCancel data-testid="activate-confirm-dialog-cancel">取消</AlertDialogCancel>
|
|
|
+ <AlertDialogAction
|
|
|
+ onClick={confirmActivateOrder}
|
|
|
+ data-testid="activate-confirm-dialog-confirm"
|
|
|
+ >
|
|
|
+ 激活
|
|
|
+ </AlertDialogAction>
|
|
|
+ </AlertDialogFooter>
|
|
|
+ </AlertDialogContent>
|
|
|
+ </AlertDialog>
|
|
|
+
|
|
|
+ {/* 关闭订单确认对话框 */}
|
|
|
+ <AlertDialog open={closeConfirmOpen} onOpenChange={setCloseConfirmOpen}>
|
|
|
+ <AlertDialogContent data-testid="close-confirm-dialog">
|
|
|
+ <AlertDialogHeader>
|
|
|
+ <AlertDialogTitle data-testid="close-confirm-dialog-title">关闭订单</AlertDialogTitle>
|
|
|
+ <AlertDialogDescription data-testid="close-confirm-dialog-description">
|
|
|
+ 确定要关闭这个订单吗?订单关闭后将无法再添加人员或资产。
|
|
|
+ </AlertDialogDescription>
|
|
|
+ </AlertDialogHeader>
|
|
|
+ <AlertDialogFooter>
|
|
|
+ <AlertDialogCancel data-testid="close-confirm-dialog-cancel">取消</AlertDialogCancel>
|
|
|
+ <AlertDialogAction
|
|
|
+ onClick={confirmCloseOrder}
|
|
|
+ data-testid="close-confirm-dialog-confirm"
|
|
|
+ >
|
|
|
+ 关闭
|
|
|
+ </AlertDialogAction>
|
|
|
+ </AlertDialogFooter>
|
|
|
+ </AlertDialogContent>
|
|
|
+ </AlertDialog>
|
|
|
</div>
|
|
|
);
|
|
|
};
|