|
@@ -11,17 +11,20 @@ import { todoRowDueOn } from "../../lib/work-order-todo-row";
|
|
|
|
|
|
|
|
type OwnerColumn = "assignee" | "team" | "none";
|
|
type OwnerColumn = "assignee" | "team" | "none";
|
|
|
type DateColumn = "created_at" | "completed_at";
|
|
type DateColumn = "created_at" | "completed_at";
|
|
|
|
|
+type LedgerItem = Omit<TicketListItem, "status"> & { status?: TicketListItem["status"] };
|
|
|
|
|
|
|
|
-function TicketLedgerRow({ item, from, ownerColumn, dateColumn, showNextStep, extraAction, mobile = false }: {
|
|
|
|
|
- item: TicketListItem;
|
|
|
|
|
|
|
+function TicketLedgerRow({ item, from, ownerColumn, dateColumn, showNextStep, showStatus, extraAction, mobile = false }: {
|
|
|
|
|
+ item: LedgerItem;
|
|
|
from: string;
|
|
from: string;
|
|
|
ownerColumn: OwnerColumn;
|
|
ownerColumn: OwnerColumn;
|
|
|
dateColumn: DateColumn;
|
|
dateColumn: DateColumn;
|
|
|
showNextStep: boolean;
|
|
showNextStep: boolean;
|
|
|
|
|
+ showStatus: boolean;
|
|
|
extraAction?: ReactNode;
|
|
extraAction?: ReactNode;
|
|
|
mobile?: boolean;
|
|
mobile?: boolean;
|
|
|
}) {
|
|
}) {
|
|
|
- const step = showNextStep ? nextStepOf(item) : null;
|
|
|
|
|
|
|
+ const statusCode = item.status ?? "";
|
|
|
|
|
+ const step = showNextStep ? nextStepOf({ ...item, status: statusCode }) : null;
|
|
|
const href = `/work-orders/${encodeURIComponent(item.ticket_id)}`;
|
|
const href = `/work-orders/${encodeURIComponent(item.ticket_id)}`;
|
|
|
const state = { from };
|
|
const state = { from };
|
|
|
const due = todoRowDueOn(item);
|
|
const due = todoRowDueOn(item);
|
|
@@ -34,7 +37,7 @@ function TicketLedgerRow({ item, from, ownerColumn, dateColumn, showNextStep, ex
|
|
|
const deadline = due ? due.replaceAll("-", ".") : <span className="table-placeholder">—</span>;
|
|
const deadline = due ? due.replaceAll("-", ".") : <span className="table-placeholder">—</span>;
|
|
|
const dateValue = item[dateColumn];
|
|
const dateValue = item[dateColumn];
|
|
|
const date = dateValue ? fmtTime(dateValue) : <span className="table-placeholder">—</span>;
|
|
const date = dateValue ? fmtTime(dateValue) : <span className="table-placeholder">—</span>;
|
|
|
- const status = <TicketStatusTag status={item.status} type={item.ticket_type} />;
|
|
|
|
|
|
|
+ const status = showStatus && <TicketStatusTag status={statusCode} type={item.ticket_type} />;
|
|
|
const type = <TicketTypeTag type={item.ticket_type} />;
|
|
const type = <TicketTypeTag type={item.ticket_type} />;
|
|
|
const action = step?.label
|
|
const action = step?.label
|
|
|
? <Link className={`work-order-next-step tone-${step.tone}`} to={step.action ? `${href}?act=${step.action}` : href} state={state}>{step.label}</Link>
|
|
? <Link className={`work-order-next-step tone-${step.tone}`} to={step.action ? `${href}?act=${step.action}` : href} state={state}>{step.label}</Link>
|
|
@@ -79,13 +82,13 @@ function TicketLedgerRow({ item, from, ownerColumn, dateColumn, showNextStep, ex
|
|
|
</td>
|
|
</td>
|
|
|
<td className="order-date" title={dateValue || undefined}>{date}</td>
|
|
<td className="order-date" title={dateValue || undefined}>{date}</td>
|
|
|
{step && <td>{action}<small title={step.hint}>{step.hint}</small></td>}
|
|
{step && <td>{action}<small title={step.hint}>{step.hint}</small></td>}
|
|
|
- <td>{status}</td>
|
|
|
|
|
|
|
+ {showStatus && <td>{status}</td>}
|
|
|
<td>{actions}</td>
|
|
<td>{actions}</td>
|
|
|
</tr>
|
|
</tr>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export function WorkOrderLedgerList<T extends TicketListItem>({
|
|
|
|
|
|
|
+export function WorkOrderLedgerList<T extends LedgerItem>({
|
|
|
rows,
|
|
rows,
|
|
|
from,
|
|
from,
|
|
|
label,
|
|
label,
|
|
@@ -94,6 +97,7 @@ export function WorkOrderLedgerList<T extends TicketListItem>({
|
|
|
ownerColumn = clientView ? "none" : "assignee",
|
|
ownerColumn = clientView ? "none" : "assignee",
|
|
|
dateColumn = "created_at",
|
|
dateColumn = "created_at",
|
|
|
showNextStep = !clientView,
|
|
showNextStep = !clientView,
|
|
|
|
|
+ showStatus = true,
|
|
|
renderRowAction,
|
|
renderRowAction,
|
|
|
}: {
|
|
}: {
|
|
|
rows: readonly T[];
|
|
rows: readonly T[];
|
|
@@ -104,6 +108,7 @@ export function WorkOrderLedgerList<T extends TicketListItem>({
|
|
|
ownerColumn?: OwnerColumn;
|
|
ownerColumn?: OwnerColumn;
|
|
|
dateColumn?: DateColumn;
|
|
dateColumn?: DateColumn;
|
|
|
showNextStep?: boolean;
|
|
showNextStep?: boolean;
|
|
|
|
|
+ showStatus?: boolean;
|
|
|
renderRowAction?: (item: T) => ReactNode;
|
|
renderRowAction?: (item: T) => ReactNode;
|
|
|
}) {
|
|
}) {
|
|
|
const tableOverflow = useHorizontalOverflow();
|
|
const tableOverflow = useHorizontalOverflow();
|
|
@@ -115,13 +120,14 @@ export function WorkOrderLedgerList<T extends TicketListItem>({
|
|
|
{ label: dateColumn === "completed_at" ? "完成时间" : "创建时间", weight: 14 },
|
|
{ label: dateColumn === "completed_at" ? "完成时间" : "创建时间", weight: 14 },
|
|
|
...(showNextStep ? [{ label: "下一步", weight: 16 }] : []),
|
|
...(showNextStep ? [{ label: "下一步", weight: 16 }] : []),
|
|
|
];
|
|
];
|
|
|
- const columns = [...infoColumns.map((column) => column.label), "状态", "操作"];
|
|
|
|
|
- const minWidth = clientView ? 980 : showNextStep ? 1280 : ownerColumn === "none" ? 980 : 1120;
|
|
|
|
|
|
|
+ const columns = [...infoColumns.map((column) => column.label), ...(showStatus ? ["状态"] : []), "操作"];
|
|
|
|
|
+ const statusWidth = showStatus ? 140 : 0;
|
|
|
|
|
+ const minWidth = (clientView ? 980 : showNextStep ? 1280 : ownerColumn === "none" ? 980 : 1120) - (showStatus ? 0 : 140);
|
|
|
const actionWidth = renderRowAction ? 172 : 92;
|
|
const actionWidth = renderRowAction ? 172 : 92;
|
|
|
- const bodyWidth = Math.max(minWidth, tableOverflow.width) - 140 - actionWidth;
|
|
|
|
|
|
|
+ const bodyWidth = Math.max(minWidth, tableOverflow.width) - statusWidth - actionWidth;
|
|
|
const totalWeight = infoColumns.reduce((sum, column) => sum + column.weight, 0);
|
|
const totalWeight = infoColumns.reduce((sum, column) => sum + column.weight, 0);
|
|
|
- const columnWidths = infoColumns.map((column) => bodyWidth * column.weight / totalWeight).concat(140, actionWidth);
|
|
|
|
|
- const rowOptions = { from, ownerColumn, dateColumn, showNextStep };
|
|
|
|
|
|
|
+ const columnWidths = [...infoColumns.map((column) => bodyWidth * column.weight / totalWeight), ...(showStatus ? [statusWidth] : []), actionWidth];
|
|
|
|
|
+ const rowOptions = { from, ownerColumn, dateColumn, showNextStep, showStatus };
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|