Commit ea6d4707 by 胡悦

refactor(channel-code, official-site-job-tab): 更新渠道活码与官方岗位标签相关功能

- 更新渠道活码更新接口的参数与调用逻辑
- 优化渠道活码查看抽屉的空代理名称展示并新增测试用例
- 补充官方网站标签列表的新增字段,调整岗位标签编辑页面配置与文案
1 parent ab2df777
......@@ -203,8 +203,8 @@ describe('channelCode API', () => {
it('调用正确的接口路径和方法', async () => {
vi.mocked(apiClient.put).mockResolvedValueOnce({ success: true, updated_at: '2026-05-15T14:00:00Z' });
await updateChannelQRCode(1, { employee_name: '李四', agent_ids: [101] });
expect(apiClient.put).toHaveBeenCalledWith('/agent-group/qrcode/1', { employee_name: '李四', agent_ids: [101] });
await updateChannelQRCode(1, { qrcode_name: '更新后的活码名称', status: 'enable', remark: '备注' });
expect(apiClient.put).toHaveBeenCalledWith('/agent-group/qrcode/1', { qrcode_name: '更新后的活码名称', status: 'enable', remark: '备注' });
});
});
......
......@@ -69,8 +69,8 @@ export interface CreateChannelQRCodeResponse {
}
export interface UpdateChannelQRCodePayload {
employee_name: string;
agent_ids: number[];
qrcode_name: string;
status?: ChannelQRCodeStatus;
remark?: string;
welcome_message?: string;
}
......
......@@ -13,6 +13,8 @@ export interface OfficialSiteTabListItem extends Record<string, unknown> {
qrcode_name: string;
qrcode_url: string;
qrcode_status: ChannelQRCodeStatus;
channel_code: string;
qrcode_employee_name: string;
display_status: OfficialSiteTabStatus;
sort_order: number;
agent_count: number;
......@@ -176,6 +178,8 @@ function fillTabListItem(item: Partial<OfficialSiteTabListItem>): OfficialSiteTa
qrcode_name: item.qrcode_name ?? '',
qrcode_url: item.qrcode_url ?? '',
qrcode_status: item.qrcode_status ?? 'enable',
channel_code: item.channel_code ?? '',
qrcode_employee_name: item.qrcode_employee_name ?? '',
display_status: displayStatus,
sort_order: item.sort_order ?? 0,
agent_count: item.agent_count ?? 0,
......
......@@ -228,8 +228,8 @@ export function ChannelCodeEditorPage({ mode }: { mode: 'create' | 'edit' }) {
try {
if (mode === 'edit' && currentCode) {
await updateChannelQRCode(currentCode.qrcode_id, {
employee_name: form.qrcode_name,
agent_ids: currentCode.agent_ids,
qrcode_name: form.qrcode_name,
status: form.status,
remark: form.description,
welcome_message: form.welcome_message,
});
......
......@@ -183,6 +183,23 @@ describe('Channel code view drawer', () => {
expect(within(drawer).getByText('管家Agent')).toBeInTheDocument();
});
it('shows dash when agent_names is empty', async () => {
vi.mocked(getChannelQRCodeDetail).mockResolvedValueOnce({
...mockChannelCodeDetail,
agent_names: [],
});
renderChannelCodes();
await screen.findByText('店销顾问渠道活码');
fireEvent.click(screen.getByRole('button', { name: '查看店销顾问渠道活码' }));
const drawer = await screen.findByRole('dialog', { name: '店销顾问渠道活码' });
// Should display "-" when no agent names
const agentSection = within(drawer).getByText('关联 Agent').parentElement;
expect(within(agentSection!).getByText('-')).toBeInTheDocument();
});
it('shows loading state while fetching detail', async () => {
vi.mocked(getChannelQRCodeDetail).mockImplementation(() => new Promise((resolve) => setTimeout(() => resolve(mockChannelCodeDetail), 100)));
......
......@@ -107,9 +107,11 @@ export function ChannelCodeViewDrawer({ open, qrcodeId, onClose }: ChannelCodeVi
<div className="grid grid-cols-[120px_1fr] gap-2 text-sm">
<span className="text-[var(--gl-color-text-secondary)]">关联 Agent</span>
<div className="flex flex-wrap gap-1">
{(detail.agent_names ?? []).map((name) => (
<Tag key={name} status="info">{name}</Tag>
))}
{(detail.agent_names?.length ?? 0) > 0
? detail.agent_names.map((name) => (
<Tag key={name} status="info">{name}</Tag>
))
: <span>-</span>}
</div>
</div>
<div className="grid grid-cols-[120px_1fr] gap-2 text-sm">
......
......@@ -145,7 +145,7 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
const order = form.tab_order;
if (mode === 'create' && !form.position_code) {
nextErrors.position_code = '请选择岗位标签';
nextErrors.position_code = '请选择对应岗位';
}
if (!Number.isInteger(order) || order < 0 || order > 99) {
......@@ -252,7 +252,7 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
<div className="rounded-[var(--gl-radius-md)] border border-[var(--gl-color-border-secondary)] bg-[var(--gl-color-bg-container)] px-8 py-10">
<div className="mx-auto grid max-w-[760px] gap-6">
<FormItem label="选择岗位标签" layout="horizontal" required={mode === 'create'} error={errors.position_code}>
<FormItem label="对应岗位" layout="horizontal" required={mode === 'create'} error={errors.position_code}>
{mode === 'edit' ? (
<Input
aria-label="岗位标签"
......@@ -262,21 +262,21 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
/>
) : (
<Select
aria-label="岗位标签"
aria-label="对应岗位"
className={fieldWidthClassName}
options={availableQRCodeOptions.map((qr) => ({
value: String(qr.qrcode_id),
label: qr.position_name,
disabled: existingPositions.includes(qr.position_name) || qr.status === 'disable',
}))}
placeholder="请选择岗位标签"
value={String(form.qrcode_id)}
placeholder="请选择对应岗位"
value={form.qrcode_id ? String(form.qrcode_id) : ''}
onChange={(value) => {
const qr = availableQRCodes.find((q) => q.qrcode_id === Number(value));
if (qr) {
setForm((current) => ({
...current,
position_code: qr.position_name,
position_code: qr.channel_code,
position_name: qr.position_name,
qrcode_id: qr.qrcode_id,
qrcode_name: qr.channel_code,
......@@ -291,21 +291,27 @@ export function OfficialSiteJobTabEditorPage({ mode }: { mode: 'create' | 'edit'
<FormItem label="关联渠道活码" layout="horizontal">
<div className={fieldWidthClassName}>
{form.qrcode_name || selectedQRCode?.channel_code || (mode === 'create' && !form.position_code ? (
{form.qrcode_name || selectedQRCode?.channel_code || currentTab?.qrcode_name || (mode === 'create' && !form.position_code ? (
<span className="text-sm text-[var(--gl-color-text-secondary)]">选择岗位后自动展示</span>
) : null)}
</div>
</FormItem>
<FormItem label="渠道编码" layout="horizontal">
<div className={fieldWidthClassName}>
{form.channel_code || currentTab?.channel_code || (mode === 'create' && !form.position_code ? (
<span className="text-sm text-[var(--gl-color-text-secondary)]">选择岗位后自动展示</span>
) : null)}
</div>
</FormItem>
{currentTab ? (
<>
<FormItem label="渠道编码" layout="horizontal">
<div className={fieldWidthClassName}>
{currentTab.qrcode_url ?? ''}
</div>
</FormItem>
</>
) : null}
<FormItem label="承接员工" layout="horizontal">
<div className={fieldWidthClassName}>
{form.employee_name || currentTab?.qrcode_employee_name || (mode === 'create' && !form.position_code ? (
<span className="text-sm text-[var(--gl-color-text-secondary)]">选择岗位后自动展示</span>
) : null)}
</div>
</FormItem>
<div className="border-t border-[var(--gl-color-border-secondary)]" />
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!