|
@@ -1,5 +1,5 @@
|
|
|
-import { useEffect, useMemo, useState, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from "react";
|
|
|
|
|
-import { AlertTriangle, ArrowLeft, ArrowRight, Building2, CalendarClock, Check, CircleDollarSign, FileSignature, FileText, Lock, Network, PencilLine, Plus, Receipt, RefreshCcw, ScrollText, Trash2, UsersRound, X } from "lucide-react";
|
|
|
|
|
|
|
+import { useEffect, useMemo, useState, type ReactNode } from "react";
|
|
|
|
|
+import { AlertTriangle, ArrowLeft, ArrowRight, Building2, CalendarClock, Check, CircleDollarSign, FileSignature, FileText, Lock, Network, Plus, Receipt, RefreshCcw, ScrollText, Trash2, UsersRound, X } from "lucide-react";
|
|
|
import { FetchError } from "../components/fetchError";
|
|
import { FetchError } from "../components/fetchError";
|
|
|
import { Link, useLocation, useMatch, useNavigate, useParams } from "react-router";
|
|
import { Link, useLocation, useMatch, useNavigate, useParams } from "react-router";
|
|
|
import { Button } from "../components/ui/button";
|
|
import { Button } from "../components/ui/button";
|
|
@@ -8,13 +8,13 @@ import { FieldHint } from "../components/ui/field-hint";
|
|
|
import { OpsNotice, OpsStatus, OpsTag, OpsTableEmpty } from "../components/OperationsKit";
|
|
import { OpsNotice, OpsStatus, OpsTag, OpsTableEmpty } from "../components/OperationsKit";
|
|
|
import { ListPager } from "../components/ListPager";
|
|
import { ListPager } from "../components/ListPager";
|
|
|
import { ReferenceDrawer, type RefTarget } from "../components/ReferenceDrawer";
|
|
import { ReferenceDrawer, type RefTarget } from "../components/ReferenceDrawer";
|
|
|
|
|
+import { InlineEditButton, RecordInlineField as InlineField } from "../components/RecordInlineField";
|
|
|
import { RecordTabs } from "../components/RecordTabs";
|
|
import { RecordTabs } from "../components/RecordTabs";
|
|
|
import { Tri } from "../components/triState";
|
|
import { Tri } from "../components/triState";
|
|
|
import { contractFromDetail, contractRawByParam, contractSourceTone, contractStatusOf, contractStatusTone, useContracts } from "../lib/contract-demo";
|
|
import { contractFromDetail, contractRawByParam, contractSourceTone, contractStatusOf, contractStatusTone, useContracts } from "../lib/contract-demo";
|
|
|
import { contractUpdate, contractChangeLog, rowsOf } from "../lib/api/bos";
|
|
import { contractUpdate, contractChangeLog, rowsOf } from "../lib/api/bos";
|
|
|
import { ticketList, statusLabel, typeLabel } from "../lib/api/ticket";
|
|
import { ticketList, statusLabel, typeLabel } from "../lib/api/ticket";
|
|
|
import { fmtDate } from "../lib/ticket";
|
|
import { fmtDate } from "../lib/ticket";
|
|
|
-import { isImeComposing } from "../lib/ime";
|
|
|
|
|
import { ApiError } from "../lib/api/http";
|
|
import { ApiError } from "../lib/api/http";
|
|
|
import { ITEM_FAMILY, label, SUBJECT_TYPE, ORDER_MODE, ORDER_STATUS } from "../lib/api/labels";
|
|
import { ITEM_FAMILY, label, SUBJECT_TYPE, ORDER_MODE, ORDER_STATUS } from "../lib/api/labels";
|
|
|
import { WORD_NOT_PROVIDED, WORD_FETCH_FAILED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
|
|
import { WORD_NOT_PROVIDED, WORD_FETCH_FAILED, WORD_UNCONFIGURED } from "../lib/api/lockedCopy";
|
|
@@ -46,62 +46,6 @@ const orderEffective = (status?: string | null) =>
|
|
|
|
|
|
|
|
type ContractTab = "profile" | "business" | "services" | "subscriptions" | "tickets" | "billing" | "history";
|
|
type ContractTab = "profile" | "business" | "services" | "subscriptions" | "tickets" | "billing" | "history";
|
|
|
|
|
|
|
|
-type InlineFieldProps = {
|
|
|
|
|
- id: string;
|
|
|
|
|
- label: string;
|
|
|
|
|
- value: string;
|
|
|
|
|
- editing: boolean;
|
|
|
|
|
- writable: boolean;
|
|
|
|
|
- onStart: () => void;
|
|
|
|
|
- onChange: (value: string) => void;
|
|
|
|
|
- onDone: () => void;
|
|
|
|
|
- onCancel: () => void;
|
|
|
|
|
- type?: "text" | "date" | "number";
|
|
|
|
|
- inputMode?: "decimal" | "numeric" | "text";
|
|
|
|
|
- min?: number;
|
|
|
|
|
- max?: number;
|
|
|
|
|
- step?: number | string;
|
|
|
|
|
- placeholder?: string;
|
|
|
|
|
- display?: ReactNode;
|
|
|
|
|
- emptyText?: string;
|
|
|
|
|
- invalid?: boolean;
|
|
|
|
|
- error?: ReactNode;
|
|
|
|
|
- selectOptions?: readonly { value: string; label: string }[];
|
|
|
|
|
- /** 只读原因:给了就在值后面挂一把锁并带悬停说明,避免"看不到铅笔"被当成页面坏了。 */
|
|
|
|
|
- lockedReason?: string;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * 详情里的单个可编辑项:非编辑态只渲染值,鼠标移入才显出铅笔;点铅笔切到输入态。
|
|
|
|
|
- * 改动先进页面草稿,由底部「保存修改」一次性整段提交(契约 §3.2 全量替换)。
|
|
|
|
|
- */
|
|
|
|
|
-function InlineField({ id, label, value, editing, writable, onStart, onChange, onDone, onCancel, type = "text", inputMode, min, max, step, placeholder, display, emptyText = WORD_UNCONFIGURED, invalid, error, selectOptions, lockedReason }: InlineFieldProps) {
|
|
|
|
|
- const shown = display ?? (value || missingValue(emptyText));
|
|
|
|
|
- if (!writable) return <span className={lockedReason ? "contract-inline-field is-locked" : "contract-inline-readonly"}>{shown}{lockedReason && <span className="contract-inline-lock" role="img" aria-label={lockedReason} title={lockedReason}><Lock size={12} /></span>}</span>;
|
|
|
|
|
- if (!editing) return <span className="contract-inline-field">
|
|
|
|
|
- <span className="contract-inline-value">{shown}</span>
|
|
|
|
|
- <button type="button" className="contract-inline-edit" aria-label={`编辑${label}`} title={`编辑${label}`} onClick={onStart}><PencilLine size={14} /></button>
|
|
|
|
|
- </span>;
|
|
|
|
|
- const onKeyDown = (event: ReactKeyboardEvent) => {
|
|
|
|
|
- // 输入法上屏用的 Enter/Esc ⛔ 当成「保存/取消」,否则拼音选字就被提交了。
|
|
|
|
|
- if (isImeComposing(event)) return;
|
|
|
|
|
- if (event.key === "Enter") { event.preventDefault(); onDone(); }
|
|
|
|
|
- if (event.key === "Escape") { event.preventDefault(); onCancel(); }
|
|
|
|
|
- };
|
|
|
|
|
- return <span className="contract-inline-editor">
|
|
|
|
|
- {selectOptions ? (
|
|
|
|
|
- <select id={id} aria-label={label} autoFocus value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown}>
|
|
|
|
|
- {selectOptions.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
|
|
|
|
|
- </select>
|
|
|
|
|
- ) : (
|
|
|
|
|
- <Input id={id} aria-label={label} autoFocus type={type} inputMode={inputMode} min={min} max={max} step={step} placeholder={placeholder} aria-invalid={invalid || undefined} value={value} onChange={(event) => onChange(event.target.value)} onKeyDown={onKeyDown} />
|
|
|
|
|
- )}
|
|
|
|
|
- <button type="button" className="contract-inline-ok" aria-label="完成编辑" title="完成" onClick={onDone}><Check size={14} /></button>
|
|
|
|
|
- <button type="button" className="contract-inline-cancel" aria-label="取消编辑" title="取消" onClick={onCancel}><X size={14} /></button>
|
|
|
|
|
- {error}
|
|
|
|
|
- </span>;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
export function ContractRecordPage() {
|
|
export function ContractRecordPage() {
|
|
|
const { no } = useParams();
|
|
const { no } = useParams();
|
|
|
const param = decodeURIComponent(no ?? "");
|
|
const param = decodeURIComponent(no ?? "");
|
|
@@ -774,11 +718,11 @@ export function ContractRecordPage() {
|
|
|
<td className="table-number">{item.quantity}</td>
|
|
<td className="table-number">{item.quantity}</td>
|
|
|
<td>{accounts === null ? <Tri tone="missing" text={WORD_UNCONFIGURED} title="目录档位额度未下发" /> : <span className="table-number">{accounts}</span>}</td>
|
|
<td>{accounts === null ? <Tri tone="missing" text={WORD_UNCONFIGURED} title="目录档位额度未下发" /> : <span className="table-number">{accounts}</span>}</td>
|
|
|
<td>{item.exits.join("、") || "—"}</td>
|
|
<td>{item.exits.join("、") || "—"}</td>
|
|
|
- {billingWritable && <td className="contract-item-actions-col">
|
|
|
|
|
- <button type="button" className="contract-row-edit" aria-label={`编辑条目 ${index + 1}`} title={`编辑条目 ${index + 1}`} onClick={() => { setEditingField(null); setEditingItem(index); }}><PencilLine size={15} />编辑</button>
|
|
|
|
|
|
|
+ {billingWritable && <td className="contract-item-actions-col"><div className="contract-item-row-actions">
|
|
|
|
|
+ <InlineEditButton label={`编辑条目 ${index + 1}`} text="编辑" onClick={() => { setEditingField(null); setEditingItem(index); }} />
|
|
|
{/* D-7:叠加服务只从链路节点下新增,页面上⛔ 平级「新增叠加服务」入口。 */}
|
|
{/* D-7:叠加服务只从链路节点下新增,页面上⛔ 平级「新增叠加服务」入口。 */}
|
|
|
- {!child && (item.planFamily === "link" || item.itemMode === "increment") && <button type="button" className="contract-row-edit" aria-label={`在条目 ${index + 1} 下添加叠加服务`} title="在该链路下添加叠加服务(出口只能从父行已选出口里取)" onClick={() => { if (item.itemMode === "increment") addIncrementChild(item); else addChildItem(item.key); }}><Plus size={14} />叠加服务</button>}
|
|
|
|
|
- </td>}
|
|
|
|
|
|
|
+ {!child && (item.planFamily === "link" || item.itemMode === "increment") && <button type="button" className="record-inline-action" aria-label={`在条目 ${index + 1} 下添加叠加服务`} title="在该链路下添加叠加服务(出口只能从父行已选出口里取)" onClick={() => { if (item.itemMode === "increment") addIncrementChild(item); else addChildItem(item.key); }}><Plus size={14} />叠加服务</button>}
|
|
|
|
|
+ </div></td>}
|
|
|
</tr>;
|
|
</tr>;
|
|
|
})}
|
|
})}
|
|
|
{!draft.items.length && <OpsTableEmpty colSpan={billingWritable ? 6 : 5}>本合同暂无服务条目。</OpsTableEmpty>}
|
|
{!draft.items.length && <OpsTableEmpty colSpan={billingWritable ? 6 : 5}>本合同暂无服务条目。</OpsTableEmpty>}
|