fix;提交代码子账号

This commit is contained in:
ljy
2026-07-09 23:52:00 +08:00
parent 336116fbf2
commit b32e2a06eb
17 changed files with 344 additions and 225 deletions
@@ -3,12 +3,23 @@ import {
Button, Drawer, Form, Input, Modal, Select, Space, Table, Tabs, Tag, Typography, message,
} from 'antd';
import type { ColumnsType } from 'antd/es/table';
import { PARTNER_STAFF_ROLE_LABELS } from '@dukang/shared-types';
import { request, type Paginated } from '../lib/api';
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, PARTNER_BILL_STATUS_LABELS, fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList';
type ParentAccount = { id: string; name: string; phone: string };
type Row = {
id: string; phone: string; name: string; status: string; isPrimary: number; createdAt: string;
id: string;
phone: string;
name: string;
status: string;
isPrimary: number;
staffRole?: string | null;
parentAccountId?: string | null;
parent?: ParentAccount | null;
createdAt: string;
partner?: { id: string; companyName: string };
};
@@ -26,6 +37,21 @@ type PartnerOption = { id: string; companyName: string };
type Detail = Row & { bills?: BillRow[]; orders?: OrderRow[] };
const ACCOUNT_TYPE_OPTIONS = [
{ value: '', label: '全部' },
{ value: '1', label: '主账号' },
{ value: '0', label: '子账号' },
];
function accountTypeLabel(isPrimary: number) {
return isPrimary === 1 ? '主账号' : '子账号';
}
function staffRoleLabel(role?: string | null) {
if (!role) return '-';
return PARTNER_STAFF_ROLE_LABELS[role as keyof typeof PARTNER_STAFF_ROLE_LABELS] ?? role;
}
export default function PartnerAccountsPage() {
const [form] = Form.useForm();
const [editForm] = Form.useForm();
@@ -37,6 +63,7 @@ export default function PartnerAccountsPage() {
const qs = new URLSearchParams();
if (filters.phone) qs.set('phone', filters.phone);
if (filters.status) qs.set('status', filters.status);
if (filters.isPrimary) qs.set('isPrimary', filters.isPrimary);
return qs;
},
[filters],
@@ -71,7 +98,27 @@ export default function PartnerAccountsPage() {
{ title: '姓名', dataIndex: 'name', width: 100 },
{ title: '手机', dataIndex: 'phone', width: 120 },
{ title: '开城合伙人', dataIndex: ['partner', 'companyName'], width: 140 },
{ title: '主账号', dataIndex: 'isPrimary', width: 80, render: (v) => (v === 1 ? '是' : '否') },
{
title: '账号类型',
dataIndex: 'isPrimary',
width: 90,
render: (v) => <Tag color={v === 1 ? 'blue' : 'default'}>{accountTypeLabel(v)}</Tag>,
},
{
title: '角色',
dataIndex: 'staffRole',
width: 100,
render: (role) => staffRoleLabel(role),
},
{
title: '所属主账号',
width: 140,
render: (_, row) => (
row.isPrimary === 1
? '-'
: (row.parent ? `${row.parent.name} / ${row.parent.phone}` : '-')
),
},
{ title: '状态', dataIndex: 'status', width: 80, render: (s) => <Tag>{ACCOUNT_STATUS_LABELS[s] || s}</Tag> },
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
{
@@ -113,9 +160,12 @@ export default function PartnerAccountsPage() {
<Form.Item name="status" label="状态">
<Select allowClear style={{ width: 100 }} options={Object.entries(ACCOUNT_STATUS_LABELS).map(([value, label]) => ({ value, label }))} />
</Form.Item>
<Form.Item name="isPrimary" label="账号类型">
<Select allowClear style={{ width: 110 }} options={ACCOUNT_TYPE_OPTIONS.filter((item) => item.value !== '')} />
</Form.Item>
<Form.Item><Button type="primary" htmlType="submit"></Button></Form.Item>
</Form>
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 900 }}
<Table rowKey="id" className="admin-table-nowrap" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1100 }}
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
<Drawer
title="编辑开城合伙人账户"
@@ -134,6 +184,20 @@ export default function PartnerAccountsPage() {
<Form.Item label="开城合伙人">
<Input value={detail.partner?.companyName} disabled />
</Form.Item>
<Form.Item label="账号类型">
<Input value={accountTypeLabel(detail.isPrimary)} disabled />
</Form.Item>
<Form.Item label="角色">
<Input value={staffRoleLabel(detail.staffRole)} disabled />
</Form.Item>
{detail.isPrimary !== 1 && (
<Form.Item label="所属主账号">
<Input
value={detail.parent ? `${detail.parent.name} / ${detail.parent.phone}` : '-'}
disabled
/>
</Form.Item>
)}
<Form.Item name="name" label="姓名" rules={[{ required: true }]}><Input /></Form.Item>
<Form.Item
name="phone"