| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639 |
- 'use client';
- import { useState, useEffect } from 'react';
- import { useRouter } from 'next/navigation';
- import { ArrowLeft, Users, Building2, Globe, DollarSign, Clock, CheckCircle2, ShieldCheck, Smartphone, Banknote } from 'lucide-react';
- import { productService, orderService, settlementService } from '@/lib/services';
- import { getCurrentUser } from '@/lib/auth';
- import ProductSearchSelector from '@/components/admin/orders/ProductSearchSelector';
- import AiDataParserPanel from '@/components/admin/orders/AiDataParserPanel';
- import DynamicOrderSchemaForm from '@/components/admin/orders/DynamicOrderSchemaForm';
- import AdminUserSelect from '@/components/common/AdminUserSelect';
- import { ImageUploadField } from '@/components/common/ImageUploadField';
- import { SchemaProperty, VasAgency } from '@/types';
- import { toast } from 'react-hot-toast';
- import { SUPPORTED_CURRENCIES, getCurrencySymbol } from '@/lib/currency';
- export default function AdminCreateOrderPage() {
- const router = useRouter();
- const [loading, setLoading] = useState(false);
- // 1. 商品状态
- const [selectedProduct, setSelectedProduct] = useState<any>(null);
- // 2. 渠道与分润归属状态
- const [channelType, setChannelType] = useState<'direct' | 'agency' | 'website'>('direct');
- const [handlerId, setHandlerId] = useState<string>('');
- const [agencies, setAgencies] = useState<VasAgency[]>([]);
- const [selectedAgencyId, setSelectedAgencyId] = useState<string>('');
- const [customPrice, setCustomPrice] = useState<string>(''); // 单位: 元/欧/刀
- const [currency, setCurrency] = useState<string>('CNY'); // 结算币种代码
- // 2.5 收款时机与收款登记状态
- const [paymentTiming, setPaymentTiming] = useState<'pay_later' | 'paid_now'>('pay_later');
- const [paymentMethod, setPaymentMethod] = useState<string>('wechat');
- const [externalTradeNo, setExternalTradeNo] = useState<string>('');
- const [voucherUrl, setVoucherUrl] = useState<string>('');
- const [paymentNote, setPaymentNote] = useState<string>('');
- // 3. 表单与 Schema 状态
- const [formSchema, setFormSchema] = useState<any>(null);
- const [formValues, setFormValues] = useState<Record<string, any>>({});
- const [sortedFields, setSortedFields] = useState<string[]>([]);
- // 加载中介列表与当前用户信息
- useEffect(() => {
- const user = getCurrentUser();
- if (user?.nickname || user?.id) {
- setHandlerId(user.nickname || user.id);
- }
- async function loadAgencies() {
- try {
- const res = await settlementService.listAgencies({ active_only: true });
- const list = res?.data?.items || res?.data || [];
- setAgencies(Array.isArray(list) ? list : []);
- } catch {
- setAgencies([]);
- }
- }
- loadAgencies();
- }, []);
- // 选中中介时自动锁定 handler_id
- const handleAgencySelect = (agencyId: string) => {
- setSelectedAgencyId(agencyId);
- const agency = agencies.find((a) => a.id === agencyId);
- if (agency) {
- setHandlerId(agency.owner_id);
- }
- };
- const selectedAgency = agencies.find((a) => a.id === selectedAgencyId);
- // 加载商品默认价与 Schema
- useEffect(() => {
- if (!selectedProduct) {
- setFormSchema(null);
- setSortedFields([]);
- setFormValues({});
- setCustomPrice('');
- return;
- }
- // 默认价格与币种填充: 优先取 price_amount,兼顾 base_price
- const prodCurrency = (selectedProduct.price_currency || selectedProduct.currency || 'CNY').toUpperCase();
- setCurrency(prodCurrency);
- if (selectedProduct.price_amount !== undefined) {
- setCustomPrice((selectedProduct.price_amount / 100).toFixed(2));
- } else if (selectedProduct.base_price !== undefined) {
- setCustomPrice((selectedProduct.base_price / 100).toFixed(2));
- }
- if (!selectedProduct.schema_id) {
- setFormSchema(null);
- setSortedFields([]);
- setFormValues({});
- return;
- }
- async function loadSchema() {
- try {
- const res = await productService.getSchemaDetail(selectedProduct.schema_id);
- const data = res?.data || res;
- const schemaJson =
- typeof data?.schema_json === 'string'
- ? JSON.parse(data.schema_json)
- : data?.schema_json;
- setFormSchema(schemaJson);
- setFormValues({});
- if (schemaJson?.properties) {
- const keys = Object.keys(schemaJson.properties);
- if (Array.isArray(schemaJson['ui:order'])) {
- setSortedFields(schemaJson['ui:order']);
- } else {
- const sorted = keys.sort((a, b) => {
- const propA = schemaJson.properties[a] as SchemaProperty;
- const propB = schemaJson.properties[b] as SchemaProperty;
- const orderA = propA['x-order'] ?? propA.order ?? 999;
- const orderB = propB['x-order'] ?? propB.order ?? 999;
- return orderA - orderB;
- });
- setSortedFields(sorted);
- }
- }
- } catch {
- toast.error('表单定义加载失败');
- }
- }
- loadSchema();
- }, [selectedProduct]);
- // AI 解析结果回填
- const handleAiFieldsParsed = (fields: Record<string, any>) => {
- setFormValues((prev) => ({
- ...prev,
- ...fields,
- }));
- };
- // 单个字段修改
- const handleInputChange = (key: string, value: any) => {
- setFormValues((prev) => ({ ...prev, [key]: value }));
- };
- // 提交订单
- const handleSubmit = async (e: React.FormEvent) => {
- e.preventDefault();
- if (!selectedProduct) return toast.error('请先搜索并选择商品');
- // 价格校验
- let finalAmountCents: number | undefined = undefined;
- if (customPrice && !isNaN(Number(customPrice))) {
- finalAmountCents = Math.round(Number(customPrice) * 100);
- }
- if (finalAmountCents === undefined || finalAmountCents <= 0) {
- return toast.error('请输入有效的金额 (必须大于 0)');
- }
- if (channelType === 'agency') {
- if (!selectedAgencyId) {
- return toast.error('请选择合作中介机构');
- }
- if (selectedAgency && finalAmountCents !== undefined && finalAmountCents < selectedAgency.min_floor_price) {
- const sym = getCurrencySymbol(currency);
- return toast.error(
- `录入价格 ${sym}${(finalAmountCents / 100).toFixed(2)} 低于该中介协议最低结算底价 ${sym}${(selectedAgency.min_floor_price / 100).toFixed(2)}!`
- );
- }
- }
- if (channelType === 'direct' && !handlerId.trim()) {
- return toast.error('社交自收直客单必须填写40%提成归属人ID/姓名');
- }
- setLoading(true);
- try {
- const payload = {
- product_id: selectedProduct.id,
- user_inputs: formValues,
- channel_type: channelType,
- agency_id: channelType === 'agency' ? selectedAgencyId : undefined,
- handler_id: channelType === 'website' ? undefined : handlerId.trim(),
- final_amount: finalAmountCents,
- currency: currency,
- payment_timing: paymentTiming,
- payment_method: paymentTiming === 'paid_now' ? paymentMethod : undefined,
- external_trade_no: paymentTiming === 'paid_now' ? (externalTradeNo.trim() || undefined) : undefined,
- voucher_url: paymentTiming === 'paid_now' ? (voucherUrl.trim() || undefined) : undefined,
- payment_note: paymentTiming === 'paid_now' ? (paymentNote.trim() || undefined) : undefined,
- };
- const res = await orderService.createByAdmin(payload);
- const orderId = res?.data?.id || res?.id || res?.data?.order_id || res?.order_id;
- if (paymentTiming === 'pay_later') {
- toast.success(`代客下单成功!任务已入队调度 [待出签/收款] 订单号: ${orderId}`);
- } else {
- toast.success(`代下单并收款核销成功!订单号: ${orderId}`);
- }
- router.push('/admin/orders');
- } catch (error: any) {
- console.error(error);
- toast.error('下单失败: ' + (error.response?.data?.message || error.message));
- } finally {
- setLoading(false);
- }
- };
- return (
- <div className="space-y-6 font-mono">
- {/* 头部导航 */}
- <div className="flex items-center justify-between border-b-2 border-black pb-4">
- <div className="flex items-center gap-3">
- <button
- onClick={() => router.back()}
- className="px-3 py-1.5 bg-white hover:bg-neutral-100 border-2 border-black text-xs font-bold uppercase shadow-[2px_2px_0px_#000] flex items-center gap-1"
- >
- <ArrowLeft size={14} /> [ 返回列表 ]
- </button>
- <div>
- <h1 className="text-base md:text-lg font-black uppercase text-black">
- [ DISPATCH // 管理员代客下单 ]
- </h1>
- <p className="text-[10px] text-neutral-500 font-mono">
- 手工为客户创建订单并即时下发抢单机器人调度队列
- </p>
- </div>
- </div>
- </div>
- <div className="space-y-6">
- {/* Step 1: 搜索选择商品 */}
- <ProductSearchSelector
- selectedProduct={selectedProduct}
- onSelectProduct={setSelectedProduct}
- />
- {/* Step 1.5: 渠道来源与合伙分润设置 */}
- {selectedProduct && (
- <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
- <div className="px-5 py-3 border-b-2 border-black bg-neutral-200 text-black flex items-center justify-between">
- <div className="flex items-center gap-2">
- <span className="w-5 h-5 bg-amber-300 border border-black flex items-center justify-center text-black text-[10px] font-black">
- 1.5
- </span>
- <label className="text-xs font-black uppercase tracking-wider text-black">
- [ CHANNEL & ASSIGNMENT // 渠道来源、销售归属与协议定价 ]
- </label>
- </div>
- <span className="text-[10px] text-neutral-500 font-bold uppercase">
- 40% 销售包干提成归属判定
- </span>
- </div>
- <div className="p-5 space-y-4">
- {/* 渠道类型选择 */}
- <div>
- <label className="text-xs font-black text-black uppercase block mb-2">
- [ 1. 选择业务合作渠道模式 ]
- </label>
- <div className="grid grid-cols-1 md:grid-cols-3 gap-3">
- {/* Direct */}
- <div
- onClick={() => {
- setChannelType('direct');
- const u = getCurrentUser();
- if (u?.nickname || u?.id) setHandlerId(u.nickname || u.id);
- }}
- className={`p-3.5 border-2 cursor-pointer transition ${
- channelType === 'direct'
- ? 'border-black bg-amber-100 shadow-[3px_3px_0px_#000]'
- : 'border-neutral-300 bg-neutral-50 hover:border-black'
- }`}
- >
- <div className="flex items-center gap-2 mb-1">
- <Users size={16} className="text-black" />
- <span className="text-xs font-black text-black uppercase">[ 社交自收直客 ]</span>
- </div>
- <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
- 小红书/微信自引流直客,拿该单 <strong>40% 销售包干提成</strong>,对录错承担全额赔偿。
- </p>
- </div>
- {/* Agency */}
- <div
- onClick={() => setChannelType('agency')}
- className={`p-3.5 border-2 cursor-pointer transition ${
- channelType === 'agency'
- ? 'border-black bg-purple-100 shadow-[3px_3px_0px_#000]'
- : 'border-neutral-300 bg-neutral-50 hover:border-black'
- }`}
- >
- <div className="flex items-center gap-2 mb-1">
- <Building2 size={16} className="text-purple-900" />
- <span className="text-xs font-black text-black uppercase">[ 中介同行渠道 ]</span>
- </div>
- <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
- 旅行社或同行转介绍,受<strong>专属底价</strong>保护,40%提成自动锁定归属该中介拓展人。
- </p>
- </div>
- {/* Website */}
- <div
- onClick={() => {
- setChannelType('website');
- setHandlerId('');
- }}
- className={`p-3.5 border-2 cursor-pointer transition ${
- channelType === 'website'
- ? 'border-black bg-neutral-200 shadow-[3px_3px_0px_#000]'
- : 'border-neutral-300 bg-neutral-50 hover:border-black'
- }`}
- >
- <div className="flex items-center gap-2 mb-1">
- <Globe size={16} className="text-black" />
- <span className="text-xs font-black text-black uppercase">[ 官网自主下单 ]</span>
- </div>
- <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
- 公海自然流量,无专属对接人,40%销售提成由合伙双方(各20%)平分。
- </p>
- </div>
- </div>
- </div>
- {/* 细化字段配置 */}
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4 pt-3 border-t-2 border-dashed border-neutral-300">
- {/* Direct: 接单客服 */}
- {channelType === 'direct' && (
- <div>
- <AdminUserSelect
- value={handlerId}
- onChange={setHandlerId}
- label="40% 销售包干提成归属人 (系统管理员)"
- badgeText="客服/销售"
- placeholder="选择系统管理员作为提成人"
- helperText="若录错护照/姓名导致废单,损失从该人当期提成中全额扣减。"
- required
- />
- </div>
- )}
- {/* Agency: 选择中介 */}
- {channelType === 'agency' && (
- <div className="space-y-2">
- <label className="text-xs font-black text-black uppercase block mb-1">
- [ 合作中介机构档案 ] <span className="text-rose-600">*</span>
- </label>
- <select
- value={selectedAgencyId}
- onChange={(e) => handleAgencySelect(e.target.value)}
- className="w-full px-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black cursor-pointer"
- >
- <option value="">-- 请选择合作中介机构 --</option>
- {agencies.map((agency) => (
- <option key={agency.id} value={agency.id}>
- {agency.name} (最低底价: ¥{(agency.min_floor_price / 100).toFixed(2)})
- </option>
- ))}
- </select>
- {selectedAgency && (
- <div className="p-2.5 bg-neutral-100 border border-black text-[11px] font-mono space-y-1">
- <div>
- <span className="text-neutral-500 font-bold">专属拓展维系人: </span>
- <span className="text-black font-black">{selectedAgency.owner_id}</span>
- <span className="text-[10px] text-purple-700 ml-1">(自动绑定拿40%提成)</span>
- </div>
- <div>
- <span className="text-neutral-500 font-bold">协议最低底价: </span>
- <span className="text-rose-600 font-black">¥{(selectedAgency.min_floor_price / 100).toFixed(2)}</span>
- <span className="text-[10px] text-neutral-400 ml-1">低于此底价系统将阻断提交</span>
- </div>
- </div>
- )}
- </div>
- )}
- {/* Website */}
- {channelType === 'website' && (
- <div className="p-3 bg-neutral-100 border border-black text-xs font-mono">
- <span className="text-neutral-500 font-bold block mb-1">公海单利润流转:</span>
- <p className="text-[11px] text-neutral-700 font-sans">
- 该单无专属对接人。40% 销售提成与 40% 合伙分红合并,由合伙人甲乙双方各按 50%(每人到手40%净利)平分;技术版权费 20% 归脚本开发者。
- </p>
- </div>
- )}
- </div>
- </div>
- </div>
- )}
- {/* Step 1.6: 收款时机与金额登记 */}
- {selectedProduct && (
- <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
- <div className="px-5 py-3 border-b-2 border-black bg-neutral-200 text-black flex items-center justify-between">
- <div className="flex items-center gap-2">
- <span className="w-5 h-5 bg-amber-300 border border-black flex items-center justify-center text-black text-[10px] font-black">
- 1.6
- </span>
- <label className="text-xs font-black uppercase tracking-wider text-black">
- [ PAYMENT & PRICING // 收款模式、结算金额与入账登记 ]
- </label>
- </div>
- <span className="text-[10px] text-neutral-500 font-bold uppercase">
- 先办后付 vs 现结核销
- </span>
- </div>
- <div className="p-5 space-y-4">
- {/* 收款时机选择 */}
- <div>
- <label className="text-xs font-black text-black uppercase block mb-2">
- [ 1. 选择收款与业务节奏模式 ]
- </label>
- <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
- {/* Pay later */}
- <div
- onClick={() => setPaymentTiming('pay_later')}
- className={`p-3.5 border-2 cursor-pointer transition ${
- paymentTiming === 'pay_later'
- ? 'border-black bg-amber-100 shadow-[3px_3px_0px_#000]'
- : 'border-neutral-300 bg-neutral-50 hover:border-black'
- }`}
- >
- <div className="flex items-center justify-between mb-1">
- <div className="flex items-center gap-2">
- <Clock size={16} className="text-amber-800" />
- <span className="text-xs font-black text-black uppercase">[ 先办后付 // 稍后收款 ]</span>
- </div>
- <span className="px-1.5 py-0.5 bg-amber-300 border border-black text-[9px] font-black">
- 业务推荐
- </span>
- </div>
- <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
- 先替客户下单,<strong>任务立即下发队列调度</strong>。待出签办妥或客户打款后,在后台随时一键<strong>[ 登记收款 ]</strong>生成流水。
- </p>
- </div>
- {/* Paid now */}
- <div
- onClick={() => setPaymentTiming('paid_now')}
- className={`p-3.5 border-2 cursor-pointer transition ${
- paymentTiming === 'paid_now'
- ? 'border-black bg-emerald-100 shadow-[3px_3px_0px_#000]'
- : 'border-neutral-300 bg-neutral-50 hover:border-black'
- }`}
- >
- <div className="flex items-center gap-2 mb-1">
- <CheckCircle2 size={16} className="text-emerald-800" />
- <span className="text-xs font-black text-black uppercase">[ 当场全款已收 // 现结录入 ]</span>
- </div>
- <p className="text-[11px] text-neutral-600 font-sans leading-relaxed">
- 客户已通过微信/支付宝/公户全款转账,现场直接核销入账,立即在数据库生成<strong>已支付流水凭据</strong>。
- </p>
- </div>
- </div>
- </div>
- {/* 金额输入及差额提示 */}
- <div className="pt-3 border-t-2 border-dashed border-neutral-300 grid grid-cols-1 md:grid-cols-2 gap-4">
- <div>
- <div className="flex items-center justify-between mb-1">
- <label className="text-xs font-black text-black uppercase">
- [ {paymentTiming === 'pay_later' ? '约定应收金额' : '实际到账金额'} ] <span className="text-rose-600">*</span>
- </label>
- <div className="flex items-center gap-1.5">
- <span className="text-[10px] text-neutral-500 font-bold uppercase">币种:</span>
- <select
- value={currency}
- onChange={(e) => setCurrency(e.target.value)}
- className="px-2 py-0.5 border-2 border-black bg-amber-100 text-xs font-black cursor-pointer shadow-[1px_1px_0px_#000] focus:outline-hidden"
- >
- {SUPPORTED_CURRENCIES.map((c) => (
- <option key={c.code} value={c.code}>
- {c.name}
- </option>
- ))}
- </select>
- </div>
- </div>
- <div className="relative">
- <span className="absolute left-3 top-2.5 text-xs font-bold text-black pointer-events-none">
- {getCurrencySymbol(currency)}
- </span>
- <input
- type="number"
- step="0.01"
- required
- value={customPrice}
- onChange={(e) => setCustomPrice(e.target.value)}
- placeholder="商品指导价"
- className="w-full pl-8 pr-3 py-2 border-2 border-black bg-neutral-50 text-xs font-mono font-black focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
- />
- </div>
- <div className="text-[10px] text-neutral-500 font-mono mt-1 flex items-center justify-between">
- <span>
- 商品指导标价: {getCurrencySymbol(selectedProduct.price_currency || 'CNY')}{((selectedProduct.price_amount || selectedProduct.base_price || 0) / 100).toFixed(2)} ({selectedProduct.price_currency || 'CNY'})
- </span>
- {customPrice && !isNaN(Number(customPrice)) && (
- <span className={`font-bold ${
- Number(customPrice) * 100 < (selectedProduct.price_amount || 0)
- ? 'text-rose-600'
- : Number(customPrice) * 100 > (selectedProduct.price_amount || 0)
- ? 'text-emerald-700'
- : 'text-neutral-500'
- }`}>
- 差额: {Number(customPrice) * 100 >= (selectedProduct.price_amount || 0) ? '+' : ''}{getCurrencySymbol(currency)}{((Number(customPrice) * 100 - (selectedProduct.price_amount || 0)) / 100).toFixed(2)}
- </span>
- )}
- </div>
- </div>
- {paymentTiming === 'pay_later' ? (
- <div className="p-3 bg-amber-50 border border-black text-xs font-mono flex items-start gap-2">
- <Clock size={16} className="text-amber-800 shrink-0 mt-0.5" />
- <div>
- <span className="text-black font-black block mb-0.5">先办后付调度保障:</span>
- <p className="text-[11px] text-neutral-700 font-sans leading-relaxed">
- 订单创建后将自动标记为 <strong>[ 待收款 (先办后付) ]</strong>,抢单机器人将以最高优先级即刻开始抓取办理。后续款项到手后,在订单列表点击 <strong>[ 💰 登记收款 ]</strong> 即可补录流水。
- </p>
- </div>
- </div>
- ) : (
- <div>
- <label className="text-xs font-black text-black uppercase block mb-1">
- [ 收款渠道方式 ] <span className="text-rose-600">*</span>
- </label>
- <div className="grid grid-cols-2 gap-2">
- {[
- { id: 'wechat', label: '微信私域转账' },
- { id: 'alipay', label: '支付宝转账' },
- { id: 'bank_transfer', label: '银行公户/私户' },
- { id: 'cash', label: '现金收款' },
- ].map((m) => (
- <button
- type="button"
- key={m.id}
- onClick={() => setPaymentMethod(m.id)}
- className={`px-2.5 py-1.5 border-2 text-xs font-bold text-left transition ${
- paymentMethod === m.id
- ? 'border-black bg-amber-300 text-black shadow-[2px_2px_0px_#000]'
- : 'border-neutral-300 bg-neutral-50 hover:border-black text-neutral-700'
- }`}
- >
- {m.label}
- </button>
- ))}
- </div>
- </div>
- )}
- </div>
- {/* 当场结清时的补充凭据 */}
- {paymentTiming === 'paid_now' && (
- <div className="grid grid-cols-1 md:grid-cols-3 gap-3 pt-3 border-t border-dashed border-neutral-300">
- <div>
- <label className="text-[11px] font-bold text-black uppercase block mb-1">
- 外部转账单号 (选填)
- </label>
- <input
- type="text"
- value={externalTradeNo}
- onChange={(e) => setExternalTradeNo(e.target.value)}
- placeholder="微信单号 / 银行流水号"
- className="w-full px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
- />
- </div>
- <div>
- <ImageUploadField
- label="转账水单/截图 (上传至 R2)"
- value={voucherUrl}
- onChange={setVoucherUrl}
- prefix="vouchers"
- maxSizeMB={5}
- helperText="点击选择水单截图,自动上传至 R2 对象存储"
- compact={true}
- />
- </div>
- <div>
- <label className="text-[11px] font-bold text-black uppercase block mb-1">
- 入账备注说明 (选填)
- </label>
- <input
- type="text"
- value={paymentNote}
- onChange={(e) => setPaymentNote(e.target.value)}
- placeholder="例如: 客户微信当面付清"
- className="w-full px-2.5 py-1.5 border-2 border-black bg-neutral-50 text-xs font-mono font-bold focus:bg-white outline-none shadow-[2px_2px_0px_#000] text-black"
- />
- </div>
- </div>
- )}
- </div>
- </div>
- )}
- {/* Step 2: 填写表单 (含 AI) */}
- {selectedProduct && (
- <form onSubmit={handleSubmit}>
- <div className="bg-white border-2 border-black shadow-[4px_4px_0px_#000] overflow-hidden">
- <div className="px-5 py-3 border-b-2 border-black bg-neutral-200 text-black flex items-center gap-2">
- <span className="w-5 h-5 bg-amber-300 border border-black flex items-center justify-center text-black text-[10px] font-black">
- 02
- </span>
- <label className="text-xs font-black uppercase tracking-wider text-black">
- [ APPLICANT DOSSIER // 填写申请资料与 Schema 字段 ]
- </label>
- </div>
- {/* AI 智能填充面板 */}
- {formSchema && (
- <AiDataParserPanel
- schemaId={selectedProduct.schema_id}
- onFieldsParsed={handleAiFieldsParsed}
- />
- )}
- {/* 动态表单项及底部提交按钮 */}
- <DynamicOrderSchemaForm
- formSchema={formSchema}
- sortedFields={sortedFields}
- formValues={formValues}
- onInputChange={handleInputChange}
- onSubmit={handleSubmit}
- loading={loading}
- selectedProduct={selectedProduct}
- />
- </div>
- </form>
- )}
- </div>
- </div>
- );
- }
|