Commit 76a1a341 by liimin

优化视觉

1 parent ff73bae9
Showing 35 changed files with 534 additions and 177 deletions
...@@ -8,10 +8,24 @@ ...@@ -8,10 +8,24 @@
# - secret = 老系统 secret(glsx SHA1 加签私钥,sign 为 40 位大写) # - secret = 老系统 secret(glsx SHA1 加签私钥,sign 为 40 位大写)
# - version = 老系统 sign.v(默认 1.0.0) # - version = 老系统 sign.v(默认 1.0.0)
# - format = 老系统 sign.format(默认 json) # - format = 老系统 sign.format(默认 json)
#
# origin 协议:内网 IP / localhost 可用 http;公网域名一律 https。
# 公网 http 会被 nginx 301 到 https,而浏览器跟随 301 时把 POST 降成 GET 并丢掉请求体,
# 表现是「状态 200、响应没数据」,网关侧报「缺少 appKey 参数」(body 没了)。
#
# origin 环境:scrm 与 dj 两行必须取自同一行环境(下表),换环境时一起换。
# 老网关的 sessionId 是分环境签发的,不是全局通行证:同一个 scrm-base-*-rop 在 scrm.dev 实测
# code 0 出数据,在 scrm.test 实测 code 21 无效的sessionId。所以域名一旦和「主壳后端签发
# loginToken 的那个环境」不一致,每个接口都会被判死,看起来像登录失效,实际是配置错环境。
# 这张对照表由 out/.temp/wire-check.mjs ⑬⑭ 从 apps/mp/usedcar/utils/request/environment.js 现读现核。
# 必填:scrm-shopmall 网关地址 # 必填:scrm-shopmall 网关地址(下面三行是同一环境的成对写法,取哪一组都要和 dj 那行同环境)
VITE_POINTS_GATEWAY_ORIGIN=http://192.168.1.158:8788/ # dev(开发内网,主壳后端默认签发的就是它)
# VITE_POINTS_GATEWAY_ORIGIN=http://scrm.test.glsx.com.cn/ VITE_POINTS_GATEWAY_ORIGIN=https://scrm.dev.glsx.com.cn/
# uat(测试域)
# VITE_POINTS_GATEWAY_ORIGIN=https://scrm.test.glsx.com.cn/
# 本机起的老服务
# VITE_POINTS_GATEWAY_ORIGIN=http://192.168.1.158:8788/
# 必填:加签凭据 # 必填:加签凭据
VITE_POINTS_GATEWAY_APP_KEY=your-app-key VITE_POINTS_GATEWAY_APP_KEY=your-app-key
...@@ -21,5 +35,9 @@ VITE_POINTS_GATEWAY_SECRET=your-secret ...@@ -21,5 +35,9 @@ VITE_POINTS_GATEWAY_SECRET=your-secret
VITE_POINTS_GATEWAY_VERSION=1.0.0 VITE_POINTS_GATEWAY_VERSION=1.0.0
VITE_POINTS_GATEWAY_FORMAT=json VITE_POINTS_GATEWAY_FORMAT=json
# 选填:dj-smartcarlife 网关独立 origin(默认与 scrm-shopmall 同域;独立域名请改) # 必填:dj 网关独立 origin(老系统与二手车小程序的环境表里 dj 与 scrm 从来是两个域名)。
VITE_POINTS_DJ_GATEWAY_ORIGIN= # 留空不会退回 scrm 域名:dj 路由挂在 scrm 域名上是 nginx 405 Not Allowed,
# 因此 credentials.ts 按网关查表取地址,缺了当场报「未配置 dj-smartcarlife 网关地址」。
# 换环境时和上面的 scrm 行一起换(协议按 ⑪ 的规则:公网写 https,哪怕小程序环境表里那行是 http)。
# dev uat prod 分别是 dj.dev / dj.test / dj.glsx.com.cn
VITE_POINTS_DJ_GATEWAY_ORIGIN=https://dj.dev.glsx.com.cn/
/**
* 用真签名直连网关,判定 sessionId 这一层到底错在哪:
* A 只放请求体 / B 只放 token 头 / C 两处都放 / D 都不放(对照)。
*/
import { readFileSync } from 'node:fs';
import { createServer, loadConfigFromFile } from 'vite';
const SID = process.argv[2] ?? 'scrm-base-a9846af8-0a90-48ce-93ea-99d852a905da-rop';
// 第三个参数可换域名试同一个 sessionId:判定「会话过期」还是「环境不匹配」
const ORIGIN = process.argv[3] ?? '';
const METHOD = 'scrm.api.shopmall.integralorder.all.page';
const env = readFileSync('.env', 'utf8');
const val = (k) => env.match(new RegExp(`^${k}=(\\S+)`, 'm'))?.[1] ?? '';
const credential = {
origin: val('VITE_POINTS_GATEWAY_ORIGIN'),
appKey: val('VITE_POINTS_GATEWAY_APP_KEY'),
secret: val('VITE_POINTS_GATEWAY_SECRET'),
version: '1.0.0',
format: 'json',
};
const cfg = await loadConfigFromFile({ command: 'serve', mode: 'development' }, 'vite.config.ts');
const server = await createServer({
...cfg.config,
appType: 'custom',
optimizeDeps: { noDiscovery: true, include: [] },
server: { ...cfg.config.server, middlewareMode: true },
logLevel: 'error',
});
const send = async (label, { bodySid, headerSid }) => {
const apiCore = await server.ssrLoadModule('@uj/api-core');
await server.ssrLoadModule('/src/adapter/gateways/index.ts');
const raw = await apiCore.prepareRpcCall(
{ gateway: 'scrm-shopmall', method: METHOD, params: { currentPage: 1, pageSize: 1 } },
{
resolveCredential: () => (ORIGIN ? { ...credential, origin: ORIGIN } : credential),
resolveToken: () => (headerSid ? SID : ''),
session: bodySid ? { name: 'sessionId', value: SID } : undefined,
timeout: 180000,
},
);
const form = new URLSearchParams(
Object.entries(raw.data).map(([k, v]) => [k, String(v)]),
).toString();
const res = await fetch(raw.url, {
method: 'POST',
headers: { 'content-type': 'application/x-www-form-urlencoded', ...(raw.headers ?? {}) },
body: form,
});
const text = (await res.text()).replace(/\s+/g, ' ').slice(0, 160);
const sentSid = raw.data.sessionId ? '有' : '无';
console.log(`${label} body.sessionId=${sentSid} token头=${headerSid ? '有' : '无'}\n → ${text}\n`);
};
try {
console.log('打到', ORIGIN || credential.origin);
await send('A 只放请求体 ', { bodySid: true, headerSid: false });
await send('B 只放 token 头 ', { bodySid: false, headerSid: true });
await send('C 两处都放 ', { bodySid: true, headerSid: true });
await send('D 都不放(对照) ', { bodySid: false, headerSid: false });
console.log('被试 sessionId =', SID);
} finally {
await server.close();
}
/**
* 直连网关复现「累计结算金额」这一条:完全照子应用的发法(同一个方法名、同样不加签)。
* 用法:node out/.temp/settle-probe.mjs <sessionId> [origin]
* 只读统计接口,不写任何数据。
*/
import { readFileSync } from 'node:fs';
import { createServer, loadConfigFromFile } from 'vite';
const SID = process.argv[2];
if (!SID) {
console.log('用法:node out/.temp/settle-probe.mjs <sessionId> [origin]');
process.exit(1);
}
const lines = readFileSync('.env', 'utf8')
.split('\n')
.filter((line) => /^[A-Z_]+=/.test(line))
.map((line) => line.split('='));
const val = (k) => lines.find(([key]) => key === k)?.[1]?.trim() ?? '';
const credential = {
origin: process.argv[3] || val('VITE_POINTS_GATEWAY_ORIGIN'),
appKey: val('VITE_POINTS_GATEWAY_APP_KEY'),
secret: val('VITE_POINTS_GATEWAY_SECRET'),
version: '1.0.0',
format: 'json',
};
const cfg = await loadConfigFromFile({ command: 'serve', mode: 'development' }, 'vite.config.ts');
const server = await createServer({
...cfg.config,
appType: 'custom',
optimizeDeps: { noDiscovery: true, include: [] },
server: { ...cfg.config.server, middlewareMode: true },
logLevel: 'error',
});
const apiCore = await server.ssrLoadModule('@uj/api-core');
await server.ssrLoadModule('/src/adapter/gateways/index.ts');
const deps = {
resolveCredential: () => credential,
resolveToken: () => SID,
session: { name: 'sessionId', value: SID },
timeout: 60000,
};
const METHOD = {
settleAmount: 'scrm.api.shopmall.integral.transfer.out.settle.amount.get',
sumAllPayAmount: 'scrm.api.shopmall.integral.transfer.out.all.pay.amount',
checkTransferType: 'scrm.api.shopmall.integral.transfer.out.check.records.transferType',
payChannels: 'scrm.api.shopmall.integral.transfer.out.getChannel',
balance: 'scrm.api.shopmall.integral.transfer.out.balance.get',
};
const ask = async (method, mode) => {
// 子应用的请求出口现在一律带 usedCarFlag=1,这里照搬,保证三种发法只差在签名上。
const raw = await apiCore.prepareRpcCall(
{ gateway: 'scrm-shopmall', method, params: { usedCarFlag: '1' }, signed: mode.signed },
deps,
);
const fields = { ...raw.data };
if (mode.dropSign) delete fields.sign;
const form = new URLSearchParams(
Object.entries(fields).map(([k, v]) => [k, typeof v === 'string' ? v : JSON.stringify(v)]),
).toString();
const reply = await fetch(raw.url, {
method: 'POST',
headers: { ...raw.headers, 'content-type': 'application/x-www-form-urlencoded' },
body: form,
})
.then((r) => r.text().then((t) => ({ http: r.status, t })))
.catch((e) => ({ http: 0, t: String(e) }));
const code = (reply.t.match(/"code"\s*:\s*"(\d+)"/) ?? reply.t.match(/code="(\d+)"/) ?? [])[1] ?? '?';
const message = (reply.t.match(/"message"\s*:\s*"([^"]*)"/) ?? reply.t.match(/<message>([^<]*)</) ?? [])[1] ?? '';
return `HTTP ${reply.http} code=${code} ${message.slice(0, 26)}`;
};
// 三种发法:照现在(signed:false,信封也不发)/ 信封齐但不带 sign / 信封齐且带 sign
for (const [name, method] of Object.entries(METHOD)) {
const asIs = await ask(method, { signed: false });
const noSign = await ask(method, { signed: true, dropSign: true });
const withSign = await ask(method, { signed: true });
console.log(`${name.padEnd(17)} 现状:${asIs} | 信封无sign:${noSign} | 带sign:${withSign}`);
}
await server.close();
...@@ -2,7 +2,6 @@ import { useEffect, useMemo, useState } from 'react'; ...@@ -2,7 +2,6 @@ import { useEffect, useMemo, useState } from 'react';
import { busEvents } from '@uj/contracts'; import { busEvents } from '@uj/contracts';
import { SubAppProvider, readInitialPage, shortName, subappBus } from '@uj/platform-sdk'; import { SubAppProvider, readInitialPage, shortName, subappBus } from '@uj/platform-sdk';
import OrderList from './pages/OrderList'; import OrderList from './pages/OrderList';
import OrderDetail from './pages/OrderDetail';
import ScoreUsers from './pages/ScoreUsers'; import ScoreUsers from './pages/ScoreUsers';
import UserScoreDetail from './pages/UserScoreDetail'; import UserScoreDetail from './pages/UserScoreDetail';
import WithdrawManage from './pages/WithdrawManage'; import WithdrawManage from './pages/WithdrawManage';
...@@ -18,7 +17,6 @@ import { UEmpty } from '@uj/ui'; ...@@ -18,7 +17,6 @@ import { UEmpty } from '@uj/ui';
*/ */
const ROUTES: RouteDef[] = [ const ROUTES: RouteDef[] = [
{ path: 'list', Page: OrderList }, { path: 'list', Page: OrderList },
{ path: 'order/:id', Page: OrderDetail },
{ path: 'users', Page: ScoreUsers }, { path: 'users', Page: ScoreUsers },
{ path: 'user/:channelSource/:staffId', Page: UserScoreDetail }, { path: 'user/:channelSource/:staffId', Page: UserScoreDetail },
{ path: 'user/:channelSource/:merchantId/:phone', Page: UserScoreDetail }, { path: 'user/:channelSource/:merchantId/:phone', Page: UserScoreDetail },
......
...@@ -16,25 +16,34 @@ import type { GatewayId } from './types'; ...@@ -16,25 +16,34 @@ import type { GatewayId } from './types';
const env = import.meta.env as Record<string, string | undefined>; const env = import.meta.env as Record<string, string | undefined>;
const SHARED = { const SHARED = {
origin: (env.VITE_POINTS_GATEWAY_ORIGIN ?? '').trim(),
appKey: (env.VITE_POINTS_GATEWAY_APP_KEY ?? '').trim(), appKey: (env.VITE_POINTS_GATEWAY_APP_KEY ?? '').trim(),
secret: (env.VITE_POINTS_GATEWAY_SECRET ?? '').trim(), secret: (env.VITE_POINTS_GATEWAY_SECRET ?? '').trim(),
version: (env.VITE_POINTS_GATEWAY_VERSION ?? '1.0.0').trim(), version: (env.VITE_POINTS_GATEWAY_VERSION ?? '1.0.0').trim(),
format: (env.VITE_POINTS_GATEWAY_FORMAT ?? 'json').trim(), format: (env.VITE_POINTS_GATEWAY_FORMAT ?? 'json').trim(),
}; };
/** 个别网关(dj)在老系统里挂在另一个域名上,允许单独覆盖。 */ /**
const OVERRIDES: Partial<Record<GatewayId, string>> = { * 每个网关的地址来自哪个环境变量 —— 取值与报错文案共用这一张表。
'dj-smartcarlife': (env.VITE_POINTS_DJ_GATEWAY_ORIGIN ?? '').trim(), *
* dj 路由不在 scrm 域名上(那里对 dj 的 POST 直接 405 Not Allowed),老系统与二手车小程序
* 的环境表里 dj 与 scrm 从来是两个域名,所以不给「读不到就退回 scrm」的兜底:
* 兜底的后果是接口静默无数据,排查成本远高于少配一个变量时当场报错。
*/
const GATEWAY_ORIGIN_ENV: Record<GatewayId, string> = {
'scrm-shopmall': 'VITE_POINTS_GATEWAY_ORIGIN',
'scrm-carlife': 'VITE_POINTS_GATEWAY_ORIGIN',
'dj-smartcarlife': 'VITE_POINTS_DJ_GATEWAY_ORIGIN',
}; };
const envOrigin = (id: GatewayId): string => (env[GATEWAY_ORIGIN_ENV[id]] ?? '').trim();
const injected = new Map<GatewayId, GatewayCredential>(); const injected = new Map<GatewayId, GatewayCredential>();
/** 运行时注入(联调脚本、灰度环境或后端下发的配置中心)。 */ /** 运行时注入(联调脚本、灰度环境或后端下发的配置中心)。 */
export function setGatewayCredential(id: GatewayId, credential: Partial<GatewayCredential>): void { export function setGatewayCredential(id: GatewayId, credential: Partial<GatewayCredential>): void {
const previous = injected.get(id); const previous = injected.get(id);
injected.set(id, { injected.set(id, {
origin: credential.origin ?? previous?.origin ?? SHARED.origin, origin: credential.origin ?? previous?.origin ?? envOrigin(id),
appKey: credential.appKey ?? previous?.appKey ?? SHARED.appKey, appKey: credential.appKey ?? previous?.appKey ?? SHARED.appKey,
secret: credential.secret ?? previous?.secret ?? SHARED.secret, secret: credential.secret ?? previous?.secret ?? SHARED.secret,
version: credential.version ?? previous?.version ?? SHARED.version, version: credential.version ?? previous?.version ?? SHARED.version,
...@@ -43,14 +52,11 @@ export function setGatewayCredential(id: GatewayId, credential: Partial<GatewayC ...@@ -43,14 +52,11 @@ export function setGatewayCredential(id: GatewayId, credential: Partial<GatewayC
} }
export function getGatewayCredential(id: GatewayId): GatewayCredential { export function getGatewayCredential(id: GatewayId): GatewayCredential {
const credential = injected.get(id) ?? { const credential = injected.get(id) ?? { ...SHARED, origin: envOrigin(id) };
...SHARED,
origin: OVERRIDES[id] || SHARED.origin,
};
if (!credential.origin) { if (!credential.origin) {
throw new Error( throw new Error(
`未配置 ${id} 网关地址:请在 .env 设置 VITE_POINTS_GATEWAY_ORIGIN(或该网关的独立 origin),` + `未配置 ${id} 网关地址:请在 .env 设置 ${GATEWAY_ORIGIN_ENV[id]}。` +
'积分域的接口不会自动改走主壳后端。', '积分域的接口不会自动改走主壳后端,也不会退回其它网关的域名。',
); );
} }
return credential; return credential;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: liimin 17653212@qq.com * @Author: liimin 17653212@qq.com
* @Date: 2026-11-06 15:45:47 * @Date: 2026-11-06 15:45:47
* @LastEditors: liimin 17653212@qq.com * @LastEditors: liimin 17653212@qq.com
* @LastEditTime: 2026-11-09 18:56:31 * @LastEditTime: 2026-11-10 16:02:45
* @FilePath: \uj-admin\apps\web\subapps\points\src\adapter\gateways\glsx.ts * @FilePath: \uj-admin\apps\web\subapps\points\src\adapter\gateways\glsx.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -83,7 +83,7 @@ export function createGlsxGateway(def: GlsxGatewayDef): GatewayStrategy { ...@@ -83,7 +83,7 @@ export function createGlsxGateway(def: GlsxGatewayDef): GatewayStrategy {
normalize: normalizeGlsxEnvelope, normalize: normalizeGlsxEnvelope,
// 老网关每次请求固定携带、且参与加签的渠道参数:与老系统 / 真实抓包一致用 'scrm-home'。 // 老网关每次请求固定携带、且参与加签的渠道参数:与老系统 / 真实抓包一致用 'scrm-home'。
// 改这个值会直接改变签名原文,联调前不要随意换渠道名。 // 改这个值会直接改变签名原文,联调前不要随意换渠道名。
fixedParams: { source: 'scrm-home' }, fixedParams: { source: 'uj-web-points' },
}; };
} }
......
...@@ -29,15 +29,16 @@ const LEGACY_TIMEOUT = 180000; ...@@ -29,15 +29,16 @@ const LEGACY_TIMEOUT = 180000;
* *
* 装配层只给环境参数: * 装配层只给环境参数:
* · gatewayCredential / gatewayToken —— 本域 .env 凭据与会话令牌,包内不留密钥字面量; * · gatewayCredential / gatewayToken —— 本域 .env 凭据与会话令牌,包内不留密钥字面量;
* · contentType:false —— 不预置 Content-Type,否则会改变主壳加签的 canonical 原文;
* · errorHandler —— 把门面的 RequestError 还原成主壳原错误(带 code=10002 等), * · errorHandler —— 把门面的 RequestError 还原成主壳原错误(带 code=10002 等),
* 保留上层按 code 判断登出的能力。401 登出与网络异常提示由主壳负责,这里不重复 toast。 * 保留上层按 code 判断登出的能力。401 登出与网络异常提示由主壳负责,这里不重复 toast。
*
* 这里不设 contentType:RPC 请求体的编码属于网关事实(glsx rop 只读 form 体),
* 由 prepareRpcCall 随请求头一起给出;在这一层再写一次就是两个真源。
*/ */
export const request = createClient({ export const request = createClient({
transport: 'host', transport: 'host',
hostSend: requestViaHost(), hostSend: requestViaHost(),
timeout: LEGACY_TIMEOUT, timeout: LEGACY_TIMEOUT,
contentType: false,
gatewayCredential: (id) => getGatewayCredential(id as GatewayId), gatewayCredential: (id) => getGatewayCredential(id as GatewayId),
gatewayToken: getGatewayToken, gatewayToken: getGatewayToken,
// sessionId 取自登录接口的 data.loginToken(老网关会话标识);facade 的 resolveSession 会在 // sessionId 取自登录接口的 data.loginToken(老网关会话标识);facade 的 resolveSession 会在
......
import { rpcCall } from '@/adapter'; import { rpcCall } from '@/adapter';
import type { GatewayId } from '@/adapter'; import type { GatewayId } from '@/adapter';
import { withUsedCarScope } from './usedCarScope';
/** /**
* 积分域的接口不是 REST:一个 RPC 方法名 + 一层平铺参数。 * 积分域的接口不是 REST:一个 RPC 方法名 + 一层平铺参数。
...@@ -34,7 +35,9 @@ export class RpcApiClient { ...@@ -34,7 +35,9 @@ export class RpcApiClient {
return rpcCall<T>({ return rpcCall<T>({
gateway, gateway,
method, method,
params, // 本域唯一的请求出口,因此也是「一律带 usedCarFlag=1」唯一的落点:
// 分页、导出、金额合计、一键操作校验全部经过这里,新加的接口不用登记也不会漏。
params: withUsedCarScope(params),
signed: options.signed, signed: options.signed,
unsignedKeys: options.unsignedKeys, unsignedKeys: options.unsignedKeys,
}); });
......
/**
* 「二手车展业门店」是这个系统的数据身份,不是筛选条件。
*
* 后端把 usedCarFlag(Integer)加在三组分页请求体上(StaffScoreRopRequest /
* IntegralOrderPageRequest / IntegralTransferOutPageRequest),同组请求体又被各自的
* 导出、金额合计、一键操作校验复用。取值只有一个口径:`1` = 只返回二手车展业门店的数据。
*
* 因此这个字段不在任何页面表单里出现,也不写在任何接口方法上:它在请求出口一次性注入
* (见 `src/api/core/rpc-client.ts`),本域的每一个 RPC 都必然带上,
* 不会出现「列表筛了、导出不筛」「这页带了、那页漏了」的口径分叉。
* 将来要接「非二手车」的第二套部署,改这一个常量与注入点即可,页面代码不用动。
*/
export const USED_CAR_FIELD_NAME = 'usedCarFlag';
/** 后端只认这一个值:`1` = 二手车展业门店。 */
export const USED_CAR_FLAG = '1';
/**
* 注入并覆盖:调用方传什么都以这里为准。
* 「一律带」是系统级口径,不能被某个页面的表单值改写 —— 所以合并放在最后一步、只放这一处。
*/
export function withUsedCarScope(params: Record<string, unknown>): Record<string, unknown> {
return { ...params, [USED_CAR_FIELD_NAME]: USED_CAR_FLAG };
}
...@@ -38,6 +38,26 @@ class PointsApi extends RpcApiClient { ...@@ -38,6 +38,26 @@ class PointsApi extends RpcApiClient {
return this.rpc<string>('scrm-shopmall', 'scrm.api.shopmall.integralorder.all.export', params); return this.rpc<string>('scrm-shopmall', 'scrm.api.shopmall.integralorder.all.export', params);
} }
/**
* 积分核销订单分页(门店版)。
*
* 后端这两个不带 `all.` 的入口与上面那对共用同一份 `IntegralOrderPageRequest`,
* 因此 `usedCarFlag` 同样生效;老系统只登记了 `all.*`,门店版没有页面调它。
* 这里登记是为了让门店端接入积分订单时不必重新摸接口 —— 看到「无人调用」先别删。
*/
pageStoreOrders(params: Record<string, unknown>) {
return this.rpc<RpcListResult<WriteOffOrder>>(
'scrm-shopmall',
'scrm.api.shopmall.integralorder.page',
params,
);
}
/** 积分核销订单导出(门店版),入参与分页同一份 */
exportStoreOrders(params: Record<string, unknown>) {
return this.rpc<string>('scrm-shopmall', 'scrm.api.shopmall.integralorder.export', params);
}
/** 批量结算导入:file 形如 "<扩展名>@<base64>" */ /** 批量结算导入:file 形如 "<扩展名>@<base64>" */
importSettlement(file: string) { importSettlement(file: string) {
return this.rpc<unknown>('scrm-shopmall', 'scrm.api.shopmall.integralorder.settlement.import', { return this.rpc<unknown>('scrm-shopmall', 'scrm.api.shopmall.integralorder.settlement.import', {
......
...@@ -114,13 +114,12 @@ class WithdrawApi extends RpcApiClient { ...@@ -114,13 +114,12 @@ class WithdrawApi extends RpcApiClient {
); );
} }
/** 校验所选记录 / 查询结果是否为同一提现类型(老系统该接口不加签) */ /** 校验所选记录 / 查询结果是否为同一提现类型(实测该接口仍必须加签) */
checkTransferType(params: Record<string, unknown> = {}) { checkTransferType(params: Record<string, unknown> = {}) {
return this.rpc<TransferTypeCheck>( return this.rpc<TransferTypeCheck>(
'scrm-shopmall', 'scrm-shopmall',
'scrm.api.shopmall.integral.transfer.out.check.records.transferType', 'scrm.api.shopmall.integral.transfer.out.check.records.transferType',
params, params,
{ signed: false },
); );
} }
...@@ -142,23 +141,21 @@ class WithdrawApi extends RpcApiClient { ...@@ -142,23 +141,21 @@ class WithdrawApi extends RpcApiClient {
); );
} }
/** 提现金额合计(按查询条件,一键操作用;老系统该接口不加签) */ /** 提现金额合计(按查询条件,一键操作用;实测仍必须加签,少了 sign 回 code 24) */
sumAllPayAmount(params: Record<string, unknown> = {}) { sumAllPayAmount(params: Record<string, unknown> = {}) {
return this.rpc<PayAmountCheck>( return this.rpc<PayAmountCheck>(
'scrm-shopmall', 'scrm-shopmall',
'scrm.api.shopmall.integral.transfer.out.all.pay.amount', 'scrm.api.shopmall.integral.transfer.out.all.pay.amount',
params, params,
{ signed: false },
); );
} }
/** 累计结算金额统计(按统计项编码平铺;老系统该接口不加签) */ /** 累计结算金额统计(按统计项编码平铺;实测仍必须加签,少了 sign 回 code 24) */
settleAmount(params: Record<string, unknown> = {}) { settleAmount(params: Record<string, unknown> = {}) {
return this.rpc<SettleAmountMap>( return this.rpc<SettleAmountMap>(
'scrm-shopmall', 'scrm-shopmall',
'scrm.api.shopmall.integral.transfer.out.settle.amount.get', 'scrm.api.shopmall.integral.transfer.out.settle.amount.get',
params, params,
{ signed: false },
); );
} }
...@@ -171,13 +168,12 @@ class WithdrawApi extends RpcApiClient { ...@@ -171,13 +168,12 @@ class WithdrawApi extends RpcApiClient {
); );
} }
/** 按提现类型/方式取可付款的渠道列表(单选那一项;老系统该接口不加签) */ /** 按提现类型/方式取可付款的渠道列表(单选那一项;实测仍必须加签,少了 sign 回 code 24) */
payChannels(params: Record<string, unknown> = {}) { payChannels(params: Record<string, unknown> = {}) {
return this.rpc<PayChannelOption[]>( return this.rpc<PayChannelOption[]>(
'scrm-shopmall', 'scrm-shopmall',
'scrm.api.shopmall.integral.transfer.out.getChannel', 'scrm.api.shopmall.integral.transfer.out.getChannel',
params, params,
{ signed: false },
); );
} }
...@@ -235,13 +231,12 @@ class WithdrawApi extends RpcApiClient { ...@@ -235,13 +231,12 @@ class WithdrawApi extends RpcApiClient {
); );
} }
/** 第三方余额:接口直接回一个金额(元,不加签),无数据时为空 */ /** 第三方余额:接口直接回一个金额(元,一样必须加签),无数据时为空 */
balance(params: Record<string, unknown> = {}) { balance(params: Record<string, unknown> = {}) {
return this.rpc<number | string | undefined>( return this.rpc<number | string | undefined>(
'scrm-shopmall', 'scrm-shopmall',
'scrm.api.shopmall.integral.transfer.out.balance.get', 'scrm.api.shopmall.integral.transfer.out.balance.get',
params, params,
{ signed: false },
); );
} }
......
...@@ -91,7 +91,7 @@ export function buildApprovalTransferColumns( ...@@ -91,7 +91,7 @@ export function buildApprovalTransferColumns(
{ {
title: '收款手机号', title: '收款手机号',
dataIndex: 'mobile', dataIndex: 'mobile',
width: 130, width: 140,
render: (value) => <span className="uj-code">{textOr(value)}</span>, render: (value) => <span className="uj-code">{textOr(value)}</span>,
}, },
]; ];
......
...@@ -83,6 +83,18 @@ ...@@ -83,6 +83,18 @@
} }
} }
/* 抽屉内空间充足(宽 ≥600),明细固定两列一行,不再跟外层 viewport 媒体查询走三列/单列。
用 .ant-drawer-body 前缀把特异性抬到 (0,2,0),稳稳压过上面的单类选择器规则;
极窄抽屉(<480,多见于手机全屏抽屉)回退单列,避免标签被挤断。 */
.ant-drawer-body .uj-points-detail-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 480px) {
.ant-drawer-body .uj-points-detail-grid {
grid-template-columns: minmax(0, 1fr);
}
}
/* 统计条容器与标题行:对齐老系统 .statistics(无外框)与 .title(16px 粗体)。 */ /* 统计条容器与标题行:对齐老系统 .statistics(无外框)与 .title(16px 粗体)。 */
.uj-points-statistics-card { .uj-points-statistics-card {
flex: none; flex: none;
...@@ -98,6 +110,18 @@ ...@@ -98,6 +110,18 @@
font-weight: 700; font-weight: 700;
color: var(--uj-text-1); color: var(--uj-text-1);
} }
/* 取数失败:整条替换成一行人话,用 error 三色把「没数据」和「没取到」区分开。 */
.uj-points-statistics-error {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border: 1px solid var(--uj-error-border);
border-radius: 6px;
background: var(--uj-error-soft);
color: var(--uj-error);
font-size: 13px;
}
/* 弹窗里的分组小标题与提示:统一比正文小一号、取第三级文字色。 */ /* 弹窗里的分组小标题与提示:统一比正文小一号、取第三级文字色。 */
.uj-points-dialog-label { .uj-points-dialog-label {
display: block; display: block;
......
/* 子应用内样式只在 <wujie-app> 的 shadowRoot 内生效,不会污染主壳。 /* 子应用内样式只在 <wujie-app> 的 shadowRoot 内生效,不会污染主壳。
tokens.css 由 main.tsx 引入;根节点带 .uj-scope 让令牌在 shadowRoot 内有本地落点, tokens.css 由 main.tsx 引入;根节点带 .uj-scope 让令牌在 shadowRoot 内有本地落点,
不依赖「自定义属性恰好能穿透 shadow DOM」这个侥幸。 */ 不依赖「自定义属性恰好能穿透 shadow DOM」这个侥幸。 */
/* 根因修复:iframe 的 html/body 必须定高,否则下方 .uj-points-app 的 height:100%
会回退成「内容高度」,导致 body 实际溢出。
溢出后 antd 抽屉打开时,rc-util 的滚动锁(useScrollLocker)检测到 body 溢出,
会给 `html body` 注入 `width: calc(100% - 滚动条宽px)` 来补偿被隐藏的滚动条 ——
可本应用滚动收在 .uj-points-app(overflow:auto)里、body 本身并不滚动,
这条补偿只会把整页宽度收窄,造成「打开抽屉整页左移、关闭复原」的抖动。
定高后 body 不再溢出,滚动锁不再注入该宽度补偿,抖动从源头消失。 */
html,
body {
height: 100%;
}
/* 兜底:万一某些长页面仍让 body 溢出(极端内容/未走 .uj-points-app 的入口),
直接强制 body 满宽,彻底消除左移,且不影响 .uj-points-app 内部自身的滚动。 */
html body {
width: 100% !important;
}
.uj-points-app { .uj-points-app {
/* height(而非 min-height):列表页要靠这条定高链路把剩余空间量出来。 /* height(而非 min-height):列表页要靠这条定高链路把剩余空间量出来。
长页面由内部 .uj-page 撑高后在本容器里滚,不会把 iframe 撑破。 */ 长页面由内部 .uj-page 撑高后在本容器里滚,不会把 iframe 撑破。 */
......
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { Skeleton, UAlert, UButton, UCard, UResult, UTitle } from '@uj/ui'; import { Skeleton, UAlert, UButton, UDrawer, UTitle } from '@uj/ui';
import { pointsApi } from '@/api'; import { pointsApi, type WriteOffOrderDetail } from '@/api';
import { PP } from '@/permissions/codes';
import { usePointsAccess } from '@/features/shared/access';
import { SETTLE_STATUS, optionLabel } from '@/features/shared/dictionaries'; import { SETTLE_STATUS, optionLabel } from '@/features/shared/dictionaries';
import { numberOr, textOr } from '@/features/shared/format'; import { numberOr, textOr } from '@/features/shared/format';
import { PageShell } from '@/features/shared/PageShell';
import type { PageParams } from '@/routes';
/** 详情字段的展示修饰:number = 按数字显示,code = 等宽字体(长单号)。 */
interface DetailField {
label: string;
key: string;
number?: boolean;
code?: boolean;
}
/** 详情字段与顺序逐字对齐老系统的 orderDetail.vue;空值一律显示占位符,不再显示 undefined。 */ /** 详情字段与顺序逐字对齐老系统的 orderDetail.vue;空值一律显示占位符,不再显示 undefined。 */
const FIELDS: DetailField[] = [ const FIELDS: { label: string; key: string; number?: boolean; code?: boolean }[] = [
{ label: '项目名称', key: 'bizRelName' }, { label: '项目名称', key: 'bizRelName' },
{ label: '消费积分', key: 'integralValue', number: true }, { label: '消费积分', key: 'integralValue', number: true },
{ label: '客户昵称', key: 'customerWechatName' }, { label: '客户昵称', key: 'customerWechatName' },
...@@ -30,43 +18,32 @@ const FIELDS: DetailField[] = [ ...@@ -30,43 +18,32 @@ const FIELDS: DetailField[] = [
{ label: '商户名称', key: 'merchantName' }, { label: '商户名称', key: 'merchantName' },
]; ];
export default function OrderDetail({ params }: { params: PageParams }) { export interface OrderDetailDrawerProps {
const { can } = usePointsAccess(); open: boolean;
const allowed = can(PP.ORDER_VIEW); id: string;
const id = params.id ?? ''; onClose: () => void;
}
/**
* 核销订单详情:原是独立路由页(order/:id),改为抽屉后,
* 用户在列表点「查看」不必跳出列表上下文,看完关掉即可继续处理。
* 内容与旧页逐字一致(字段、文案、空值占位)。
*/
export function OrderDetailDrawer({ open, id, onClose }: OrderDetailDrawerProps) {
const detail = useQuery({ const detail = useQuery({
queryKey: ['points', 'order', id], queryKey: ['points', 'order', id],
queryFn: () => pointsApi.orderDetail(id), queryFn: () => pointsApi.orderDetail(id),
enabled: allowed && !!id, enabled: open && !!id,
}); });
if (!allowed) { const data = detail.data as WriteOffOrderDetail | undefined;
return (
<UResult status="403" title="无积分核销订单访问权限" subTitle="请联系管理员确认账号权限。" />
);
}
if (!id) {
return (
<UResult
status="warning"
title="缺少订单标识"
subTitle="请从积分核销订单列表点击进入查看。"
/>
);
}
const data = detail.data;
// 结算状态文案老系统在页面里由 settlementStatus 现算,这里同样不依赖接口的冗余字段。 // 结算状态文案老系统在页面里由 settlementStatus 现算,这里同样不依赖接口的冗余字段。
const values: Record<string, string> = { const values: Record<string, string> = {
settlementStatusTxt: optionLabel(SETTLE_STATUS, data?.settlementStatus), settlementStatusTxt: optionLabel(SETTLE_STATUS, data?.settlementStatus),
}; };
return ( return (
<PageShell <UDrawer title="核销订单详情" width={600} open={open} onClose={onClose}>
title="核销订单详情"
description="这一笔积分核销的项目、客户与结算信息;返回后可在列表继续处理。"
back="list"
>
{detail.isError ? ( {detail.isError ? (
<UAlert <UAlert
type="error" type="error"
...@@ -82,7 +59,8 @@ export default function OrderDetail({ params }: { params: PageParams }) { ...@@ -82,7 +59,8 @@ export default function OrderDetail({ params }: { params: PageParams }) {
) : detail.isPending ? ( ) : detail.isPending ? (
<Skeleton variant="detail" /> <Skeleton variant="detail" />
) : ( ) : (
<UCard size="small"> <>
{/* 抽屉面板本身就是容器,不再套带描边的卡片,避免双重边框。 */}
<UTitle level={5}>订单信息</UTitle> <UTitle level={5}>订单信息</UTitle>
<dl className="uj-points-detail-grid"> <dl className="uj-points-detail-grid">
{FIELDS.map((field) => { {FIELDS.map((field) => {
...@@ -99,8 +77,8 @@ export default function OrderDetail({ params }: { params: PageParams }) { ...@@ -99,8 +77,8 @@ export default function OrderDetail({ params }: { params: PageParams }) {
); );
})} })}
</dl> </dl>
</UCard> </>
)} )}
</PageShell> </UDrawer>
); );
} }
...@@ -10,9 +10,9 @@ import { compactParams, errorMessage, expandDateRanges } from '@/features/shared ...@@ -10,9 +10,9 @@ import { compactParams, errorMessage, expandDateRanges } from '@/features/shared
import { isExcel, readLegacyFile, sizeError } from '@/features/shared/files'; import { isExcel, readLegacyFile, sizeError } from '@/features/shared/files';
import { firstPage, useExport, useList, usePageClamp, useRefresh } from '@/features/shared/queries'; import { firstPage, useExport, useList, usePageClamp, useRefresh } from '@/features/shared/queries';
import { PageShell } from '@/features/shared/PageShell'; import { PageShell } from '@/features/shared/PageShell';
import { goTo } from '@/features/shared/navigate';
import { useConfirmAction } from '@/features/shared/useConfirmAction'; import { useConfirmAction } from '@/features/shared/useConfirmAction';
import { buildOrderColumns } from './tools/columns'; import { buildOrderColumns } from './tools/columns';
import { OrderDetailDrawer } from './components/OrderDetailDrawer';
const SCOPE = ['points', 'orders'] as const; const SCOPE = ['points', 'orders'] as const;
...@@ -28,6 +28,7 @@ const FIELDS: FieldSchema<Record<string, unknown>>[] = [ ...@@ -28,6 +28,7 @@ const FIELDS: FieldSchema<Record<string, unknown>>[] = [
type: 'input', type: 'input',
placeholder: '请输入项目名称', placeholder: '请输入项目名称',
inputProps: { maxLength: 100 }, inputProps: { maxLength: 100 },
essential: true,
}, },
{ {
name: 'merchantName', name: 'merchantName',
...@@ -35,8 +36,15 @@ const FIELDS: FieldSchema<Record<string, unknown>>[] = [ ...@@ -35,8 +36,15 @@ const FIELDS: FieldSchema<Record<string, unknown>>[] = [
type: 'input', type: 'input',
placeholder: '请输入商户名称', placeholder: '请输入商户名称',
inputProps: { maxLength: 100 }, inputProps: { maxLength: 100 },
essential: true,
},
{
name: 'settlementStatus',
label: '结算状态',
type: 'select',
options: withAll(SETTLE_STATUS),
essential: true,
}, },
{ name: 'settlementStatus', label: '结算状态', type: 'select', options: withAll(SETTLE_STATUS) },
{ name: 'verificationTimeStr', label: '核销日期', type: 'dateRange' }, { name: 'verificationTimeStr', label: '核销日期', type: 'dateRange' },
]; ];
...@@ -46,6 +54,7 @@ export default function OrderList() { ...@@ -46,6 +54,7 @@ export default function OrderList() {
const allowed = can(PP.ORDER_VIEW); const allowed = can(PP.ORDER_VIEW);
const [filters, setFilters] = useState<Record<string, unknown>>({}); const [filters, setFilters] = useState<Record<string, unknown>>({});
const [page, setPage] = useState(firstPage); const [page, setPage] = useState(firstPage);
const [detailId, setDetailId] = useState<string>();
const refresh = useRefresh([...SCOPE]); const refresh = useRefresh([...SCOPE]);
const list = useList<WriteOffOrder>({ const list = useList<WriteOffOrder>({
scope: [...SCOPE], scope: [...SCOPE],
...@@ -81,7 +90,7 @@ export default function OrderList() { ...@@ -81,7 +90,7 @@ export default function OrderList() {
const columns = buildOrderColumns(); const columns = buildOrderColumns();
const rowActions: RowActionSchema<WriteOffOrder>[] = [ const rowActions: RowActionSchema<WriteOffOrder>[] = [
{ label: '查看', onClick: (row) => goTo(`order/${row.id}`) }, { label: '查看', onClick: (row) => setDetailId(row.id) },
{ {
label: (row) => (Number(row.settlementStatus) === 1 ? '取消结算' : '去结算'), label: (row) => (Number(row.settlementStatus) === 1 ? '取消结算' : '去结算'),
visible: () => can(PP.ORDER_SETTLE), visible: () => can(PP.ORDER_SETTLE),
...@@ -133,7 +142,11 @@ export default function OrderList() { ...@@ -133,7 +142,11 @@ export default function OrderList() {
<UCard className="uj-filter-card" size="small"> <UCard className="uj-filter-card" size="small">
<SearchForm <SearchForm
fields={FIELDS} fields={FIELDS}
initialValues={{ bizRelName: '', merchantName: '', settlementStatus: '' }} initialValues={{
bizRelName: '',
merchantName: '',
settlementStatus: '',
}}
onSearch={(values) => { onSearch={(values) => {
setFilters(compactParams(expandDateRanges({ ...values }, DATE_RANGES))); setFilters(compactParams(expandDateRanges({ ...values }, DATE_RANGES)));
setPage(firstPage); setPage(firstPage);
...@@ -180,6 +193,7 @@ export default function OrderList() { ...@@ -180,6 +193,7 @@ export default function OrderList() {
/> />
</UCard> </UCard>
{settle.modal} {settle.modal}
<OrderDetailDrawer open={!!detailId} id={detailId ?? ''} onClose={() => setDetailId(undefined)} />
</PageShell> </PageShell>
); );
} }
...@@ -26,13 +26,13 @@ export function buildOrderColumns(): DataTableColumnsType<WriteOffOrder> { ...@@ -26,13 +26,13 @@ export function buildOrderColumns(): DataTableColumnsType<WriteOffOrder> {
{ {
title: '手机号', title: '手机号',
dataIndex: 'customerPhone', dataIndex: 'customerPhone',
width: 120, width: 140,
render: (value) => <span className="uj-code">{textOr(value)}</span>, render: (value) => <span className="uj-code">{textOr(value)}</span>,
}, },
{ {
title: '核销员工', title: '核销员工',
dataIndex: 'verificationStaffName', dataIndex: 'verificationStaffName',
width: 110, width: 140,
render: (value) => textOr(value), render: (value) => textOr(value),
}, },
{ title: '商户名称', dataIndex: 'merchantName', width: 200, render: (value) => textOr(value) }, { title: '商户名称', dataIndex: 'merchantName', width: 200, render: (value) => textOr(value) },
......
...@@ -30,13 +30,16 @@ const DATE_RANGES = [ ...@@ -30,13 +30,16 @@ const DATE_RANGES = [
/** /**
* 详情子页面的身份参数走路径段:阳光激励按员工号定位,另外两个渠道按「门店 + 手机号」定位。 * 详情子页面的身份参数走路径段:阳光激励按员工号定位,另外两个渠道按「门店 + 手机号」定位。
* 缺任一段就拼不出安全的地址,此时不提供入口(老系统会带着 undefined 去查,结果是错的人的积分)。 * 缺任一段就拼不出安全的地址,此时不提供入口(老系统会带着 undefined 去查,结果是错的人的积分)。
* 门店范围不再进地址:它是系统级口径,由请求出口统一注入,地址只负责「哪一个人」。
*/ */
function detailPath(row: StaffScoreRow, channelSource: string): string | undefined { function detailPath(row: StaffScoreRow, channelSource: string): string | undefined {
if (channelSource === '1') { if (channelSource === '1') {
return row.staffId ? `user/1/${encodeURIComponent(row.staffId)}` : undefined; return row.staffId ? `user/1/${encodeURIComponent(row.staffId)}` : undefined;
} }
if (!row.merchantId || !row.staffPhone) return undefined; if (!row.merchantId || !row.staffPhone) return undefined;
return `user/${channelSource}/${encodeURIComponent(row.merchantId)}/${encodeURIComponent(row.staffPhone)}`; return `user/${channelSource}/${encodeURIComponent(row.merchantId)}/${encodeURIComponent(
row.staffPhone,
)}`;
} }
export default function ScoreUsers() { export default function ScoreUsers() {
...@@ -88,7 +91,7 @@ export default function ScoreUsers() { ...@@ -88,7 +91,7 @@ export default function ScoreUsers() {
options: withAll(merchants.options), options: withAll(merchants.options),
essential: true, essential: true,
}, },
{ name: 'rewardTime', label: '积分收益时间', type: 'dateRange', essential: true }, { name: 'rewardTime', label: '积分收益时间', type: 'dateRange' },
{ name: 'reviewTime', label: '积分付款时间', type: 'dateRange' }, { name: 'reviewTime', label: '积分付款时间', type: 'dateRange' },
{ name: 'successTime', label: '积分到账时间', type: 'dateRange' }, { name: 'successTime', label: '积分到账时间', type: 'dateRange' },
]; ];
......
...@@ -23,6 +23,8 @@ const DATE_RANGES = [ ...@@ -23,6 +23,8 @@ const DATE_RANGES = [
/** /**
* 定位「哪一个人」:阳光激励用员工号,续保客户与管理层用门店 + 手机号。 * 定位「哪一个人」:阳光激励用员工号,续保客户与管理层用门店 + 手机号。
* 这两组字段名就是老接口 detailList 详情按钮传过去的那几个,不做改名。 * 这两组字段名就是老接口 detailList 详情按钮传过去的那几个,不做改名。
* 门店范围不在这里:顶部累计卡(staff.score.page)与流水(detail.list)都由请求出口统一注入,
* 地址里少一段,就不会出现「列表一个口径、详情另一个口径」。
*/ */
function buildIdentity(params: PageParams): Record<string, unknown> | undefined { function buildIdentity(params: PageParams): Record<string, unknown> | undefined {
const channelSource = params.channelSource ?? ''; const channelSource = params.channelSource ?? '';
...@@ -31,7 +33,11 @@ function buildIdentity(params: PageParams): Record<string, unknown> | undefined ...@@ -31,7 +33,11 @@ function buildIdentity(params: PageParams): Record<string, unknown> | undefined
return params.staffId ? { channelSource, staffId: params.staffId } : undefined; return params.staffId ? { channelSource, staffId: params.staffId } : undefined;
} }
if (!params.merchantId || !params.phone) return undefined; if (!params.merchantId || !params.phone) return undefined;
return { channelSource, merchantId: params.merchantId, staffPhone: params.phone }; return {
channelSource,
merchantId: params.merchantId,
staffPhone: params.phone,
};
} }
export default function UserScoreDetail({ params }: { params: PageParams }) { export default function UserScoreDetail({ params }: { params: PageParams }) {
......
...@@ -330,8 +330,12 @@ export default function WithdrawList() { ...@@ -330,8 +330,12 @@ export default function WithdrawList() {
const selection: DataTableRowSelection<WithdrawRow> = { const selection: DataTableRowSelection<WithdrawRow> = {
selectedRowKeys: selectedIds, selectedRowKeys: selectedIds,
disabled: list.query.isFetching, disabled: list.query.isFetching,
// 后端 id 实际是 number(老系统自增主键),但本页把它当 string 用:
// 这里绝不能 keys.map(String) —— 那样 selectedRowKeys 会变成字符串、而 antd 用行 id(number)
// 比对,'123' === 123 永假,复选框就永远勾不上。统一交给 rowKey 返回 String(id) 来归一,
// 这里原样存 antd 给的 key 即可(它已基于 rowKey 的值,即 string 化后的 id)。
onChange: (keys, rows) => { onChange: (keys, rows) => {
setSelectedIds(keys.map(String)); setSelectedIds(keys as string[]);
setSelectedRows(rows); setSelectedRows(rows);
}, },
}; };
...@@ -369,7 +373,12 @@ export default function WithdrawList() { ...@@ -369,7 +373,12 @@ export default function WithdrawList() {
}} }}
/> />
</UCard> </UCard>
<SettleAmountStrip amounts={amounts.data} onOpenAll={() => setMoreAmounts(true)} /> <SettleAmountStrip
amounts={amounts.data}
error={amounts.isError ? amounts.error : undefined}
onRetry={() => void amounts.refetch()}
onOpenAll={() => setMoreAmounts(true)}
/>
{list.query.isError ? ( {list.query.isError ? (
<UAlert <UAlert
type="error" type="error"
...@@ -457,7 +466,9 @@ export default function WithdrawList() { ...@@ -457,7 +466,9 @@ export default function WithdrawList() {
</div> </div>
<DataTable<WithdrawRow> <DataTable<WithdrawRow>
columns={columns} columns={columns}
rowKey="id" // rowKey 归一为字符串:后端 id 实际是 number,统一 String(id) 后,选中键(也是基于 rowKey)
// 与行 id 同为 string,selectedRowKeys 才能命中;同时提交给后端的 ids 保持 string 不变。
rowKey={(row: WithdrawRow) => String(row.id)}
rowSelection={selection} rowSelection={selection}
fillHeight fillHeight
actionColumnWidth={180} actionColumnWidth={180}
......
import { UButton, UModal } from '@uj/ui'; import { UButton, UModal } from '@uj/ui';
import type { SettleAmountMap } from '@/api'; import type { SettleAmountMap } from '@/api';
import { SETTLE_STATISTICS, SETTLE_STATISTICS_PREVIEW } from '@/features/shared/dictionaries'; import { SETTLE_STATISTICS, SETTLE_STATISTICS_PREVIEW } from '@/features/shared/dictionaries';
import { EMPTY } from '@/features/shared/format'; import { EMPTY, errorMessage } from '@/features/shared/format';
/** /**
* 累计结算金额:老系统把 10 个统计项写死在 constants.statisticsTypeList, * 累计结算金额:老系统把 10 个统计项写死在 constants.statisticsTypeList,
...@@ -22,31 +22,50 @@ function itemsOf(amounts: SettleAmountMap | undefined) { ...@@ -22,31 +22,50 @@ function itemsOf(amounts: SettleAmountMap | undefined) {
export interface SettleAmountStripProps { export interface SettleAmountStripProps {
amounts: SettleAmountMap | undefined; amounts: SettleAmountMap | undefined;
/**
* 取数失败本身。没有这一项时,「接口挂了」与「这个渠道确实没有结算额」在页面上是同一个样子:
* 一排 `—`。数字缺席必须说得出为什么缺席。
*/
error?: unknown;
onRetry?: () => void;
/** 老系统只有「查看更多」一个动作,展开弹窗。 */ /** 老系统只有「查看更多」一个动作,展开弹窗。 */
onOpenAll: () => void; onOpenAll: () => void;
} }
export function SettleAmountStrip({ amounts, onOpenAll }: SettleAmountStripProps) { export function SettleAmountStrip({ amounts, error, onRetry, onOpenAll }: SettleAmountStripProps) {
const preview = itemsOf(amounts).slice(0, SETTLE_STATISTICS_PREVIEW); const preview = itemsOf(amounts).slice(0, SETTLE_STATISTICS_PREVIEW);
return ( return (
<div className="uj-points-statistics-card"> <div className="uj-points-statistics-card">
<div className="uj-points-statistics-head"> <div className="uj-points-statistics-head">
<span>累计结算金额</span> <span>累计结算金额</span>
<UButton type="link" onClick={onOpenAll}> {!error ? (
查看更多 <UButton type="link" onClick={onOpenAll}>
</UButton> 查看更多
</UButton>
) : null}
</div> </div>
<div className="uj-points-statistics"> {error ? (
{preview.map((item) => ( <div className="uj-points-statistics-error">
<div className="uj-points-statistics-item" key={item.key}> <span>{`取数失败:${errorMessage(error)}`}</span>
<div className="uj-points-statistics-label">{item.label}</div> {onRetry ? (
<div className="uj-points-statistics-value"> <UButton type="link" onClick={onRetry}>
{item.value} 重试
<span>元</span> </UButton>
) : null}
</div>
) : (
<div className="uj-points-statistics">
{preview.map((item) => (
<div className="uj-points-statistics-item" key={item.key}>
<div className="uj-points-statistics-label">{item.label}</div>
<div className="uj-points-statistics-value">
{item.value}
<span>元</span>
</div>
</div> </div>
</div> ))}
))} </div>
</div> )}
</div> </div>
); );
} }
......
...@@ -93,7 +93,7 @@ export function buildApprovalFields( ...@@ -93,7 +93,7 @@ export function buildApprovalFields(
options: withAll(statusOptions(APPROVAL_STATUS)), options: withAll(statusOptions(APPROVAL_STATUS)),
essential: true, essential: true,
}, },
{ name: 'approvalTime', label: '审批时间', type: 'dateRange', essential: true }, { name: 'approvalTime', label: '审批时间', type: 'dateRange' },
{ name: 'oaApprovalTime', label: 'OA审批时间', type: 'dateRange' }, { name: 'oaApprovalTime', label: 'OA审批时间', type: 'dateRange' },
{ name: 'userSettleTime', label: '付款时间', type: 'dateRange' }, { name: 'userSettleTime', label: '付款时间', type: 'dateRange' },
]; ];
......
...@@ -150,11 +150,12 @@ export function buildTransferColumns( ...@@ -150,11 +150,12 @@ export function buildTransferColumns(
width: 150, width: 150,
render: (value) => textOr(value), render: (value) => textOr(value),
}, },
{ title: '收款手机号', dataIndex: 'mobile', width: 130, render: (value) => textOr(value) }, { title: '收款手机号', dataIndex: 'mobile', width: 140, render: (value) => textOr(value) },
{ {
title: '微信openid', title: '微信openid',
dataIndex: 'customerOpenId', dataIndex: 'customerOpenId',
width: 130, line: 1,
width: 150,
render: (value) => textOr(value), render: (value) => textOr(value),
}, },
{ {
......
...@@ -84,7 +84,7 @@ export function buildTransferFields( ...@@ -84,7 +84,7 @@ export function buildTransferFields(
options: withAll(statusOptions(TRANSFER_STATUS)), options: withAll(statusOptions(TRANSFER_STATUS)),
essential: true, essential: true,
}, },
{ name: 'applyDateStr', label: '申请时间', type: 'dateRange', essential: true }, { name: 'applyDateStr', label: '申请时间', type: 'dateRange' },
{ name: 'payTimeStr', label: '付款时间', type: 'dateRange' }, { name: 'payTimeStr', label: '付款时间', type: 'dateRange' },
{ name: 'channel', label: '付款渠道', type: 'select', options: withAll(deps.channels) }, { name: 'channel', label: '付款渠道', type: 'select', options: withAll(deps.channels) },
{ {
......
...@@ -15,8 +15,8 @@ export interface MatchedRoute { ...@@ -15,8 +15,8 @@ export interface MatchedRoute {
} }
/** /**
* 按段匹配:`user/:channelSource/:merchantId/:phone` 只吃三段, * 按段匹配:段数不等的路径互不干扰(`user/:channelSource/:staffId` 三段、
* 段数不等直接跳过,因此同一前缀下的长短路径可以共存(user/1/9 与 user/2/8/13800000000)。 * `user/:channelSource/:merchantId/:phone` 四段),因此同一前缀下的长短路径可以共存。
* 参数值做 decodeURIComponent,手机号与门店编号里不会有需要转义的字符,但保持成对。 * 参数值做 decodeURIComponent,手机号与门店编号里不会有需要转义的字符,但保持成对。
*/ */
export function matchRoute(routes: RouteDef[], subPath: string): MatchedRoute | undefined { export function matchRoute(routes: RouteDef[], subPath: string): MatchedRoute | undefined {
......
...@@ -189,7 +189,7 @@ export interface RequestConfig { ...@@ -189,7 +189,7 @@ export interface RequestConfig {
gatewayCredential?: (id: string) => GatewayCredential; gatewayCredential?: (id: string) => GatewayCredential;
/** 会话令牌提供器(主壳登录态 / 网关侧令牌)。 */ /** 会话令牌提供器(主壳登录态 / 网关侧令牌)。 */
gatewayToken?: () => string; gatewayToken?: () => string;
/** 该次调用是否加签,缺省 true(对应老网关 `signed: false` 的免签接口)。 */ /** 该次调用是否加签,缺省 true。false 只去掉 sign 一个键,appKey 等身份信封照发。 */
signed?: boolean; signed?: boolean;
/** 参与请求但不进签名原文的参数名(老系统 noSignAttr,文件 Base64 这类大字段)。 */ /** 参与请求但不进签名原文的参数名(老系统 noSignAttr,文件 Base64 这类大字段)。 */
unsignedKeys?: string[]; unsignedKeys?: string[];
......
...@@ -63,26 +63,28 @@ export async function prepareRpcCall(call: RpcCall, deps: RpcPrepareDeps): Promi ...@@ -63,26 +63,28 @@ export async function prepareRpcCall(call: RpcCall, deps: RpcPrepareDeps): Promi
: {}), : {}),
}; };
const body: Record<string, unknown> = { ...effectiveParams, method: call.method }; const body: Record<string, unknown> = { ...effectiveParams, method: call.method };
if (needsSign) { if (needsSign && !credential.secret) {
if (!credential.secret) { throw new Error(`网关 ${call.gateway} 的接口需要加签,但未配置 appKey / secret。`);
throw new Error(`网关 ${call.gateway} 的接口需要加签,但未配置 appKey / secret。`);
}
Object.assign(
body,
await Promise.resolve(
strategy.signer.fields({
method: call.method,
params: effectiveParams,
timestamp: Date.now(),
appKey: credential.appKey,
secret: credential.secret,
version: credential.version,
format: credential.format,
exclude: call.unsignedKeys,
}),
),
);
} }
// 签名策略同时产出「身份信封」(appKey / v / format / timestamp)与 sign:
// appKey 是网关路由到具体接入方的身份,少了它连方法都不会被执行(实测 HTTP 200 + code 22 缺少appKey参数)。
// 所以 signed:false 只摘掉 sign 这一个键,信封照发 —— 否则「免签」会变成「必定失败的请求」。
// 真正无签名的策略(signer 不产出 appKey)在这里自然得到空信封,不受影响。
const envelope = await Promise.resolve(
strategy.signer.fields({
method: call.method,
params: effectiveParams,
timestamp: Date.now(),
appKey: credential.appKey,
// 不加签时不需要私钥(HMAC 之类算法拿空 secret 派生密钥会直接抛错),传空串只为让信封成形。
secret: needsSign ? credential.secret : '',
version: credential.version,
format: credential.format,
exclude: call.unsignedKeys,
}),
);
if (!needsSign) delete envelope.sign;
Object.assign(body, envelope);
const token = deps.resolveToken?.() ?? ''; const token = deps.resolveToken?.() ?? '';
const origin = credential.origin.replace(/\/+$/, ''); const origin = credential.origin.replace(/\/+$/, '');
...@@ -90,7 +92,13 @@ export async function prepareRpcCall(call: RpcCall, deps: RpcPrepareDeps): Promi ...@@ -90,7 +92,13 @@ export async function prepareRpcCall(call: RpcCall, deps: RpcPrepareDeps): Promi
method: 'POST', method: 'POST',
url: `${origin}/${strategy.router.replace(/^\/+/, '')}`, url: `${origin}/${strategy.router.replace(/^\/+/, '')}`,
data: body, data: body,
headers: token ? { [strategy.tokenHeader]: token } : {}, // RPC 网关(glsx rop)只按 form 解析请求体:不带这个头时,传输层(axios)会按
// 默认 JSON 序列化,网关读不到 appKey/method,回 HTTP 200 + `<error code="22">缺少appKey参数</error>`。
// 头名与第一代 rop 客户端逐字一致,保证 web 与小程序两条链路同一份线上字节。
headers: {
'content-type': 'application/x-www-form-urlencoded',
...(token ? { [strategy.tokenHeader]: token } : {}),
},
timeout: deps.timeout, timeout: deps.timeout,
normalize: strategy.normalize, normalize: strategy.normalize,
}; };
...@@ -108,8 +116,6 @@ export function createRpcDispatcher(deps: RpcDispatcherDeps) { ...@@ -108,8 +116,6 @@ export function createRpcDispatcher(deps: RpcDispatcherDeps) {
return async function rpcCall<T = unknown>(call: RpcCall): Promise<T> { return async function rpcCall<T = unknown>(call: RpcCall): Promise<T> {
const req = await prepareRpcCall(call, { resolveCredential, resolveToken, timeout }); const req = await prepareRpcCall(call, { resolveCredential, resolveToken, timeout });
return sender return sender.send(req).then((res) => unwrapEnvelope(res.data as NormalizedEnvelope) as T);
.send(req)
.then((res) => unwrapEnvelope(res.data as NormalizedEnvelope) as T);
}; };
} }
...@@ -55,7 +55,7 @@ export interface DataTableProps<T> extends Pick< ...@@ -55,7 +55,7 @@ export interface DataTableProps<T> extends Pick<
rowActions?: RowActionSchema<T>[]; rowActions?: RowActionSchema<T>[];
/** 行内操作列标题,默认“操作”。 */ /** 行内操作列标题,默认“操作”。 */
actionColumnTitle?: ReactNode; actionColumnTitle?: ReactNode;
/** 行内操作列宽度。 */ /** 行内操作列宽度。可不传:未传时按按钮文案自动估算;传了但偏小时也会自动取较大值,避免按钮被列宽砍掉。 */
actionColumnWidth?: number; actionColumnWidth?: number;
actionColumnFixed?: 'left' | 'right'; actionColumnFixed?: 'left' | 'right';
toolbarClassName?: string; toolbarClassName?: string;
...@@ -156,11 +156,19 @@ export function DataTable<T extends object>({ ...@@ -156,11 +156,19 @@ export function DataTable<T extends object>({
</UButton> </UButton>
); );
}; };
// 操作列宽度:页面可显式给 actionColumnWidth,但多数页面估不准、给小了按钮就被列宽砍掉
// (.uj-row-actions 是 nowrap,不会换行、只会溢出)。这里按按钮文案自动算出所需宽度,
// 取「页面给的」与「算出来的」二者较大值——页面给大了尊重页面,给小了或没给就自动兜底。
// 列宽是 fixed 布局下的硬约束,算出来的宽度已包住整组按钮,保证一行放得下、不被砍。
const resolvedActionWidth =
actionColumnWidth != null
? Math.max(actionColumnWidth, estimateActionWidth(rowActions))
: estimateActionWidth(rowActions);
const actionColumn: ColumnsType<T>[number] | undefined = rowActions?.length const actionColumn: ColumnsType<T>[number] | undefined = rowActions?.length
? { ? {
title: actionColumnTitle, title: actionColumnTitle,
key: '__actions', key: '__actions',
width: actionColumnWidth, width: resolvedActionWidth,
fixed: actionColumnFixed, fixed: actionColumnFixed,
render: (_: unknown, record: T) => { render: (_: unknown, record: T) => {
const visibleActions = rowActions.filter((action) => action.visible?.(record) ?? true); const visibleActions = rowActions.filter((action) => action.visible?.(record) ?? true);
...@@ -271,6 +279,25 @@ function getMinimumTableWidth<T extends object>(columns: ColumnsType<T>): number ...@@ -271,6 +279,25 @@ function getMinimumTableWidth<T extends object>(columns: ColumnsType<T>): number
}, 0); }, 0);
} }
/**
* 估出操作列该给多宽:逐按钮量字面宽度(中文 ~14px / 其它 ~8px)+ 小号文字按钮左右内边距(各 7px)
* + 按钮间距(--uj-space-1=4px)+ 单元格左右内边距(各 16px)。
* 动态文案(函数型 label)按 4 个汉字保守估,宁可宽一点也不要把按钮挤掉。
*/
function estimateActionWidth<T extends object>(actions?: RowActionSchema<T>[]): number {
if (!actions?.length) return 0;
const buttonWidth = (action: RowActionSchema<T>): number => {
const raw = typeof action.label === 'function' ? '四个字' : action.label;
const text = typeof raw === 'string' ? raw : '四个字';
let textWidth = 0;
for (const char of text) textWidth += /[一-龥]/.test(char) ? 14 : 8;
return textWidth + 14; // 小号文字按钮左右内边距 7px × 2
};
const buttons = actions.reduce((sum, action) => sum + buttonWidth(action), 0);
const gaps = (actions.length - 1) * 4;
return Math.ceil(buttons + gaps + 32); // 32 = 单元格左右内边距 16px × 2
}
function withLineLimit<T extends object>(columns: DataTableColumnsType<T>): ColumnsType<T> { function withLineLimit<T extends object>(columns: DataTableColumnsType<T>): ColumnsType<T> {
return columns.map((column) => { return columns.map((column) => {
if ('children' in column && column.children) { if ('children' in column && column.children) {
......
...@@ -18,6 +18,11 @@ export interface SearchFormProps<T extends Record<string, unknown>> { ...@@ -18,6 +18,11 @@ export interface SearchFormProps<T extends Record<string, unknown>> {
* 真源就在字段定义那一行 —— 哪个条件重要是一个业务判断,只有写它的人知道; * 真源就在字段定义那一行 —— 哪个条件重要是一个业务判断,只有写它的人知道;
* 不在 SearchForm 上传 visibleCount,也不在别处维护第二份「常显字段」清单, * 不在 SearchForm 上传 visibleCount,也不在别处维护第二份「常显字段」清单,
* 那样改一次要改两处、还容易漏。 * 那样改一次要改两处、还容易漏。
*
* 时间区间(dateRange)的常显规则例外:它默认进「更多筛选」(区间控件要跨 2 列才完整),
* 但「轻量表单」(常显非日期字段 ≤2 且整页条件 ≤3,如积分详情只有积分类型 + 积分变化时间)
* 或显式标了 essential:true 的区间会直接常显,避免「就两三个条件」的页还要点开更多。
* 具体阈值见组件内的 dateInline 启发式。
*/ */
fields: FieldSchema<T>[]; fields: FieldSchema<T>[];
initialValues?: Partial<T>; initialValues?: Partial<T>;
...@@ -49,11 +54,32 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -49,11 +54,32 @@ export function SearchForm<T extends Record<string, unknown>>({
size: pagination?.size ?? DEFAULT_PAGE_SIZE, size: pagination?.size ?? DEFAULT_PAGE_SIZE,
}; };
// 一条 essential 都没有时保持原行为:全部常显、不出现「更多筛选」。 const hasAnyEssential = fields.some((field) => field.essential);
// 让页面可以逐批迁移,不会因为共享层升级就突然把条件藏起来。 // 常显的非日期字段:标了 essential 的,或「全都不标 essential」时全部常显(门店列表这类没有
const hasSplit = fields.some((field) => field.essential); // 重点字段的页,非日期字段仍作常显锚点,避免常显行空着只剩按钮)。
const primaryFields = hasSplit ? fields.filter((field) => field.essential) : fields; const primaryNonDate = fields.filter(
const extraFields = hasSplit ? fields.filter((field) => !field.essential) : []; (field) => field.type !== 'dateRange' && (field.essential === true || !hasAnyEssential),
);
const dateFields = fields.filter((field) => field.type === 'dateRange');
// 时间区间是否常显(不进「更多筛选」)的启发式:
// - 显式 essential:true 的日期区间强制常显(页面作者明确要它常显);
// - 否则只在「轻量表单」里常显 —— 常显的非日期字段很少(≤2)且整页条件总数也少(≤3),
// 即「就两三个查询条件」的页面(如积分详情:积分类型 + 积分变化时间),
// 区间直接常显更顺手,不必点开「更多筛选」;
// - 没有任何非日期常显字段时(纯日期区间表单),也常显,避免常显行空着却把日期收进更多;
// 其余(字段多 / 非日期常显已 ≥3)保持原行为:日期区间进「更多筛选」,
// 防止把常显行挤爆、把「查询 / 重置」挤到第二行。
// 区间控件要显示「开始 ~ 结束」,放进更多时会跨 2 列(见 renderField 的 span)才完整。
const lightForm = primaryNonDate.length <= 2 && fields.length <= 3;
const dateInline = dateFields.length > 0 && (primaryNonDate.length === 0 || lightForm);
const isPrimary = (field: FieldSchema<T>): boolean => {
if (field.type === 'dateRange') return field.essential === true || dateInline;
return field.essential === true || !hasAnyEssential;
};
const primaryFields = fields.filter(isPrimary);
const extraFields = fields.filter((field) => !isPrimary(field));
const activeExtraCount = extraFields.filter((field) => isSet(values?.[field.name])).length; const activeExtraCount = extraFields.filter((field) => isSet(values?.[field.name])).length;
const control = (field: FieldSchema<T>) => { const control = (field: FieldSchema<T>) => {
...@@ -86,16 +112,20 @@ export function SearchForm<T extends Record<string, unknown>>({ ...@@ -86,16 +112,20 @@ export function SearchForm<T extends Record<string, unknown>>({
); );
}; };
const renderField = (field: FieldSchema<T>) => ( const renderField = (field: FieldSchema<T>) => {
<UFormItem // 时间区间选择器默认跨 2 列(见 FieldSchema.span 注释);其余类型默认 1,
key={field.name} // 显式传 span 可覆盖。跨列只是「腾出空间」,再用 maxWidth 把控件卡在合理宽度:
name={field.name as string} // 既够显示「开始 ~ 结束」(约 236px 控件),又不会被宽屏的 auto-fit 撑到整行那么宽。
label={field.label} const span = field.span ?? (field.type === 'dateRange' ? 2 : 1);
style={{ marginBottom: 0, minWidth: 0 }} const style: React.CSSProperties = { marginBottom: 0, minWidth: 0 };
> if (span > 1) style.gridColumn = `span ${span}`;
{control(field)} if (field.type === 'dateRange') style.maxWidth = 340;
</UFormItem> return (
); <UFormItem key={field.name} name={field.name as string} label={field.label} style={style}>
{control(field)}
</UFormItem>
);
};
return ( return (
<UForm <UForm
......
...@@ -24,6 +24,11 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string, ...@@ -24,6 +24,11 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
type: FieldType; type: FieldType;
placeholder?: string; placeholder?: string;
width?: number | string; width?: number | string;
/**
* 在筛选栅格里跨几列(默认 1)。时间区间选择器(dateRange)要显示「开始 ~ 结束」,
* 单列的 ~136px 控件放不下,默认 2 列;其余类型如需更宽也可显式指定。
*/
span?: number;
options?: FieldOption[]; options?: FieldOption[];
rules?: Rule[]; rules?: Rule[];
section?: string; section?: string;
......
...@@ -247,9 +247,13 @@ body { ...@@ -247,9 +247,13 @@ body {
动作列用固定宽度而非 auto:常显区与收起区(.uj-filter-more)必须用同一列模板, 动作列用固定宽度而非 auto:常显区与收起区(.uj-filter-more)必须用同一列模板,
否则后者少了动作列、字段列会更宽,两排控件对不齐。--uj-filter-actions-col 即预留的动作列宽。 */ 否则后者少了动作列、字段列会更宽,两排控件对不齐。--uj-filter-actions-col 即预留的动作列宽。 */
.uj-filter-grid { .uj-filter-grid {
--uj-filter-actions-col: 240px; /* 列数由「筛选卡实时宽度」自动决定(auto-fit):能塞几列就几列,
空出来的轨道自动坍缩 —— 所以「5 个字段」绝不会被强行塞进 6 列而压窄,
多余的空列不存在,字段直接撑宽。字段列最小 240px(标签 104 + 控件 ≥136),
保证每个输入框都从容;窗口变窄时自动减列、字段换行,按钮始终钉在第一排。 */
--uj-filter-actions-col: 220px;
display: grid; display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr)) var(--uj-filter-actions-col); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) var(--uj-filter-actions-col);
column-gap: var(--uj-space-4, 16px); column-gap: var(--uj-space-4, 16px);
row-gap: var(--uj-space-3, 12px); row-gap: var(--uj-space-3, 12px);
align-items: center; align-items: center;
...@@ -273,7 +277,10 @@ body { ...@@ -273,7 +277,10 @@ body {
} }
/* 动作区:固定在栅格最后一列(动作列),与字段同一排、垂直居中。 */ /* 动作区:固定在栅格最后一列(动作列),与字段同一排、垂直居中。 */
.uj-filter-actions { .uj-filter-actions {
/* 钉在栅格第一行最后一列:无论字段有没有换行,按钮永远和首排字段同排,
不会被多出来的字段顶到第二排。 */
grid-column: -2 / -1; grid-column: -2 / -1;
grid-row: 1;
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
...@@ -283,9 +290,10 @@ body { ...@@ -283,9 +290,10 @@ body {
/* 收起后的第二排:与第一排同栅格、同列模板(含等宽动作列预留,空着), /* 收起后的第二排:与第一排同栅格、同列模板(含等宽动作列预留,空着),
靠一条淡分隔线区隔,不另起一个卡片。字段列因此与常显区严格对齐。 */ 靠一条淡分隔线区隔,不另起一个卡片。字段列因此与常显区严格对齐。 */
.uj-filter-more { .uj-filter-more {
--uj-filter-actions-col: 240px; /* 与常显区同列模板(auto-fit + 等宽动作列预留),两排控件严格对齐。 */
--uj-filter-actions-col: 220px;
display: grid; display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr)) var(--uj-filter-actions-col); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) var(--uj-filter-actions-col);
column-gap: var(--uj-space-4, 16px); column-gap: var(--uj-space-4, 16px);
row-gap: var(--uj-space-3, 12px); row-gap: var(--uj-space-3, 12px);
align-items: center; align-items: center;
...@@ -322,32 +330,22 @@ body { ...@@ -322,32 +330,22 @@ body {
transform: rotate(180deg); transform: rotate(180deg);
} }
/* 标签移到左侧后每组字段多占 104px,列数按「控件至少约 170px」反推: /* 超窄屏:auto-fit 仍会保留右侧 220px 动作列、字段挤成单列,
1700 以下 3 列、1400 以下 2 列、1100 以下 1 列;动作列在窄屏退回整行。 */ 故在此让字段单列堆叠、按钮整行沉底,避免字段被压成 160px 以下的细条。 */
@media (max-width: 1700px) { @media (max-width: 640px) {
.uj-filter-grid { .uj-filter-grid,
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.uj-filter-grid .uj-filter-actions {
grid-column: 1 / -1;
}
.uj-filter-more { .uj-filter-more {
grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-columns: minmax(0, 1fr);
}
}
@media (max-width: 1400px) {
.uj-filter-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
} }
.uj-filter-more { .uj-filter-grid .uj-filter-actions,
grid-template-columns: repeat(2, minmax(0, 1fr)); .uj-filter-more .uj-filter-actions {
grid-column: 1 / -1;
grid-row: auto;
} }
} }
/* 页面级标题行在窄屏改为纵向堆叠(视口级,与筛选卡无关)。 */
@media (max-width: 1100px) { @media (max-width: 1100px) {
.uj-filter-grid,
.uj-filter-more {
grid-template-columns: minmax(0, 1fr);
}
.uj-page__header { .uj-page__header {
flex-direction: column; flex-direction: column;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!