From 751a45782f1c53376203fc88a8b8f066850601ad Mon Sep 17 00:00:00 2001 From: yml Date: Tue, 24 Nov 2026 17:08:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(fulfillment):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=96=97=E9=B1=BC=E5=95=86=E5=93=81=E6=98=A0=E5=B0=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 表格压缩为无横向滚动,操作收进更多菜单,删除/归档随时可见 - 新建和编辑改为右侧抽屉表单,不再占用列表顶部 - 增加 SKU 搜索、销售模式过滤、归档开关和刷新 - 表格合并活动批次/商品 ID 到次要信息,减少列宽 --- .../src/pages/PlatformFulfillmentPage.tsx | 469 +++++++++++------- 1 file changed, 287 insertions(+), 182 deletions(-) diff --git a/web/frontend/src/pages/PlatformFulfillmentPage.tsx b/web/frontend/src/pages/PlatformFulfillmentPage.tsx index e835850..edd5e51 100644 --- a/web/frontend/src/pages/PlatformFulfillmentPage.tsx +++ b/web/frontend/src/pages/PlatformFulfillmentPage.tsx @@ -2,8 +2,8 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import dayjs from 'dayjs'; import type { Dayjs } from 'dayjs'; -import { Alert, Button, Card, Col, DatePicker, Descriptions, Drawer, Empty, Input, InputNumber, Modal, QRCode, Row, Segmented, Select, Space, Switch, Table, Tabs, Tag, Timeline, Typography } from 'antd'; -import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, DownloadOutlined, GiftOutlined, LinkOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UndoOutlined, UserSwitchOutlined } from '@ant-design/icons'; +import { Alert, Button, Card, Col, DatePicker, Descriptions, Drawer, Dropdown, Empty, Input, InputNumber, Modal, QRCode, Row, Segmented, Select, Space, Switch, Table, Tag, Timeline, Typography } from 'antd'; +import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, DownloadOutlined, GiftOutlined, LinkOutlined, MoreOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UndoOutlined, UserSwitchOutlined } from '@ant-design/icons'; import type { ColumnsType } from 'antd/es/table'; import { douyuApi, platformFulfillmentApi } from '../api/modules'; import type { DouyuGoodsItem, DouyuTaskItem, PlatformFulfillmentBindingLog, PlatformFulfillmentDetail, PlatformFulfillmentMapping, PlatformFulfillmentSettings, PlatformFulfillmentTask } from '../api/modules'; @@ -482,6 +482,9 @@ export default function PlatformFulfillmentPage() { const [bindingQrImage, setBindingQrImage] = useState(''); const [bindingQrLoading, setBindingQrLoading] = useState(false); const [mappingOpen, setMappingOpen] = useState(false); + const [mappingEditorOpen, setMappingEditorOpen] = useState(false); + const [mappingSaving, setMappingSaving] = useState(false); + const [mappingKeyword, setMappingKeyword] = useState(''); const [mappingSku, setMappingSku] = useState(''); const [mappingEditingId, setMappingEditingId] = useState(null); const [mappingCampaignKey, setMappingCampaignKey] = useState('douyu-current'); @@ -1020,7 +1023,7 @@ export default function PlatformFulfillmentPage() { }; const loadMappingRows = async ( - keyword = mappingSku.trim(), + keyword = mappingKeyword.trim(), mode = mappingFilterMode, includeArchived = mappingIncludeArchived, ) => { @@ -1035,12 +1038,15 @@ export default function PlatformFulfillmentPage() { const openMapping = async (task?: PlatformFulfillmentTask) => { resetMappingForm(task); setMappingOpen(true); + if (task) setMappingEditorOpen(true); setMappingGoodsLoading(true); try { + const keyword = task?.internalSkuKey || ''; + setMappingKeyword(keyword); const [goodsRows, mappingRows] = await Promise.all([ douyuApi.listLiveGoods(), platformFulfillmentApi.listMappings({ - keyword: task?.internalSkuKey || '', + keyword, sale_mode: mappingFilterMode || undefined, include_archived: mappingIncludeArchived, }), @@ -1057,7 +1063,13 @@ export default function PlatformFulfillmentPage() { } }; + const openMappingCreate = () => { + resetMappingForm(); + setMappingEditorOpen(true); + }; + const editMapping = (row: PlatformFulfillmentMapping) => { + setMappingEditorOpen(true); setMappingEditingId(row.id); setMappingSku(row.internalSkuKey); setMappingCampaignKey(row.campaignKey || 'douyu-current'); @@ -1141,6 +1153,7 @@ export default function PlatformFulfillmentPage() { }; const saveMapping = async () => { + if (mappingSaving) return; if (!mappingSku.trim() || !mappingCampaignKey.trim() || !mappingGoodsId || !mappingSaleMode) { message.warning('请填写内部 SKU、活动批次、销售模式并选择斗鱼商品'); return; @@ -1163,17 +1176,21 @@ export default function PlatformFulfillmentPage() { available_until: mappingAvailableUntil?.toISOString() || null, enabled: mappingEnabled, }; + setMappingSaving(true); if (mappingEditingId) { await platformFulfillmentApi.updateMapping(mappingEditingId, payload); } else { await platformFulfillmentApi.createMapping(payload); } message.success('商品映射已保存'); + setMappingEditorOpen(false); resetMappingForm(); await loadMappingRows(); await loadTasks(); } catch (error) { message.error(getErrorMessage(error)); + } finally { + setMappingSaving(false); } }; @@ -2456,196 +2473,284 @@ export default function PlatformFulfillmentPage() { void saveMapping()} - onCancel={() => setMappingOpen(false)} + width={1080} + footer={null} + onCancel={() => { + setMappingOpen(false); + setMappingEditorOpen(false); + }} > - - - ({ value, label })), + ]} + onChange={(value) => { + setMappingFilterMode(value); + void loadMappingRows(mappingKeyword.trim(), value).catch((error) => message.error(getErrorMessage(error))); + }} + style={{ width: 150 }} + /> + + 显示已归档 + { + setMappingIncludeArchived(checked); + void loadMappingRows(mappingKeyword.trim(), mappingFilterMode, checked).catch((error) => message.error(getErrorMessage(error))); + }} + /> + + + + + - - - setMappingSku(event.target.value)} style={{ width: 260 }} /> - setMappingCampaignKey(event.target.value)} style={{ width: 260 }} /> - setMappingCampaignName(event.target.value)} style={{ width: 220 }} /> - - - ({ value, label }))} - onChange={setMappingSaleMode} - style={{ width: 140 }} - /> - 所需积分 - setMappingPoints(value)} /> - 启用 - - - - 商品开放时间 - - 至 - - - + 共 {mappings.length} 条映射;编辑、停用、归档、删除都在“更多”里,不需要横向滚动。 + + + rowKey="id" + size="small" + tableLayout="fixed" + pagination={{ pageSize: 10, hideOnSinglePage: true, showSizeChanger: false }} + dataSource={mappings} + columns={[ { - key: 'current', - label: '当前映射', - children: ( - - rowKey="id" - size="small" - pagination={false} - dataSource={mappings} - columns={[ - { title: '内部 SKU', dataIndex: 'internalSkuKey', width: 150 }, - { - title: '活动批次', - key: 'campaign', - width: 170, - render: (_: unknown, row) => ( - - {row.campaignName || row.campaignKey} - {row.campaignKey} - - ), - }, - { title: '商品', dataIndex: 'goodsName', width: 150 }, - { title: '商品 ID', dataIndex: 'commodityId', width: 180 }, - { - title: '分类', - key: 'saleMode', - width: 130, - render: (_: unknown, row) => ( - - - {SALE_MODE_LABELS[row.saleMode] || row.saleMode} - - {AVAILABILITY_LABELS[row.availabilityState] || row.availabilityState} - - ), - }, - { title: '积分', dataIndex: 'requiredPoints', width: 80 }, - { title: '影响任务', dataIndex: 'affectedTasks', width: 90 }, - { - title: '状态', - dataIndex: 'enabled', - width: 100, - render: (value: boolean, row) => ( - - {row.archivedAt ? '已归档' : value ? '启用' : '停用'} - - ), - }, - { - title: '操作', - key: 'actions', - width: 310, - render: (_: unknown, row) => ( - - - {row.archivedAt ? ( - - ) : ( - <> - - - - )} - - - ), - }, - ]} - scroll={{ x: 1300 }} - /> + title: '内部 SKU', + dataIndex: 'internalSkuKey', + width: 170, + ellipsis: true, + render: (value: string, row) => ( + + {value} + + {row.campaignName || row.campaignKey || '-'} + + + ), + }, + { + title: '商品', + dataIndex: 'goodsName', + width: 250, + ellipsis: true, + render: (value: string, row) => ( + + {value || row.commodityId || '-'} + + {row.commodityId} + + + ), + }, + { + title: '分类', + key: 'saleMode', + width: 110, + render: (_: unknown, row) => ( + + + {SALE_MODE_LABELS[row.saleMode] || row.saleMode} + + {AVAILABILITY_LABELS[row.availabilityState] || row.availabilityState} + + ), + }, + { title: '积分', dataIndex: 'requiredPoints', width: 70 }, + { title: '影响任务', dataIndex: 'affectedTasks', width: 80 }, + { + title: '状态', + dataIndex: 'enabled', + width: 80, + render: (value: boolean, row) => ( + + {row.archivedAt ? '已归档' : value ? '启用' : '停用'} + + ), + }, + { + title: '操作', + key: 'actions', + width: 150, + render: (_: unknown, row) => ( + + + { + if (key === 'toggle') { + runMappingAction(row, row.enabled ? 'disable' : 'enable'); + } else if (key === 'archive') { + runMappingAction(row, 'archive'); + } else if (key === 'restore') { + runMappingAction(row, 'restore'); + } else if (key === 'delete') { + removeMapping(row); + } + }, + }} + > + + + ), }, ]} /> + + setMappingEditorOpen(false)} + extra={ + + + + + } + > + +
+ 内部 SKU + setMappingSku(event.target.value)} + style={{ marginTop: 6 }} + /> +
+ + + 活动批次 + setMappingCampaignKey(event.target.value)} + style={{ marginTop: 6 }} + /> + + + 活动名称 + setMappingCampaignName(event.target.value)} + style={{ marginTop: 6 }} + /> + + +
+ 斗鱼精英宝典商品 + + ({ value, label }))} + onChange={setMappingSaleMode} + style={{ width: '100%', marginTop: 6 }} + /> + + + 所需积分 + setMappingPoints(value)} + style={{ width: '100%', marginTop: 6 }} + /> + + + 启用 +
+ +
+ + +
+ 商品开放时间 + + + 至 + + +
+ + + ); }