diff --git a/backend/app/service/FeishuNotificationService.php b/backend/app/service/FeishuNotificationService.php index 557cff1..cdabd01 100644 --- a/backend/app/service/FeishuNotificationService.php +++ b/backend/app/service/FeishuNotificationService.php @@ -310,9 +310,9 @@ class FeishuNotificationService // 操作按钮区域 $actions = []; - // 如果有审批单ID,添加审批操作按钮 + // 如果有审批单ID,添加审批操作按钮(使用快速审批页面,无感操作) if ($orderId) { - // 通过按钮(绿色) + // 通过按钮(绿色)- 快速审批页面 $actions[] = [ 'tag' => 'button', 'text' => [ @@ -321,10 +321,10 @@ class FeishuNotificationService ], 'type' => 'primary', 'size' => 'medium', - 'url' => "https://xsm.dev.hnxinyouhe.com/approval/detail/{$orderId}?action=approve", + 'url' => "https://xsm.dev.hnxinyouhe.com/approval/quick-action?action=approve&order_id={$orderId}", ]; - // 拒绝按钮(红色) + // 拒绝按钮(红色)- 快速审批页面 $actions[] = [ 'tag' => 'button', 'text' => [ @@ -333,7 +333,7 @@ class FeishuNotificationService ], 'type' => 'danger', 'size' => 'medium', - 'url' => "https://xsm.dev.hnxinyouhe.com/approval/detail/{$orderId}?action=reject", + 'url' => "https://xsm.dev.hnxinyouhe.com/approval/quick-action?action=reject&order_id={$orderId}", ]; } diff --git a/frontend/src/pages/approval/quick-action.tsx b/frontend/src/pages/approval/quick-action.tsx new file mode 100644 index 0000000..e2896b4 --- /dev/null +++ b/frontend/src/pages/approval/quick-action.tsx @@ -0,0 +1,111 @@ +import { useEffect, useState } from 'react' +import { useNavigate, useLocation } from 'react-router-dom' +import { SpinLoading, Toast } from 'antd-mobile' +import { approvalApi } from '@/services/api' + +export default function QuickAction() { + const navigate = useNavigate() + const location = useLocation() + const [loading, setLoading] = useState(true) + const [status, setStatus] = useState('processing') + + useEffect(() => { + const processAction = async () => { + try { + const urlParams = new URLSearchParams(window.location.search) + const action = urlParams.get('action') as 'approve' | 'reject' | null + const orderId = urlParams.get('order_id') + const token = localStorage.getItem('token') + + console.log('🚀 快速审批:', { action, orderId, hasToken: !!token }) + + if (!action || !orderId) { + setStatus('error') + Toast.show('参数错误') + setTimeout(() => navigate('/login', { replace: true }), 1500) + return + } + + // 检查是否登录 + if (!token) { + console.log('⚠️ 未登录,跳转到登录页') + setStatus('unauthorized') + Toast.show('请先登录') + setTimeout(() => { + window.location.href = '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search) + }, 1500) + return + } + + setStatus('processing') + + // 执行审批操作 + if (action === 'approve') { + console.log('✅ 执行通过操作') + await approvalApi.approve(Number(orderId), '') + Toast.show('已通过') + } else if (action === 'reject') { + console.log('❌ 执行拒绝操作') + await approvalApi.reject(Number(orderId), '已拒绝') + Toast.show('已拒绝') + } + + setStatus('success') + + // 操作成功后关闭页面(在飞书客户端中) + setTimeout(() => { + console.log('✅ 操作完成,关闭页面') + // 在飞书客户端中,关闭当前页面 + if ((window as any).tt && (window as any).tt.close) { + (window as any).tt.close() + } else { + // 其他情况跳转到审批列表 + navigate('/approval', { replace: true }) + } + }, 1000) + + } catch (error: any) { + console.error('❌ 操作失败:', error) + setStatus('error') + Toast.show(error.message || '操作失败') + setTimeout(() => navigate('/approval', { replace: true }), 2000) + } finally { + setLoading(false) + } + } + + processAction() + }, []) + + return ( +
+ {loading && ( + <> + +

处理中...

+ + )} + + {status === 'success' && ( + <> +
✅
+

操作成功

+ + )} + + {status === 'error' && ( + <> +
❌
+

操作失败

+ + )} +
+ ) +} diff --git a/frontend/src/router/index.tsx b/frontend/src/router/index.tsx index 350117a..672bbfd 100644 --- a/frontend/src/router/index.tsx +++ b/frontend/src/router/index.tsx @@ -11,6 +11,7 @@ import SelectApprover from '@/pages/business-trip/select-approver' import SelectCc from '@/pages/business-trip/select-cc' import ApprovalList from '@/pages/approval/list' import ApprovalDetail from '@/pages/approval/detail' +import QuickAction from '@/pages/approval/quick-action' import Login from '@/pages/login' import SimpleLogin from '@/pages/login-simple' import DebugFeishu from '@/pages/debug-feishu' @@ -32,6 +33,7 @@ const router = createBrowserRouter([ { path: 'business-trip/:id', element: }, { path: 'approval', element: }, { path: 'approval/:id', element: }, + { path: 'approval/quick-action', element: }, ], }, { path: '/login', element: },