v3.5.9版本迭代列表优化
CI / verify (pull_request) Waiting to run

This commit is contained in:
2026-08-25 12:38:21 +08:00
parent 282da24bc4
commit f4da71e952
62 changed files with 5027 additions and 4202 deletions
@@ -55,15 +55,29 @@ type UserRow = Pick<
avatar?: { url: string } | null;
};
function parseColumnWidths(raw: unknown): Record<string, number> | undefined {
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return undefined;
const out: Record<string, number> = {};
for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {
if (!key.trim()) continue;
const n = typeof value === 'number' ? value : Number(value);
if (!Number.isFinite(n)) continue;
out[key] = Math.min(960, Math.max(48, Math.round(n)));
}
return Object.keys(out).length ? out : undefined;
}
function parseListColumnPrefs(raw: unknown): HqListColumnPrefsMap {
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};
const out: HqListColumnPrefsMap = {};
for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {
if (!isHqListColumnKey(key) || !value || typeof value !== 'object' || Array.isArray(value)) continue;
const row = value as { order?: unknown; hidden?: unknown };
const row = value as { order?: unknown; hidden?: unknown; widths?: unknown };
const widths = parseColumnWidths(row.widths);
out[key] = {
order: Array.isArray(row.order) ? row.order.filter((v): v is string => typeof v === 'string') : [],
hidden: Array.isArray(row.hidden) ? row.hidden.filter((v): v is string => typeof v === 'string') : [],
...(widths ? { widths } : {}),
};
}
return out;
@@ -1238,7 +1252,7 @@ export class AuthService {
actorType: string,
actorId: bigint,
listKey: string,
dto: { reset?: boolean; order?: string[]; hidden?: string[] },
dto: { reset?: boolean; order?: string[]; hidden?: string[]; widths?: Record<string, number> },
) {
if (actorType !== 'HQ') throw new ForbiddenException('仅总部账号可保存列表列设置');
if (!isHqListColumnKey(listKey)) throw new BadRequestException('未知列表');
@@ -1251,9 +1265,19 @@ export class AuthService {
if (dto.reset) {
delete current[listKey];
} else {
const prev = current[listKey];
const widths =
dto.widths !== undefined ? parseColumnWidths(dto.widths) : prev?.widths;
current[listKey] = {
order: (dto.order ?? []).filter((k) => typeof k === 'string' && k.trim()),
hidden: (dto.hidden ?? []).filter((k) => typeof k === 'string' && k.trim()),
order:
dto.order !== undefined
? dto.order.filter((k) => typeof k === 'string' && k.trim())
: (prev?.order ?? []),
hidden:
dto.hidden !== undefined
? dto.hidden.filter((k) => typeof k === 'string' && k.trim())
: (prev?.hidden ?? []),
...(widths && Object.keys(widths).length ? { widths } : {}),
};
}
const updated = await this.prisma.hqAccount.update({
@@ -1,4 +1,4 @@
import { IsArray, IsBoolean, IsIn, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { IsArray, IsBoolean, IsIn, IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';
import { SmsScene } from '@dukang/shared-types';
export class SendSmsDto {
@@ -144,4 +144,8 @@ export class SaveHqListColumnPrefsDto {
@IsArray()
@IsString({ each: true })
hidden?: string[];
@IsOptional()
@IsObject()
widths?: Record<string, number>;
}
@@ -33,7 +33,20 @@ export class AdminBenefitService {
take: pageSize,
include: {
user: { select: { id: true, userNo: true, phone: true, nickname: true } },
order: { select: { id: true, orderNo: true, status: true } },
order: {
select: {
id: true,
orderNo: true,
status: true,
productName: true,
productSpec: true,
quantity: true,
saleUnit: true,
deliveryType: true,
payAmount: true,
benefitAmount: true,
},
},
},
}),
this.prisma.benefitCoupon.count({ where }),
@@ -46,7 +59,20 @@ export class AdminBenefitService {
where: { id },
include: {
user: { select: { id: true, userNo: true, phone: true, nickname: true } },
order: { select: { id: true, orderNo: true, status: true, payAmount: true } },
order: {
select: {
id: true,
orderNo: true,
status: true,
payAmount: true,
productName: true,
productSpec: true,
quantity: true,
saleUnit: true,
deliveryType: true,
benefitAmount: true,
},
},
},
});
if (!coupon) throw new NotFoundException('权益券不存在');