Mẫu giao diện
Mỗi mẫu là một file app/page.tsx viết bằng framework Manh, chạy ngay trong trang với dữ liệu giả. Tab Code để xem và sao chép, Mở để sửa để sửa thử trong Playground. Khi giao việc cho agent, nêu tên mẫu là đủ để nó dựng màn hình theo đúng khung đó.
App trọn vẹn (giao diện, API, database, dữ liệu mẫu) nằm ở trang App mẫu.
Khung app ProLayout
Menu nhiều cấp, nút chuyển app, avatar người dùng. App nào cũng bắt đầu từ khung này.
// Khung app: ProLayout mix + menu nhóm 3 cấp + app launcher 9 chấm + icon header + avatar.
// Trong app thật: menuItemRender dùng useNavigate()/<Link>, location = useLocation().
import { useState } from "react";
import { PageContainer, ProCard, ProLayout } from "@ant-design/pro-components";
import { Dropdown, Typography, theme } from "antd";
import {
AppstoreOutlined, AuditOutlined, BarChartOutlined, FileTextOutlined, GithubFilled,
InfoCircleFilled, LogoutOutlined, QuestionCircleFilled, ShoppingOutlined, TeamOutlined,
} from "@ant-design/icons";
const route = {
path: "/",
children: [
{
path: "/ops", name: "Vận hành", icon: <AppstoreOutlined />,
children: [
{ path: "/ops/orders", name: "Đơn hàng", icon: <ShoppingOutlined />, children: [
{ path: "/ops/orders/all", name: "Tất cả đơn" },
{ path: "/ops/orders/pending", name: "Chờ xử lý" },
] },
{ path: "/ops/requests", name: "Đề xuất mua sắm", icon: <FileTextOutlined />, children: [
{ path: "/ops/requests/mine", name: "Của tôi" },
{ path: "/ops/requests/inbox", name: "Cần tôi duyệt" },
] },
],
},
{
path: "/report", name: "Báo cáo", icon: <BarChartOutlined />,
children: [
{ path: "/report/sales", name: "Doanh số", icon: <BarChartOutlined />, children: [
{ path: "/report/sales/month", name: "Theo tháng" },
] },
],
},
],
};
const appList = [
{ title: "Nội bộ", desc: "Ứng dụng của công ty", children: [
{ title: "CRM", desc: "Khách hàng & cơ hội", icon: <TeamOutlined />, url: "#crm" },
{ title: "Kho", desc: "Tồn kho & phiếu xuất", icon: <ShoppingOutlined />, url: "#kho" },
] },
{ title: "Công cụ", desc: "Dùng chung", children: [
{ title: "Duyệt mua sắm", desc: "Đề xuất & phê duyệt", icon: <AuditOutlined />, url: "#duyet" },
] },
];
export default function Page() {
const { token } = theme.useToken();
const [pathname, setPathname] = useState("/ops/orders/all");
return (
<div style={{ height: "100vh" }}>
<ProLayout
title="Acme Admin"
logo={<AuditOutlined style={{ fontSize: 22, color: token.colorPrimary }} />}
layout="mix"
splitMenus
siderMenuType="group"
menu={{ collapsedShowGroupTitle: true, locale: false }}
fixSiderbar
route={route}
location={{ pathname }}
menuItemRender={(item, dom) => <a onClick={() => item.path && setPathname(item.path)}>{dom}</a>}
appList={appList}
bgLayoutImgList={[
{ src: "https://img.alicdn.com/imgextra/i2/O1CN01O4etvp1DvpFLKfuWq_!!6000000000279-2-tps-609-606.png", left: 85, bottom: 100, height: "303px" },
{ src: "https://img.alicdn.com/imgextra/i3/O1CN018NxReL1shX85Yz6Cx_!!6000000005798-2-tps-884-496.png", bottom: 0, left: 0, width: "331px" },
]}
actionsRender={(p) => (p.isMobile ? [] : [<InfoCircleFilled key="i" />, <QuestionCircleFilled key="q" />, <GithubFilled key="g" />])}
avatarProps={{
size: "small",
title: "Nguyễn Thu Hà",
src: "https://manh.run/avatars/06.svg",
render: (_, dom) => <Dropdown menu={{ items: [{ key: "out", icon: <LogoutOutlined />, label: "Đăng xuất" }] }}>{dom}</Dropdown>,
}}
menuFooterRender={(p) => (p?.collapsed ? undefined : <div style={{ textAlign: "center", paddingBlockStart: 12, color: token.colorTextTertiary }}>v1.0 · Acme</div>)}
>
<PageContainer subTitle={pathname}>
<ProCard>
<Typography.Paragraph>
Bấm các mục menu (trên: nhóm cấp 1, trái: tiêu đề nhóm cấp 2 + mục cấp 3) và nút 9 chấm cạnh logo.
</Typography.Paragraph>
</ProCard>
</PageContainer>
</ProLayout>
</div>
);
}
Làm màn hình "Khung app ProLayout" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Khung app: ProLayout mix + menu nhóm 3 cấp + app launcher 9 chấm + icon header + avatar. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Đăng nhập
Đăng nhập bằng email và mật khẩu, trả về JWT. Có sẵn khi tạo project từ starter đăng nhập.
// Đăng nhập: LoginForm của pro-components, có label (truy cập + test tìm theo label), lỗi server hiện trong `message`.
import { useState } from "react";
import { LoginForm, ProFormCheckbox, ProFormText } from "@ant-design/pro-components";
import { Alert, Flex, Typography, theme } from "antd";
import { AuditOutlined, LockOutlined, MailOutlined } from "@ant-design/icons";
export default function Page() {
const { token } = theme.useToken();
const [error, setError] = useState<string | null>(null);
return (
<Flex vertical justify="center" style={{ minHeight: "100vh", background: `linear-gradient(180deg, ${token.colorPrimaryBg} 0%, ${token.colorBgLayout} 45%)` }}>
<LoginForm
logo={<AuditOutlined style={{ fontSize: 40, color: token.colorPrimary }} />}
title="Duyệt mua sắm"
subTitle="Đề xuất, duyệt và theo dõi chi tiêu mua sắm"
submitter={{ searchConfig: { submitText: "Đăng nhập" } }}
initialValues={{ remember: true }}
message={error ? <Alert type="error" showIcon title={error} style={{ marginBottom: 24 }} /> : undefined}
actions={
<Flex vertical gap={8}>
<Typography.Text type="secondary">Chưa có tài khoản? <a>Đăng ký</a></Typography.Text>
{/* Mẫu giao diện (Playground / docs): nói rõ là demo để không ai nhập mật khẩu thật. */}
<Typography.Text type="secondary" style={{ fontSize: 12 }}>Bản demo giao diện — không nhập mật khẩu thật, không có dữ liệu nào được gửi đi. Mật khẩu thử: 123456.</Typography.Text>
</Flex>
}
onFinish={async (v: { email: string; password: string }) => {
// Thử: mật khẩu khác "123456" sẽ báo lỗi như server trả 401.
if (v.password !== "123456") { setError("Sai email hoặc mật khẩu"); return false; }
setError(null);
return true;
}}
>
<ProFormText name="email" label="Email" placeholder="ten@congty.vn" fieldProps={{ size: "large", prefix: <MailOutlined /> }} rules={[{ required: true, type: "email", message: "Nhập email hợp lệ" }]} />
<ProFormText.Password name="password" label="Mật khẩu" placeholder="Mật khẩu" fieldProps={{ size: "large", prefix: <LockOutlined />, autoComplete: "off" }} rules={[{ required: true, message: "Nhập mật khẩu" }]} />
<div style={{ marginBlockEnd: 24 }}>
<ProFormCheckbox noStyle name="remember">Ghi nhớ đăng nhập</ProFormCheckbox>
<a style={{ float: "right" }}>Quên mật khẩu?</a>
</div>
</LoginForm>
</Flex>
);
}
Làm màn hình "Đăng nhập" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Đăng nhập: LoginForm của pro-components, có label (truy cập + test tìm theo label), lỗi server hiện trong `message`. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Danh sách ProTable
Form tìm kiếm, tab trạng thái có số đếm, chọn nhiều dòng để duyệt cùng lúc, phân trang từ API.
// Danh sách: ProTable với form tìm kiếm, tab trạng thái có số đếm, chọn nhiều để duyệt, valueEnum dạng Badge.
// Trong app thật: request gọi api.<resource>.list(...) và trả { data, total, success: true }.
import { useMemo, useRef, useState } from "react";
import { PageContainer, ProTable, type ActionType, type ProColumns } from "@ant-design/pro-components";
import { App, Badge, Button, Popconfirm, Space, Typography } from "antd";
import { CheckOutlined, PlusOutlined } from "@ant-design/icons";
type Status = "pending" | "approved" | "rejected";
type Row = { id: number; title: string; amount: number; owner: string; dept: string; status: Status; category: string; createdAt: string };
const STATUS = {
pending: { text: "Chờ duyệt", status: "Processing" },
approved: { text: "Đã duyệt", status: "Success" },
rejected: { text: "Từ chối", status: "Error" },
} as const;
const CATEGORY = { office: { text: "Văn phòng phẩm" }, equipment: { text: "Thiết bị" }, software: { text: "Phần mềm" } };
const vnd = (n: number) => `${n.toLocaleString("vi-VN")} ₫`;
const SEED: Row[] = [
{ id: 9, title: "Gia hạn Microsoft 365 (12 tháng, 10 user)", amount: 18600000, owner: "Trần Thị Lan", dept: "Hành chính", status: "pending", category: "software", createdAt: "2026-11-10" },
{ id: 8, title: "2 màn hình Dell P2423 cho team dev", amount: 7800000, owner: "Lê Văn Minh", dept: "Kỹ thuật", status: "pending", category: "equipment", createdAt: "2026-11-09" },
{ id: 7, title: "Giấy in A4 (20 ram)", amount: 2400000, owner: "Trần Thị Lan", dept: "Hành chính", status: "approved", category: "office", createdAt: "2026-11-05" },
{ id: 6, title: "Bàn phím cơ cho dev", amount: 1890000, owner: "Lê Văn Minh", dept: "Kỹ thuật", status: "rejected", category: "equipment", createdAt: "2026-11-02" },
];
export default function Page() {
const { message } = App.useApp();
const ref = useRef<ActionType>(undefined);
const [rows, setRows] = useState(SEED);
const [tab, setTab] = useState<"all" | Status>("pending");
const counts = useMemo(() => ({
all: rows.length,
pending: rows.filter((r) => r.status === "pending").length,
approved: rows.filter((r) => r.status === "approved").length,
rejected: rows.filter((r) => r.status === "rejected").length,
}), [rows]);
const columns: ProColumns<Row>[] = [
{ title: "Tiêu đề", dataIndex: "title", ellipsis: true, fieldProps: { placeholder: "Tìm theo tiêu đề" },
render: (_, r) => (
<Space orientation="vertical" size={0}>
<Typography.Link strong>{r.title}</Typography.Link>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>#{r.id} · {r.createdAt}</Typography.Text>
</Space>
) },
{ title: "Số tiền", dataIndex: "amount", align: "right", search: false, render: (_, r) => <b>{vnd(r.amount)}</b> },
{ title: "Người tạo", dataIndex: "owner", search: false,
render: (_, r) => <Space orientation="vertical" size={0}><span>{r.owner}</span><Typography.Text type="secondary" style={{ fontSize: 12 }}>{r.dept}</Typography.Text></Space> },
{ title: "Trạng thái", dataIndex: "status", valueEnum: STATUS, search: false },
{ title: "Hạng mục", dataIndex: "category", valueType: "select", valueEnum: CATEGORY },
{ title: "Thao tác", valueType: "option", render: () => [<a key="v">Xem</a>] },
];
return (
<PageContainer title="Tất cả đề xuất" subTitle="Duyệt hoặc từ chối đề xuất của nhân viên">
<ProTable<Row>
actionRef={ref}
rowKey="id"
cardBordered
columns={columns}
params={{ tab, rows }}
search={{ labelWidth: "auto", searchText: "Tìm", resetText: "Xoá lọc" }}
pagination={{ pageSize: 10, showTotal: (t) => `${t} đề xuất` }}
request={async (p: Record<string, unknown>) => {
const data = rows
.filter((r) => tab === "all" || r.status === tab)
.filter((r) => !p.title || r.title.toLowerCase().includes(String(p.title).toLowerCase()))
.filter((r) => !p.category || r.category === p.category);
return { data, total: data.length, success: true };
}}
toolbar={{
menu: {
type: "tab",
activeKey: tab,
onChange: (k) => setTab(k as typeof tab),
items: (["all", "pending", "approved", "rejected"] as const).map((k) => ({
key: k,
label: <span>{k === "all" ? "Tất cả" : STATUS[k].text}<Badge count={counts[k]} color={k === "pending" ? "orange" : "#bfbfbf"} style={{ marginInlineStart: 6 }} /></span>,
})),
},
}}
rowSelection={tab === "pending" ? {} : undefined}
tableAlertRender={({ selectedRows }) => <span>Đã chọn <b>{selectedRows.length}</b> · tổng <b>{vnd(selectedRows.reduce((a, r) => a + r.amount, 0))}</b></span>}
tableAlertOptionRender={({ selectedRows, onCleanSelected }) => (
<Space>
<a onClick={onCleanSelected}>Bỏ chọn</a>
<Popconfirm title={`Duyệt ${selectedRows.length} đề xuất?`} onConfirm={() => {
const ids = new Set(selectedRows.map((r) => r.id));
setRows((all) => all.map((r) => (ids.has(r.id) ? { ...r, status: "approved" } : r)));
message.success(`Đã duyệt ${ids.size} đề xuất`);
onCleanSelected();
}}>
<Button type="primary" size="small" icon={<CheckOutlined />}>Duyệt đã chọn</Button>
</Popconfirm>
</Space>
)}
toolBarRender={() => [<Button key="n" type="primary" icon={<PlusOutlined />}>Tạo yêu cầu</Button>]}
/>
</PageContainer>
);
}
Làm màn hình "Danh sách ProTable" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Danh sách: ProTable với form tìm kiếm, tab trạng thái có số đếm, chọn nhiều để duyệt, valueEnum dạng Badge. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Danh sách dạng thẻ
Lưới thẻ có nhãn, thanh tiến độ, rê chuột vào thì hiện nút thao tác.
// Danh sách dạng thẻ: lưới Card (title, tag, avatar, mô tả, tiến độ, thao tác khi hover).
import { PageContainer } from "@ant-design/pro-components";
import { Avatar, Card, Progress, Segmented, Tag } from "antd";
import { useState } from "react";
/** Mock people get a face (manh.run avatars 01–24), the same one for the same name. */
const face = (name: string) => {
let h = 0;
for (const ch of name) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
return `https://manh.run/avatars/${String((h % 24) + 1).padStart(2, "0")}.svg`;
};
const projects = [
{ id: 1, name: "Triển khai CRM", owner: "Lê Văn Minh", tag: "Đang chạy", pct: 72, desc: "Chuyển khách hàng từ Excel sang CRM, đào tạo 12 sales." },
{ id: 2, name: "Kiểm kê kho Q4", owner: "Trần Thị Lan", tag: "Sắp hạn", pct: 40, desc: "Đối soát tồn kho 3 kho trước 30/11." },
{ id: 3, name: "Website tuyển dụng", owner: "Phạm Quốc Bảo", tag: "Hoàn tất", pct: 100, desc: "Trang tuyển dụng mới + form ứng tuyển." },
{ id: 4, name: "Số hoá hợp đồng", owner: "Nguyễn Thu Hà", tag: "Đang chạy", pct: 18, desc: "Scan và gắn nhãn 1.200 hợp đồng cũ." },
];
const TAG_COLOR: Record<string, string> = { "Đang chạy": "processing", "Sắp hạn": "warning", "Hoàn tất": "success" };
export default function Page() {
const [filter, setFilter] = useState("Tất cả");
const data = projects.filter((p) => filter === "Tất cả" || p.tag === filter);
return (
<PageContainer title="Dự án" extra={<Segmented options={["Tất cả", "Đang chạy", "Sắp hạn", "Hoàn tất"]} value={filter} onChange={(v) => setFilter(String(v))} />}>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
{data.map((r) => (
<Card key={r.id} hoverable className="group">
<Card.Meta
avatar={<Avatar src={face(r.owner)} alt={r.owner} />}
title={
<div className="flex flex-wrap items-center gap-2">
<span>{r.name}</span>
<Tag color={TAG_COLOR[r.tag]}>{r.tag}</Tag>
</div>
}
description={r.desc}
/>
<Progress className="!mt-3" percent={r.pct} size="small" status={r.pct === 100 ? "success" : "active"} />
<div className="mt-2 flex justify-end gap-4 opacity-0 transition-opacity group-hover:opacity-100">
<a>Mở</a>
<a>Sửa</a>
</div>
</Card>
))}
</div>
</PageContainer>
);
}
Làm màn hình "Danh sách dạng thẻ" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Danh sách dạng thẻ: lưới Card (title, tag, avatar, mô tả, tiến độ, thao tác khi hover). Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Kanban kéo thả
Cột theo trạng thái, kéo thẻ giữa các cột bằng dnd-kit.
// Kanban pipeline khách hàng: @dnd-kit kéo thẻ giữa các cột, đếm và tổng giá trị mỗi cột, thẻ ProCard theo token antd.
import { useMemo, useState } from "react";
import { PageContainer } from "@ant-design/pro-components";
import { Avatar, Badge, Card, Flex, Tag, Typography, theme } from "antd";
import { DndContext, DragOverlay, PointerSensor, useDroppable, useDraggable, useSensor, useSensors, type DragEndEvent, type DragStartEvent } from "@dnd-kit/core";
/** Mock people get a face (manh.run avatars 01–24), the same one for the same name. */
const face = (name: string) => {
let h = 0;
for (const ch of name) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
return `https://manh.run/avatars/${String((h % 24) + 1).padStart(2, "0")}.svg`;
};
type Stage = "lead" | "contact" | "quote" | "won";
type Deal = { id: string; name: string; company: string; value: number; owner: string; stage: Stage };
const STAGES: Array<{ key: Stage; title: string; color: string }> = [
{ key: "lead", title: "Khách tiềm năng", color: "default" },
{ key: "contact", title: "Đã liên hệ", color: "processing" },
{ key: "quote", title: "Đã báo giá", color: "warning" },
{ key: "won", title: "Chốt đơn", color: "success" },
];
const DEALS: Deal[] = [
{ id: "d1", name: "Phần mềm kho", company: "Cty An Khang", value: 120_000_000, owner: "Minh", stage: "lead" },
{ id: "d2", name: "Gói CRM 20 user", company: "Đông Á Group", value: 85_000_000, owner: "Lan", stage: "contact" },
{ id: "d3", name: "Bảo trì năm 2027", company: "Thép Việt", value: 40_000_000, owner: "Bảo", stage: "quote" },
{ id: "d4", name: "Tích hợp hoá đơn", company: "Café Mộc", value: 25_000_000, owner: "Minh", stage: "won" },
{ id: "d5", name: "Dashboard bán hàng", company: "Siêu thị Xanh", value: 60_000_000, owner: "Hà", stage: "lead" },
];
const vnd = (n: number) => n.toLocaleString("vi-VN") + " ₫";
function DealCard({ deal, dragging }: { deal: Deal; dragging?: boolean }) {
return (
<Card size="small" style={{ cursor: "grab", opacity: dragging ? 0.4 : 1 }}>
<Typography.Text strong>{deal.name}</Typography.Text>
<div style={{ fontSize: 12 }}>
<Typography.Text type="secondary">{deal.company}</Typography.Text>
</div>
<Flex justify="space-between" align="center" style={{ marginTop: 8 }}>
<Typography.Text>{vnd(deal.value)}</Typography.Text>
<Avatar size="small" src={face(deal.owner)} alt={deal.owner} />
</Flex>
</Card>
);
}
function Draggable({ deal }: { deal: Deal }) {
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({ id: deal.id });
return (
<div ref={setNodeRef} {...listeners} {...attributes}>
<DealCard deal={deal} dragging={isDragging} />
</div>
);
}
function Column({ stage, deals }: { stage: (typeof STAGES)[number]; deals: Deal[] }) {
const { token } = theme.useToken();
const { setNodeRef, isOver } = useDroppable({ id: stage.key });
const total = deals.reduce((a, d) => a + d.value, 0);
return (
<div
ref={setNodeRef}
style={{ flex: "1 1 240px", minWidth: 220, background: isOver ? token.colorPrimaryBg : token.colorFillQuaternary, borderRadius: token.borderRadiusLG, padding: token.paddingSM }}
>
<Flex justify="space-between" align="center" style={{ marginBottom: 8 }}>
<Flex gap={6} align="center">
<Tag color={stage.color}>{stage.title}</Tag>
<Badge count={deals.length} showZero color={token.colorTextTertiary} />
</Flex>
<Typography.Text type="secondary" style={{ fontSize: 12 }}>{vnd(total)}</Typography.Text>
</Flex>
<Flex vertical gap={8} style={{ minHeight: 120 }}>
{deals.map((d) => (
<Draggable key={d.id} deal={d} />
))}
</Flex>
</div>
);
}
export default function Page() {
const [deals, setDeals] = useState(DEALS);
const [active, setActive] = useState<string | null>(null);
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
const byStage = useMemo(() => Object.fromEntries(STAGES.map((s) => [s.key, deals.filter((d) => d.stage === s.key)])), [deals]);
const onStart = (e: DragStartEvent) => setActive(String(e.active.id));
const onEnd = (e: DragEndEvent) => {
setActive(null);
const to = e.over?.id as Stage | undefined;
if (!to) return;
// Real app: await api.deals.update(id, { stage: to }) then refresh().
setDeals((ds) => ds.map((d) => (d.id === e.active.id ? { ...d, stage: to } : d)));
};
return (
<PageContainer title="Pipeline khách hàng" subTitle="Kéo thẻ sang cột khác để đổi giai đoạn">
<DndContext sensors={sensors} onDragStart={onStart} onDragEnd={onEnd}>
<Flex gap={12} wrap align="flex-start">
{STAGES.map((s) => (
<Column key={s.key} stage={s} deals={byStage[s.key]} />
))}
</Flex>
<DragOverlay>{active ? <DealCard deal={deals.find((d) => d.id === active)!} /> : null}</DragOverlay>
</DndContext>
</PageContainer>
);
}
Làm màn hình "Kanban kéo thả (dnd-kit)" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Kanban pipeline khách hàng: @dnd-kit kéo thẻ giữa các cột, đếm và tổng giá trị mỗi cột, thẻ ProCard theo token antd. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Dashboard
Chỉ số theo tháng, việc cần làm xếp theo hạn, biểu đồ vòng theo hạng mục.
// Dashboard người duyệt: StatisticCard.Group (mỗi số có dòng phụ) + danh sách việc cần làm (Listy) + biểu đồ donut.
import { PageContainer, ProCard, StatisticCard } from "@ant-design/pro-components";
import { Avatar, Button, Col, Flex, Grid, Listy, Row, Space, Typography, theme } from "antd";
import { ClockCircleOutlined, RightOutlined } from "@ant-design/icons";
import { Pie } from "@ant-design/charts";
/** Mock people get a face (manh.run avatars 01–24), the same one for the same name. */
const face = (name: string) => {
let h = 0;
for (const ch of name) h = (h * 31 + ch.charCodeAt(0)) >>> 0;
return `https://manh.run/avatars/${String((h % 24) + 1).padStart(2, "0")}.svg`;
};
const { Statistic } = StatisticCard;
const vnd = (n: number) => `${n.toLocaleString("vi-VN")} ₫`;
const todo = [
{ id: 10, title: "Sửa điều hoà phòng họp tầng 3", who: "Trần Thị Lan · Hành chính", due: "08/11 · quá hạn", late: true, amount: 1500000 },
{ id: 9, title: "Gia hạn Microsoft 365 (12 tháng)", who: "Trần Thị Lan · Hành chính", due: "13/11", late: false, amount: 18600000 },
{ id: 8, title: "2 màn hình Dell P2423", who: "Lê Văn Minh · Kỹ thuật", due: "15/11", late: false, amount: 7800000 },
];
export default function Page() {
const { token } = theme.useToken();
const md = Grid.useBreakpoint().md;
return (
<PageContainer title="Chào buổi chiều, Nguyễn Thu Hà" subTitle="3 đề xuất đang chờ bạn duyệt"
extra={<Button type="primary">Mở hộp duyệt <RightOutlined /></Button>}>
{/* Cards share one left/right edge: Flex for the vertical rhythm, Row/Col for columns (not ProCard gutter). */}
<Flex vertical gap={16}>
<StatisticCard.Group direction={md ? "row" : "column"}>
<StatisticCard statistic={{ title: "Đang chờ duyệt", value: 3, description: <Statistic title="Giá trị" value={vnd(27900000)} /> }} />
<StatisticCard.Divider type={md ? "vertical" : "horizontal"} />
<StatisticCard statistic={{ title: "Đã duyệt tháng này", value: 12090000, formatter: (v) => vnd(Number(v)), description: <Statistic title="So với tháng trước" value="tăng 12%" /> }} />
<StatisticCard.Divider type={md ? "vertical" : "horizontal"} />
<StatisticCard statistic={{ title: "Từ chối tháng này", value: 1, description: <Statistic title="Tổng đề xuất" value={8} /> }} />
</StatisticCard.Group>
<Row gutter={[16, 16]}>
<Col xs={24} lg={15}>
<ProCard title="Cần tôi duyệt" subTitle="gần hạn trước" extra={<a>Xem tất cả</a>} headerBordered style={{ height: "100%" }}>
<Listy
rowKey="id"
items={todo}
rowHoverable={false}
itemRender={(r) => (
<div className="flex items-start gap-3">
<Avatar className="shrink-0" src={face(r.who)} alt={r.who} />
<div className="min-w-0 flex-1">
<div className="font-medium">{r.title}</div>
<Space size={12} className="text-fg-secondary"><span>{r.who}</span><Typography.Text type={r.late ? "danger" : "secondary"}><ClockCircleOutlined /> {r.due}</Typography.Text></Space>
</div>
<b className="shrink-0">{vnd(r.amount)}</b>
</div>
)}
/>
</ProCard>
</Col>
<Col xs={24} lg={9}>
<ProCard title="Đã duyệt tháng này" subTitle="theo hạng mục" headerBordered style={{ height: "100%" }}>
<Pie
height={260}
data={[{ type: "Thiết bị", value: 4990000 }, { type: "Văn phòng phẩm", value: 2400000 }, { type: "Dịch vụ", value: 4700000 }]}
angleField="value"
colorField="type"
innerRadius={0.62}
label={false}
legend={{ color: { position: "bottom", layout: { justifyContent: "center" } } }}
tooltip={{ items: [{ field: "value", valueFormatter: (v: number) => vnd(v) }] }}
/>
</ProCard>
</Col>
</Row>
</Flex>
</PageContainer>
);
}
Làm màn hình "Dashboard" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Dashboard người duyệt: StatisticCard.Group (mỗi số có dòng phụ) + danh sách việc cần làm (Listy) + biểu đồ donut. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Form trong Drawer
Tạo và sửa bản ghi trong Drawer, kiểm tra dữ liệu nhập, khi chưa có dữ liệu thì hiện hướng dẫn.
// Form tạo/sửa trong DrawerForm: ProFormMoney (₫), nhóm field, tooltip, chặn ngày quá khứ, trả true để đóng.
import { useState } from "react";
import { DrawerForm, PageContainer, ProCard, ProFormDatePicker, ProFormGroup, ProFormMoney, ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-components";
import { App, Button, Empty, Listy } from "antd";
import { PlusOutlined } from "@ant-design/icons";
import dayjs from "dayjs";
type Req = { title: string; amount: number; category: string; neededBy?: string };
export default function Page() {
const { message } = App.useApp();
const [items, setItems] = useState<Req[]>([]);
return (
<PageContainer title="Đề xuất của tôi">
<ProCard
title="Đã gửi"
headerBordered
extra={
<DrawerForm<Record<string, unknown>>
title="Tạo yêu cầu mua sắm"
width={560}
trigger={<Button type="primary" icon={<PlusOutlined />}>Tạo yêu cầu</Button>}
drawerProps={{ destroyOnHidden: true }}
submitter={{ searchConfig: { submitText: "Gửi đề xuất", resetText: "Huỷ" } }}
initialValues={{ category: "office" }}
onFinish={async (v) => {
setItems((x) => [{ title: String(v.title), amount: Number(v.amount), category: String(v.category), neededBy: v.neededBy ? String(v.neededBy) : undefined }, ...x]);
message.success("Đã gửi đề xuất — đang chờ quản lý duyệt");
return true; // đóng drawer
}}
>
<ProFormText name="title" label="Tiêu đề" placeholder="VD: Gia hạn Microsoft 365" tooltip="Viết đủ để quản lý hiểu không cần mở chi tiết" rules={[{ required: true, min: 3, message: "Ít nhất 3 ký tự" }]} />
<ProFormGroup>
<ProFormMoney name="amount" label="Số tiền" width="sm" customSymbol="₫" locale="vi-VN" min={1} fieldProps={{ precision: 0 }} rules={[{ required: true, message: "Nhập số tiền" }]} />
<ProFormSelect name="category" label="Hạng mục" width="sm" valueEnum={{ office: "Văn phòng phẩm", equipment: "Thiết bị", software: "Phần mềm", service: "Dịch vụ" }} rules={[{ required: true }]} />
</ProFormGroup>
<ProFormDatePicker name="neededBy" label="Cần trước ngày" width="sm" fieldProps={{ format: "DD/MM/YYYY", disabledDate: (d: dayjs.Dayjs) => d.isBefore(dayjs().startOf("day")) }}
// submitted in the DISPLAY format ("20/11/2026") — convert to ISO for the API
transform={(v: string | undefined) => ({ neededBy: v ? v.split("/").reverse().join("-") : undefined })} />
<ProFormTextArea name="description" label="Mô tả" placeholder="Lý do, nhà cung cấp, link báo giá…" fieldProps={{ rows: 4, maxLength: 2000, showCount: true }} />
</DrawerForm>
}
>
{items.length ? (
(items?.length ? (
<Listy items={items} itemRender={(r) => <div className="flex items-start gap-4">
<div className="min-w-0 flex-1">{r.title}{r.neededBy ? ` · cần trước ${r.neededBy}` : ""}</div>
<div className="shrink-0"><b>{r.amount.toLocaleString("vi-VN")} ₫</b></div>
</div>}
rowKey={(_, i) => i}
rowHoverable={false}
/>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
))
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="Chưa có đề xuất nào — bấm “Tạo yêu cầu”." />
)}
</ProCard>
</PageContainer>
);
}
Làm màn hình "Form trong Drawer" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Form tạo/sửa trong DrawerForm: ProFormMoney (₫), nhóm field, tooltip, chặn ngày quá khứ, trả true để đóng. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Form nhiều bước
Phiếu chuyển kho ba bước: điền, xác nhận, hoàn tất.
// Form nhiều bước: StepsForm (điền → xác nhận → kết quả). Bước cuối ẩn nút, hiện Result.
import { useState } from "react";
import { PageContainer, ProCard, ProFormDigit, ProFormSelect, ProFormText, StepsForm } from "@ant-design/pro-components";
import { Alert, Button, Descriptions, Result } from "antd";
export default function Page() {
const [current, setCurrent] = useState(0);
const [data, setData] = useState<Record<string, unknown>>({});
return (
<PageContainer title="Chuyển kho" subTitle="Chuyển hàng giữa các kho trong 3 bước">
<ProCard>
<StepsForm
current={current}
onCurrentChange={setCurrent}
submitter={{
render: (props, dom) => (props.step === 2 ? null : dom),
submitButtonProps: { style: { minWidth: 120 } },
}}
onFinish={async () => true}
>
<StepsForm.StepForm name="fill" title="Điền phiếu" onFinish={async (v) => { setData(v); return true; }}>
<ProFormSelect name="from" label="Từ kho" width="md" rules={[{ required: true }]} valueEnum={{ hn: "Kho Hà Nội", hcm: "Kho TP.HCM" }} />
<ProFormSelect name="to" label="Đến kho" width="md" rules={[{ required: true }]} valueEnum={{ hn: "Kho Hà Nội", hcm: "Kho TP.HCM", dn: "Kho Đà Nẵng" }} />
<ProFormText name="sku" label="Mã hàng" width="md" placeholder="SKU-0001" rules={[{ required: true }]} />
<ProFormDigit name="qty" label="Số lượng" width="sm" min={1} fieldProps={{ precision: 0 }} rules={[{ required: true }]} />
</StepsForm.StepForm>
<StepsForm.StepForm name="confirm" title="Xác nhận">
<Alert type="info" showIcon title="Kiểm tra lại trước khi tạo phiếu — phiếu đã tạo không sửa được." style={{ marginBottom: 24 }} />
<Descriptions column={1} bordered size="small" items={[{ label: "Từ kho", children: String(data.from ?? "") }, { label: "Đến kho", children: String(data.to ?? "") }, { label: "Mã hàng", children: String(data.sku ?? "") }, { label: "Số lượng", children: String(data.qty ?? "") }]} />
</StepsForm.StepForm>
<StepsForm.StepForm name="done" title="Hoàn tất">
<Result status="success" title="Đã tạo phiếu chuyển kho" subTitle="Kho nhận sẽ thấy phiếu trong hộp “Chờ nhận”."
extra={[<Button key="again" type="primary" onClick={() => setCurrent(0)}>Tạo phiếu khác</Button>, <Button key="view">Xem phiếu</Button>]} />
</StepsForm.StepForm>
</StepsForm>
</ProCard>
</PageContainer>
);
}
Làm màn hình "Form nhiều bước" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Form nhiều bước: StepsForm (điền → xác nhận → kết quả). Bước cuối ẩn nút, hiện Result. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Trang chi tiết và duyệt
Thông tin bản ghi, lịch sử thay đổi, nút duyệt hoặc từ chối kèm lý do.
// Trang chi tiết: PageContainer (breadcrumb, tag, tóm tắt, số chính) + Steps tiến trình + Info + Timeline + nút quyết định cố định ở chân.
// Không dùng PageContainer onBack (làm sập trang trên runtime này) — dùng breadcrumb.
import { useState } from "react";
import { ModalForm, PageContainer, ProCard, ProDescriptions, ProFormTextArea } from "@ant-design/pro-components";
import { Alert, App, Button, Col, Flex, Row, Space, Steps, Tag, Timeline, Typography } from "antd";
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
export default function Page() {
const { message } = App.useApp();
const [status, setStatus] = useState<"pending" | "approved" | "rejected">("pending");
const [note, setNote] = useState<string | null>(null);
const events = [
{ color: "blue", text: <><b>Trần Thị Lan</b> tạo đề xuất</>, at: "12:52 10/11/2026" },
...(status !== "pending" ? [{ color: status === "approved" ? "green" : "red", text: <><b>Nguyễn Thu Hà</b> {status === "approved" ? "duyệt" : "từ chối"}{note ? <> — <i>“{note}”</i></> : null}</>, at: "vừa xong" }] : []),
];
const decide = (to: "approved" | "rejected") => async (v: { note?: string }) => {
setStatus(to); setNote(v.note ?? null);
message.success(to === "approved" ? "Đã duyệt" : "Đã từ chối");
return true;
};
return (
<PageContainer
header={{
title: "Gia hạn Microsoft 365 Business (12 tháng, 10 user)",
breadcrumb: { items: [{ title: <a>Đề xuất</a> }, { title: "#9" }] },
tags: <Tag color={status === "pending" ? "processing" : status === "approved" ? "success" : "error"}>{status === "pending" ? "Chờ duyệt" : status === "approved" ? "Đã duyệt" : "Từ chối"}</Tag>,
}}
content={
<ProDescriptions column={{ xs: 1, sm: 2, lg: 3 }}>
<ProDescriptions.Item label="Người tạo">Trần Thị Lan · Hành chính</ProDescriptions.Item>
<ProDescriptions.Item label="Hạng mục">Phần mềm</ProDescriptions.Item>
<ProDescriptions.Item label="Cần trước">13/11/2026</ProDescriptions.Item>
</ProDescriptions>
}
extraContent={
<Space orientation="vertical" size={0} style={{ textAlign: "right" }}>
<Typography.Text type="secondary">Số tiền đề xuất</Typography.Text>
<Typography.Text strong style={{ fontSize: 28 }}>18.600.000 ₫</Typography.Text>
</Space>
}
footer={status === "pending" ? [
<ModalForm key="r" title="Từ chối đề xuất" width={480} trigger={<Button danger icon={<CloseOutlined />}>Từ chối</Button>} onFinish={decide("rejected")} modalProps={{ okText: "Từ chối", okButtonProps: { danger: true } }}>
<ProFormTextArea name="note" label="Lý do từ chối" rules={[{ required: true, whitespace: true, message: "Cần ghi lý do" }]} />
</ModalForm>,
<ModalForm key="a" title="Duyệt đề xuất" width={480} trigger={<Button type="primary" icon={<CheckOutlined />}>Duyệt</Button>} onFinish={decide("approved")} modalProps={{ okText: "Duyệt" }}>
<ProFormTextArea name="note" label="Ghi chú (tuỳ chọn)" />
</ModalForm>,
] : undefined}
>
<Flex vertical gap={16}>
<ProCard title="Tiến trình" headerBordered>
<Steps current={status === "pending" ? 1 : 2} status={status === "rejected" ? "error" : status === "approved" ? "finish" : "process"}
items={[{ title: "Gửi đề xuất", content: "Trần Thị Lan · 12:52 10/11" }, { title: status === "pending" ? "Quản lý duyệt" : status === "approved" ? "Đã duyệt" : "Từ chối", content: status === "pending" ? "Cần trước 13/11" : "Nguyễn Thu Hà" }]} />
</ProCard>
{status === "rejected" && <Alert type="error" showIcon title="Bị từ chối bởi Nguyễn Thu Hà" description={`Lý do: ${note}`} />}
<Row gutter={[16, 16]}>
<Col xs={24} lg={15}>
<ProCard title="Thông tin" headerBordered style={{ height: "100%" }}>
<Typography.Paragraph>Bản hiện tại hết hạn cuối tháng, cần gia hạn để không gián đoạn email.</Typography.Paragraph>
</ProCard>
</Col>
<Col xs={24} lg={9}>
<ProCard title="Lịch sử" headerBordered style={{ height: "100%" }}>
<Timeline items={events.map((e) => ({ color: e.color, children: <><div>{e.text}</div><Typography.Text type="secondary" style={{ fontSize: 12 }}>{e.at}</Typography.Text></> }))} />
</ProCard>
</Col>
</Row>
</Flex>
</PageContainer>
);
}
Làm màn hình "Trang chi tiết + duyệt" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Trang chi tiết: PageContainer (breadcrumb, tag, tóm tắt, số chính) + Steps tiến trình + Info + Timeline + nút quyết định cố định ở chân. Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Sơ đồ tổ chức
Cây phòng ban và người phụ trách vẽ bằng @ant-design/graphs.
// Sơ đồ tổ chức chỉ-xem: @ant-design/graphs OrganizationChart từ dữ liệu phòng ban (G6: { nodes: [{ id, data }], edges }).
import { useMemo, useState } from "react";
import { PageContainer, ProCard } from "@ant-design/pro-components";
import { Segmented } from "antd";
import { OrganizationChart } from "@ant-design/graphs";
const people = [
{ id: "ceo", name: "Nguyễn An · Giám đốc", manager: null },
{ id: "cfo", name: "Trần Bình · Kế toán trưởng", manager: "ceo" },
{ id: "coo", name: "Lê Chi · Vận hành", manager: "ceo" },
{ id: "sales", name: "Phạm Dũng · Kinh doanh", manager: "ceo" },
{ id: "acc1", name: "Hà · Kế toán", manager: "cfo" },
{ id: "wh", name: "Quang · Kho", manager: "coo" },
{ id: "ship", name: "Vy · Giao hàng", manager: "coo" },
{ id: "s1", name: "Minh · Sales", manager: "sales" },
{ id: "s2", name: "Lan · Sales", manager: "sales" },
];
export default function Page() {
const [direction, setDirection] = useState<"vertical" | "horizontal">("vertical");
const data = useMemo(
() => ({
nodes: people.map((p) => ({ id: p.id, data: { name: p.name } })),
edges: people.filter((p) => p.manager).map((p) => ({ source: p.manager as string, target: p.id })),
}),
[],
);
return (
<PageContainer title="Sơ đồ tổ chức">
<ProCard
extra={
<Segmented
value={direction}
onChange={(v) => setDirection(v as "vertical" | "horizontal")}
options={[
{ value: "vertical", label: "Dọc" },
{ value: "horizontal", label: "Ngang" },
]}
/>
}
>
<div style={{ height: 520 }}>
<OrganizationChart key={direction} data={data} direction={direction} labelField={(d: { data?: { name?: string } }) => d.data?.name ?? ""} autoFit="view" />
</div>
</ProCard>
</PageContainer>
);
}
Làm màn hình "Sơ đồ tổ chức (graphs)" cho app của tôi theo mẫu manh.run UI playbook (framework_docs("pro")): Sơ đồ tổ chức chỉ-xem: @ant-design/graphs OrganizationChart từ dữ liệu phòng ban (G6: { nodes: [{ id, data }], edges }). Dữ liệu lấy từ API của app qua useApiClient(); nhãn và trường theo spec của tôi.Bước tiếp theo
- Ví dụ chạy tại chỗ — màn hình nghiệp vụ trọn vẹn: dashboard điều hành, bán tại quầy, công nợ.
- Chọn component theo việc — biết nên dùng bảng, kanban, lịch hay form nào cho từng việc.