feat(huya): 协作台账店铺字典·新建强校验·同买家多单 + uid 放开(迁移 0057/0058)

- 店铺字典(迁移 0057):大按钮点选 + 「新店」自定义自动登记;重命名可级联、
  停用/备注;列表行内改、详情、筛选条共用同一个 picker
- 新建强校验:订单编号/店铺/CK/礼包名/主页截图必填;贴 CK 即探针预览,
  读不到绑定角色禁止提交;礼包用工作台配置的活动 SID 现拉(浏览器缓存 + 强制刷新)
- 图片:绑定图停用、「绑定斗鱼号」下线(绑定关系改由探针读 bind_game_*),
  主页截图改为新建必填(弹窗内先传 OSS 再随表单落库)
- 同买家多单软识别:按「绑定账号 + 绑定角色」整批一次查询,列表「同买家」列 +
  详情分组,点单号直接切单
- uid 放开唯一性(迁移 0058):同一份 CK 可服务多单,原 409 冲突改为提示 + 审计
- 列表体验:序号列、搜索扩到 11 个字段、CK 状态列截断、新建弹窗放大并去滚动条
- 验证:pytest 932 passed / 6 skipped;接口冒烟 56 项全绿;tsc+eslint+build 通过
This commit is contained in:
yml2213
2026-10-16 21:29:08 +08:00
parent df8c63b829
commit aac264b639
17 changed files with 3237 additions and 155 deletions
@@ -0,0 +1,143 @@
/**
* 新建协作单时的「主页截图」上传(先传 OSS 拿 object_key,随表单一起提交)。
*
* - 第一张就是封面(列表和详情都按第一张当封面);
* - 新建时还没落库,所以预览用的地址来自上传接口返回的 thumbnail_url / url;
* - 放进 `Form.Item name="home_images"`,值就是 object_key 数组。
*/
import { useEffect, useRef, useState } from 'react';
import { Button, Image, Popconfirm, Space, Tag, Tooltip, Typography, Upload } from 'antd';
import { CloudUploadOutlined, DeleteOutlined, SwapOutlined } from '@ant-design/icons';
import { fileApi } from '../api/files';
import type { FileUploadResult } from '../api/types';
import { message } from '../utils/antdMessage';
import { getErrorMessage } from '../utils/error';
const { Text } = Typography;
type Preview = Pick<FileUploadResult, 'url' | 'thumbnail_url'>;
export default function HuyaCollabHomeImageUploader({
value = [],
max = 20,
disabled,
onChange,
}: {
value?: string[];
max?: number;
disabled?: boolean;
onChange?: (value: string[]) => void;
}) {
const [busy, setBusy] = useState(false);
const [previews, setPreviews] = useState<Record<string, Preview>>({});
// 连传多张时每次都用"上一次的结果 + 新 key",不吃闭包里的旧 value(否则会互相覆盖)
const keysRef = useRef<string[]>(value ?? []);
useEffect(() => {
keysRef.current = value ?? [];
}, [value]);
const keys = value ?? [];
const full = keys.length >= max;
const uploadOne = async (file: File) => {
setBusy(true);
try {
const uploaded = await fileApi.upload(file, 'collab');
setPreviews((prev) => ({
...prev,
[uploaded.object_key]: { url: uploaded.url, thumbnail_url: uploaded.thumbnail_url },
}));
const next = [...keysRef.current, uploaded.object_key];
keysRef.current = next;
onChange?.(next);
} catch (e: unknown) {
message.error(getErrorMessage(e));
} finally {
setBusy(false);
}
};
const remove = (key: string) => {
const next = keysRef.current.filter((item) => item !== key);
keysRef.current = next;
onChange?.(next);
};
const setCover = (key: string) => {
const next = [key, ...keysRef.current.filter((item) => item !== key)];
keysRef.current = next;
onChange?.(next);
};
return (
<Space direction="vertical" size={8} style={{ width: '100%' }}>
{keys.length === 0 ? (
<Text type="secondary">还没有图(必填:至少 1 张,第一张作封面)</Text>
) : (
<Image.PreviewGroup
items={keys.map((key) => previews[key]?.url || `/api/files/object?key=${encodeURIComponent(key)}`)}
>
<Space wrap size={12}>
{keys.map((key, index) => (
<Space key={key} direction="vertical" size={2} align="center">
<div style={{ position: 'relative' }}>
<Image
src={
previews[key]?.thumbnail_url
|| previews[key]?.url
|| `/api/files/object?key=${encodeURIComponent(key)}&variant=thumb`
}
width={88}
height={88}
style={{ objectFit: 'cover', borderRadius: 4 }}
alt={`主页截图${index + 1}`}
/>
{index === 0 && (
<Tag color="blue" style={{ position: 'absolute', left: 0, top: 0, margin: 0 }}>
封面
</Tag>
)}
</div>
{!disabled && (
<Space size={2}>
{index !== 0 && (
<Tooltip title="设为封面">
<Button size="small" type="text" icon={<SwapOutlined />} onClick={() => setCover(key)} />
</Tooltip>
)}
<Popconfirm
title="去掉这张图?"
description="对象不会立刻删除,交给孤儿清理脚本"
onConfirm={() => remove(key)}
>
<Tooltip title="移除">
<Button size="small" type="text" danger icon={<DeleteOutlined />} />
</Tooltip>
</Popconfirm>
</Space>
)}
</Space>
))}
</Space>
</Image.PreviewGroup>
)}
{!disabled && (
<Upload
accept="image/*"
multiple
showUploadList={false}
disabled={busy || full}
beforeUpload={(file) => {
void uploadOne(file as File);
return false;
}}
>
<Button icon={<CloudUploadOutlined />} loading={busy} disabled={full}>
{full ? `最多 ${max} 张` : '上传主页截图'}
</Button>
</Upload>
)}
</Space>
);
}