|
|
@@ -11,21 +11,20 @@
|
|
|
* ⛔ 把未上传的文件名随单提交,材料在建单后到工单详情直传(§5.8)。
|
|
|
*/
|
|
|
import { useCallback, useEffect, useId, useState, type FormEvent } from "react";
|
|
|
-import { ArrowRight, Check, CircleAlert, ClipboardCheck, ClipboardList, Clock3, FileText, Info, RefreshCw, Search, Send, X } from "lucide-react";
|
|
|
+import { ArrowRight, Check, CircleAlert, ClipboardCheck, ClipboardList, Clock3, FileText, Headphones, Info, Paperclip, RefreshCw, Search, Send, Wrench, X } from "lucide-react";
|
|
|
import { Link, useLocation, useSearchParams } from "react-router";
|
|
|
import { Button } from "../components/ui/button";
|
|
|
+import { Input } from "../components/ui/input";
|
|
|
import { SearchInput } from "../components/ui/search-input";
|
|
|
import { FilterSelect } from "../components/ui/filter-select";
|
|
|
import { DateRangeFilter } from "../components/ui/date-range-filter";
|
|
|
-import { FieldHint } from "../components/ui/field-hint";
|
|
|
import { ServerListPager } from "../components/ListPager";
|
|
|
import { TicketState } from "../components/ticketState";
|
|
|
import { TicketStatusTag, TicketTypeTag } from "../components/work-order/TicketBadges";
|
|
|
import { PageIntro } from "../components/PageIntro";
|
|
|
-import { WorkspaceEmpty, WorkspaceHeading, WorkspacePanel } from "../components/RoleWorkspaceKit";
|
|
|
+import { WorkspaceEmpty } from "../components/RoleWorkspaceKit";
|
|
|
import { OpsDialog, OpsNotice, OpsTableColumns } from "../components/OperationsKit";
|
|
|
import { useDemoIdentity } from "../lib/demo-session";
|
|
|
-import { readCustomers } from "../lib/customer-records";
|
|
|
import { detailLinkState } from "../lib/detail-navigation";
|
|
|
import { classifyTicketError, fmtTime, TICKET_PAGE_SIZE, useTicketDetail, useTicketList } from "../lib/ticket";
|
|
|
import { ticketCreate, TICKET_STATUSES, TICKET_TYPES, nonMainlineStatusLabel, typeLabel, ticketConfirmClose, ticketWithdraw } from "../lib/api/ticket";
|
|
|
@@ -38,12 +37,19 @@ import "../styles/operations.css";
|
|
|
import "../styles/orders.css";
|
|
|
import "../styles/work-orders.css";
|
|
|
import "../styles/work-order-ledger.css";
|
|
|
+import "../styles/customer-ticket-submit.css";
|
|
|
+
|
|
|
+const REQUEST_TYPES = [
|
|
|
+ { code: "fault", icon: Wrench, description: "连接异常、网络中断或服务不可用" },
|
|
|
+ { code: "after_sale", icon: Headphones, description: "使用咨询或已开通服务的协助" },
|
|
|
+] as const;
|
|
|
+
|
|
|
+type RequestType = (typeof REQUEST_TYPES)[number]["code"];
|
|
|
|
|
|
export function CustomerSubmitPage() {
|
|
|
const location = useLocation();
|
|
|
const identity = useDemoIdentity();
|
|
|
- const customer = readCustomers().find((item) => item.no === identity?.customerNo);
|
|
|
- const [type, setType] = useState<"fault" | "after_sale">("fault");
|
|
|
+ const [type, setType] = useState<RequestType>("fault");
|
|
|
const [title, setTitle] = useState("");
|
|
|
const [description, setDescription] = useState("");
|
|
|
const [errors, setErrors] = useState({ title: "", desc: "" });
|
|
|
@@ -54,16 +60,18 @@ export function CustomerSubmitPage() {
|
|
|
|
|
|
async function onSubmit(event: FormEvent) {
|
|
|
event.preventDefault();
|
|
|
+ if (submit.busy) return;
|
|
|
setDone(null);
|
|
|
+ submit.clear();
|
|
|
// D-17:⛔ HTML5 required 静默拦截——浏览器先拦则提示永不出现;校验一律走这里。
|
|
|
// 一次提交收集**全部**缺失项一并回显,⛔ 只报第一条(修完一条又冒下一条=挤牙膏)。
|
|
|
const next = {
|
|
|
- title: title.trim().length < 2 || title.trim().length > 128 ? "请填写事项标题(2–128 字,服务端必填)。" : "",
|
|
|
- desc: description.trim().length < 2 ? "请至少填写 2 个字,描述具体事项。" : "",
|
|
|
+ title: title.trim().length < 2 || title.trim().length > 128 ? "事项标题需填写 2 至 128 个字。" : "",
|
|
|
+ desc: description.trim().length < 2 ? "请至少填写 2 个字,说明具体情况。" : "",
|
|
|
};
|
|
|
setErrors(next);
|
|
|
if (next.title || next.desc) return;
|
|
|
- const ok = await submit.run(() => ticketCreate({
|
|
|
+ await submit.run(() => ticketCreate({
|
|
|
ticket_type: type,
|
|
|
title: title.trim(),
|
|
|
detail: description.trim(),
|
|
|
@@ -71,39 +79,112 @@ export function CustomerSubmitPage() {
|
|
|
setDone({ id: r.ticket_id, no: r.ticket_no });
|
|
|
setTitle(""); setDescription("");
|
|
|
}));
|
|
|
- if (!ok) return;
|
|
|
}
|
|
|
const failure = submit.error ? classifyTicketError(submit.error) : null;
|
|
|
const titleInvalid = Boolean(errors.title);
|
|
|
const descInvalid = Boolean(errors.desc);
|
|
|
|
|
|
- return <section className="role-workspace">
|
|
|
- <WorkspaceHeading title="提交故障或售后" description={`为 ${customer?.name ?? identity.customerNo ?? "本企业"} 提交服务请求,运维团队受理后可在工单中跟进。`} aside={<Link className="workspace-link" to="/workspace/progress">查看工单进度 <ArrowRight size={15} /></Link>} />
|
|
|
- <div className="workspace-split">
|
|
|
- <WorkspacePanel title="描述需要协助的事项" description="尽量说明发生时间、影响范围和具体表现,便于团队定位。">
|
|
|
- {done && <div className="workspace-success" role="status"><Check size={18} /><span>{`工单 ${done.no} 已提交,运维团队将尽快与您联系。`} <Link className="workspace-link" to={`/work-orders/${encodeURIComponent(done.no ?? done.id)}`} state={detailState}>查看工单 <ArrowRight size={14} /></Link></span></div>}
|
|
|
- <form className="workspace-form !pt-0" noValidate onSubmit={onSubmit}>
|
|
|
- <label className="workspace-field"><span>事项类型 <em>*</em></span><select value={type} onChange={(event) => setType(event.target.value as "fault" | "after_sale")}><option value="fault">故障报修</option><option value="after_sale">售后服务</option></select></label>
|
|
|
- <label className="workspace-field"><span>事项标题 <em>*</em><FieldHint label="事项标题说明">受理方按标题快速识别事项,最长 128 字。</FieldHint></span><input maxLength={128} placeholder="一句话说明诉求" value={title} aria-invalid={titleInvalid || undefined} aria-describedby={titleInvalid ? "submit-title-error" : undefined} onChange={(event) => { setTitle(event.target.value); setErrors((prev) => (prev.title ? { ...prev, title: "" } : prev)); }} />{titleInvalid && <small id="submit-title-error" className="workspace-error" role="alert">{errors.title}</small>}</label>
|
|
|
- <label className="workspace-field"><span>问题描述 <em>*</em></span><textarea maxLength={1000} rows={7} placeholder="例如:今天上午办公应用无法访问,已重启客户端,仍提示连接超时……" value={description} aria-invalid={descInvalid || undefined} aria-describedby={descInvalid ? "submit-desc-error" : undefined} onChange={(event) => { setDescription(event.target.value); setErrors((prev) => (prev.desc ? { ...prev, desc: "" } : prev)); }} /><small>{description.length} / 1000 字</small>{descInvalid && <small id="submit-desc-error" className="workspace-error" role="alert">{errors.desc}</small>}</label>
|
|
|
- <p className="text-[13px] leading-6 text-muted-foreground">现场照片、录音等材料请在工单创建后到工单详情上传。</p>
|
|
|
- {(errors.title || errors.desc) && <p className="workspace-error" role="alert">请补全以下内容后重新提交:{[errors.title, errors.desc].filter(Boolean).join(";")}</p>}
|
|
|
- {failure && <p className="workspace-error" role="alert">{failure.message}</p>}
|
|
|
- {submit.busy && <p className="text-sm text-muted-foreground">提交中…</p>}
|
|
|
- <footer><Button type="submit" disabled={submit.busy}><Send size={16} />提交工单</Button></footer>
|
|
|
- </form>
|
|
|
- </WorkspacePanel>
|
|
|
- <aside className="workspace-panel workspace-aside">
|
|
|
- <h3>提交之后会发生什么</h3>
|
|
|
- <ol>
|
|
|
- <li><strong>团队受理与分派</strong><br />工单先进入挂接的运维团队,由团队主账号安排责任人。</li>
|
|
|
- <li><strong>处理与进度记录</strong><br />在「工单进度」中查看处理记录和结果;本人提交的单在完成前可填写原因撤回。</li>
|
|
|
- <li><strong>确认关闭</strong><br />运维标记完成后,由提交人确认关闭,形成服务闭环。</li>
|
|
|
- </ol>
|
|
|
- <p className="mt-5 border-t border-border pt-4 text-[13px]">每次提交都会生成一张独立工单,请在「工单进度」中分别跟踪。此入口只受理故障与售后;开户、停机与套餐变更请联系运营办理。</p>
|
|
|
- </aside>
|
|
|
- </div>
|
|
|
- </section>;
|
|
|
+ return (
|
|
|
+ <section className="order-page customer-ticket-submit">
|
|
|
+ <header className="order-heading">
|
|
|
+ <div>
|
|
|
+ <h1>提交故障或售后</h1>
|
|
|
+ <PageIntro>向运维团队报修或申请售后协助。</PageIntro>
|
|
|
+ </div>
|
|
|
+ <Link className="ops-table-action" to="/workspace/progress">查看工单进度<ArrowRight size={15} aria-hidden="true" /></Link>
|
|
|
+ </header>
|
|
|
+
|
|
|
+ <div className="customer-request-layout">
|
|
|
+ <section className="order-list-shell customer-request-panel" aria-labelledby="customer-request-heading">
|
|
|
+ <header className="customer-request-panel-heading">
|
|
|
+ <h2 id="customer-request-heading">填写工单</h2>
|
|
|
+ </header>
|
|
|
+
|
|
|
+ {done && <div className="customer-request-success" role="status">
|
|
|
+ <Check size={18} aria-hidden="true" />
|
|
|
+ <div><strong>工单已提交</strong><span>{done.no}</span></div>
|
|
|
+ <Link className="ops-table-action" to={`/work-orders/${encodeURIComponent(done.no ?? done.id)}`} state={detailState}>查看工单<ArrowRight size={14} aria-hidden="true" /></Link>
|
|
|
+ </div>}
|
|
|
+
|
|
|
+ <form noValidate onSubmit={onSubmit} aria-busy={submit.busy}>
|
|
|
+ <div className="customer-request-fields">
|
|
|
+ <fieldset className="customer-request-type" disabled={submit.busy}>
|
|
|
+ <legend>事项类型</legend>
|
|
|
+ <div className="customer-request-options">
|
|
|
+ {REQUEST_TYPES.map(({ code, icon: Icon, description }) => (
|
|
|
+ <label className="customer-request-choice" key={code}>
|
|
|
+ <input className="sr-only" type="radio" name="ticket-type" value={code} checked={type === code} onChange={() => setType(code)} />
|
|
|
+ <span className="customer-request-choice-icon"><Icon size={18} aria-hidden="true" /></span>
|
|
|
+ <span className="customer-request-choice-text"><strong>{typeLabel(code)}</strong><small>{description}</small></span>
|
|
|
+ <span className="customer-request-choice-marker" aria-hidden="true" />
|
|
|
+ </label>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </fieldset>
|
|
|
+
|
|
|
+ <div className="customer-request-field">
|
|
|
+ <label htmlFor="customer-request-title">事项标题 <span aria-hidden="true">*</span></label>
|
|
|
+ <Input
|
|
|
+ id="customer-request-title"
|
|
|
+ required
|
|
|
+ maxLength={128}
|
|
|
+ placeholder="用一句话概括需要协助的事项"
|
|
|
+ value={title}
|
|
|
+ disabled={submit.busy}
|
|
|
+ aria-invalid={titleInvalid || undefined}
|
|
|
+ aria-describedby={titleInvalid ? "submit-title-error" : undefined}
|
|
|
+ onChange={(event) => {
|
|
|
+ setTitle(event.target.value);
|
|
|
+ setErrors((prev) => prev.title ? { ...prev, title: "" } : prev);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {titleInvalid && <small id="submit-title-error" className="customer-request-error" role="alert">{errors.title}</small>}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div className="customer-request-field">
|
|
|
+ <label htmlFor="customer-request-description">问题描述 <span aria-hidden="true">*</span></label>
|
|
|
+ <textarea
|
|
|
+ id="customer-request-description"
|
|
|
+ required
|
|
|
+ maxLength={1000}
|
|
|
+ rows={6}
|
|
|
+ placeholder="请说明发生时间、涉及的服务和影响范围,也可补充已尝试的处理方法。"
|
|
|
+ value={description}
|
|
|
+ disabled={submit.busy}
|
|
|
+ aria-invalid={descInvalid || undefined}
|
|
|
+ aria-describedby={descInvalid ? "submit-desc-error" : undefined}
|
|
|
+ onChange={(event) => {
|
|
|
+ setDescription(event.target.value);
|
|
|
+ setErrors((prev) => prev.desc ? { ...prev, desc: "" } : prev);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <div className="customer-request-field-meta">
|
|
|
+ {descInvalid && <small id="submit-desc-error" className="customer-request-error" role="alert">{errors.desc}</small>}
|
|
|
+ <span>{description.length} / 1000 字</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ {failure && <p className="ops-form-error" role="alert">{failure.message}</p>}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <footer className="customer-request-footer">
|
|
|
+ <p><Paperclip size={15} aria-hidden="true" />提交后可在工单详情补充照片、录音等材料。</p>
|
|
|
+ <Button type="submit" disabled={submit.busy}><Send size={16} aria-hidden="true" />{submit.busy ? "提交中…" : "提交工单"}</Button>
|
|
|
+ </footer>
|
|
|
+ </form>
|
|
|
+ </section>
|
|
|
+
|
|
|
+ <aside className="order-list-shell customer-request-guide" aria-labelledby="customer-request-guide-heading">
|
|
|
+ <h2 id="customer-request-guide-heading">提交后如何跟进</h2>
|
|
|
+ <ol>
|
|
|
+ <li><strong>等待运维受理</strong><p>运维团队收到工单后会安排人员处理。</p></li>
|
|
|
+ <li><strong>查看处理进度</strong><p>在“工单进度”查看记录。本人提交的工单可在处理完成前撤回。</p></li>
|
|
|
+ <li><strong>确认处理结果</strong><p>运维标记完成后,可确认并关闭工单。</p></li>
|
|
|
+ </ol>
|
|
|
+ <p className="customer-request-scope"><Info size={15} aria-hidden="true" />开户、停机或套餐变更,请联系运营对接人。</p>
|
|
|
+ </aside>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/* ═════════════════ 工单进度=客户侧「我的工单」(缺陷 P-21)════════════════ */
|