| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- 'use client';
- import { useState } from 'react';
- import { Loader2, X, AlertTriangle } from 'lucide-react';
- import { toast } from 'react-hot-toast';
- import { ActionType } from '@/types';
- interface TicketActionModalProps {
- isOpen: boolean;
- onClose: () => void;
- ticketId: number | null;
- actionType: ActionType | null;
- onSubmit: (ticketId: number, type: ActionType, comment: string) => Promise<void>;
- }
- export default function TicketActionModal({ isOpen, onClose, ticketId, actionType, onSubmit }: TicketActionModalProps) {
- const [comment, setComment] = useState('');
- const [loading, setLoading] = useState(false);
- if (!isOpen || !ticketId || !actionType) return null;
- const handleSubmit = async () => {
- if (!comment.trim()) {
- toast.error("请输入处理备注");
- return;
- }
- setLoading(true);
- try {
- await onSubmit(ticketId, actionType, comment);
- setComment('');
- toast.success('工单处理成功');
- onClose();
- } catch (error) {
- // ignore
- } finally {
- setLoading(false);
- }
- };
- const config = {
- 'approve': { title: '批准退款申请', text: '确认核销批准' },
- 'reject': { title: '驳回申请诉求', text: '确认驳回' },
- 'need-info': { title: '要求申请人补件', text: '下发补件通知' },
- };
- const currentConfig = config[actionType];
- return (
- <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-grayscale font-mono">
- <div className="bg-neutral-50 border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-md overflow-hidden animate-in zoom-in-95 duration-200">
-
- {/* Header */}
- <div className="px-5 py-3.5 border-b-2 border-black flex justify-between items-center bg-neutral-200 text-black select-none">
- <div className="flex items-center gap-2 text-xs font-bold uppercase tracking-wider">
- <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
- <span>[ ACTION // #{ticketId} // {currentConfig.title} ]</span>
- </div>
- <button
- onClick={onClose}
- className="w-6 h-6 bg-white hover:bg-amber-300 border border-black flex items-center justify-center font-bold text-xs transition"
- >
- ✕
- </button>
- </div>
-
- <div className="p-6 bg-white space-y-4">
- <div className="space-y-1">
- <label className="block text-xs font-bold uppercase text-black">
- [ 管理员处理核批意见 / 答复说明 ]: <span className="text-black">*</span>
- </label>
- <textarea
- className="w-full border-2 border-black bg-neutral-50 p-2.5 text-xs font-sans focus:bg-white outline-none shadow-[2px_2px_0px_#000] resize-none text-black"
- rows={4}
- placeholder={actionType === 'reject' ? "请输入详细驳回理由..." : "请输入批准备注或补件指引..."}
- value={comment}
- onChange={e => setComment(e.target.value)}
- />
- </div>
- <div className="pt-2 flex justify-end gap-3 border-t-2 border-dashed border-neutral-300">
- <button
- onClick={onClose}
- className="px-4 py-2 border-2 border-black bg-neutral-100 hover:bg-neutral-200 text-black font-bold text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 uppercase"
- >
- [ 取消 ]
- </button>
- <button
- onClick={handleSubmit}
- disabled={loading}
- className="px-6 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[3px_3px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none flex items-center gap-1.5 uppercase disabled:opacity-50"
- >
- {loading ? <Loader2 size={14} className="animate-spin" /> : null}
- <span>[ {currentConfig.text} ]</span>
- </button>
- </div>
- </div>
- </div>
- </div>
- );
- }
|