Commit 21a74715 by 张立顺

Merge branch 'v1.0.0' of http://192.168.3.233:8090/ujia/uj-store into v1.0.0

2 parents c5ef1e43 d380a252
Pipeline #357 for 21a74715 failed in 0 seconds
# 2026-10-13 工作日志
## 请求签名 10011:半角括号 ( ) 触发签名/发送 query 编码不一致(16:04 提出,16:15 更正)
- 现象:同一 approval/pending 接口,productCategory 含半角括号 `3级(集锦)` 的请求报 10011,而含全角括号 `改装豆(原厂)` 的请求正常返回。**不是"有没有括号"的问题,是半角 `()` vs 全角 `()` 的编码差异**。
- 根因(已用 node 实测 URLSearchParams / encodeURIComponent 两种编码确认):
- 前端签名 query 原先由 `URLSearchParams.append` 构造 → 半角 `( )` 被编码成 `%28%29`;
- axios 默认用 `encodeURIComponent` 序列化 params(项目无自定义 paramsSerializer)→ 半角 `( )` **保持原样**;
- 后端按"实际收到的原始 query"验签,即 literal `( )`。于是签名里是 `%28%29`、实际收到是 `( )` → 错位 → 10011。
- 全角 `()` 在两种编码下都编成 `%EF%BC%88/%EF%BC%89`,结果一致,故全角那条始终正常,正是这个对照暴露了半角才是真凶。
- 修复(src/api/core/http.ts):query 构造由 `decodeURIComponent(encodeURIComponent(v))`(错误方向,会把原本正常的全角请求也改坏)改回**对 key/value 用 `encodeURIComponent` 重建**(与 axios 发送、后端收包口径逐字节一致);按 key 字典序排序不变。tsc --noEmit 通过(EXIT=0)。
- 教训:签名 canonical 的 query 必须与"axios 实际发出的 query"完全一致;选错编码器(URLSearchParams/encodeURIComponent/解码)都会在特殊字符上翻车,且只在含半角括号等"编码边界字符"时暴露——无括号接口编解码后对等,表现正常,容易误判。
## 签名 10011 收尾:把"其他特殊符号"一并根治(16:18 提出,已落地)
- 超人追问:问题已暴露,是否还有其他特殊符号没堵。用 node 实测 `URLSearchParams` vs `encodeURIComponent` 全量差异,结果不一致的共 5 个:半角 `()`、空格(`+`/`%20`)、`'`、`~`、`!`。`()` 已爆,其余 4 个属同级别潜伏雷(尤其空格,业务参数易含)。
- 根因共性:都是"签名用的编码器"与"axios 实际发送编码器"口径不同。逐字符打补丁是 whack-a-mole,不彻底。
- 修复(src/api/core/http.ts):新增 `serializeRequestParams(config)` + `sortParamsByKey(params)`,签名 query **直接复用 axios 自身的 `config.paramsSerializer`** 生成(数组/特殊字符等所有情况与线上逐字节同源),兜底退化为 encodeURIComponent(=axios 默认);内联在 `config.url` 的 `?x=y` 走 `full.search` 原样保留(axios 不重编码),再与 params 合并按 key 升序排序对齐后端 canonical。
- 效果:签名 query 与线上发送 query 结构性同源,任何字符(含未来新增)都不可能再出现编码分歧;不只是修了 `()`。
- tsc --noEmit 通过(EXIT=0)。
## http.ts 按功能拆分:抽出 signCanonical.ts(16:31 起,已落地)
- 超人反馈 http.ts 开始臃肿,要求把功能函数拆到 utils。新增 `src/api/core/signCanonical.ts`,收纳全部「签名 canonical 构造」纯函数(无 axios 实例依赖、无模块级状态、输入 config 输出字符串):
- `serializeRequestParams(config)`(复用 axios 自身 paramsSerializer,含 sortParamsByKey 内部辅助)
- `buildCanonicalTarget(config)` → `{ canonPath, query }`(路径斜杠压缩 + query 与线上同源,含 5 字符差异表注释)
- `extractMediaType(headers, isForm, hasBody)`
- `buildSignCanonical(parts)`(8 行 \n 拼接)、`maskDebugCanonical(canonical)`(密码脱敏)
- http.ts 仅保留:axios 实例、请求拦截(token/context-path/装配调用)、401 回调、响应拦截(验签+统一错误)、initSign/ensureSignReady。请求拦截体从 ~50 行压到 ~30 行,签名细节均委托 signCanonical。
- 行为完全保持:路径解析、query 序列化、Content-Type、canonical 拼接逐项核对与改动前一致;`existingCt` 局部变量消解(改由 extractMediaType 内部处理,末段 Content-Type 兜底改判 `!headers['Content-Type'] && !headers['content-type']`)。tsc --noEmit 通过(EXIT=0)。
...@@ -18,7 +18,7 @@ export function UModal(props: ModalProps) { ...@@ -18,7 +18,7 @@ export function UModal(props: ModalProps) {
<Modal <Modal
centered={centered} centered={centered}
destroyOnHidden={destroyOnHidden} destroyOnHidden={destroyOnHidden}
mask={mask ?? (maskClosable === undefined ? undefined : { closable: maskClosable })} mask={mask ?? (maskClosable === undefined ? { closable: false } : { closable: maskClosable })}
okButtonProps={{ type: 'primary', ...okButtonProps }} okButtonProps={{ type: 'primary', ...okButtonProps }}
{...rest} {...rest}
/> />
......
...@@ -14,6 +14,12 @@ import { ...@@ -14,6 +14,12 @@ import {
import { SIGN_CONFIG, SIGN_ENABLED, API_CONTEXT_PATH } from './config'; import { SIGN_CONFIG, SIGN_ENABLED, API_CONTEXT_PATH } from './config';
import { getToken, clearToken } from './token'; import { getToken, clearToken } from './token';
import { parseStoreResponse } from './storeJson'; import { parseStoreResponse } from './storeJson';
import {
buildCanonicalTarget,
extractMediaType,
buildSignCanonical,
maskDebugCanonical,
} from './signCanonical';
const http: AxiosInstance = axios.create({ const http: AxiosInstance = axios.create({
baseURL: SIGN_CONFIG.BASE_URL, baseURL: SIGN_CONFIG.BASE_URL,
...@@ -52,54 +58,28 @@ http.interceptors.request.use((config: any) => { ...@@ -52,54 +58,28 @@ http.interceptors.request.use((config: any) => {
config.data = JSON.stringify(config.data); config.data = JSON.stringify(config.data);
} }
// 2) 解析真实 path(含 context-path)与查询串(来自 url + params,按字典序升序) // 2) 解析真实 path(含 context-path)与查询串:统一委托 signCanonical 构造。
const basePath = (config.baseURL || '').replace(/\/$/, ''); // 路径斜杠压缩、query 与 axios 线上编码同源(含 ( ) 空格 ' ~ ! 等特殊字符)等细节均在 signCanonical.ts。
let urlPath = config.url || ''; const { canonPath, query } = buildCanonicalTarget(config);
if (/^https?:\/\//i.test(urlPath)) {
const u = new URL(urlPath);
urlPath = u.pathname + u.search;
} else {
urlPath = urlPath.replace(/^\//, '');
}
// 拼接 base + path,并压缩路径中的重复斜杠。
// 注意:不能用全局 /\/{2,}/ → '/' 替换——basePath 为完整地址时会把 'http://' 压成 'http:/',
// new URL() 随即把 host:port 误当作 path,canonical 第 2 行会变成
// '/192.168.1.117:8788/system/auth/login'(正确应为 '/system/auth/login')→ 后端验签必失败。
// 故只压缩「前面不是冒号」的重复斜杠,跳过协议里的 //。
const full = new URL(`${basePath}/${urlPath}`.replace(/(^|[^:])\/{2,}/g, '$1/'), 'http://_');
if (config.params && typeof config.params === 'object') {
Object.entries(config.params).forEach(([k, v]) => {
if (v !== undefined && v !== null) full.searchParams.append(String(k), String(v));
});
}
const path = full.pathname; // 浏览器侧完整路径,直连模式下为 /system/auth/login(无 /api 前缀)
// 待签名原文的 path 必须与后端 request.getRequestURI() 一致。
// 直连模式下 baseURL 是完整地址(如 http://192.168.1.117:8788),path 不含 /api,直接作为 canonical 第 2 行;
// 与参考 sign-client.html(直连 /system/auth/login)对齐。若走代理(baseURL='/api')则此处会再摘掉 /api 前缀。
const canonPath = basePath && path.startsWith(basePath) ? path.slice(basePath.length) : path;
const query = full.search.slice(1).split('&').filter(Boolean).sort().join('&');
// 3) Content-Type 仅取媒体类型;文件上传固定 multipart/form-data,且请求体不参与签名(§3.1/§9.6) // 3) Content-Type 仅取媒体类型;文件上传固定 multipart/form-data,且请求体不参与签名(§3.1/§9.6)
const existingCt = headers['Content-Type'] || headers['content-type']; const media = extractMediaType(headers, isForm, !!config.data);
const media = isForm
? 'multipart/form-data'
: (existingCt || (config.data ? 'application/json' : '')).split(';')[0].trim().toLowerCase();
const timestamp = String(Date.now()); const timestamp = String(Date.now());
const nonce = uuid(); const nonce = uuid();
const bodyStr = isForm ? '' : config.data || ''; const bodyStr = isForm ? '' : config.data || '';
// 待签名原文:8 行 \n 连接,末尾不加换行(§3.1) // 待签名原文:8 行 \n 连接,末尾不加换行(§3.1)
const canonical = [ const canonical = buildSignCanonical({
(config.method || 'GET').toUpperCase(), method: (config.method || 'GET').toUpperCase(),
canonPath, path: canonPath,
query, query,
media, media,
timestamp, timestamp,
nonce, nonce,
APP_ID, appId: APP_ID,
bodyStr, body: bodyStr,
].join('\n'); });
const signValue = rsaSign(canonical); const signValue = rsaSign(canonical);
headers['X-App-Id'] = APP_ID; headers['X-App-Id'] = APP_ID;
...@@ -111,7 +91,7 @@ http.interceptors.request.use((config: any) => { ...@@ -111,7 +91,7 @@ http.interceptors.request.use((config: any) => {
// 调试开关(VITE_SIGN_DEBUG=true):打印待签名原文与签名头,便于后端核对 // 调试开关(VITE_SIGN_DEBUG=true):打印待签名原文与签名头,便于后端核对
// canonical/算法是否与其一致。注意:原文含请求体(登录含明文密码),仅本地调试用。 // canonical/算法是否与其一致。注意:原文含请求体(登录含明文密码),仅本地调试用。
if ((import.meta.env as any).VITE_SIGN_DEBUG === 'true') { if ((import.meta.env as any).VITE_SIGN_DEBUG === 'true') {
const safeCanonical = canonical.replace(/"password"\s*:\s*"[^"]*"/g, '"password":"***"'); const safeCanonical = maskDebugCanonical(canonical);
console.warn( console.warn(
'[sign:debug] canonical:\n' + '[sign:debug] canonical:\n' +
safeCanonical + safeCanonical +
...@@ -127,7 +107,7 @@ http.interceptors.request.use((config: any) => { ...@@ -127,7 +107,7 @@ http.interceptors.request.use((config: any) => {
}), }),
); );
} }
if (config.data && !isForm && !existingCt) { if (config.data && !isForm && !headers['Content-Type'] && !headers['content-type']) {
headers['Content-Type'] = 'application/json'; headers['Content-Type'] = 'application/json';
} }
config.headers = headers; config.headers = headers;
......
// 请求签名 canonical 构造工具(规范 §三/§五)
// 集中封装「签名算什么」所需的纯函数,与 http.ts 的请求拦截解耦,便于单测与排错。
// 本模块不依赖 axios 实例、不持有模块级状态,输入 config 输出字符串,无副作用。
// ---------- query 序列化:与 axios 线上编码同源 ----------
// 仅对纯对象按 key 升序排列(与后端 canonical 顺序一致);数组 / URLSearchParams 等保持原样交给序列化器。
function sortParamsByKey(params: any): any {
if (
!params ||
typeof params !== 'object' ||
Array.isArray(params) ||
params instanceof URLSearchParams
) {
return params;
}
const out: Record<string, any> = {};
Object.keys(params)
.filter((k) => params[k] !== undefined && params[k] !== null)
.sort()
.forEach((k) => (out[k] = params[k]));
return out;
}
// 复用 axios 自身将使用的 paramsSerializer,确保「签名算什么」==「线上发什么」。
// 未显式配置 serializer 时退化为 axios 默认口径(encodeURIComponent per key/value)。
export function serializeRequestParams(config: any): string {
const params = sortParamsByKey(config.params);
const ps = config.paramsSerializer;
if (ps && typeof ps === 'object' && typeof ps.serialize === 'function') {
return ps.serialize(params) || '';
}
if (typeof ps === 'function') return ps(params) || '';
if (params && typeof params === 'object') {
return Object.keys(params)
.filter((k) => params[k] !== undefined && params[k] !== null)
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(String(params[k]))}`)
.join('&');
}
return '';
}
// ---------- 路径与 query 解析 ----------
function normalizeBase(baseURL?: string): string {
return (baseURL || '').replace(/\/$/, '');
}
// 摘出 path + 内联 query:绝对 URL 取 pathname+search;相对路径去掉前导斜杠(交给下方 base 拼接)。
function normalizeUrlPath(url?: string): string {
let urlPath = url || '';
if (/^https?:\/\//i.test(urlPath)) {
const u = new URL(urlPath);
urlPath = u.pathname + u.search;
} else {
urlPath = urlPath.replace(/^\//, '');
}
return urlPath;
}
export interface CanonicalTarget {
canonPath: string;
query: string;
}
// 解析「签名 canonical 第 2 行 path」与「第 3 行 query」,二者同源、一次算清。
// 关键约束:
// 1) 路径只压缩「前面不是冒号」的重复斜杠(/(^|[^:])\/{2,}/g)——basePath 为完整地址时若全局替换会把
// 'http://' 压成 'http:/',new URL() 随即把 host:port 误当 path,canonical 第 2 行变成
// '/192.168.1.117:8788/system/auth/login'(正确应为 '/system/auth/login')→ 后端验签必失败。
// 2) query 必须与 axios 实际发出的 query 逐字节一致,否则后端验签 10011。
// 根因:同一份 params,URLSearchParams 与 axios 默认(encodeURIComponent)对部分字符编码口径不同:
// 半角括号 () → URLSearchParams=%28%29 / axios=( ) ★ 已爆出的 10011
// 空格 → URLSearchParams=+ / axios=%20
// 单引号 ' → URLSearchParams=%27 / axios='
// 波浪号 ~ → URLSearchParams=%7E / axios=~
// 叹号 ! → URLSearchParams=%21 / axios=!
// 故一律复用 axios 自身的 paramsSerializer 序列化 config.params(数组/特殊字符等所有情况与线上同源),
// 再与内联在 config.url 里的 ?x=y(原样保留,axios 不会重编码它)合并、按 key 升序排序。
export function buildCanonicalTarget(config: any): CanonicalTarget {
const basePath = normalizeBase(config.baseURL);
const urlPath = normalizeUrlPath(config.url);
// 只压缩「前面不是冒号」的重复斜杠,跳过协议里的 //。
const full = new URL(`${basePath}/${urlPath}`.replace(/(^|[^:])\/{2,}/g, '$1/'), 'http://_');
const path = full.pathname; // 浏览器侧完整路径,直连模式下为 /system/auth/login(无 /api 前缀)
// 直连模式下 baseURL 是完整地址(如 http://192.168.1.117:8788),path 不含 /api,直接作为 canonical 第 2 行;
// 与参考 sign-client.html(直连 /system/auth/login)对齐。若走代理(baseURL='/api')则此处会再摘掉 /api 前缀。
const canonPath = basePath && path.startsWith(basePath) ? path.slice(basePath.length) : path;
const inlineQuery = full.search.replace(/^\?/, '');
const paramsQuery = serializeRequestParams(config);
const tokens: string[] = [];
if (inlineQuery) tokens.push(...inlineQuery.split('&').filter(Boolean));
if (paramsQuery) tokens.push(...paramsQuery.split('&').filter(Boolean));
return { canonPath, query: tokens.sort().join('&') };
}
// ---------- Content-Type(仅取媒体类型) ----------
// 文件上传固定 multipart/form-data 且请求体不参与签名;其余取已有 Content-Type 或按是否有 body 补 application/json。
export function extractMediaType(
headers: Record<string, any>,
isForm: boolean,
hasBody: boolean,
): string {
const existingCt = headers['Content-Type'] || headers['content-type'];
return isForm
? 'multipart/form-data'
: (existingCt || (hasBody ? 'application/json' : '')).split(';')[0].trim().toLowerCase();
}
// ---------- canonical 拼接与脱敏 ----------
export interface SignParts {
method: string;
path: string;
query: string;
media: string;
timestamp: string;
nonce: string;
appId: string;
body: string;
}
// 待签名原文:8 行 \n 连接,末尾不加换行(§3.1)。
export function buildSignCanonical(p: SignParts): string {
return [p.method, p.path, p.query, p.media, p.timestamp, p.nonce, p.appId, p.body].join('\n');
}
// 调试脱敏:把 canonical 里的明文密码替换为 ***(VITE_SIGN_DEBUG=true 时打印用)。
export function maskDebugCanonical(canonical: string): string {
return canonical.replace(/"password"\s*:\s*"[^"]*"/g, '"password":"***"');
}
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
} from '@/components'; } from '@/components';
import { P, PermButton } from '@/access'; import { P, PermButton } from '@/access';
import { role, type RolePageItem, type RolePageParams } from '@/api'; import { role, type RolePageItem, type RolePageParams } from '@/api';
import { getDataScopeLabel } from '@/constants/dataScope';
import { RoleModal } from './components/RoleModal'; import { RoleModal } from './components/RoleModal';
import { RoleDetailDrawer } from './components/RoleDetailDrawer'; import { RoleDetailDrawer } from './components/RoleDetailDrawer';
import { getBaseList } from './tools/constants'; import { getBaseList } from './tools/constants';
...@@ -23,7 +22,6 @@ interface Row { ...@@ -23,7 +22,6 @@ interface Row {
id: number; id: number;
name: string; name: string;
code: string; code: string;
scope: string;
userCount: number; userCount: number;
description: string; description: string;
type: string; type: string;
...@@ -41,8 +39,6 @@ function createRolePageParams( ...@@ -41,8 +39,6 @@ function createRolePageParams(
keyword: values.keyword as string | undefined, keyword: values.keyword as string | undefined,
isBuiltin: values.type === '' || values.type === undefined ? undefined : Number(values.type), isBuiltin: values.type === '' || values.type === undefined ? undefined : Number(values.type),
status: values.status === '' || values.status === undefined ? undefined : Number(values.status), status: values.status === '' || values.status === undefined ? undefined : Number(values.status),
defaultDataScope:
values.scope === '' || values.scope === undefined ? undefined : Number(values.scope),
}; };
} }
...@@ -52,7 +48,6 @@ export default function RoleManage() { ...@@ -52,7 +48,6 @@ export default function RoleManage() {
size: DEFAULT_PAGE_SIZE, size: DEFAULT_PAGE_SIZE,
isBuiltin: undefined, isBuiltin: undefined,
status: undefined, status: undefined,
defaultDataScope: undefined,
}); });
const [queryVersion, setQueryVersion] = useState(0); const [queryVersion, setQueryVersion] = useState(0);
const [roleModalOpen, setRoleModalOpen] = useState(false); const [roleModalOpen, setRoleModalOpen] = useState(false);
...@@ -79,7 +74,6 @@ export default function RoleManage() { ...@@ -79,7 +74,6 @@ export default function RoleManage() {
id: item.roleId, id: item.roleId,
name: item.roleName, name: item.roleName,
code: item.roleCode, code: item.roleCode,
scope: getDataScopeLabel(item.defaultDataScope),
userCount: item.userCount, userCount: item.userCount,
description: item.description ?? '—', description: item.description ?? '—',
type: item.isBuiltin === 1 ? '内置' : '自定义', type: item.isBuiltin === 1 ? '内置' : '自定义',
...@@ -102,34 +96,25 @@ export default function RoleManage() { ...@@ -102,34 +96,25 @@ export default function RoleManage() {
type: 'select', type: 'select',
options: getBaseList('roleStatus'), options: getBaseList('roleStatus'),
}, },
{
name: 'scope',
label: '默认数据域',
type: 'select',
options: getBaseList('dataScope'),
},
]; ];
const columns: DataTableColumnsType<Row> = [ const columns: DataTableColumnsType<Row> = [
{ title: '角色名称', dataIndex: 'name', width: 200, line: 1 }, { title: '角色名称', dataIndex: 'name', width: 220, line: 1 },
{ {
title: '角色编码', title: '角色编码',
dataIndex: 'code', dataIndex: 'code',
width: 200, width: 220,
line: 1, line: 1,
render: (v) => <UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{v}</UText>, render: (v) => <UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{v}</UText>,
}, },
{ title: '默认数据域', dataIndex: 'scope' }, { title: '账号数', dataIndex: 'userCount' },
{ title: '账号数', dataIndex: 'userCount', width: 90 }, { title: '角色描述', dataIndex: 'description', width: 450, line: 1 },
{ title: '角色描述', dataIndex: 'description', width: 400, line: 1 },
{ {
title: '类型', title: '类型',
dataIndex: 'type', dataIndex: 'type',
width: 90,
render: (v) => <UTag color={v === '内置' ? 'geekblue' : 'default'}>{v}</UTag>, render: (v) => <UTag color={v === '内置' ? 'geekblue' : 'default'}>{v}</UTag>,
}, },
{ {
title: '状态', title: '状态',
width: 90,
render: (_, r) => ( render: (_, r) => (
<UTag color={r.status === 1 ? 'green' : 'default'}> <UTag color={r.status === 1 ? 'green' : 'default'}>
● {r.status === 1 ? '启用' : '停用'} ● {r.status === 1 ? '启用' : '停用'}
...@@ -182,7 +167,7 @@ export default function RoleManage() { ...@@ -182,7 +167,7 @@ export default function RoleManage() {
<UCard size="small"> <UCard size="small">
<SearchForm <SearchForm
fields={fields} fields={fields}
initialValues={{ type: '', status: '', scope: '' }} initialValues={{ type: '', status: '' }}
onSearch={(values, pagination) => { onSearch={(values, pagination) => {
setParams(createRolePageParams(values, pagination)); setParams(createRolePageParams(values, pagination));
setQueryVersion((version) => version + 1); setQueryVersion((version) => version + 1);
......
import { InfoCircleFilled, CheckCircleFilled } from '@ant-design/icons'; import { InfoCircleFilled, CheckCircleFilled } from '@ant-design/icons';
import { UCard, UTag } from '@uj/ui'; import { UCard } from '@uj/ui';
import { useAppStore } from '@/store/useAppStore'; import { useAppStore } from '@/store/useAppStore';
export type ChainNodeStatus = 'done' | 'active' | 'pending'; export type ChainNodeStatus = 'done' | 'active' | 'pending';
...@@ -97,7 +97,6 @@ function NodeLine({ status }: { status: ChainNodeStatus }) { ...@@ -97,7 +97,6 @@ function NodeLine({ status }: { status: ChainNodeStatus }) {
export interface ApprovalChainPreviewProps { export interface ApprovalChainPreviewProps {
nodes?: ChainNode[]; nodes?: ChainNode[];
chainType?: string;
/** (可选)覆盖默认的提交人名称。不传则取当前登录用户名 */ /** (可选)覆盖默认的提交人名称。不传则取当前登录用户名 */
submitterName?: string; submitterName?: string;
/** (可选)覆盖默认的提交时间,格式 YYYY-MM-DD HH:mm */ /** (可选)覆盖默认的提交时间,格式 YYYY-MM-DD HH:mm */
...@@ -105,10 +104,11 @@ export interface ApprovalChainPreviewProps { ...@@ -105,10 +104,11 @@ export interface ApprovalChainPreviewProps {
} }
/** /**
* 生成默认 3 节点审批链: * 生成默认 4 节点审批链:
* - 第 1 个节点「提交」:副标题 = 当前登录用户名(外部 prop 覆盖优先);时间 = submitTime 或 DEFAULT_SUBMIT_TIME * - 第 1 个节点「提交」:副标题 = 当前登录用户名(外部 prop 覆盖优先);时间 = submitTime 或 DEFAULT_SUBMIT_TIME
* - 第 2 个节点「优加财务经理」:唯一审批节点 * - 第 2 个节点「优加商务经理」:当前审批节点(active)
* - 第 3 个节点「生效」:写入门店列表 * - 第 3 个节点「优加财务经理」:下一审批节点(pending)
* - 第 4 个节点「生效」:写入门店列表
*/ */
function buildDefaultNodes(submitter: string, time: string): ChainNode[] { function buildDefaultNodes(submitter: string, time: string): ChainNode[] {
return [ return [
...@@ -120,8 +120,13 @@ function buildDefaultNodes(submitter: string, time: string): ChainNode[] { ...@@ -120,8 +120,13 @@ function buildDefaultNodes(submitter: string, time: string): ChainNode[] {
}, },
{ {
status: 'active', status: 'active',
title: '优加商务经理',
subtitle: '当前审批节点',
},
{
status: 'pending',
title: '优加财务经理', title: '优加财务经理',
subtitle: '唯一审批节点', subtitle: '下一审批节点',
}, },
{ {
status: 'pending', status: 'pending',
...@@ -133,7 +138,6 @@ function buildDefaultNodes(submitter: string, time: string): ChainNode[] { ...@@ -133,7 +138,6 @@ function buildDefaultNodes(submitter: string, time: string): ChainNode[] {
export function ApprovalChainPreview({ export function ApprovalChainPreview({
nodes, nodes,
chainType = '单级审批',
submitterName, submitterName,
submitTime, submitTime,
}: ApprovalChainPreviewProps) { }: ApprovalChainPreviewProps) {
...@@ -153,11 +157,6 @@ export function ApprovalChainPreview({ ...@@ -153,11 +157,6 @@ export function ApprovalChainPreview({
<span style={{ fontSize: 15, fontWeight: 600 }}>审批链预览</span> <span style={{ fontSize: 15, fontWeight: 600 }}>审批链预览</span>
</div> </div>
} }
extra={
<UTag color="default" bordered style={{ fontSize: 12 }}>
{chainType}
</UTag>
}
> >
<div style={{ display: 'flex', padding: '20px 8px 8px' }}> <div style={{ display: 'flex', padding: '20px 8px 8px' }}>
{finalNodes.map((n, i) => ( {finalNodes.map((n, i) => (
......
...@@ -7,7 +7,7 @@ export interface ConfirmActionBarProps { ...@@ -7,7 +7,7 @@ export interface ConfirmActionBarProps {
onSubmit?: () => void; onSubmit?: () => void;
} }
export function ConfirmActionBar({ passCount = 12, onBack, onSubmit }: ConfirmActionBarProps) { export function ConfirmActionBar({ onBack, onSubmit }: ConfirmActionBarProps) {
return ( return (
<div <div
style={{ style={{
......
import { useMemo } from 'react'; import { useMemo } from 'react';
import { InfoCircleFilled, UploadOutlined, DownloadOutlined } from '@ant-design/icons'; import { InfoCircleFilled, UploadOutlined, DownloadOutlined } from '@ant-design/icons';
import { UCard, UButton, UTag } from '@uj/ui'; import { UCard, UButton } from '@uj/ui';
import type { StoreImportFailVO, StoreImportCheckVO } from '@/api/modules/store'; import type { StoreImportFailVO, StoreImportCheckVO } from '@/api/modules/store';
export interface FailDetailCardProps { export interface FailDetailCardProps {
...@@ -130,7 +130,9 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -130,7 +130,9 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
<div <div
style={{ style={{
width: '100%', width: '100%',
maxHeight: 360,
overflowX: 'auto', overflowX: 'auto',
overflowY: 'auto',
marginBottom: 14, marginBottom: 14,
}} }}
> >
...@@ -149,7 +151,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -149,7 +151,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
))} ))}
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr style={{ position: 'sticky', top: 0, zIndex: 1 }}>
{FAIL_COL_LABELS.map((c) => ( {FAIL_COL_LABELS.map((c) => (
<th <th
key={c.key} key={c.key}
...@@ -161,6 +163,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -161,6 +163,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
padding: '10px 8px', padding: '10px 8px',
borderBottom: '1px solid #F3F4F6', borderBottom: '1px solid #F3F4F6',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
background: '#fff',
}} }}
> >
{c.label} {c.label}
...@@ -170,7 +173,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail ...@@ -170,7 +173,7 @@ export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetail
</thead> </thead>
<tbody> <tbody>
{hasFailures ? ( {hasFailures ? (
failures.slice(0, 3).map((f, i) => ( failures.map((f, i) => (
<tr key={`${f.rowIndex ?? i}-${f.levelCode ?? ''}-${f.productCategory ?? ''}`}> <tr key={`${f.rowIndex ?? i}-${f.levelCode ?? ''}-${f.productCategory ?? ''}`}>
{/* 行号(蓝 #2563EB) */} {/* 行号(蓝 #2563EB) */}
<td <td
......
...@@ -10,7 +10,6 @@ export interface SubmitActionBarProps { ...@@ -10,7 +10,6 @@ export interface SubmitActionBarProps {
} }
export function SubmitActionBar({ export function SubmitActionBar({
totalRows = 12,
loading = false, loading = false,
disabled = false, disabled = false,
onBack, onBack,
......
...@@ -44,19 +44,18 @@ function buildInfoFromCheckResult(vo: StoreImportCheckVO): SubmitConfirmInfo { ...@@ -44,19 +44,18 @@ function buildInfoFromCheckResult(vo: StoreImportCheckVO): SubmitConfirmInfo {
const monthly = Math.round(first?.costMonthly ?? 0); const monthly = Math.round(first?.costMonthly ?? 0);
const labor = Math.round(first?.costLabor ?? 0); const labor = Math.round(first?.costLabor ?? 0);
const total = deco + monthly + labor; const total = deco + monthly + labor;
const approvalRole = vo.nextRoleName ?? '优加财务经理'; const approvalRole = vo.nextRoleName ?? '-';
return { return {
storeName: vo.storeName ?? '巴州强冠东风汽车销售服务有限公司', storeName: vo.storeName ?? '-',
storeMerchantNo: vo.merchantNo ?? 'SQ20240115', storeMerchantNo: vo.merchantNo ?? '-',
categoryCount: vo.distinctProductCategoryCount ?? 6, categoryCount: vo.distinctProductCategoryCount ?? 6,
sceneCount: vo.distinctBusinessSceneCount ?? 2, sceneCount: vo.distinctBusinessSceneCount ?? 2,
totalRows: vo.productCategoryRowCount ?? vo.totalRows ?? 12, totalRows: vo.productCategoryRowCount ?? vo.totalRows ?? 12,
operatingCost: total > 0 ? `¥ ${total.toLocaleString('en-US')}` : '¥ 1,500.00', operatingCost: total > 0 ? `¥ ${total.toLocaleString('en-US')}` : '-',
operatingCostDetail: `门店维度字段(装修设备 ${deco} + 当月产生 ${monthly} + 人工成本 ${labor})`, operatingCostDetail: `门店维度字段(装修设备 ${deco} + 当月产生 ${monthly} + 人工成本 ${labor})`,
approvalChain: approvalRole, approvalChain: approvalRole,
approvalChainTag: '单级审批', approvalChainTag: '两级审批',
approvalChainDesc: '提交后直接进入单级审批,无中间节点', approvalChainDesc: '提交后直接进入两级审批,无中间节点',
// 预计审批人 = 当前提交人(登录用户名) + (审批角色)
expectedApprover: `${approvalRole}`, expectedApprover: `${approvalRole}`,
}; };
} }
......
...@@ -82,22 +82,10 @@ export interface ValidationStatsProps { ...@@ -82,22 +82,10 @@ export interface ValidationStatsProps {
checkResult?: StoreImportCheckVO; checkResult?: StoreImportCheckVO;
} }
function calcOperatingCost(vo: StoreImportCheckVO): number {
const rows = vo.previewRows ?? [];
if (rows.length === 0) return 0;
const first = rows[0];
return (
Math.round(first.costDecoration ?? 0) +
Math.round(first.costMonthly ?? 0) +
Math.round(first.costLabor ?? 0)
);
}
function buildStatsFromCheckResult(vo: StoreImportCheckVO): StatItem[] { function buildStatsFromCheckResult(vo: StoreImportCheckVO): StatItem[] {
const rows = vo.productCategoryRowCount ?? vo.totalRows; const rows = vo.productCategoryRowCount ?? vo.totalRows;
const storeCount = 1; const storeCount = 1;
const sceneCount = vo.distinctBusinessSceneCount; const sceneCount = vo.distinctBusinessSceneCount;
const operating = calcOperatingCost(vo);
const items: StatItem[] = [ const items: StatItem[] = [
{ {
...@@ -123,13 +111,6 @@ function buildStatsFromCheckResult(vo: StoreImportCheckVO): StatItem[] { ...@@ -123,13 +111,6 @@ function buildStatsFromCheckResult(vo: StoreImportCheckVO): StatItem[] {
}); });
} }
items.push({
label: '运营成本合计',
value: operating > 0 ? `¥ ${operating.toLocaleString('en-US')}` : '-',
desc: '门店维度(装修设备 + 当月产生 + 人工成本)',
tone: 'default',
});
return items; return items;
} }
...@@ -151,11 +132,13 @@ const defaultStats: StatItem[] = [ ...@@ -151,11 +132,13 @@ const defaultStats: StatItem[] = [
export function ValidationStats({ stats, checkResult }: ValidationStatsProps) { export function ValidationStats({ stats, checkResult }: ValidationStatsProps) {
const finalStats: StatItem[] = const finalStats: StatItem[] =
stats ?? (checkResult ? buildStatsFromCheckResult(checkResult) : defaultStats); stats ?? (checkResult ? buildStatsFromCheckResult(checkResult) : defaultStats);
// 按实际卡片数量平分整行宽度
const colCount = Math.max(1, finalStats.length);
return ( return (
<div <div
style={{ style={{
display: 'grid', display: 'grid',
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', gridTemplateColumns: `repeat(${colCount}, minmax(0, 1fr))`,
gap: 16, gap: 16,
marginBottom: 20, marginBottom: 20,
}} }}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!