Compare commits
6
Commits
111f400bdb
...
1cf790d6ab
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cf790d6ab | ||
|
|
694d7fff40 | ||
|
|
fb08f4552e | ||
|
|
402c10e9b6 | ||
|
|
9979011ac2 | ||
|
|
d1e06f362e |
@@ -0,0 +1,11 @@
|
||||
-- 为接单分类表增加二级目录支持与图标支持
|
||||
|
||||
ALTER TABLE work_categories
|
||||
ADD COLUMN IF NOT EXISTS parent_id bigint REFERENCES work_categories(id) ON DELETE SET NULL,
|
||||
ADD COLUMN IF NOT EXISTS icon_url text;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_work_categories_parent_id
|
||||
ON work_categories(parent_id);
|
||||
|
||||
COMMENT ON COLUMN work_categories.parent_id IS '父级分类 ID,NULL 表示一级分类,非空表示二级分类';
|
||||
COMMENT ON COLUMN work_categories.icon_url IS '分类图标 URL,用于接单大厅等位置展示';
|
||||
@@ -256,6 +256,8 @@ export type WorkCategoryRow = {
|
||||
id: number
|
||||
category_key: string
|
||||
name: string
|
||||
parent_id?: number | null
|
||||
icon_url?: string | null
|
||||
sort_order: number
|
||||
status: string
|
||||
created_at: string
|
||||
@@ -402,6 +404,8 @@ export type WorkOrderRow = {
|
||||
active_share_quantity?: number
|
||||
pending_share_count?: number
|
||||
category_name?: string
|
||||
parent_category_id?: number | null
|
||||
parent_category_name?: string
|
||||
worker_username?: string
|
||||
worker_display_name?: string
|
||||
/** 取消信息,由工单查询从取消类事件推导,仅已取消工单有值。 */
|
||||
|
||||
@@ -36,19 +36,30 @@ export async function listAllWorkCategories(): Promise<WorkCategoryRow[]> {
|
||||
export async function upsertWorkCategory(input: {
|
||||
categoryKey: string
|
||||
name: string
|
||||
parentId?: number | null
|
||||
iconUrl?: string | null
|
||||
sortOrder: number
|
||||
status: string
|
||||
now: string
|
||||
}): Promise<WorkCategoryRow | null> {
|
||||
const result = await query<WorkCategoryRow>(
|
||||
`
|
||||
INSERT INTO work_categories (category_key, name, sort_order, status, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
INSERT INTO work_categories (category_key, name, parent_id, icon_url, sort_order, status, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
ON CONFLICT (category_key) DO UPDATE
|
||||
SET name = EXCLUDED.name, sort_order = EXCLUDED.sort_order, status = EXCLUDED.status, updated_at = EXCLUDED.updated_at
|
||||
SET name = EXCLUDED.name, parent_id = EXCLUDED.parent_id, icon_url = EXCLUDED.icon_url, sort_order = EXCLUDED.sort_order, status = EXCLUDED.status, updated_at = EXCLUDED.updated_at
|
||||
RETURNING *
|
||||
`,
|
||||
[input.categoryKey, input.name, input.sortOrder, input.status, input.now, input.now],
|
||||
[
|
||||
input.categoryKey,
|
||||
input.name,
|
||||
input.parentId ?? null,
|
||||
input.iconUrl ?? null,
|
||||
input.sortOrder,
|
||||
input.status,
|
||||
input.now,
|
||||
input.now,
|
||||
],
|
||||
)
|
||||
return result.rows[0] || null
|
||||
}
|
||||
@@ -56,8 +67,9 @@ export async function upsertWorkCategory(input: {
|
||||
export async function countWorkCategoryUsages(categoryId: number | string): Promise<{
|
||||
workOrderCount: number
|
||||
productRuleCount: number
|
||||
childCategoryCount: number
|
||||
}> {
|
||||
const [orders, rules] = await Promise.all([
|
||||
const [orders, rules, children] = await Promise.all([
|
||||
query<{ total: number }>(
|
||||
'SELECT COUNT(*)::int AS total FROM work_orders WHERE category_id = $1',
|
||||
[Number(categoryId)],
|
||||
@@ -66,10 +78,15 @@ export async function countWorkCategoryUsages(categoryId: number | string): Prom
|
||||
'SELECT COUNT(*)::int AS total FROM work_product_rules WHERE category_id = $1',
|
||||
[Number(categoryId)],
|
||||
),
|
||||
query<{ total: number }>(
|
||||
'SELECT COUNT(*)::int AS total FROM work_categories WHERE parent_id = $1',
|
||||
[Number(categoryId)],
|
||||
),
|
||||
])
|
||||
return {
|
||||
workOrderCount: Number(orders.rows[0]?.total || 0),
|
||||
productRuleCount: Number(rules.rows[0]?.total || 0),
|
||||
childCategoryCount: Number(children.rows[0]?.total || 0),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ export const WORK_ORDER_SELECT = `
|
||||
COALESCE(share_summary.active_share_quantity, 0)::int AS active_share_quantity,
|
||||
COALESCE(share_summary.pending_share_count, 0)::int AS pending_share_count,
|
||||
wc.name AS category_name,
|
||||
parent_wc.id AS parent_category_id,
|
||||
parent_wc.name AS parent_category_name,
|
||||
wu.username AS worker_username,
|
||||
wu.display_name AS worker_display_name,
|
||||
cancel_info.cancel_reason,
|
||||
@@ -20,6 +22,7 @@ export const WORK_ORDER_SELECT = `
|
||||
cancel_info.cancelled_at
|
||||
FROM work_orders wo
|
||||
LEFT JOIN work_categories wc ON wc.id = wo.category_id
|
||||
LEFT JOIN work_categories parent_wc ON parent_wc.id = wc.parent_id
|
||||
LEFT JOIN worker_users wu ON wu.id = wo.assigned_worker_id
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT
|
||||
@@ -862,7 +865,9 @@ export function buildWorkOrderWhere({
|
||||
}
|
||||
if (categoryId) {
|
||||
params.push(categoryId)
|
||||
filters.push(`wo.category_id = $${params.length}`)
|
||||
filters.push(
|
||||
`(wo.category_id = $${params.length} OR wo.category_id IN (SELECT id FROM work_categories WHERE parent_id = $${params.length}))`,
|
||||
)
|
||||
}
|
||||
if (acceptanceMode) {
|
||||
params.push(normalizeWorkOrderAcceptanceMode(acceptanceMode))
|
||||
@@ -917,12 +922,21 @@ function buildHallCandidateIdsSql(limitPlaceholder: string, categoryLimitsPlaceh
|
||||
return `
|
||||
SELECT ranked.id
|
||||
FROM (
|
||||
SELECT candidate.id, candidate.category_id, candidate.hall_queued_at,
|
||||
SELECT
|
||||
candidate.id,
|
||||
candidate.category_id,
|
||||
candidate.hall_queued_at,
|
||||
COALESCE(candidate_wc.parent_id, candidate.category_id) AS primary_category_id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY COALESCE(candidate_wc.parent_id, candidate.category_id)
|
||||
ORDER BY candidate.hall_queued_at ASC NULLS LAST, candidate.id ASC
|
||||
) AS primary_category_rank,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY candidate.category_id
|
||||
ORDER BY candidate.hall_queued_at ASC NULLS LAST, candidate.id ASC
|
||||
) AS category_rank
|
||||
) AS sub_category_rank
|
||||
FROM work_orders candidate
|
||||
LEFT JOIN work_categories candidate_wc ON candidate_wc.id = candidate.category_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
work_order_id,
|
||||
@@ -936,10 +950,15 @@ function buildHallCandidateIdsSql(limitPlaceholder: string, categoryLimitsPlaceh
|
||||
OR COALESCE(candidate_shares.active_share_quantity, 0) < candidate.sharing_total_quantity
|
||||
)
|
||||
) ranked
|
||||
WHERE ranked.category_rank <= COALESCE(
|
||||
NULLIF(${categoryLimitsPlaceholder}::jsonb ->> ranked.category_id::text, '')::int,
|
||||
WHERE ranked.primary_category_rank <= COALESCE(
|
||||
NULLIF(${categoryLimitsPlaceholder}::jsonb ->> ranked.primary_category_id::text, '')::int,
|
||||
${limitPlaceholder}
|
||||
)
|
||||
AND (
|
||||
NULLIF(${categoryLimitsPlaceholder}::jsonb ->> ranked.category_id::text, '') IS NULL
|
||||
OR ranked.category_id = ranked.primary_category_id
|
||||
OR ranked.sub_category_rank <= NULLIF(${categoryLimitsPlaceholder}::jsonb ->> ranked.category_id::text, '')::int
|
||||
)
|
||||
ORDER BY ranked.hall_queued_at ASC NULLS LAST, ranked.id ASC
|
||||
LIMIT ${limitPlaceholder}
|
||||
`
|
||||
|
||||
@@ -225,12 +225,23 @@ export function refreshUploadedFileUrls(value: unknown) {
|
||||
}
|
||||
}
|
||||
|
||||
export const PUBLIC_SCENES = new Set(['category_icon', 'hall_icon', 'public', 'announcement'])
|
||||
|
||||
export function isPublicObjectKey(objectKey: string) {
|
||||
const normalized = normalizeObjectKey(objectKey)
|
||||
const firstSegment = normalized.split('/')[0] || ''
|
||||
return PUBLIC_SCENES.has(firstSegment)
|
||||
}
|
||||
|
||||
export function verifyFileAccessSignature(
|
||||
objectKey: string,
|
||||
expiresValue: unknown,
|
||||
signatureValue: unknown,
|
||||
nowSeconds = Math.floor(Date.now() / 1000),
|
||||
) {
|
||||
if (isPublicObjectKey(objectKey)) {
|
||||
return
|
||||
}
|
||||
const expires = Number(expiresValue || 0)
|
||||
const signature = String(signatureValue || '').trim()
|
||||
if (!Number.isSafeInteger(expires) || expires < nowSeconds || !signature) {
|
||||
@@ -388,22 +399,24 @@ async function generateImageVariants(objectKey: string, data: Buffer, contentTyp
|
||||
|
||||
for (const config of configs) {
|
||||
try {
|
||||
const content = await sharp(data)
|
||||
.rotate()
|
||||
.resize({
|
||||
width: config.maxSide,
|
||||
height: config.maxSide,
|
||||
fit: 'inside',
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
.flatten({ background: '#ffffff' })
|
||||
.jpeg({ quality: config.quality, mozjpeg: true })
|
||||
.toBuffer()
|
||||
const isAlpha = contentType === 'image/png' || contentType === 'image/webp'
|
||||
const pipeline = sharp(data).rotate().resize({
|
||||
width: config.maxSide,
|
||||
height: config.maxSide,
|
||||
fit: 'inside',
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
const content = isAlpha
|
||||
? await pipeline.webp({ quality: config.quality, alphaQuality: 95 }).toBuffer()
|
||||
: await pipeline
|
||||
.flatten({ background: '#ffffff' })
|
||||
.jpeg({ quality: config.quality, mozjpeg: true })
|
||||
.toBuffer()
|
||||
variants.push({
|
||||
name: config.name,
|
||||
key: imageVariantKey(objectKey, config.name),
|
||||
content,
|
||||
contentType: 'image/jpeg',
|
||||
contentType: isAlpha ? 'image/webp' : 'image/jpeg',
|
||||
})
|
||||
} catch {
|
||||
return variants
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
countWorkCategoryUsages,
|
||||
deleteWorkCategory,
|
||||
getWorkCategoryById,
|
||||
getWorkCategoryByKey,
|
||||
listAllWorkCategories,
|
||||
upsertWorkCategory,
|
||||
} from '../../repositories/worker-platform/work-category-repo.js'
|
||||
@@ -75,10 +76,57 @@ export async function saveAdminWorkCategory(payload: JsonObject = {}) {
|
||||
DEFAULT_CATEGORY_KEY,
|
||||
)
|
||||
const name = String(payload.name || '').trim() || '默认分类'
|
||||
const rawParentId = payload.parentId ?? payload.parent_id
|
||||
const parentId =
|
||||
rawParentId !== undefined && rawParentId !== null && String(rawParentId).trim() !== ''
|
||||
? Number(rawParentId)
|
||||
: null
|
||||
const iconUrl =
|
||||
payload.iconUrl !== undefined
|
||||
? String(payload.iconUrl || '').trim() || null
|
||||
: payload.icon_url !== undefined
|
||||
? String(payload.icon_url || '').trim() || null
|
||||
: null
|
||||
|
||||
if (parentId) {
|
||||
const parent = await getWorkCategoryById(parentId)
|
||||
if (!parent) {
|
||||
throw createHttpError('所选上级分类不存在', {
|
||||
statusCode: 400,
|
||||
errorCode: 'parent_category_not_found',
|
||||
})
|
||||
}
|
||||
if (parent.category_key === categoryKey) {
|
||||
throw createHttpError('上级分类不能是当前分类自身', {
|
||||
statusCode: 400,
|
||||
errorCode: 'invalid_parent_category',
|
||||
})
|
||||
}
|
||||
if (parent.parent_id) {
|
||||
throw createHttpError('暂不支持三级及以上分类,上级分类必须是一级分类', {
|
||||
statusCode: 400,
|
||||
errorCode: 'parent_cannot_be_subcategory',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const existing = await getWorkCategoryByKey(categoryKey)
|
||||
if (existing && parentId) {
|
||||
const usages = await countWorkCategoryUsages(existing.id)
|
||||
if (usages.childCategoryCount > 0) {
|
||||
throw createHttpError('该分类下已有子分类,无法再作为二级分类', {
|
||||
statusCode: 400,
|
||||
errorCode: 'category_has_children',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const category = await upsertWorkCategory({
|
||||
categoryKey,
|
||||
name,
|
||||
sortOrder: normalizeInteger(payload.sortOrder, 100),
|
||||
parentId,
|
||||
iconUrl,
|
||||
sortOrder: normalizeInteger(payload.sortOrder ?? payload.sort_order, 100),
|
||||
status: normalizeEnabledStatus(payload.status),
|
||||
now,
|
||||
})
|
||||
@@ -94,14 +142,15 @@ export async function deleteAdminWorkCategory(categoryId: number | string) {
|
||||
})
|
||||
}
|
||||
const usages = await countWorkCategoryUsages(Number(categoryId))
|
||||
if (usages.workOrderCount > 0 || usages.productRuleCount > 0) {
|
||||
throw createHttpError(
|
||||
`该分类已被 ${usages.workOrderCount} 个工单和 ${usages.productRuleCount} 条物品规则使用,无法删除,请先停用`,
|
||||
{
|
||||
statusCode: 409,
|
||||
errorCode: 'work_category_in_use',
|
||||
},
|
||||
)
|
||||
if (usages.workOrderCount > 0 || usages.productRuleCount > 0 || usages.childCategoryCount > 0) {
|
||||
const reasons: string[] = []
|
||||
if (usages.workOrderCount > 0) reasons.push(`${usages.workOrderCount} 个工单`)
|
||||
if (usages.productRuleCount > 0) reasons.push(`${usages.productRuleCount} 条物品规则`)
|
||||
if (usages.childCategoryCount > 0) reasons.push(`${usages.childCategoryCount} 个子分类`)
|
||||
throw createHttpError(`该分类已被 ${reasons.join('、')} 引用,无法删除,请先处理关联数据`, {
|
||||
statusCode: 409,
|
||||
errorCode: 'work_category_in_use',
|
||||
})
|
||||
}
|
||||
const { deleted } = await deleteWorkCategory(Number(categoryId))
|
||||
return { deleted }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { WORK_ORDER_STATUS } from '../../domain/work-order-status.js'
|
||||
import { countWorkOrders, listWorkerUsers } from '../../repositories/worker-platform/index.js'
|
||||
import { refreshStoredFileUrl } from '../file-storage/file-storage-service.js'
|
||||
import { publishWorkerHallRealtimeRefresh } from '../realtime/realtime-event-service.js'
|
||||
import { getWorkerHallConfig, saveWorkerHallConfig } from './worker-hall-config-service.js'
|
||||
|
||||
@@ -55,6 +56,7 @@ export async function getAdminWorkerHallConfig() {
|
||||
])
|
||||
return {
|
||||
...config,
|
||||
allIconUrl: config.allIconUrl ? refreshStoredFileUrl(config.allIconUrl) : null,
|
||||
visibleOrderCount: visibleOpenOrderCount,
|
||||
queuedOrderCount: Math.max(0, openOrderCount - visibleOpenOrderCount),
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ import {
|
||||
} from '../../repositories/worker-platform/index.js'
|
||||
import type { JsonObject } from '../../types/json.js'
|
||||
import { safeParseJson } from '../admin/admin-query-utils.js'
|
||||
import { refreshUploadedFileUrls } from '../file-storage/file-storage-service.js'
|
||||
import {
|
||||
refreshStoredFileUrl,
|
||||
refreshUploadedFileUrls,
|
||||
} from '../file-storage/file-storage-service.js'
|
||||
import { DEFAULT_DEPOSIT_THRESHOLD_AMOUNT } from './worker-finance-mappers.js'
|
||||
import { normalizeUploadedFiles } from './worker-input-normalizers.js'
|
||||
import { resolveFreezeDepositAmount } from './worker-permission-utils.js'
|
||||
@@ -33,6 +36,8 @@ export function mapWorkCategory(category: WorkCategoryRow | null | undefined) {
|
||||
categoryId: Number(category.id),
|
||||
categoryKey: category.category_key,
|
||||
name: category.name,
|
||||
parentId: category.parent_id ? Number(category.parent_id) : null,
|
||||
iconUrl: category.icon_url ? refreshStoredFileUrl(category.icon_url) : null,
|
||||
sortOrder: Number(category.sort_order || 100),
|
||||
status: category.status,
|
||||
createdAt: category.created_at,
|
||||
|
||||
@@ -9,29 +9,46 @@ import {
|
||||
test('大厅配置默认展示 50 个订单', () => {
|
||||
assert.deepEqual(createDefaultWorkerHallConfig(), {
|
||||
maxVisibleOrders: 50,
|
||||
showSubcategories: true,
|
||||
allIconUrl: null,
|
||||
categoryMaxVisibleOrders: {},
|
||||
})
|
||||
assert.deepEqual(normalizeWorkerHallConfig({}), {
|
||||
maxVisibleOrders: 50,
|
||||
showSubcategories: true,
|
||||
allIconUrl: null,
|
||||
categoryMaxVisibleOrders: {},
|
||||
})
|
||||
assert.equal(normalizeWorkerHallConfig({ showSubcategories: false }).showSubcategories, false)
|
||||
assert.equal(
|
||||
normalizeWorkerHallConfig({ allIconUrl: ' https://example.com/icon.png ' }).allIconUrl,
|
||||
'https://example.com/icon.png',
|
||||
)
|
||||
})
|
||||
|
||||
test('大厅配置只接受 1 到 500 的整数', () => {
|
||||
assert.deepEqual(normalizeWorkerHallConfig({ maxVisibleOrders: 88 }), {
|
||||
maxVisibleOrders: 88,
|
||||
showSubcategories: true,
|
||||
allIconUrl: null,
|
||||
categoryMaxVisibleOrders: {},
|
||||
})
|
||||
assert.deepEqual(normalizeWorkerHallConfig({ max_visible_orders: 999 }), {
|
||||
maxVisibleOrders: 500,
|
||||
showSubcategories: true,
|
||||
allIconUrl: null,
|
||||
categoryMaxVisibleOrders: {},
|
||||
})
|
||||
assert.deepEqual(normalizeWorkerHallConfig({ maxVisibleOrders: 0 }), {
|
||||
maxVisibleOrders: 1,
|
||||
showSubcategories: true,
|
||||
allIconUrl: null,
|
||||
categoryMaxVisibleOrders: {},
|
||||
})
|
||||
assert.deepEqual(normalizeWorkerHallConfig({ maxVisibleOrders: 1.5 }), {
|
||||
maxVisibleOrders: 50,
|
||||
showSubcategories: true,
|
||||
allIconUrl: null,
|
||||
categoryMaxVisibleOrders: {},
|
||||
})
|
||||
assert.deepEqual(
|
||||
|
||||
@@ -4,6 +4,8 @@ import { readAppConfigEntry, saveAppConfigEntry } from '../config/app-config-sto
|
||||
|
||||
export type WorkerHallConfig = {
|
||||
maxVisibleOrders: number
|
||||
showSubcategories: boolean
|
||||
allIconUrl: string | null
|
||||
categoryMaxVisibleOrders: Record<string, number>
|
||||
}
|
||||
|
||||
@@ -24,14 +26,37 @@ export async function saveWorkerHallConfig(rawValue: unknown): Promise<WorkerHal
|
||||
}
|
||||
|
||||
export function createDefaultWorkerHallConfig(): WorkerHallConfig {
|
||||
return { maxVisibleOrders: 50, categoryMaxVisibleOrders: {} }
|
||||
return {
|
||||
maxVisibleOrders: 50,
|
||||
showSubcategories: true,
|
||||
allIconUrl: null,
|
||||
categoryMaxVisibleOrders: {},
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeWorkerHallConfig(rawValue: unknown): WorkerHallConfig {
|
||||
const source = isPlainObject(rawValue) ? rawValue : {}
|
||||
const value = Number(source.maxVisibleOrders ?? source.max_visible_orders)
|
||||
const showSubcategories =
|
||||
source.showSubcategories !== undefined
|
||||
? Boolean(source.showSubcategories)
|
||||
: source.show_subcategories !== undefined
|
||||
? Boolean(source.show_subcategories)
|
||||
: true
|
||||
const allIconUrl =
|
||||
source.allIconUrl !== undefined
|
||||
? typeof source.allIconUrl === 'string' && source.allIconUrl.trim()
|
||||
? source.allIconUrl.trim()
|
||||
: null
|
||||
: source.all_icon_url !== undefined
|
||||
? typeof source.all_icon_url === 'string' && source.all_icon_url.trim()
|
||||
? source.all_icon_url.trim()
|
||||
: null
|
||||
: null
|
||||
return {
|
||||
maxVisibleOrders: Number.isInteger(value) ? Math.min(500, Math.max(1, value)) : 50,
|
||||
showSubcategories,
|
||||
allIconUrl,
|
||||
categoryMaxVisibleOrders: normalizeCategoryMaxVisibleOrders(
|
||||
source.categoryMaxVisibleOrders ?? source.category_max_visible_orders,
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '../../repositories/worker-platform/index.js'
|
||||
import type { JsonObject } from '../../types/json.js'
|
||||
import { normalizePage, normalizePageSize } from '../admin/admin-query-utils.js'
|
||||
import { refreshStoredFileUrl } from '../file-storage/file-storage-service.js'
|
||||
import {
|
||||
mapWorkCategory,
|
||||
mapWorkOrderForWorker,
|
||||
@@ -90,6 +91,8 @@ export async function listWorkerHallOrders(query: JsonObject = {}, session: Work
|
||||
}),
|
||||
pagination: { page, pageSize, total },
|
||||
categories,
|
||||
showSubcategories: hallConfig.showSubcategories,
|
||||
allIconUrl: hallConfig.allIconUrl ? refreshStoredFileUrl(hallConfig.allIconUrl) : null,
|
||||
visibleDelaySeconds,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { App, Button, Layout, Menu, Typography } from 'antd'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import type { MenuProps } from 'antd'
|
||||
import { useEffect } from 'react'
|
||||
import { useEffect, useMemo } from 'react'
|
||||
import { Outlet, useLocation, useNavigate } from 'react-router'
|
||||
|
||||
import { logoutWorker } from '@/services/worker'
|
||||
import { fetchWorkerAfterSalesCases, fetchWorkerProfile, logoutWorker } from '@/services/worker'
|
||||
import { useIsMobile } from '@/utils/use-is-mobile'
|
||||
import {
|
||||
clearWorkerSession,
|
||||
@@ -50,6 +50,45 @@ export default function WorkerLayout() {
|
||||
const status = getWorkerStatus()
|
||||
const currentKey = resolveSelectedKey(location.pathname)
|
||||
|
||||
const profileQuery = useQuery({
|
||||
queryKey: ['worker-profile'],
|
||||
queryFn: () => fetchWorkerProfile(),
|
||||
retry: false,
|
||||
staleTime: 10_000,
|
||||
})
|
||||
const worker = profileQuery.data?.data.worker
|
||||
|
||||
const afterSalesQuery = useQuery({
|
||||
queryKey: ['worker-after-sales-cases'],
|
||||
queryFn: fetchWorkerAfterSalesCases,
|
||||
retry: false,
|
||||
staleTime: 10_000,
|
||||
})
|
||||
const afterSalesPendingCount = (afterSalesQuery.data?.data.items || []).filter(
|
||||
(item) => item.status === 'awaiting_worker_response',
|
||||
).length
|
||||
|
||||
const dynamicMenuItems: MenuProps['items'] = useMemo(
|
||||
() => [
|
||||
{ key: '/hall', icon: <ShoppingOutlined />, label: '抢单大厅' },
|
||||
{ key: '/orders', icon: <ContainerOutlined />, label: '我的订单' },
|
||||
{
|
||||
key: '/orders/after-sales',
|
||||
icon: <SafetyCertificateOutlined />,
|
||||
label: (
|
||||
<span className="worker-menu-label-with-badge">
|
||||
<span>售后问题单</span>
|
||||
{afterSalesPendingCount > 0 ? (
|
||||
<span className="worker-menu-badge">{afterSalesPendingCount}</span>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{ key: '/profile', icon: <UserOutlined />, label: '个人中心' },
|
||||
],
|
||||
[afterSalesPendingCount],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
const navigateToLogin = () => {
|
||||
if (window.location.pathname !== '/') {
|
||||
@@ -170,29 +209,62 @@ export default function WorkerLayout() {
|
||||
|
||||
return (
|
||||
<Layout className="admin-shell worker-shell">
|
||||
<Layout.Sider width={220} className="admin-sider" trigger={null}>
|
||||
<Layout.Sider width={230} className="admin-sider worker-sider" trigger={null}>
|
||||
<div className="admin-sider-inner">
|
||||
<div className="admin-brand">
|
||||
<div className="admin-brand-copy">
|
||||
<strong>王大锤</strong>
|
||||
<span>接单平台</span>
|
||||
<div className="worker-sider-brand">
|
||||
<div className="worker-sider-brand-logo">
|
||||
<span>锤</span>
|
||||
</div>
|
||||
<div className="worker-sider-brand-text">
|
||||
<strong>王大锤电竞</strong>
|
||||
<span className="worker-sider-brand-sub">
|
||||
<span className="worker-sider-pulse-dot" />
|
||||
打手工作台
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="admin-sidebar-profile">
|
||||
<Typography.Text strong>{username}</Typography.Text>
|
||||
<Typography.Text type="secondary">{formatWorkerStatus(status)}</Typography.Text>
|
||||
|
||||
<div className="worker-sider-profile-card">
|
||||
<div className="worker-sider-profile-top">
|
||||
<div className="worker-sider-avatar">
|
||||
{(worker?.displayName || username).slice(0, 1)}
|
||||
</div>
|
||||
<div className="worker-sider-user-meta">
|
||||
<strong className="worker-sider-username" title={worker?.displayName || username}>
|
||||
{worker?.displayName || username}
|
||||
</strong>
|
||||
<span className="worker-sider-status-badge">● {formatWorkerStatus(status)}</span>
|
||||
</div>
|
||||
</div>
|
||||
{worker?.level?.name ? (
|
||||
<div className="worker-sider-level-pill">
|
||||
<span className="worker-sider-level-text">{worker.level.name}</span>
|
||||
{worker.wallet ? (
|
||||
<span className="worker-sider-balance-text">
|
||||
¥{(Number(worker.wallet.availableAmount || 0) / 100).toFixed(2)}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<Menu
|
||||
mode="inline"
|
||||
inlineIndent={16}
|
||||
inlineIndent={14}
|
||||
selectedKeys={[currentKey]}
|
||||
items={menuItems}
|
||||
className="admin-menu"
|
||||
items={dynamicMenuItems}
|
||||
className="worker-menu"
|
||||
onClick={({ key }) => navigate(String(key))}
|
||||
/>
|
||||
<div className="admin-sider-footer">
|
||||
|
||||
<div className="worker-sider-footer">
|
||||
<WorkerNewOrderSpeech />
|
||||
<Button block icon={<LogoutOutlined />} onClick={submitLogout}>
|
||||
<Button
|
||||
block
|
||||
icon={<LogoutOutlined />}
|
||||
className="worker-sider-logout-btn"
|
||||
onClick={confirmLogout}
|
||||
>
|
||||
退出登录
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { UploadOutlined } from '@ant-design/icons'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import {
|
||||
App,
|
||||
Avatar,
|
||||
Button,
|
||||
Card,
|
||||
Form,
|
||||
@@ -12,22 +14,35 @@ import {
|
||||
Table,
|
||||
Tag,
|
||||
Typography,
|
||||
Upload,
|
||||
} from 'antd'
|
||||
import type { TableColumnsType } from 'antd'
|
||||
import { useState } from 'react'
|
||||
import { useMemo, useState } from 'react'
|
||||
|
||||
import {
|
||||
deleteAdminWorkCategory,
|
||||
fetchAdminWorkCategories,
|
||||
saveAdminWorkCategory,
|
||||
} from '@/services/admin'
|
||||
import { uploadFile } from '@/services/files'
|
||||
import type { WorkCategory } from '@/types/worker-platform'
|
||||
|
||||
type CategoryFormValues = {
|
||||
categoryKey: string
|
||||
name: string
|
||||
parentId?: number
|
||||
iconUrl?: string
|
||||
sortOrder?: number
|
||||
status?: string
|
||||
}
|
||||
|
||||
export default function CategoriesPanel() {
|
||||
const { message } = App.useApp()
|
||||
const [form] = Form.useForm()
|
||||
const [form] = Form.useForm<CategoryFormValues>()
|
||||
const [editingCategory, setEditingCategory] = useState<WorkCategory | null>(null)
|
||||
const [deletingCategory, setDeletingCategory] = useState<WorkCategory | null>(null)
|
||||
const [uploadingIcon, setUploadingIcon] = useState(false)
|
||||
|
||||
const categoriesQuery = useQuery({
|
||||
queryKey: ['admin-worker-platform-categories'],
|
||||
queryFn: () => fetchAdminWorkCategories(),
|
||||
@@ -37,11 +52,56 @@ export default function CategoriesPanel() {
|
||||
await categoriesQuery.refetch()
|
||||
}
|
||||
|
||||
const rawCategories = categoriesQuery.data?.data.items || []
|
||||
|
||||
// 一级分类选项(排除正在编辑的分类自身,防止自引用)
|
||||
const parentOptions = useMemo(() => {
|
||||
const level1Categories = rawCategories.filter(
|
||||
(c) => !c.parentId && (!editingCategory || c.categoryId !== editingCategory.categoryId),
|
||||
)
|
||||
return [
|
||||
{ value: 0, label: '无(作为一级分类)' },
|
||||
...level1Categories.map((c) => ({
|
||||
value: c.categoryId,
|
||||
label: `${c.name} (${c.categoryKey})`,
|
||||
})),
|
||||
]
|
||||
}, [rawCategories, editingCategory])
|
||||
|
||||
// 构建树形表格数据(一级分类包含 children,二级分类挂在下面)
|
||||
const treeData = useMemo(() => {
|
||||
const rootCategories = rawCategories.filter((item) => !item.parentId)
|
||||
const childrenMap = new Map<number, WorkCategory[]>()
|
||||
for (const item of rawCategories) {
|
||||
if (item.parentId) {
|
||||
const list = childrenMap.get(item.parentId) || []
|
||||
list.push(item)
|
||||
childrenMap.set(item.parentId, list)
|
||||
}
|
||||
}
|
||||
|
||||
return rootCategories.map((root) => {
|
||||
const children = childrenMap.get(root.categoryId) || []
|
||||
return {
|
||||
...root,
|
||||
children:
|
||||
children.length > 0
|
||||
? children.map((c) => ({
|
||||
...c,
|
||||
parentName: root.name,
|
||||
}))
|
||||
: undefined,
|
||||
}
|
||||
})
|
||||
}, [rawCategories])
|
||||
|
||||
function startEdit(category: WorkCategory) {
|
||||
setEditingCategory(category)
|
||||
form.setFieldsValue({
|
||||
categoryKey: category.categoryKey,
|
||||
name: category.name,
|
||||
parentId: category.parentId || 0,
|
||||
iconUrl: category.iconUrl || '',
|
||||
sortOrder: category.sortOrder,
|
||||
status: category.status,
|
||||
})
|
||||
@@ -52,14 +112,30 @@ export default function CategoriesPanel() {
|
||||
form.resetFields()
|
||||
}
|
||||
|
||||
async function saveCategory(values: {
|
||||
categoryKey: string
|
||||
name: string
|
||||
sortOrder?: number
|
||||
status?: string
|
||||
}) {
|
||||
async function handleUploadIcon(file: File) {
|
||||
setUploadingIcon(true)
|
||||
try {
|
||||
await saveAdminWorkCategory(values)
|
||||
const uploaded = await uploadFile(file, 'category_icon', 'admin')
|
||||
form.setFieldValue('iconUrl', uploaded.url)
|
||||
message.success('图标上传成功')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '图标上传失败')
|
||||
} finally {
|
||||
setUploadingIcon(false)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
async function saveCategory(values: CategoryFormValues) {
|
||||
try {
|
||||
await saveAdminWorkCategory({
|
||||
categoryKey: values.categoryKey,
|
||||
name: values.name,
|
||||
parentId: values.parentId ? Number(values.parentId) : null,
|
||||
iconUrl: values.iconUrl ? String(values.iconUrl).trim() : null,
|
||||
sortOrder: values.sortOrder,
|
||||
status: values.status,
|
||||
})
|
||||
message.success(editingCategory ? '分类已更新' : '分类已保存')
|
||||
cancelEdit()
|
||||
await refreshCategories()
|
||||
@@ -73,6 +149,8 @@ export default function CategoriesPanel() {
|
||||
await saveAdminWorkCategory({
|
||||
categoryKey: category.categoryKey,
|
||||
name: category.name,
|
||||
parentId: category.parentId || null,
|
||||
iconUrl: category.iconUrl || null,
|
||||
sortOrder: category.sortOrder,
|
||||
status: category.status === 'active' ? 'disabled' : 'active',
|
||||
})
|
||||
@@ -97,12 +175,55 @@ export default function CategoriesPanel() {
|
||||
}
|
||||
|
||||
const columns: TableColumnsType<WorkCategory> = [
|
||||
{ title: '分类', dataIndex: 'name' },
|
||||
{ title: '标识', dataIndex: 'categoryKey' },
|
||||
{ title: '排序', dataIndex: 'sortOrder', width: 100 },
|
||||
{
|
||||
title: '分类名称',
|
||||
dataIndex: 'name',
|
||||
render: (_, row) => (
|
||||
<Space align="center">
|
||||
{row.iconUrl ? (
|
||||
<Avatar src={row.iconUrl} size={28} shape="square" />
|
||||
) : (
|
||||
<Avatar
|
||||
size={28}
|
||||
shape="square"
|
||||
style={{
|
||||
backgroundColor: row.parentId ? '#bae0ff' : '#ffd591',
|
||||
color: '#1f1f1f',
|
||||
fontSize: 13,
|
||||
}}
|
||||
>
|
||||
{row.name.slice(0, 1)}
|
||||
</Avatar>
|
||||
)}
|
||||
<span>{row.name}</span>
|
||||
{row.parentId ? (
|
||||
<Tag color="blue" style={{ marginLeft: 4 }}>
|
||||
二级
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag color="orange" style={{ marginLeft: 4 }}>
|
||||
一级
|
||||
</Tag>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '上级分类',
|
||||
width: 140,
|
||||
render: (_, row) => {
|
||||
if (!row.parentId) {
|
||||
return <Typography.Text type="secondary">-</Typography.Text>
|
||||
}
|
||||
const parent = rawCategories.find((c) => c.categoryId === row.parentId)
|
||||
return <Tag color="geekblue">{parent ? parent.name : `ID: ${row.parentId}`}</Tag>
|
||||
},
|
||||
},
|
||||
{ title: '标识', dataIndex: 'categoryKey', width: 150 },
|
||||
{ title: '排序', dataIndex: 'sortOrder', width: 90 },
|
||||
{
|
||||
title: '状态',
|
||||
width: 120,
|
||||
width: 100,
|
||||
render: (_, row) => (
|
||||
<Tag color={row.status === 'active' ? 'green' : 'default'}>
|
||||
{row.status === 'active' ? '启用' : '停用'}
|
||||
@@ -111,7 +232,7 @@ export default function CategoriesPanel() {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
width: 220,
|
||||
render: (_, row) => (
|
||||
<Space wrap>
|
||||
<Button size="small" onClick={() => startEdit(row)}>
|
||||
@@ -136,33 +257,61 @@ export default function CategoriesPanel() {
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="inline"
|
||||
initialValues={{ status: 'active', sortOrder: 100 }}
|
||||
layout="vertical"
|
||||
initialValues={{ parentId: 0, status: 'active', sortOrder: 100 }}
|
||||
onFinish={saveCategory}
|
||||
>
|
||||
<Form.Item
|
||||
label="标识"
|
||||
name="categoryKey"
|
||||
rules={[{ required: true, message: '请输入标识' }]}
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))',
|
||||
gap: '12px 16px',
|
||||
}}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="名称" name="name" rules={[{ required: true, message: '请输入名称' }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item label="排序" name="sortOrder">
|
||||
<InputNumber min={0} max={9999} />
|
||||
</Form.Item>
|
||||
<Form.Item label="状态" name="status">
|
||||
<Select
|
||||
style={{ width: 110 }}
|
||||
options={[
|
||||
{ value: 'active', label: '启用' },
|
||||
{ value: 'disabled', label: '停用' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Form.Item
|
||||
label="上级分类"
|
||||
name="parentId"
|
||||
tooltip="选择一级分类即可设为该分类下的二级目录;留空或选「无」则作为独立一级分类。"
|
||||
>
|
||||
<Select options={parentOptions} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="标识"
|
||||
name="categoryKey"
|
||||
rules={[{ required: true, message: '请输入标识' }]}
|
||||
>
|
||||
<Input placeholder="如 hpjy、dtts" />
|
||||
</Form.Item>
|
||||
<Form.Item label="名称" name="name" rules={[{ required: true, message: '请输入名称' }]}>
|
||||
<Input placeholder="如 和平精英、地铁装备" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="分类图标"
|
||||
name="iconUrl"
|
||||
tooltip="在接单大厅等位置展示的图标。支持直接填写链接,或点击右侧按钮上传。"
|
||||
>
|
||||
<Space.Compact style={{ width: '100%' }}>
|
||||
<Input placeholder="图标 URL(可选)" />
|
||||
<Upload showUploadList={false} beforeUpload={handleUploadIcon} accept="image/*">
|
||||
<Button icon={<UploadOutlined />} loading={uploadingIcon}>
|
||||
上传
|
||||
</Button>
|
||||
</Upload>
|
||||
</Space.Compact>
|
||||
</Form.Item>
|
||||
<Form.Item label="排序" name="sortOrder">
|
||||
<InputNumber min={0} max={9999} style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item label="状态" name="status">
|
||||
<Select
|
||||
options={[
|
||||
{ value: 'active', label: '启用' },
|
||||
{ value: 'disabled', label: '停用' },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
<Form.Item style={{ marginBottom: 0 }}>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit">
|
||||
保存
|
||||
@@ -172,13 +321,14 @@ export default function CategoriesPanel() {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Card>
|
||||
<Card title="分类列表" bordered={false}>
|
||||
<Card title="分类列表(树形层级)" bordered={false}>
|
||||
<Table<WorkCategory>
|
||||
rowKey="categoryId"
|
||||
loading={categoriesQuery.isLoading}
|
||||
dataSource={categoriesQuery.data?.data.items || []}
|
||||
dataSource={treeData}
|
||||
columns={columns}
|
||||
pagination={false}
|
||||
defaultExpandAllRows
|
||||
/>
|
||||
</Card>
|
||||
<Modal
|
||||
@@ -192,7 +342,7 @@ export default function CategoriesPanel() {
|
||||
>
|
||||
<Typography.Text>
|
||||
确定删除分类「{deletingCategory?.name}
|
||||
」?已引用该分类的工单和物品规则将无法删除,需先处理。
|
||||
」?已引用该分类的工单、接单模板或下属子分类将无法删除,需先处理关联。
|
||||
</Typography.Text>
|
||||
</Modal>
|
||||
</section>
|
||||
|
||||
@@ -1,16 +1,34 @@
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { App, Button, Card, Descriptions, Form, InputNumber, Space, Table, Tag } from 'antd'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { UploadOutlined } from '@ant-design/icons'
|
||||
import {
|
||||
App,
|
||||
Avatar,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
Space,
|
||||
Switch,
|
||||
Table,
|
||||
Tag,
|
||||
Upload,
|
||||
} from 'antd'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
|
||||
import {
|
||||
fetchAdminWorkCategories,
|
||||
fetchAdminWorkerHallConfig,
|
||||
saveAdminWorkerHallConfig,
|
||||
} from '@/services/admin'
|
||||
import { uploadFile } from '@/services/files'
|
||||
import type { WorkCategory } from '@/types/worker-platform'
|
||||
|
||||
type HallConfigFormValues = {
|
||||
maxVisibleOrders: number
|
||||
showSubcategories: boolean
|
||||
allIconUrl?: string
|
||||
categoryMaxVisibleOrders: Record<string, number>
|
||||
}
|
||||
|
||||
@@ -19,6 +37,9 @@ export default function HallConfigPanel() {
|
||||
const queryClient = useQueryClient()
|
||||
const [form] = Form.useForm<HallConfigFormValues>()
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [uploadingAllIcon, setUploadingAllIcon] = useState(false)
|
||||
const currentAllIconUrl = Form.useWatch('allIconUrl', form)
|
||||
|
||||
const configQuery = useQuery({
|
||||
queryKey: ['admin-worker-hall-config'],
|
||||
queryFn: fetchAdminWorkerHallConfig,
|
||||
@@ -29,20 +50,60 @@ export default function HallConfigPanel() {
|
||||
if (config) {
|
||||
form.setFieldsValue({
|
||||
maxVisibleOrders: config.maxVisibleOrders,
|
||||
showSubcategories: config.showSubcategories ?? true,
|
||||
allIconUrl: config.allIconUrl || '',
|
||||
categoryMaxVisibleOrders: config.categoryMaxVisibleOrders || {},
|
||||
})
|
||||
}
|
||||
}, [config, form])
|
||||
|
||||
const categoriesQuery = useQuery({
|
||||
queryKey: ['admin-worker-platform-categories'],
|
||||
queryFn: fetchAdminWorkCategories,
|
||||
})
|
||||
|
||||
const treeData = useMemo(() => {
|
||||
const rawCategories = categoriesQuery.data?.data.items || []
|
||||
const rootCategories = rawCategories.filter((item) => !item.parentId)
|
||||
const childrenMap = new Map<number, WorkCategory[]>()
|
||||
for (const item of rawCategories) {
|
||||
if (item.parentId) {
|
||||
const list = childrenMap.get(item.parentId) || []
|
||||
list.push(item)
|
||||
childrenMap.set(item.parentId, list)
|
||||
}
|
||||
}
|
||||
|
||||
return rootCategories.map((root) => {
|
||||
const children = childrenMap.get(root.categoryId) || []
|
||||
return {
|
||||
...root,
|
||||
children: children.length > 0 ? children : undefined,
|
||||
}
|
||||
})
|
||||
}, [categoriesQuery.data?.data.items])
|
||||
|
||||
async function handleUploadAllIcon(file: File) {
|
||||
setUploadingAllIcon(true)
|
||||
try {
|
||||
const uploaded = await uploadFile(file, 'hall_icon', 'admin')
|
||||
form.setFieldValue('allIconUrl', uploaded.url)
|
||||
message.success('「全部」图标上传成功')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '图标上传失败')
|
||||
} finally {
|
||||
setUploadingAllIcon(false)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
async function saveConfig(values: HallConfigFormValues) {
|
||||
setSaving(true)
|
||||
try {
|
||||
await saveAdminWorkerHallConfig({
|
||||
maxVisibleOrders: Number(values.maxVisibleOrders),
|
||||
showSubcategories: Boolean(values.showSubcategories),
|
||||
allIconUrl: values.allIconUrl ? String(values.allIconUrl).trim() : null,
|
||||
categoryMaxVisibleOrders: values.categoryMaxVisibleOrders || {},
|
||||
})
|
||||
await Promise.all([
|
||||
@@ -59,29 +120,66 @@ export default function HallConfigPanel() {
|
||||
|
||||
return (
|
||||
<Card title="大厅配置" bordered={false} loading={configQuery.isLoading}>
|
||||
<Space direction="vertical" size="middle" style={{ width: '100%', maxWidth: 560 }}>
|
||||
<Space direction="vertical" size="middle" style={{ width: '100%', maxWidth: 700 }}>
|
||||
<Descriptions size="small" column={3}>
|
||||
<Descriptions.Item label="展示中">{config?.visibleOrderCount || 0}</Descriptions.Item>
|
||||
<Descriptions.Item label="等待入厅">{config?.queuedOrderCount || 0}</Descriptions.Item>
|
||||
<Descriptions.Item label="当前上限">{config?.maxVisibleOrders || '-'}</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Form form={form} layout="vertical" onFinish={saveConfig}>
|
||||
<Form.Item
|
||||
name="maxVisibleOrders"
|
||||
label="大厅订单总数"
|
||||
rules={[{ required: true, message: '请输入大厅订单总数' }]}
|
||||
>
|
||||
<InputNumber min={1} max={500} precision={0} style={{ width: 160 }} />
|
||||
</Form.Item>
|
||||
<Space size="large" align="start" wrap style={{ marginBottom: 8 }}>
|
||||
<Form.Item
|
||||
name="maxVisibleOrders"
|
||||
label="大厅订单总数"
|
||||
rules={[{ required: true, message: '请输入大厅订单总数' }]}
|
||||
style={{ marginBottom: 12 }}
|
||||
>
|
||||
<InputNumber min={1} max={500} precision={0} style={{ width: 140 }} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="showSubcategories"
|
||||
label="大厅二级目录展示"
|
||||
valuePropName="checked"
|
||||
tooltip="开启后,接单大厅一级分类下方联动展示其二级分类选项;关闭后大厅只展示一级分类。"
|
||||
style={{ marginBottom: 12 }}
|
||||
>
|
||||
<Switch checkedChildren="开启展示" unCheckedChildren="关闭展示" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="allIconUrl"
|
||||
label="「全部」按钮图标"
|
||||
tooltip="接单大厅第一个「全部」按钮展示的自定义图标。留空则显示默认应用图标。"
|
||||
style={{ marginBottom: 12, minWidth: 280 }}
|
||||
>
|
||||
<Space.Compact style={{ width: '100%' }}>
|
||||
{currentAllIconUrl ? (
|
||||
<Avatar
|
||||
src={currentAllIconUrl}
|
||||
size={32}
|
||||
shape="square"
|
||||
style={{ marginRight: 8, flexShrink: 0 }}
|
||||
/>
|
||||
) : null}
|
||||
<Input placeholder="图标 URL(可选)" allowClear />
|
||||
<Upload showUploadList={false} beforeUpload={handleUploadAllIcon} accept="image/*">
|
||||
<Button icon={<UploadOutlined />} loading={uploadingAllIcon}>
|
||||
上传
|
||||
</Button>
|
||||
</Upload>
|
||||
</Space.Compact>
|
||||
</Form.Item>
|
||||
</Space>
|
||||
|
||||
<Form.Item>
|
||||
<Button type="primary" htmlType="submit" loading={saving}>
|
||||
保存
|
||||
保存配置
|
||||
</Button>
|
||||
</Form.Item>
|
||||
|
||||
<div>
|
||||
<Tag color="blue">分类上限</Tag>
|
||||
<span style={{ marginLeft: 8, color: '#666' }}>
|
||||
未填写的分类沿用大厅总上限;填写后仅限制该分类最多展示数量。
|
||||
<Tag color="blue">分类最多展示上限</Tag>
|
||||
<span style={{ marginLeft: 8, color: '#666', fontSize: 13 }}>
|
||||
一级分类限额将限制该游戏及旗下所有子分类的总单量;二级分类可单独设置细化限额。
|
||||
</span>
|
||||
</div>
|
||||
<Table<WorkCategory>
|
||||
@@ -89,11 +187,39 @@ export default function HallConfigPanel() {
|
||||
size="small"
|
||||
pagination={false}
|
||||
loading={categoriesQuery.isLoading}
|
||||
dataSource={categoriesQuery.data?.data.items || []}
|
||||
dataSource={treeData}
|
||||
defaultExpandAllRows
|
||||
columns={[
|
||||
{ title: '分类', dataIndex: 'name' },
|
||||
{
|
||||
title: '分类名称',
|
||||
dataIndex: 'name',
|
||||
render: (_, category) => (
|
||||
<Space size="small">
|
||||
{category.iconUrl ? (
|
||||
<Avatar src={category.iconUrl} size={20} shape="square" />
|
||||
) : null}
|
||||
<span>{category.name}</span>
|
||||
{category.parentId ? (
|
||||
<Tag
|
||||
color="blue"
|
||||
style={{ fontSize: 11, lineHeight: '18px', padding: '0 4px' }}
|
||||
>
|
||||
二级
|
||||
</Tag>
|
||||
) : (
|
||||
<Tag
|
||||
color="orange"
|
||||
style={{ fontSize: 11, lineHeight: '18px', padding: '0 4px' }}
|
||||
>
|
||||
一级
|
||||
</Tag>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
width: 90,
|
||||
render: (_, category) => (
|
||||
<Tag color={category.status === 'active' ? 'green' : 'default'}>
|
||||
{category.status === 'active' ? '启用' : '停用'}
|
||||
@@ -102,12 +228,19 @@ export default function HallConfigPanel() {
|
||||
},
|
||||
{
|
||||
title: '最多展示',
|
||||
width: 180,
|
||||
render: (_, category) => (
|
||||
<Form.Item
|
||||
name={['categoryMaxVisibleOrders', String(category.categoryId)]}
|
||||
style={{ margin: 0 }}
|
||||
>
|
||||
<InputNumber min={1} max={500} precision={0} placeholder="跟随总上限" />
|
||||
<InputNumber
|
||||
min={1}
|
||||
max={500}
|
||||
precision={0}
|
||||
placeholder={category.parentId ? '跟随父级' : '跟随总上限'}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Form.Item>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -41,7 +41,12 @@ import {
|
||||
saveAdminWorkProductRule,
|
||||
syncAdminWorkProductRulePrice,
|
||||
} from '@/services/admin'
|
||||
import type { CollectField, WorkProductRule, WorkProductRuleMapping } from '@/types/worker-platform'
|
||||
import type {
|
||||
CollectField,
|
||||
WorkCategory,
|
||||
WorkProductRule,
|
||||
WorkProductRuleMapping,
|
||||
} from '@/types/worker-platform'
|
||||
import type { AdminKuaishouIndustryShopOption } from '@/types/admin'
|
||||
import { ADMIN_DEFAULT_PAGE_SIZE, buildAdminTablePagination } from '@/utils/admin-pagination'
|
||||
import { formatMoney } from './shared'
|
||||
@@ -92,6 +97,36 @@ export default function ProductRulesPanel() {
|
||||
queryKey: ['admin-worker-platform-categories'],
|
||||
queryFn: () => fetchAdminWorkCategories(),
|
||||
})
|
||||
|
||||
const categoryOptions = useMemo(() => {
|
||||
const raw = categoriesQuery.data?.data.items || []
|
||||
const rootCategories = raw.filter((c) => !c.parentId)
|
||||
const childrenMap = new Map<number, typeof raw>()
|
||||
for (const c of raw) {
|
||||
if (c.parentId) {
|
||||
const list = childrenMap.get(c.parentId) || []
|
||||
list.push(c)
|
||||
childrenMap.set(c.parentId, list)
|
||||
}
|
||||
}
|
||||
const result: Array<{ label: string; value: number }> = []
|
||||
for (const root of rootCategories) {
|
||||
const children = childrenMap.get(root.categoryId) || []
|
||||
result.push({ label: root.name, value: root.categoryId })
|
||||
for (const child of children) {
|
||||
result.push({ label: ` └ ${child.name}`, value: child.categoryId })
|
||||
}
|
||||
}
|
||||
return result
|
||||
}, [categoriesQuery.data?.data.items])
|
||||
|
||||
const categoryMap = useMemo(() => {
|
||||
const map = new Map<number, WorkCategory>()
|
||||
for (const item of categoriesQuery.data?.data.items || []) {
|
||||
map.set(item.categoryId, item)
|
||||
}
|
||||
return map
|
||||
}, [categoriesQuery.data?.data.items])
|
||||
const shopsQuery = useQuery({
|
||||
queryKey: ['admin-kuaishou-industry-shops', 'product-rules'],
|
||||
queryFn: fetchAdminKuaishouIndustryShops,
|
||||
@@ -777,10 +812,7 @@ export default function ProductRulesPanel() {
|
||||
allowClear
|
||||
placeholder="选择分类"
|
||||
loading={categoriesQuery.isLoading}
|
||||
options={(categoriesQuery.data?.data.items || []).map((item) => ({
|
||||
value: item.categoryId,
|
||||
label: item.name,
|
||||
}))}
|
||||
options={categoryOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
@@ -1113,9 +1145,11 @@ export default function ProductRulesPanel() {
|
||||
{ key: 'all', label: `全部 (${rulesPagination?.total || 0})` },
|
||||
...(categoriesQuery.data?.data.items || []).map((item) => {
|
||||
const count = categoryCounts.get(String(item.categoryId)) || 0
|
||||
const parent = item.parentId ? categoryMap.get(item.parentId) : null
|
||||
const displayName = parent ? `${parent.name} · ${item.name}` : item.name
|
||||
return {
|
||||
key: String(item.categoryId),
|
||||
label: `${item.name}${count ? ` (${count})` : ''}`,
|
||||
label: `${displayName}${count ? ` (${count})` : ''}`,
|
||||
}
|
||||
}),
|
||||
]}
|
||||
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
Typography,
|
||||
} from 'antd'
|
||||
import type { TableColumnsType } from 'antd'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useNavigate, useSearchParams } from 'react-router'
|
||||
|
||||
import JsonPreview from '@/components/admin/JsonPreview'
|
||||
@@ -325,6 +325,50 @@ export default function WorkOrdersPanel() {
|
||||
queryKey: ['admin-worker-platform-categories'],
|
||||
queryFn: () => fetchAdminWorkCategories(),
|
||||
})
|
||||
|
||||
const categoryOptions = useMemo(() => {
|
||||
const raw = categoriesQuery.data?.data.items || []
|
||||
const rootCategories = raw.filter((c) => !c.parentId)
|
||||
const childrenMap = new Map<number, typeof raw>()
|
||||
for (const c of raw) {
|
||||
if (c.parentId) {
|
||||
const list = childrenMap.get(c.parentId) || []
|
||||
list.push(c)
|
||||
childrenMap.set(c.parentId, list)
|
||||
}
|
||||
}
|
||||
const result: Array<{ label: string; value: number }> = []
|
||||
for (const root of rootCategories) {
|
||||
const children = childrenMap.get(root.categoryId) || []
|
||||
result.push({ label: root.name, value: root.categoryId })
|
||||
for (const child of children) {
|
||||
result.push({ label: ` └ ${child.name}`, value: child.categoryId })
|
||||
}
|
||||
}
|
||||
return result
|
||||
}, [categoriesQuery.data?.data.items])
|
||||
|
||||
const activeCategoryOptions = useMemo(() => {
|
||||
const raw = (categoriesQuery.data?.data.items || []).filter((c) => c.status === 'active')
|
||||
const rootCategories = raw.filter((c) => !c.parentId)
|
||||
const childrenMap = new Map<number, typeof raw>()
|
||||
for (const c of raw) {
|
||||
if (c.parentId) {
|
||||
const list = childrenMap.get(c.parentId) || []
|
||||
list.push(c)
|
||||
childrenMap.set(c.parentId, list)
|
||||
}
|
||||
}
|
||||
const result: Array<{ label: string; value: number }> = []
|
||||
for (const root of rootCategories) {
|
||||
const children = childrenMap.get(root.categoryId) || []
|
||||
result.push({ label: root.name, value: root.categoryId })
|
||||
for (const child of children) {
|
||||
result.push({ label: ` └ ${child.name}`, value: child.categoryId })
|
||||
}
|
||||
}
|
||||
return result
|
||||
}, [categoriesQuery.data?.data.items])
|
||||
const workerLevelsQuery = useQuery({
|
||||
queryKey: ['admin-worker-platform-levels'],
|
||||
queryFn: () => fetchAdminWorkerLevels(),
|
||||
@@ -1376,10 +1420,7 @@ export default function WorkOrdersPanel() {
|
||||
placeholder="全部接单分类"
|
||||
style={{ width: 180 }}
|
||||
loading={categoriesQuery.isLoading}
|
||||
options={(categoriesQuery.data?.data.items || []).map((category) => ({
|
||||
value: category.categoryId,
|
||||
label: category.name,
|
||||
}))}
|
||||
options={categoryOptions}
|
||||
onChange={(nextCategoryId) => {
|
||||
setCategoryId(nextCategoryId)
|
||||
setPage(1)
|
||||
@@ -1892,16 +1933,7 @@ export default function WorkOrdersPanel() {
|
||||
<Input placeholder="留空表示无平台订单号" />
|
||||
</Form.Item>
|
||||
<Form.Item label="分类" name="categoryId">
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="选择接单分类"
|
||||
options={(categoriesQuery.data?.data.items || [])
|
||||
.filter((category) => category.status === 'active')
|
||||
.map((category) => ({
|
||||
label: category.name,
|
||||
value: category.categoryId,
|
||||
}))}
|
||||
/>
|
||||
<Select allowClear placeholder="选择接单分类" options={activeCategoryOptions} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="接单金额"
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
import { ReloadOutlined } from '@ant-design/icons'
|
||||
import {
|
||||
AlertOutlined,
|
||||
AuditOutlined,
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
CloseCircleOutlined,
|
||||
DollarCircleOutlined,
|
||||
DownOutlined,
|
||||
FormOutlined,
|
||||
ReloadOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
UpOutlined,
|
||||
UserOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
App,
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
Empty,
|
||||
Form,
|
||||
Input,
|
||||
Modal,
|
||||
Segmented,
|
||||
Space,
|
||||
Tabs,
|
||||
Tag,
|
||||
Typography,
|
||||
} from 'antd'
|
||||
@@ -33,14 +47,6 @@ type StatusFilter =
|
||||
| 'recovery_pending'
|
||||
| 'closed'
|
||||
|
||||
const STATUS_FILTERS: Array<{ value: StatusFilter; label: string }> = [
|
||||
{ value: 'all', label: '全部' },
|
||||
{ value: 'awaiting_worker_response', label: '待说明' },
|
||||
{ value: 'under_review', label: '处理中' },
|
||||
{ value: 'recovery_pending', label: '追缴中' },
|
||||
{ value: 'closed', label: '已关闭' },
|
||||
]
|
||||
|
||||
/** 待办优先:待说明 > 处理中 > 追缴中 > 已关闭,同状态按发起时间倒序。 */
|
||||
const STATUS_WEIGHT: Record<string, number> = {
|
||||
awaiting_worker_response: 0,
|
||||
@@ -56,7 +62,7 @@ export function formatWorkerAfterSalesStatus(status: string) {
|
||||
if (status === 'awaiting_worker_response') return '待说明'
|
||||
if (status === 'under_review') return '处理中'
|
||||
if (status === 'recovery_pending') return '追缴中'
|
||||
return '已关闭'
|
||||
return '已结案'
|
||||
}
|
||||
|
||||
export function resolveWorkerAfterSalesStatusColor(status: string) {
|
||||
@@ -114,14 +120,18 @@ export default function WorkerAfterSalesPage() {
|
||||
})
|
||||
const allCases = afterSalesCasesQuery.data?.data.items || []
|
||||
const pendingCount = allCases.filter((item) => item.status === 'awaiting_worker_response').length
|
||||
const countByFilter = useMemo(() => {
|
||||
const counts: Record<string, number> = { all: allCases.length }
|
||||
for (const filter of STATUS_FILTERS) {
|
||||
if (filter.value === 'all') continue
|
||||
counts[filter.value] = allCases.filter((item) => matchesFilter(item, filter.value)).length
|
||||
}
|
||||
return counts
|
||||
}, [allCases])
|
||||
const reviewCount = allCases.filter((item) => item.status === 'under_review').length
|
||||
const recoveryCount = allCases.filter((item) => item.status === 'recovery_pending').length
|
||||
const closedCount = allCases.filter((item) => isAfterSalesClosed(item.status)).length
|
||||
|
||||
const countByFilter: Record<StatusFilter, number> = {
|
||||
all: allCases.length,
|
||||
awaiting_worker_response: pendingCount,
|
||||
under_review: reviewCount,
|
||||
recovery_pending: recoveryCount,
|
||||
closed: closedCount,
|
||||
}
|
||||
|
||||
const afterSalesCases = useMemo(
|
||||
() =>
|
||||
allCases
|
||||
@@ -134,69 +144,236 @@ export default function WorkerAfterSalesPage() {
|
||||
[allCases, statusFilter],
|
||||
)
|
||||
|
||||
const tabItems = [
|
||||
{
|
||||
key: 'all',
|
||||
label: (
|
||||
<span className="worker-order-tab-label-main">
|
||||
全部售后
|
||||
{countByFilter.all > 0 ? (
|
||||
<span className="worker-order-tab-count">{countByFilter.all}</span>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'awaiting_worker_response',
|
||||
label: (
|
||||
<span className="worker-order-tab-label-main">
|
||||
待我说明
|
||||
{countByFilter.awaiting_worker_response > 0 ? (
|
||||
<span className="worker-order-tab-count is-warn">
|
||||
{countByFilter.awaiting_worker_response}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'under_review',
|
||||
label: (
|
||||
<span className="worker-order-tab-label-main">
|
||||
平台处理中
|
||||
{countByFilter.under_review > 0 ? (
|
||||
<span className="worker-order-tab-count">{countByFilter.under_review}</span>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'recovery_pending',
|
||||
label: (
|
||||
<span className="worker-order-tab-label-main">
|
||||
待追缴/扣款
|
||||
{countByFilter.recovery_pending > 0 ? (
|
||||
<span className="worker-order-tab-count is-danger">
|
||||
{countByFilter.recovery_pending}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'closed',
|
||||
label: (
|
||||
<span className="worker-order-tab-label-main">
|
||||
已结案
|
||||
{countByFilter.closed > 0 ? (
|
||||
<span className="worker-order-tab-count">{countByFilter.closed}</span>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<section
|
||||
className={
|
||||
isMobile ? 'worker-after-sales-page worker-after-sales-mobile' : 'worker-after-sales-page'
|
||||
}
|
||||
>
|
||||
{pendingCount > 0 ? (
|
||||
<Alert
|
||||
className="worker-after-sales-reminder"
|
||||
type="warning"
|
||||
showIcon
|
||||
message={`你有 ${pendingCount} 条售后单待提交说明,请尽快处理,逾期可能影响结算与等级`}
|
||||
/>
|
||||
) : null}
|
||||
<div className="worker-after-sales-toolbar">
|
||||
<Segmented
|
||||
options={STATUS_FILTERS.map((filter) => ({
|
||||
value: filter.value,
|
||||
label: (
|
||||
<Space size={4}>
|
||||
{filter.label}
|
||||
{countByFilter[filter.value] > 0 ? (
|
||||
<span className="worker-after-sales-filter-count">
|
||||
{countByFilter[filter.value]}
|
||||
</span>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
}))}
|
||||
value={statusFilter}
|
||||
onChange={(value) => setStatusFilter(value as StatusFilter)}
|
||||
block={isMobile}
|
||||
/>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
loading={afterSalesCasesQuery.isFetching}
|
||||
onClick={() => afterSalesCasesQuery.refetch()}
|
||||
>
|
||||
刷新
|
||||
</Button>
|
||||
<section className="page-stack worker-after-sales-page">
|
||||
{/* 桌面端标准整合头部 (与“我的订单”与“接单大厅”全局保持一致) */}
|
||||
<div className="worker-orders-desktop-header">
|
||||
<div className="worker-orders-header-left">
|
||||
<Typography.Title level={3} className="worker-orders-heading">
|
||||
售后问题单
|
||||
</Typography.Title>
|
||||
{pendingCount > 0 ? (
|
||||
<span className="worker-after-sales-alert-pill">
|
||||
<span className="worker-after-sales-pulse-dot" />
|
||||
{pendingCount} 笔待提交说明
|
||||
</span>
|
||||
) : (
|
||||
<span className="worker-orders-live-badge">
|
||||
<span className="worker-orders-pulse-dot" />
|
||||
工单售后与申诉仲裁
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="worker-orders-header-right">
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
loading={afterSalesCasesQuery.isFetching}
|
||||
onClick={() => afterSalesCasesQuery.refetch()}
|
||||
>
|
||||
刷新
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{afterSalesCasesQuery.isLoading ? (
|
||||
<Typography.Text type="secondary">加载中…</Typography.Text>
|
||||
) : afterSalesCasesQuery.isError ? (
|
||||
<Alert
|
||||
type="error"
|
||||
showIcon
|
||||
message="售后问题单加载失败"
|
||||
description="请刷新后重试;若问题持续存在,请联系客服。"
|
||||
/>
|
||||
) : afterSalesCases.length === 0 ? (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description="暂无售后问题单,请保持验收资料真实完整"
|
||||
/>
|
||||
) : (
|
||||
<div className="worker-after-sales-list">
|
||||
{afterSalesCases.map((item) => (
|
||||
<WorkerAfterSalesItem key={item.caseId} item={item} isMobile={isMobile} />
|
||||
))}
|
||||
{/* 4 栏工单态势 KPI 仪表盘 (与接单平台全局 KPI 网格一致) */}
|
||||
<div className="worker-orders-kpi-grid">
|
||||
{/* 卡片 1: 待我说明 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${statusFilter === 'awaiting_worker_response' ? 'active' : ''}`}
|
||||
onClick={() =>
|
||||
setStatusFilter(
|
||||
statusFilter === 'awaiting_worker_response' ? 'all' : 'awaiting_worker_response',
|
||||
)
|
||||
}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap problem">
|
||||
<AlertOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">待我举证说明</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{pendingCount}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">
|
||||
{pendingCount > 0 ? '需尽快提交情况说明' : '暂无待处理'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 卡片 2: 客服处理中 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${statusFilter === 'under_review' ? 'active' : ''}`}
|
||||
onClick={() => setStatusFilter(statusFilter === 'under_review' ? 'all' : 'under_review')}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap in-progress">
|
||||
<AuditOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">平台仲裁中</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{reviewCount}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">客服公正审理审核中</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 3: 待追缴/扣款 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${statusFilter === 'recovery_pending' ? 'active' : ''}`}
|
||||
onClick={() =>
|
||||
setStatusFilter(statusFilter === 'recovery_pending' ? 'all' : 'recovery_pending')
|
||||
}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap pending">
|
||||
<DollarCircleOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">待追缴/扣款</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{recoveryCount}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">存在待抵扣补缴资金</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 4: 已完结/已结案 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${statusFilter === 'closed' ? 'active' : ''}`}
|
||||
onClick={() => setStatusFilter(statusFilter === 'closed' ? 'all' : 'closed')}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap accepted">
|
||||
<CheckCircleOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">已结案归档</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{closedCount}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">历史完结记录 (默认折叠)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 主卡片:统一 AntD Tabs 标签切换与售后单列表 */}
|
||||
<Card bordered={false} className="worker-orders-card">
|
||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||
<Tabs
|
||||
className="worker-order-tabs"
|
||||
activeKey={statusFilter}
|
||||
items={tabItems}
|
||||
onChange={(key) => setStatusFilter(key as StatusFilter)}
|
||||
/>
|
||||
|
||||
{afterSalesCasesQuery.isLoading ? (
|
||||
<div className="worker-as-loading-state">
|
||||
<Typography.Text type="secondary">正在加载售后问题单…</Typography.Text>
|
||||
</div>
|
||||
) : afterSalesCasesQuery.isError ? (
|
||||
<Alert
|
||||
type="error"
|
||||
showIcon
|
||||
message="售后问题单加载失败"
|
||||
description="请刷新后重试;若问题持续存在,请联系客服。"
|
||||
/>
|
||||
) : afterSalesCases.length === 0 ? (
|
||||
<div className="worker-as-empty-card">
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description="暂无匹配的售后问题单,请保持验收资料真实完整"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="worker-after-sales-list">
|
||||
{afterSalesCases.map((item) => (
|
||||
<WorkerAfterSalesItem key={item.caseId} item={item} isMobile={isMobile} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Space>
|
||||
</Card>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -214,6 +391,10 @@ function WorkerAfterSalesItem({
|
||||
const [files, setFiles] = useState<UploadedFile[]>([])
|
||||
const [form] = Form.useForm<AfterSalesResponseFormValues>()
|
||||
|
||||
const isClosed = isAfterSalesClosed(item.status)
|
||||
// 关闭完成的默认折叠,未关闭的默认展开
|
||||
const [collapsed, setCollapsed] = useState(isClosed)
|
||||
|
||||
async function submit(values: AfterSalesResponseFormValues) {
|
||||
const response = String(values.response || '').trim()
|
||||
if (!response && files.length === 0) {
|
||||
@@ -240,180 +421,373 @@ function WorkerAfterSalesItem({
|
||||
Number(item.recoveryAmount || 0) > 0 ||
|
||||
Number(item.pendingDepositDeductionAmount || 0) > 0 ||
|
||||
Number(item.availableDeductionAmount || 0) > 0 ||
|
||||
Number(item.debtAmount || 0) > 0
|
||||
Number(item.debtAmount || 0) > 0 ||
|
||||
Number(item.refundedAmount || 0) > 0
|
||||
|
||||
return (
|
||||
<>
|
||||
<article
|
||||
className={`worker-after-sales-item${item.status === 'awaiting_worker_response' ? ' is-awaiting' : ''}`}
|
||||
className={`worker-as-case-card is-status-${item.status}${collapsed ? ' is-collapsed' : ''}`}
|
||||
>
|
||||
<div className="worker-after-sales-item-head">
|
||||
<Space size={6} wrap>
|
||||
<Tag color={resolveWorkerAfterSalesStatusColor(item.status)}>
|
||||
{formatWorkerAfterSalesStatus(item.status)}
|
||||
</Tag>
|
||||
<Tag color={resolveWorkerAfterSalesProblemTypeColor(item.problemType)}>
|
||||
{formatWorkerAfterSalesProblemType(item.problemType)}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Typography.Text strong ellipsis={{ tooltip: item.productName || item.caseNo }}>
|
||||
{item.productName || item.caseNo}
|
||||
</Typography.Text>
|
||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||
发起 {formatDateTime(item.createdAt)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Space size={12} wrap className="worker-after-sales-item-meta">
|
||||
<Typography.Text
|
||||
type="secondary"
|
||||
style={{ fontSize: 12 }}
|
||||
copyable={{ text: item.workOrderNo || item.caseNo }}
|
||||
>
|
||||
工单号 {item.workOrderNo || item.caseNo}
|
||||
</Typography.Text>
|
||||
<Typography.Text
|
||||
type="secondary"
|
||||
style={{ fontSize: 12 }}
|
||||
copyable={{ text: item.caseNo }}
|
||||
>
|
||||
售后单号 {item.caseNo}
|
||||
</Typography.Text>
|
||||
{item.shareQuantity ? (
|
||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||
拼单 {item.shareQuantity} 份
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
</Space>
|
||||
|
||||
<div className="worker-after-sales-block">
|
||||
<div className="worker-after-sales-block-label">投诉内容</div>
|
||||
<Typography.Paragraph style={{ marginBottom: item.complaintFiles.length ? 8 : 0 }}>
|
||||
{item.complaintNote || '-'}
|
||||
</Typography.Paragraph>
|
||||
{item.complaintFiles.length > 0 ? (
|
||||
<ImagePreviewList files={item.complaintFiles} size={48} maxVisible={5} />
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{item.workerResponse || item.workerResponseFiles.length > 0 ? (
|
||||
<div className="worker-after-sales-block is-mine">
|
||||
<div className="worker-after-sales-block-label">
|
||||
我提交的说明{item.respondedAt ? ` · ${formatDateTime(item.respondedAt)}` : ''}
|
||||
</div>
|
||||
{item.workerResponse ? (
|
||||
<Typography.Paragraph
|
||||
style={{ marginBottom: item.workerResponseFiles.length ? 8 : 0 }}
|
||||
{/* 折叠状态下的紧凑单行摘要 */}
|
||||
{collapsed ? (
|
||||
<div className="worker-as-collapsed-row" onClick={() => setCollapsed(false)}>
|
||||
<div className="worker-as-collapsed-left">
|
||||
<span className={`worker-as-status-badge is-${item.status}`}>
|
||||
<span className="worker-as-status-dot" />
|
||||
{formatWorkerAfterSalesStatus(item.status)}
|
||||
</span>
|
||||
<Tag
|
||||
color={resolveWorkerAfterSalesProblemTypeColor(item.problemType)}
|
||||
className="worker-as-problem-tag"
|
||||
>
|
||||
{item.workerResponse}
|
||||
</Typography.Paragraph>
|
||||
) : null}
|
||||
{item.workerResponseFiles.length > 0 ? (
|
||||
<ImagePreviewList files={item.workerResponseFiles} size={48} maxVisible={5} />
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{resolutionLabel || item.resolutionNote || hasRecoveryDetail ? (
|
||||
<div className="worker-after-sales-block is-result">
|
||||
<div className="worker-after-sales-block-label">处理结果</div>
|
||||
<Space direction="vertical" size={6} style={{ width: '100%' }}>
|
||||
{formatWorkerAfterSalesProblemType(item.problemType)}
|
||||
</Tag>
|
||||
<Typography.Text
|
||||
strong
|
||||
className="worker-as-product-title-collapsed"
|
||||
ellipsis={{ tooltip: item.productName || item.caseNo }}
|
||||
>
|
||||
{item.productName || item.caseNo}
|
||||
</Typography.Text>
|
||||
{resolutionLabel ? (
|
||||
<Space size={8} wrap>
|
||||
<Tag color={resolveWorkerAfterSalesResolutionColor(item.resolutionAction)}>
|
||||
{resolutionLabel}
|
||||
</Tag>
|
||||
{item.resolvedAt ? (
|
||||
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{formatDateTime(item.resolvedAt)}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
</Space>
|
||||
<Tag
|
||||
color={resolveWorkerAfterSalesResolutionColor(item.resolutionAction)}
|
||||
style={{ margin: 0 }}
|
||||
>
|
||||
{resolutionLabel}
|
||||
</Tag>
|
||||
) : null}
|
||||
{item.resolutionNote ? (
|
||||
<Typography.Paragraph style={{ marginBottom: 0 }}>
|
||||
{item.resolutionNote}
|
||||
</Typography.Paragraph>
|
||||
{Number(item.recoveryAmount || 0) > 0 ? (
|
||||
<span className="worker-as-recovery-brief">
|
||||
追缴 {formatMoney(item.recoveryAmount)}
|
||||
</span>
|
||||
) : null}
|
||||
{hasRecoveryDetail ? (
|
||||
<Space size={12} wrap>
|
||||
{Number(item.recoveryAmount || 0) > 0 ? (
|
||||
<Typography.Text type="danger" strong>
|
||||
追缴 {formatMoney(item.recoveryAmount)}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
{Number(item.pendingDepositDeductionAmount || 0) > 0 ? (
|
||||
<Typography.Text type="secondary">
|
||||
待解冻资金抵扣 {formatMoney(item.pendingDepositDeductionAmount)}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
{Number(item.availableDeductionAmount || 0) > 0 ? (
|
||||
<Typography.Text type="secondary">
|
||||
余额抵扣 {formatMoney(item.availableDeductionAmount)}
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
{Number(item.debtAmount || 0) > 0 ? (
|
||||
<Typography.Text type="danger" strong>
|
||||
待追缴 {formatMoney(item.debtAmount)},后续验收报酬将自动抵扣
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
{Number(item.refundedAmount || 0) > 0 ? (
|
||||
<Typography.Text type="success" strong>
|
||||
已退还追缴 {formatMoney(item.refundedAmount)} 至可用余额
|
||||
</Typography.Text>
|
||||
) : null}
|
||||
</Space>
|
||||
) : null}
|
||||
</Space>
|
||||
</div>
|
||||
) : item.status === 'under_review' ? (
|
||||
<Typography.Text type="secondary">已提交说明,等待客服处理</Typography.Text>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{item.status === 'awaiting_worker_response' ? (
|
||||
<div className="worker-after-sales-item-actions">
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setFiles([])
|
||||
form.resetFields()
|
||||
setResponseOpen(true)
|
||||
}}
|
||||
>
|
||||
提交说明
|
||||
</Button>
|
||||
<div className="worker-as-collapsed-right" onClick={(e) => e.stopPropagation()}>
|
||||
<span className="worker-as-meta-time">发起 {formatDateTime(item.createdAt)}</span>
|
||||
<Typography.Text
|
||||
className="worker-as-meta-code"
|
||||
type="secondary"
|
||||
copyable={{
|
||||
text: item.workOrderNo || item.caseNo,
|
||||
tooltips: ['复制工单号', '已复制'],
|
||||
}}
|
||||
>
|
||||
工单 {item.workOrderNo || item.caseNo}
|
||||
</Typography.Text>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
className="worker-as-toggle-btn"
|
||||
icon={<DownOutlined />}
|
||||
onClick={() => setCollapsed(false)}
|
||||
>
|
||||
展开详情
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
) : (
|
||||
/* 展开状态下的完整详情视图 */
|
||||
<>
|
||||
{/* 卡片头部:状态、问题类型、工单标题、订单单号、收起按钮 */}
|
||||
<div className="worker-as-card-header">
|
||||
<div className="worker-as-card-header-left">
|
||||
<span className={`worker-as-status-badge is-${item.status}`}>
|
||||
<span className="worker-as-status-dot" />
|
||||
{formatWorkerAfterSalesStatus(item.status)}
|
||||
</span>
|
||||
<Tag
|
||||
color={resolveWorkerAfterSalesProblemTypeColor(item.problemType)}
|
||||
className="worker-as-problem-tag"
|
||||
>
|
||||
{formatWorkerAfterSalesProblemType(item.problemType)}
|
||||
</Tag>
|
||||
<Typography.Text
|
||||
strong
|
||||
className="worker-as-product-title"
|
||||
ellipsis={{ tooltip: item.productName || item.caseNo }}
|
||||
>
|
||||
{item.productName || item.caseNo}
|
||||
</Typography.Text>
|
||||
{item.shareQuantity ? (
|
||||
<Tag className="worker-as-share-tag">拼单 {item.shareQuantity} 份</Tag>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="worker-as-card-header-right">
|
||||
<span className="worker-as-meta-time">
|
||||
<ClockCircleOutlined style={{ marginRight: 4 }} />
|
||||
发起 {formatDateTime(item.createdAt)}
|
||||
</span>
|
||||
<Typography.Text
|
||||
className="worker-as-meta-code"
|
||||
type="secondary"
|
||||
copyable={{
|
||||
text: item.workOrderNo || item.caseNo,
|
||||
tooltips: ['复制工单号', '已复制'],
|
||||
}}
|
||||
>
|
||||
工单 {item.workOrderNo || item.caseNo}
|
||||
</Typography.Text>
|
||||
<Typography.Text
|
||||
className="worker-as-meta-code"
|
||||
type="secondary"
|
||||
copyable={{ text: item.caseNo, tooltips: ['复制售后单号', '已复制'] }}
|
||||
>
|
||||
售后单 {item.caseNo}
|
||||
</Typography.Text>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
className="worker-as-toggle-btn"
|
||||
icon={<UpOutlined />}
|
||||
onClick={() => setCollapsed(true)}
|
||||
>
|
||||
收起详情
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 主体对比区域:买家投诉诉求 vs 打手答辩举证 (并排双列) */}
|
||||
<div className="worker-as-card-body">
|
||||
{/* 左列:买家投诉诉求 */}
|
||||
<div className="worker-as-col worker-as-buyer-col">
|
||||
<div className="worker-as-col-header">
|
||||
<div className="worker-as-avatar-pill buyer">
|
||||
<UserOutlined />
|
||||
</div>
|
||||
<span className="worker-as-col-title">买家投诉诉求</span>
|
||||
</div>
|
||||
<div className="worker-as-box buyer-box">
|
||||
<div className="worker-as-box-text">
|
||||
{item.complaintNote ? (
|
||||
<p className="worker-as-complaint-text">{item.complaintNote}</p>
|
||||
) : (
|
||||
<p className="worker-as-empty-text">买家未填写文字描述</p>
|
||||
)}
|
||||
</div>
|
||||
{item.complaintFiles.length > 0 && (
|
||||
<div className="worker-as-box-files">
|
||||
<div className="worker-as-files-label">
|
||||
买家举证材料 ({item.complaintFiles.length}):
|
||||
</div>
|
||||
<ImagePreviewList files={item.complaintFiles} size={54} maxVisible={6} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 右列:打手答辩与举证 */}
|
||||
<div className="worker-as-col worker-as-worker-col">
|
||||
<div className="worker-as-col-header">
|
||||
<div className="worker-as-avatar-pill worker">
|
||||
<SafetyCertificateOutlined />
|
||||
</div>
|
||||
<span className="worker-as-col-title">我的答辩与说明</span>
|
||||
{item.respondedAt && (
|
||||
<span className="worker-as-col-subtitle">
|
||||
提交于 {formatDateTime(item.respondedAt)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{item.workerResponse || item.workerResponseFiles.length > 0 ? (
|
||||
<div className="worker-as-box worker-box">
|
||||
<div className="worker-as-box-text">
|
||||
{item.workerResponse ? (
|
||||
<p className="worker-as-worker-text">{item.workerResponse}</p>
|
||||
) : null}
|
||||
</div>
|
||||
{item.workerResponseFiles.length > 0 && (
|
||||
<div className="worker-as-box-files">
|
||||
<div className="worker-as-files-label">
|
||||
补救举证材料 ({item.workerResponseFiles.length}):
|
||||
</div>
|
||||
<ImagePreviewList
|
||||
files={item.workerResponseFiles}
|
||||
size={54}
|
||||
maxVisible={6}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : item.status === 'awaiting_worker_response' ? (
|
||||
<div className="worker-as-box awaiting-cta-box">
|
||||
<div className="worker-as-cta-content">
|
||||
<div className="worker-as-cta-icon-wrap">
|
||||
<AlertOutlined className="worker-as-cta-icon" />
|
||||
</div>
|
||||
<div className="worker-as-cta-info">
|
||||
<h4 className="worker-as-cta-title">等待您提交说明材料</h4>
|
||||
<p className="worker-as-cta-desc">
|
||||
买家已发起售后申诉,请针对上述问题提交文字说明或补救凭据,以便平台客服公允判定。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
type="primary"
|
||||
className="worker-as-submit-btn"
|
||||
icon={<FormOutlined />}
|
||||
onClick={() => {
|
||||
setFiles([])
|
||||
form.resetFields()
|
||||
setResponseOpen(true)
|
||||
}}
|
||||
>
|
||||
立即提交说明与凭据
|
||||
</Button>
|
||||
</div>
|
||||
) : item.status === 'under_review' ? (
|
||||
<div className="worker-as-box neutral-state-box">
|
||||
<ClockCircleOutlined className="worker-as-neutral-icon" />
|
||||
<p className="worker-as-neutral-text">
|
||||
未补充文字材料,平台客服正在结合买家举证与订单原始验收凭据进行裁决审核。
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="worker-as-box neutral-state-box is-closed">
|
||||
<CheckCircleOutlined className="worker-as-neutral-icon" />
|
||||
<p className="worker-as-neutral-text">本工单已结案(未补充答辩记录)</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 底部横幅:平台仲裁裁决与资金明细 */}
|
||||
{resolutionLabel ||
|
||||
item.resolutionNote ||
|
||||
hasRecoveryDetail ||
|
||||
item.status === 'under_review' ? (
|
||||
<div
|
||||
className={`worker-as-resolution-banner ${item.status === 'under_review' && !resolutionLabel ? 'is-pending' : ''}`}
|
||||
>
|
||||
<div className="worker-as-resolution-head">
|
||||
<div className="worker-as-resolution-head-left">
|
||||
<span className="worker-as-gavel-icon">
|
||||
<AuditOutlined />
|
||||
</span>
|
||||
<span className="worker-as-resolution-title">平台仲裁判定</span>
|
||||
{resolutionLabel ? (
|
||||
<Tag
|
||||
color={resolveWorkerAfterSalesResolutionColor(item.resolutionAction)}
|
||||
className="worker-as-resolution-tag"
|
||||
>
|
||||
{item.resolutionAction === 'upheld' && (
|
||||
<CloseCircleOutlined style={{ marginRight: 4 }} />
|
||||
)}
|
||||
{item.resolutionAction === 'not_upheld' && (
|
||||
<CheckCircleOutlined style={{ marginRight: 4 }} />
|
||||
)}
|
||||
{resolutionLabel}
|
||||
</Tag>
|
||||
) : item.status === 'under_review' ? (
|
||||
<Tag color="blue" className="worker-as-resolution-tag">
|
||||
客服审核中
|
||||
</Tag>
|
||||
) : null}
|
||||
{item.resolvedAt ? (
|
||||
<span className="worker-as-resolution-time">
|
||||
裁决时间:{formatDateTime(item.resolvedAt)}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{item.resolutionNote && (
|
||||
<div className="worker-as-resolution-note">
|
||||
<span className="note-label">判定说明:</span>
|
||||
<span className="note-content">{item.resolutionNote}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{hasRecoveryDetail && (
|
||||
<div className="worker-as-financial-breakdown">
|
||||
<span className="financial-label">资金处理明细:</span>
|
||||
<div className="financial-chips-wrap">
|
||||
{Number(item.recoveryAmount || 0) > 0 && (
|
||||
<span className="financial-chip is-recovery">
|
||||
<span className="chip-name">追缴金额</span>
|
||||
<span className="chip-amount">{formatMoney(item.recoveryAmount)}</span>
|
||||
</span>
|
||||
)}
|
||||
{Number(item.pendingDepositDeductionAmount || 0) > 0 && (
|
||||
<span className="financial-chip is-deposit">
|
||||
<span className="chip-name">待解冻资金抵扣</span>
|
||||
<span className="chip-amount">
|
||||
{formatMoney(item.pendingDepositDeductionAmount)}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
{Number(item.availableDeductionAmount || 0) > 0 && (
|
||||
<span className="financial-chip is-available">
|
||||
<span className="chip-name">余额抵扣</span>
|
||||
<span className="chip-amount">
|
||||
{formatMoney(item.availableDeductionAmount)}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
{Number(item.debtAmount || 0) > 0 && (
|
||||
<span className="financial-chip is-debt">
|
||||
<span className="chip-name">待追缴欠款</span>
|
||||
<span className="chip-amount">{formatMoney(item.debtAmount)}</span>
|
||||
<span className="chip-hint">(后续报酬自动抵扣)</span>
|
||||
</span>
|
||||
)}
|
||||
{Number(item.refundedAmount || 0) > 0 && (
|
||||
<span className="financial-chip is-refunded">
|
||||
<span className="chip-name">退还追缴</span>
|
||||
<span className="chip-amount">{formatMoney(item.refundedAmount)}</span>
|
||||
<span className="chip-hint">(已入可用余额)</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
</article>
|
||||
|
||||
{/* 提交说明材料弹窗 */}
|
||||
<Modal
|
||||
title={`售后说明 · ${item.productName || item.caseNo}`}
|
||||
title={`提交售后说明 · ${item.productName || item.caseNo}`}
|
||||
open={responseOpen}
|
||||
width={isMobile ? '92%' : 560}
|
||||
width={isMobile ? '94%' : 580}
|
||||
onCancel={() => setResponseOpen(false)}
|
||||
onOk={() => form.submit()}
|
||||
okText="提交说明"
|
||||
okText="确认提交说明"
|
||||
destroyOnHidden
|
||||
className="worker-as-submit-modal"
|
||||
>
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="请针对售后问题说明情况或提交补救材料,原验收资料不可在此修改。"
|
||||
style={{ marginBottom: 12 }}
|
||||
message="请针对售后问题如实说明情况或提交补救凭证。原订单验收资料不可在此修改。"
|
||||
style={{ marginBottom: 14 }}
|
||||
/>
|
||||
<div className="worker-after-sales-block">
|
||||
<div className="worker-after-sales-block-label">
|
||||
投诉内容 · {formatWorkerAfterSalesProblemType(item.problemType)}
|
||||
|
||||
{/* 弹窗内展示买家投诉内容供参考 */}
|
||||
<div className="worker-as-modal-buyer-summary">
|
||||
<div className="modal-summary-title">
|
||||
<UserOutlined style={{ marginRight: 6, color: '#ef4444' }} />
|
||||
买家投诉内容 · {formatWorkerAfterSalesProblemType(item.problemType)}
|
||||
</div>
|
||||
<Typography.Paragraph style={{ marginBottom: item.complaintFiles.length ? 8 : 0 }}>
|
||||
{item.complaintNote || '-'}
|
||||
</Typography.Paragraph>
|
||||
{item.complaintFiles.length > 0 ? (
|
||||
<ImagePreviewList files={item.complaintFiles} size={44} maxVisible={4} />
|
||||
) : null}
|
||||
<div className="modal-summary-content">
|
||||
{item.complaintNote || '(买家未填写文字描述)'}
|
||||
</div>
|
||||
{item.complaintFiles.length > 0 && (
|
||||
<div className="modal-summary-files">
|
||||
<ImagePreviewList files={item.complaintFiles} size={46} maxVisible={4} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Form form={form} layout="vertical" onFinish={submit} style={{ marginTop: 12 }}>
|
||||
|
||||
<Form form={form} layout="vertical" onFinish={submit} style={{ marginTop: 14 }}>
|
||||
<Form.Item
|
||||
label="说明"
|
||||
label="我的说明与答辩"
|
||||
name="response"
|
||||
extra="说明与补救材料至少填写一项"
|
||||
rules={[
|
||||
@@ -421,7 +795,7 @@ function WorkerAfterSalesItem({
|
||||
validator: (_, value) =>
|
||||
String(value || '').trim() || files.length > 0
|
||||
? Promise.resolve()
|
||||
: Promise.reject(new Error('请填写说明或至少上传一张图片')),
|
||||
: Promise.reject(new Error('请填写说明或至少上传一张补救材料图片')),
|
||||
},
|
||||
]}
|
||||
>
|
||||
@@ -429,10 +803,10 @@ function WorkerAfterSalesItem({
|
||||
rows={4}
|
||||
maxLength={2000}
|
||||
showCount
|
||||
placeholder="请说明当时的处理情况"
|
||||
placeholder="请详细客观说明当时订单处理情况、与买家沟通情况或补救事实…"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="补救材料图片">
|
||||
<Form.Item label="补救举证材料图片 (支持粘贴直接上传)">
|
||||
<ImageUpload
|
||||
scene="worker-acceptance"
|
||||
scope="worker"
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import {
|
||||
AppstoreOutlined,
|
||||
ArrowRightOutlined,
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
FireOutlined,
|
||||
PushpinOutlined,
|
||||
QuestionCircleOutlined,
|
||||
ReloadOutlined,
|
||||
SearchOutlined,
|
||||
ThunderboltOutlined,
|
||||
TrophyOutlined,
|
||||
WalletOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
@@ -27,6 +33,7 @@ import {
|
||||
Typography,
|
||||
} from 'antd'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
|
||||
import {
|
||||
fetchWorkerHallOrders,
|
||||
@@ -63,25 +70,29 @@ export default function WorkerHallPage() {
|
||||
const queryClient = useQueryClient()
|
||||
const [keywordInput, setKeywordInput] = useState('')
|
||||
const [keyword, setKeyword] = useState('')
|
||||
const [categoryId, setCategoryId] = useState(0)
|
||||
const [primaryCategoryId, setPrimaryCategoryId] = useState(0)
|
||||
const [subCategoryId, setSubCategoryId] = useState(0)
|
||||
const effectiveCategoryId = subCategoryId || primaryCategoryId || 0
|
||||
const [grabbingId, setGrabbingId] = useState(0)
|
||||
const [sharingOrder, setSharingOrder] = useState<WorkOrder | null>(null)
|
||||
const [leaderboardOpen, setLeaderboardOpen] = useState(false)
|
||||
const [leaderboardPeriod, setLeaderboardPeriod] = useState<WorkerLeaderboardPeriod>('all')
|
||||
const [sharingQuantity, setSharingQuantity] = useState(1)
|
||||
const [submittingSharing, setSubmittingSharing] = useState(false)
|
||||
const [failedImageKeys, setFailedImageKeys] = useState<Record<string | number, boolean>>({})
|
||||
const [confirmOpen, setConfirmOpen] = useState(false)
|
||||
const [grabConfirmEnabled, setGrabConfirmEnabled] = useState(isGrabConfirmEnabled)
|
||||
const loadMoreRef = useRef<HTMLDivElement | null>(null)
|
||||
|
||||
const ordersQuery = useInfiniteQuery({
|
||||
queryKey: ['worker-hall-orders', keyword, categoryId],
|
||||
queryKey: ['worker-hall-orders', keyword, effectiveCategoryId],
|
||||
initialPageParam: 1,
|
||||
queryFn: ({ pageParam }) =>
|
||||
fetchWorkerHallOrders({
|
||||
keyword,
|
||||
page: Number(pageParam),
|
||||
pageSize: HALL_PAGE_SIZE,
|
||||
categoryId: categoryId || undefined,
|
||||
categoryId: effectiveCategoryId || undefined,
|
||||
}),
|
||||
getNextPageParam: (lastPage) => {
|
||||
const pagination = lastPage.data.pagination
|
||||
@@ -127,7 +138,36 @@ export default function WorkerHallPage() {
|
||||
|
||||
const orders = ordersQuery.data?.pages.flatMap((page) => page.data.items) || []
|
||||
const firstPage = ordersQuery.data?.pages[0]?.data
|
||||
const categories = firstPage?.categories || []
|
||||
const allCategories = firstPage?.categories || []
|
||||
const showSubcategoriesConfig = firstPage?.showSubcategories ?? true
|
||||
|
||||
const allCategoryFromList = allCategories.find(
|
||||
(c) => !c.parentId && (c.categoryKey === 'all' || c.name === '全部'),
|
||||
)
|
||||
const allIconUrl = firstPage?.allIconUrl || allCategoryFromList?.iconUrl || null
|
||||
|
||||
const primaryCategories = allCategories.filter(
|
||||
(c) => !c.parentId && c.categoryKey !== 'all' && c.name !== '全部',
|
||||
)
|
||||
const hasCategoryBar = primaryCategories.length > 0 || Boolean(allIconUrl)
|
||||
const subCategoriesMap = new Map<number, typeof allCategories>()
|
||||
for (const c of allCategories) {
|
||||
if (c.parentId) {
|
||||
const list = subCategoriesMap.get(c.parentId) || []
|
||||
list.push(c)
|
||||
subCategoriesMap.set(c.parentId, list)
|
||||
}
|
||||
}
|
||||
|
||||
const currentSubCategories = primaryCategoryId
|
||||
? subCategoriesMap.get(primaryCategoryId) || []
|
||||
: []
|
||||
const shouldShowSubcategories = showSubcategoriesConfig && currentSubCategories.length > 0
|
||||
|
||||
function handleSelectPrimaryCategory(nextId: number) {
|
||||
setPrimaryCategoryId(nextId)
|
||||
setSubCategoryId(0)
|
||||
}
|
||||
const worker = profileQuery.data?.data.worker
|
||||
const activeCount = Number(profileQuery.data?.data.summary.activeOrderCount || 0)
|
||||
const pendingAcceptanceCount = hallSummaryQuery.data?.pendingAcceptanceCount || 0
|
||||
@@ -135,6 +175,9 @@ export default function WorkerHallPage() {
|
||||
const maxActiveOrders = Number(worker?.level?.permissions.maxActiveOrders || 0)
|
||||
const remainingSlots = maxActiveOrders > 0 ? Math.max(0, maxActiveOrders - activeCount) : null
|
||||
const shouldWarn = (remainingSlots !== null && remainingSlots <= 0) || problemCount > 0
|
||||
const totalHallOrders = Number(ordersQuery.data?.pages[0]?.data.pagination.total || orders.length)
|
||||
const quotaPercent =
|
||||
maxActiveOrders > 0 ? Math.min(100, Math.round((activeCount / maxActiveOrders) * 100)) : 0
|
||||
|
||||
useEffect(() => {
|
||||
const target = loadMoreRef.current
|
||||
@@ -331,28 +374,98 @@ export default function WorkerHallPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 移动端横向滑动分类条 */}
|
||||
{categories.length > 0 ? (
|
||||
<div className="worker-hall-mobile-category-bar">
|
||||
{/* 移动端一级分类/游戏卡片横向滑动条 */}
|
||||
{hasCategoryBar ? (
|
||||
<div className="worker-hall-game-cards-scroll">
|
||||
<button
|
||||
type="button"
|
||||
className={`worker-hall-mobile-cat-pill ${categoryId === 0 ? 'active' : ''}`}
|
||||
onClick={() => {
|
||||
setCategoryId(0)
|
||||
}}
|
||||
className={`worker-hall-game-card ${primaryCategoryId === 0 ? 'active' : ''}`}
|
||||
onClick={() => handleSelectPrimaryCategory(0)}
|
||||
>
|
||||
全部
|
||||
<div
|
||||
className="worker-hall-game-icon-box"
|
||||
style={
|
||||
primaryCategoryId === 0 && (!allIconUrl || failedImageKeys['all'])
|
||||
? { background: 'linear-gradient(135deg, #ff6a00 0%, #ff8e3c 100%)' }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{allIconUrl && !failedImageKeys['all'] ? (
|
||||
<img
|
||||
src={allIconUrl}
|
||||
alt="全部"
|
||||
className="worker-hall-game-img"
|
||||
onError={() => setFailedImageKeys((prev) => ({ ...prev, all: true }))}
|
||||
/>
|
||||
) : (
|
||||
<AppstoreOutlined
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: primaryCategoryId === 0 ? '#ffffff' : '#64748b',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<span className="worker-hall-game-title">全部</span>
|
||||
</button>
|
||||
{categories.map((category) => (
|
||||
{primaryCategories.map((category) => (
|
||||
<button
|
||||
key={category.categoryId}
|
||||
type="button"
|
||||
className={`worker-hall-mobile-cat-pill ${categoryId === category.categoryId ? 'active' : ''}`}
|
||||
onClick={() => {
|
||||
setCategoryId(category.categoryId)
|
||||
}}
|
||||
className={`worker-hall-game-card ${primaryCategoryId === category.categoryId ? 'active' : ''}`}
|
||||
onClick={() => handleSelectPrimaryCategory(category.categoryId)}
|
||||
>
|
||||
{category.name}
|
||||
<div
|
||||
className="worker-hall-game-icon-box"
|
||||
style={
|
||||
!category.iconUrl || failedImageKeys[category.categoryId]
|
||||
? { background: getCategoryGradient(category.name, category.categoryId) }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{category.iconUrl && !failedImageKeys[category.categoryId] ? (
|
||||
<img
|
||||
src={category.iconUrl}
|
||||
alt={category.name}
|
||||
className="worker-hall-game-img"
|
||||
onError={() =>
|
||||
setFailedImageKeys((prev) => ({
|
||||
...prev,
|
||||
[category.categoryId]: true,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<span className="worker-hall-game-initial">{category.name.slice(0, 1)}</span>
|
||||
)}
|
||||
</div>
|
||||
<span className="worker-hall-game-title" title={category.name}>
|
||||
{category.name}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{/* 移动端二级分类联动条 */}
|
||||
{shouldShowSubcategories ? (
|
||||
<div className="worker-hall-subcat-bar">
|
||||
<span className="worker-hall-subcat-label">业务类型:</span>
|
||||
<button
|
||||
type="button"
|
||||
className={`worker-hall-mobile-cat-pill ${subCategoryId === 0 ? 'active' : ''}`}
|
||||
onClick={() => setSubCategoryId(0)}
|
||||
>
|
||||
全部
|
||||
</button>
|
||||
{currentSubCategories.map((sub) => (
|
||||
<button
|
||||
key={sub.categoryId}
|
||||
type="button"
|
||||
className={`worker-hall-mobile-cat-pill ${subCategoryId === sub.categoryId ? 'active' : ''}`}
|
||||
onClick={() => setSubCategoryId(sub.categoryId)}
|
||||
>
|
||||
{sub.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
@@ -442,7 +555,9 @@ export default function WorkerHallPage() {
|
||||
) : null}
|
||||
{order.categoryName ? (
|
||||
<Tag color="blue" className="worker-hall-mobile-tag">
|
||||
{order.categoryName}
|
||||
{order.parentCategoryName
|
||||
? `${order.parentCategoryName} · ${order.categoryName}`
|
||||
: order.categoryName}
|
||||
</Tag>
|
||||
) : null}
|
||||
{order.sharing?.enabled ? (
|
||||
@@ -528,54 +643,25 @@ export default function WorkerHallPage() {
|
||||
</div>
|
||||
) : (
|
||||
<section className="page-stack">
|
||||
<div className="worker-page-head">
|
||||
<div className="worker-page-head-title-row">
|
||||
<Typography.Title level={3}>抢单大厅</Typography.Title>
|
||||
<div className="worker-hall-page-actions">
|
||||
<div className="worker-hall-head-controls">
|
||||
<Tooltip title="开启后点击抢单会先弹窗确认,防止误点">
|
||||
<span className="worker-hall-grab-confirm-toggle">
|
||||
抢单确认
|
||||
<Switch
|
||||
size="small"
|
||||
checked={grabConfirmEnabled}
|
||||
onChange={toggleGrabConfirm}
|
||||
/>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
loading={
|
||||
ordersQuery.isFetching ||
|
||||
profileQuery.isFetching ||
|
||||
hallSummaryQuery.isFetching
|
||||
}
|
||||
onClick={() => refreshAll()}
|
||||
>
|
||||
刷新
|
||||
</Button>
|
||||
</div>
|
||||
<div className="worker-hall-leaderboard-trigger">
|
||||
<Tooltip title="接单排行榜">
|
||||
<Button
|
||||
aria-label="接单排行榜"
|
||||
icon={<TrophyOutlined />}
|
||||
onClick={() => setLeaderboardOpen(true)}
|
||||
>
|
||||
接单排行榜
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
{/* 桌面端整合头部:标题 + 实时派单标签 + 居中全局搜索 + 快捷操作 */}
|
||||
<div className="worker-hall-desktop-header">
|
||||
<div className="worker-hall-header-left">
|
||||
<Typography.Title level={3} className="worker-hall-heading">
|
||||
抢单大厅
|
||||
</Typography.Title>
|
||||
<span className="worker-hall-live-badge">
|
||||
<span className="worker-hall-pulse-dot" />
|
||||
实时派单
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="worker-hall-search-bar">
|
||||
<Space.Compact className="worker-hall-search">
|
||||
<div className="worker-hall-header-center">
|
||||
<Space.Compact className="worker-hall-desktop-search">
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="搜索商品名称 / 订单号 / 游戏ID / 游戏昵称"
|
||||
prefix={<SearchOutlined />}
|
||||
prefix={<SearchOutlined style={{ color: '#94a3b8' }} />}
|
||||
onChange={(event) => {
|
||||
const nextKeyword = event.target.value
|
||||
setKeywordInput(nextKeyword)
|
||||
@@ -595,34 +681,242 @@ export default function WorkerHallPage() {
|
||||
</Button>
|
||||
</Space.Compact>
|
||||
</div>
|
||||
|
||||
<div className="worker-hall-header-right">
|
||||
<Tooltip title="开启后点击抢单会先弹窗确认,防止误触">
|
||||
<label className="worker-hall-header-switch-wrap">
|
||||
<span>抢单确认</span>
|
||||
<Switch size="small" checked={grabConfirmEnabled} onChange={toggleGrabConfirm} />
|
||||
</label>
|
||||
</Tooltip>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
loading={
|
||||
ordersQuery.isFetching || profileQuery.isFetching || hallSummaryQuery.isFetching
|
||||
}
|
||||
onClick={() => refreshAll()}
|
||||
>
|
||||
刷新
|
||||
</Button>
|
||||
<Button icon={<TrophyOutlined />} onClick={() => setLeaderboardOpen(true)}>
|
||||
接单排行榜
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 桌面端 4 栏 KPI 仪表盘 */}
|
||||
<div className="worker-hall-kpi-grid">
|
||||
{/* 卡片 1: 账户资产 */}
|
||||
<div className="worker-hall-kpi-card">
|
||||
<div className="worker-hall-kpi-top">
|
||||
<div className="worker-hall-kpi-icon-wrap kpi-wallet">
|
||||
<WalletOutlined />
|
||||
</div>
|
||||
<div className="worker-hall-kpi-info">
|
||||
<span className="worker-hall-kpi-title">可用余额</span>
|
||||
<strong className="worker-hall-kpi-val">
|
||||
{worker ? formatMoney(worker.wallet.availableAmount) : '-'}
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-hall-kpi-bottom">
|
||||
<div className="worker-hall-kpi-sub-item">
|
||||
<span className="kpi-sub-label">冻结押金:</span>
|
||||
<span className="kpi-sub-val">
|
||||
{worker ? formatMoney(worker.wallet.frozenDepositAmount) : '¥0.00'}
|
||||
</span>
|
||||
</div>
|
||||
{worker?.level?.name ? (
|
||||
<span className="worker-hall-kpi-level-badge">{worker.level.name}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 2: 接单配额 */}
|
||||
<div className="worker-hall-kpi-card">
|
||||
<div className="worker-hall-kpi-top">
|
||||
<div className="worker-hall-kpi-icon-wrap kpi-quota">
|
||||
<ThunderboltOutlined />
|
||||
</div>
|
||||
<div className="worker-hall-kpi-info">
|
||||
<span className="worker-hall-kpi-title">接单配额</span>
|
||||
<strong className="worker-hall-kpi-val">
|
||||
{remainingSlots === null ? '未限制' : `${activeCount} / ${maxActiveOrders}`}
|
||||
<span className="worker-hall-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-hall-kpi-bottom">
|
||||
<div className="worker-hall-kpi-progress-track">
|
||||
<div
|
||||
className={`worker-hall-kpi-progress-bar ${
|
||||
quotaPercent > 85 ? 'danger' : quotaPercent > 60 ? 'warning' : 'safe'
|
||||
}`}
|
||||
style={{ width: `${quotaPercent}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="worker-hall-kpi-sub-text">
|
||||
{remainingSlots === null
|
||||
? '等级未限'
|
||||
: remainingSlots > 0
|
||||
? `还可接 ${remainingSlots} 单`
|
||||
: '已达上限'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 3: 进行中任务 */}
|
||||
<div className="worker-hall-kpi-card">
|
||||
<div className="worker-hall-kpi-top">
|
||||
<div className="worker-hall-kpi-icon-wrap kpi-tasks">
|
||||
<ClockCircleOutlined />
|
||||
</div>
|
||||
<div className="worker-hall-kpi-info">
|
||||
<span className="worker-hall-kpi-title">进行中任务</span>
|
||||
<strong className="worker-hall-kpi-val">
|
||||
{activeCount}
|
||||
<span className="worker-hall-kpi-unit"> 单代练中</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-hall-kpi-bottom">
|
||||
<div className="worker-hall-kpi-stat-tags">
|
||||
<span className="worker-hall-kpi-tag blue">待验收 {pendingAcceptanceCount}</span>
|
||||
<span className={`worker-hall-kpi-tag ${problemCount > 0 ? 'red' : 'neutral'}`}>
|
||||
问题单 {problemCount}
|
||||
</span>
|
||||
</div>
|
||||
<Link to="/orders" className="worker-hall-kpi-link">
|
||||
工单管理 <ArrowRightOutlined style={{ fontSize: 10 }} />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 4: 实时订单池 */}
|
||||
<div className="worker-hall-kpi-card">
|
||||
<div className="worker-hall-kpi-top">
|
||||
<div className="worker-hall-kpi-icon-wrap kpi-pool">
|
||||
<FireOutlined />
|
||||
</div>
|
||||
<div className="worker-hall-kpi-info">
|
||||
<span className="worker-hall-kpi-title">大厅可抢订单</span>
|
||||
<strong className="worker-hall-kpi-val">
|
||||
{totalHallOrders}
|
||||
<span className="worker-hall-kpi-unit"> 单在池</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-hall-kpi-bottom">
|
||||
<span className="worker-hall-kpi-pool-hint">
|
||||
<span className="worker-hall-kpi-dot-online" />
|
||||
极速响应 · 秒级派发
|
||||
</span>
|
||||
<span className="worker-hall-kpi-pool-sub">支持拼单</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card className="worker-hall-board-card" bordered={false}>
|
||||
<div className="worker-hall-summary-strip">
|
||||
{summaryItems.map((item) => (
|
||||
<div key={item.label} className="worker-hall-summary-item">
|
||||
<span className="worker-hall-summary-label">{item.label}</span>
|
||||
<strong className="worker-hall-summary-value">{item.value}</strong>
|
||||
<small className="worker-hall-summary-note">{item.note}</small>
|
||||
{/* 桌面端一级分类卡片与二级联动 */}
|
||||
{hasCategoryBar ? (
|
||||
<div style={{ marginBottom: 14 }}>
|
||||
<div className="worker-hall-game-cards-scroll">
|
||||
<button
|
||||
type="button"
|
||||
className={`worker-hall-game-card ${primaryCategoryId === 0 ? 'active' : ''}`}
|
||||
onClick={() => handleSelectPrimaryCategory(0)}
|
||||
>
|
||||
<div
|
||||
className="worker-hall-game-icon-box"
|
||||
style={
|
||||
primaryCategoryId === 0 && (!allIconUrl || failedImageKeys['all'])
|
||||
? { background: 'linear-gradient(135deg, #ff6a00 0%, #ff8e3c 100%)' }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{allIconUrl && !failedImageKeys['all'] ? (
|
||||
<img
|
||||
src={allIconUrl}
|
||||
alt="全部"
|
||||
className="worker-hall-game-img"
|
||||
onError={() => setFailedImageKeys((prev) => ({ ...prev, all: true }))}
|
||||
/>
|
||||
) : (
|
||||
<AppstoreOutlined
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: primaryCategoryId === 0 ? '#ffffff' : '#64748b',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<span className="worker-hall-game-title">全部</span>
|
||||
</button>
|
||||
{primaryCategories.map((category) => (
|
||||
<button
|
||||
key={category.categoryId}
|
||||
type="button"
|
||||
className={`worker-hall-game-card ${primaryCategoryId === category.categoryId ? 'active' : ''}`}
|
||||
onClick={() => handleSelectPrimaryCategory(category.categoryId)}
|
||||
>
|
||||
<div
|
||||
className="worker-hall-game-icon-box"
|
||||
style={
|
||||
!category.iconUrl || failedImageKeys[category.categoryId]
|
||||
? {
|
||||
background: getCategoryGradient(category.name, category.categoryId),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{category.iconUrl && !failedImageKeys[category.categoryId] ? (
|
||||
<img
|
||||
src={category.iconUrl}
|
||||
alt={category.name}
|
||||
className="worker-hall-game-img"
|
||||
onError={() =>
|
||||
setFailedImageKeys((prev) => ({
|
||||
...prev,
|
||||
[category.categoryId]: true,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<span className="worker-hall-game-initial">
|
||||
{category.name.slice(0, 1)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<span className="worker-hall-game-title" title={category.name}>
|
||||
{category.name}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{categories.length > 0 ? (
|
||||
<Tabs
|
||||
size="small"
|
||||
activeKey={String(categoryId)}
|
||||
items={[
|
||||
{ key: '0', label: '全部' },
|
||||
...categories.map((category) => ({
|
||||
key: String(category.categoryId),
|
||||
label: category.name,
|
||||
})),
|
||||
]}
|
||||
onChange={(nextKey) => {
|
||||
setCategoryId(Number(nextKey) || 0)
|
||||
}}
|
||||
/>
|
||||
{shouldShowSubcategories ? (
|
||||
<div className="worker-hall-subcat-bar" style={{ marginTop: 10 }}>
|
||||
<span className="worker-hall-subcat-label">业务分类:</span>
|
||||
<button
|
||||
type="button"
|
||||
className={`worker-hall-mobile-cat-pill ${subCategoryId === 0 ? 'active' : ''}`}
|
||||
onClick={() => setSubCategoryId(0)}
|
||||
>
|
||||
全部
|
||||
</button>
|
||||
{currentSubCategories.map((sub) => (
|
||||
<button
|
||||
key={sub.categoryId}
|
||||
type="button"
|
||||
className={`worker-hall-mobile-cat-pill ${subCategoryId === sub.categoryId ? 'active' : ''}`}
|
||||
onClick={() => setSubCategoryId(sub.categoryId)}
|
||||
>
|
||||
{sub.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{shouldWarn ? (
|
||||
@@ -665,33 +959,50 @@ export default function WorkerHallPage() {
|
||||
const disabledReason = resolveGrabDisabledReason(order, worker, remainingSlots)
|
||||
const productName = resolveHallProductName(order) || '未命名商品'
|
||||
const sharingRemaining = resolveSharingRemaining(order)
|
||||
const depositAmount = resolveHallDepositAmount(order)
|
||||
const rewardAmount = resolveHallRewardAmount(order)
|
||||
|
||||
return (
|
||||
<article key={order.workOrderId} className="worker-hall-card">
|
||||
<div className="worker-hall-card-title">
|
||||
{order.pinnedAt ? (
|
||||
<Tag
|
||||
color="gold"
|
||||
icon={<PushpinOutlined />}
|
||||
className="worker-hall-pinned-tag"
|
||||
>
|
||||
置顶
|
||||
<div className="worker-hall-card-header">
|
||||
<div className="worker-hall-card-tags">
|
||||
{order.pinnedAt ? (
|
||||
<Tag
|
||||
color="gold"
|
||||
icon={<PushpinOutlined />}
|
||||
className="worker-hall-pinned-tag"
|
||||
>
|
||||
置顶
|
||||
</Tag>
|
||||
) : null}
|
||||
<Tag className="worker-hall-category-tag">
|
||||
{order.parentCategoryName
|
||||
? `${order.parentCategoryName} · ${order.categoryName}`
|
||||
: order.categoryName || '默认分类'}
|
||||
</Tag>
|
||||
) : null}
|
||||
{order.sharing?.enabled ? <Tag color="purple">拼单</Tag> : null}
|
||||
{Number(order.timeoutMinutes || 0) > 0 ? (
|
||||
<Tag color="orange" icon={<ClockCircleOutlined />}>
|
||||
限时 {order.timeoutMinutes}m
|
||||
</Tag>
|
||||
) : null}
|
||||
</div>
|
||||
<span
|
||||
className="worker-hall-card-orderno"
|
||||
title={`订单号:${getDisplayOrderNo(order)}`}
|
||||
>
|
||||
{getDisplayOrderNo(order)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="worker-hall-card-body">
|
||||
<strong className="worker-hall-card-title-text" title={productName}>
|
||||
{productName}
|
||||
</strong>
|
||||
<Typography.Text type="secondary">
|
||||
{order.categoryName || '默认分类'}
|
||||
</Typography.Text>
|
||||
<Typography.Text type="secondary">
|
||||
订单号:{getDisplayOrderNo(order)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
|
||||
{order.sharing?.enabled ? (
|
||||
<div className="worker-hall-card-sharing">
|
||||
<Tag color="purple">拼单</Tag>
|
||||
<Typography.Text type="secondary">
|
||||
单价 {formatMoney(order.sharing.unitReward)} · 进度{' '}
|
||||
{order.sharingProgress?.joinedQuantity || 0}/
|
||||
@@ -700,21 +1011,24 @@ export default function WorkerHallPage() {
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{Number(order.timeoutMinutes || 0) > 0 ? (
|
||||
<div className="worker-hall-card-sharing">
|
||||
<Tag color="orange" icon={<ClockCircleOutlined />}>
|
||||
限时 {order.timeoutMinutes} 分钟
|
||||
</Tag>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="worker-hall-card-amount-row">
|
||||
<div className="worker-hall-card-amount">
|
||||
{formatMoney(resolveHallRewardAmount(order))}
|
||||
<div className="worker-hall-card-amount-group">
|
||||
<span className="worker-hall-card-amount-label">接单报酬</span>
|
||||
<div className="worker-hall-card-amount">
|
||||
{formatMoney(rewardAmount)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-hall-card-deposit-group">
|
||||
{depositAmount <= 0 ? (
|
||||
<span className="worker-hall-deposit-free-badge">
|
||||
<CheckCircleOutlined /> 免保证金
|
||||
</span>
|
||||
) : (
|
||||
<span className="worker-hall-deposit-badge">
|
||||
保证金 {formatMoney(depositAmount)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Typography.Text type="secondary" className="worker-hall-card-deposit">
|
||||
所需保证金:{formatMoney(resolveHallDepositAmount(order))}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
|
||||
{disabledReason ? (
|
||||
@@ -744,6 +1058,7 @@ export default function WorkerHallPage() {
|
||||
<Button
|
||||
type="primary"
|
||||
size="large"
|
||||
className="worker-hall-card-grab-btn"
|
||||
disabled={Boolean(disabledReason)}
|
||||
loading={grabbingId === order.workOrderId}
|
||||
onClick={() => requestGrab(order)}
|
||||
@@ -890,6 +1205,22 @@ export default function WorkerHallPage() {
|
||||
)
|
||||
}
|
||||
|
||||
function getCategoryGradient(name: string, id: number): string {
|
||||
const gradients = [
|
||||
'linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%)',
|
||||
'linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%)',
|
||||
'linear-gradient(135deg, #10b981 0%, #059669 100%)',
|
||||
'linear-gradient(135deg, #f59e0b 0%, #ea580c 100%)',
|
||||
'linear-gradient(135deg, #ec4899 0%, #f43f5e 100%)',
|
||||
'linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%)',
|
||||
'linear-gradient(135deg, #14b8a6 0%, #0d9488 100%)',
|
||||
'linear-gradient(135deg, #f97316 0%, #c2410c 100%)',
|
||||
]
|
||||
const charCode = (name && name.charCodeAt(0)) || 0
|
||||
const index = Math.abs((id * 31 + charCode) % gradients.length)
|
||||
return gradients[index]
|
||||
}
|
||||
|
||||
function resolveGrabDisabledReason(
|
||||
order: WorkOrder,
|
||||
worker: WorkerUser | undefined,
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { ReloadOutlined, SearchOutlined } from '@ant-design/icons'
|
||||
import {
|
||||
CheckCircleOutlined,
|
||||
ClockCircleOutlined,
|
||||
ReloadOutlined,
|
||||
SearchOutlined,
|
||||
ThunderboltOutlined,
|
||||
WarningOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { Button, Card, Empty, Input, Space, Table, Tabs, Typography } from 'antd'
|
||||
import type { TableColumnsType } from 'antd'
|
||||
|
||||
@@ -52,16 +59,167 @@ export function WorkerOrderDesktopList({
|
||||
onKeywordSearch: () => void
|
||||
onPageChange: (page: number, pageSize: number) => void
|
||||
}) {
|
||||
const inProgressCount = Number(overviewByStatus.get('in_progress')?.orderCount || 0)
|
||||
const inProgressSettlement = Number(overviewByStatus.get('in_progress')?.settlementAmount || 0)
|
||||
|
||||
const pendingCount = Number(overviewByStatus.get('pending_acceptance')?.orderCount || 0)
|
||||
const pendingSettlement = Number(
|
||||
overviewByStatus.get('pending_acceptance')?.settlementAmount || 0,
|
||||
)
|
||||
|
||||
const problemCount = Number(overviewByStatus.get('problem')?.orderCount || 0)
|
||||
const openCount = Number(overviewByStatus.get('open')?.orderCount || 0)
|
||||
const evidenceCount = Number(overviewByStatus.get('vip_evidence_pending')?.orderCount || 0)
|
||||
const abnormalTotal = problemCount + openCount + evidenceCount
|
||||
|
||||
const acceptedCount = Number(overviewByStatus.get('accepted')?.orderCount || 0)
|
||||
const acceptedSettlement = Number(overviewByStatus.get('accepted')?.settlementAmount || 0)
|
||||
|
||||
return (
|
||||
<section className="page-stack">
|
||||
<div className="worker-page-head">
|
||||
<Typography.Title level={3}>我的订单</Typography.Title>
|
||||
<Button icon={<ReloadOutlined />} loading={refreshing} onClick={onRefresh}>
|
||||
刷新
|
||||
</Button>
|
||||
{/* 桌面端全新整合头部 */}
|
||||
<div className="worker-orders-desktop-header">
|
||||
<div className="worker-orders-header-left">
|
||||
<Typography.Title level={3} className="worker-orders-heading">
|
||||
我的订单
|
||||
</Typography.Title>
|
||||
<span className="worker-orders-live-badge">
|
||||
<span className="worker-orders-pulse-dot" />
|
||||
在办工单实时监控
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="worker-orders-header-center">
|
||||
<Space.Compact className="worker-orders-desktop-search">
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="搜索订单号 / 商品名 / 游戏ID / 游戏昵称"
|
||||
prefix={<SearchOutlined style={{ color: '#94a3b8' }} />}
|
||||
onChange={(event) => onKeywordInputChange(event.target.value)}
|
||||
onPressEnter={onKeywordSearch}
|
||||
/>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<SearchOutlined />}
|
||||
loading={searching}
|
||||
onClick={onKeywordSearch}
|
||||
>
|
||||
搜索
|
||||
</Button>
|
||||
</Space.Compact>
|
||||
</div>
|
||||
|
||||
<div className="worker-orders-header-right">
|
||||
<Button icon={<ReloadOutlined />} loading={refreshing} onClick={onRefresh}>
|
||||
刷新
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card bordered={false}>
|
||||
{/* 4 栏工单态势 KPI 仪表盘 */}
|
||||
<div className="worker-orders-kpi-grid">
|
||||
{/* 卡片 1: 代练中 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${status === 'in_progress' ? 'active' : ''}`}
|
||||
onClick={() => onStatusChange(status === 'in_progress' ? '' : 'in_progress')}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap in-progress">
|
||||
<ThunderboltOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">代练进行中</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{inProgressCount}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">待结算预估:</span>
|
||||
<span className="worker-orders-kpi-sub-val">{formatMoney(inProgressSettlement)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 2: 待验收 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${status === 'pending_acceptance' ? 'active' : ''}`}
|
||||
onClick={() =>
|
||||
onStatusChange(status === 'pending_acceptance' ? '' : 'pending_acceptance')
|
||||
}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap pending">
|
||||
<ClockCircleOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">已提交待验收</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{pendingCount}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">待审核报酬:</span>
|
||||
<span className="worker-orders-kpi-sub-val">{formatMoney(pendingSettlement)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 3: 异常单 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${
|
||||
status === 'problem' || status === 'open' || status === 'vip_evidence_pending'
|
||||
? 'active'
|
||||
: ''
|
||||
}`}
|
||||
onClick={() => onStatusChange(status === 'problem' ? '' : 'problem')}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap problem">
|
||||
<WarningOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">异常与问题工单</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{abnormalTotal}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">
|
||||
超时 {openCount} · 补图 {evidenceCount} · 问题 {problemCount}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 卡片 4: 已验收 */}
|
||||
<div
|
||||
className={`worker-orders-kpi-card ${status === 'accepted' ? 'active' : ''}`}
|
||||
onClick={() => onStatusChange(status === 'accepted' ? '' : 'accepted')}
|
||||
>
|
||||
<div className="worker-orders-kpi-top">
|
||||
<div className="worker-orders-kpi-icon-wrap accepted">
|
||||
<CheckCircleOutlined />
|
||||
</div>
|
||||
<div className="worker-orders-kpi-info">
|
||||
<span className="worker-orders-kpi-title">已验收完结</span>
|
||||
<strong className="worker-orders-kpi-val">
|
||||
{acceptedCount}
|
||||
<span className="worker-orders-kpi-unit"> 单</span>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className="worker-orders-kpi-bottom">
|
||||
<span className="worker-orders-kpi-sub-label">已结算到账:</span>
|
||||
<span className="worker-orders-kpi-sub-val">{formatMoney(acceptedSettlement)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card bordered={false} className="worker-orders-card">
|
||||
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||
<Tabs
|
||||
className="worker-order-tabs"
|
||||
@@ -88,26 +246,13 @@ export function WorkerOrderDesktopList({
|
||||
onChange={(nextKey) => onStatusChange(nextKey === 'all' ? '' : nextKey)}
|
||||
/>
|
||||
|
||||
<Space.Compact style={{ width: '100%', maxWidth: 460 }}>
|
||||
<Input
|
||||
allowClear
|
||||
value={keywordInput}
|
||||
placeholder="搜索订单号 / 商品名 / 游戏ID / 游戏昵称"
|
||||
prefix={<SearchOutlined />}
|
||||
onChange={(event) => onKeywordInputChange(event.target.value)}
|
||||
onPressEnter={onKeywordSearch}
|
||||
/>
|
||||
<Button icon={<SearchOutlined />} loading={searching} onClick={onKeywordSearch}>
|
||||
搜索
|
||||
</Button>
|
||||
</Space.Compact>
|
||||
|
||||
<Table<WorkOrder>
|
||||
rowKey="workOrderId"
|
||||
size="small"
|
||||
size="middle"
|
||||
loading={loading}
|
||||
dataSource={orders}
|
||||
columns={columns}
|
||||
className="worker-orders-table"
|
||||
locale={{
|
||||
emptyText: error ? (
|
||||
<Empty description={error instanceof Error ? error.message : '读取我的订单失败'} />
|
||||
@@ -125,7 +270,7 @@ export function WorkerOrderDesktopList({
|
||||
total: pagination?.total || 0,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
showTotal: (total) => `共 ${total} 条`,
|
||||
showTotal: (total) => `共 ${total} 条工单`,
|
||||
onChange: onPageChange,
|
||||
}}
|
||||
scroll={{ x: 1440 }}
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import {
|
||||
BankOutlined,
|
||||
ClockCircleOutlined,
|
||||
CopyOutlined,
|
||||
CustomerServiceOutlined,
|
||||
GlobalOutlined,
|
||||
LockOutlined,
|
||||
LogoutOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
TrophyOutlined,
|
||||
UserOutlined,
|
||||
WalletOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { Avatar, Button, Card, Descriptions, Progress, Space, Tag, Tooltip, Typography } from 'antd'
|
||||
import { Button, Card, Descriptions, Progress, Space, Tag, Tooltip, Typography } from 'antd'
|
||||
|
||||
import type {
|
||||
WorkerLevelProgress,
|
||||
@@ -17,12 +20,10 @@ import type {
|
||||
WorkerWithdrawalAccount,
|
||||
} from '@/types/worker-platform'
|
||||
import { formatDateTime } from '@/utils/date-time'
|
||||
|
||||
import {
|
||||
formatMoney,
|
||||
formatWorkerStatus,
|
||||
formatWithdrawChannel,
|
||||
resolveWorkerInitial,
|
||||
formatWorkerStatus,
|
||||
resolveWorkerStatusColor,
|
||||
} from './worker-profile-view-utils'
|
||||
|
||||
@@ -35,88 +36,155 @@ export function WorkerProfileDesktopIdentity({
|
||||
worker: WorkerUser
|
||||
summary: WorkerProfileSummary | undefined
|
||||
levelProgress: WorkerLevelProgress | null | undefined
|
||||
onCopyInviteCode: () => void
|
||||
onCopyInviteCode?: () => void
|
||||
}) {
|
||||
const nextRequired =
|
||||
levelProgress && levelProgress.nextThreshold
|
||||
? Math.max(0, levelProgress.nextThreshold - (summary?.acceptedOrderCount || 0))
|
||||
: 0
|
||||
|
||||
return (
|
||||
<Card size="small">
|
||||
<Space size={16} wrap align="start">
|
||||
<Avatar size={64}>{resolveWorkerInitial(worker)}</Avatar>
|
||||
<Space direction="vertical" size={2}>
|
||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||
{worker.displayName || worker.username}
|
||||
</Typography.Title>
|
||||
<Typography.Text type="secondary">账号:{worker.username}</Typography.Text>
|
||||
<Typography.Text type="secondary">手机号:{worker.phone || '-'}</Typography.Text>
|
||||
</Space>
|
||||
<Space size={[8, 8]} wrap>
|
||||
<Tag color={resolveWorkerStatusColor(worker.status)}>
|
||||
{formatWorkerStatus(worker.status)}
|
||||
</Tag>
|
||||
<Tag color={worker.workerType === 'internal' ? 'blue' : 'default'}>
|
||||
{worker.workerType === 'internal' ? '内部打手' : '外部打手'}
|
||||
</Tag>
|
||||
<Tag>{worker.level?.name || '未分级'}</Tag>
|
||||
</Space>
|
||||
</Space>
|
||||
<Space direction="vertical" size={4} style={{ marginTop: 12, width: '100%' }}>
|
||||
<Space wrap size={[8, 8]}>
|
||||
<Typography.Text type="secondary">我的邀请码:</Typography.Text>
|
||||
<Typography.Text strong>{worker.inviteCode || '-'}</Typography.Text>
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
icon={<CopyOutlined />}
|
||||
disabled={!worker.inviteCode}
|
||||
onClick={onCopyInviteCode}
|
||||
>
|
||||
复制
|
||||
</Button>
|
||||
</Space>
|
||||
{levelProgress && levelProgress.nextThreshold !== null ? (
|
||||
<Space direction="vertical" size={0} style={{ width: '100%' }}>
|
||||
<Typography.Text type="secondary">
|
||||
已累计完成 {summary?.acceptedOrderCount || 0} 单,距下一等级还需{' '}
|
||||
{Math.max(0, levelProgress.nextThreshold - (summary?.acceptedOrderCount || 0))} 单
|
||||
</Typography.Text>
|
||||
<Progress
|
||||
percent={levelProgress.progressPercent}
|
||||
size="small"
|
||||
format={(percent) => `${percent}%`}
|
||||
/>
|
||||
</Space>
|
||||
) : (
|
||||
<Typography.Text type="secondary">
|
||||
已累计完成 {summary?.acceptedOrderCount || 0} 单,当前已是最高等级
|
||||
</Typography.Text>
|
||||
)}
|
||||
</Space>
|
||||
</Card>
|
||||
<div className="worker-profile-hero-card">
|
||||
<div className="worker-profile-hero-top">
|
||||
<div className="worker-profile-hero-user">
|
||||
<div className="worker-profile-avatar">
|
||||
{(worker.displayName || worker.username).slice(0, 1)}
|
||||
</div>
|
||||
<div className="worker-profile-user-info">
|
||||
<div className="worker-profile-name-row">
|
||||
<strong className="worker-profile-name">
|
||||
{worker.displayName || worker.username}
|
||||
</strong>
|
||||
<Tag
|
||||
color={resolveWorkerStatusColor(worker.status)}
|
||||
className="worker-profile-status-tag"
|
||||
>
|
||||
{formatWorkerStatus(worker.status)}
|
||||
</Tag>
|
||||
{worker.level?.name ? (
|
||||
<span className="worker-profile-level-badge">{worker.level.name}</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="worker-profile-meta-row">
|
||||
<span className="worker-profile-meta-item">账号: {worker.username}</span>
|
||||
<span className="worker-profile-meta-divider">·</span>
|
||||
<span className="worker-profile-meta-item">UID: {worker.workerId}</span>
|
||||
{worker.phone ? (
|
||||
<>
|
||||
<span className="worker-profile-meta-divider">·</span>
|
||||
<span className="worker-profile-meta-item">手机: {worker.phone}</span>
|
||||
</>
|
||||
) : null}
|
||||
{worker.inviteCode ? (
|
||||
<>
|
||||
<span className="worker-profile-meta-divider">·</span>
|
||||
<span className="worker-profile-meta-item">
|
||||
邀请码: <strong>{worker.inviteCode}</strong>
|
||||
{onCopyInviteCode ? (
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
icon={<CopyOutlined />}
|
||||
style={{ padding: '0 4px', height: 'auto' }}
|
||||
onClick={onCopyInviteCode}
|
||||
/>
|
||||
) : null}
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="worker-profile-privileges">
|
||||
<div className="worker-profile-priv-chip">
|
||||
<span className="priv-label">免押额度</span>
|
||||
<strong className="priv-val">{formatMoney(worker.effectiveDepositFreeAmount)}</strong>
|
||||
</div>
|
||||
<div className="worker-profile-priv-chip">
|
||||
<span className="priv-label">最大接单</span>
|
||||
<strong className="priv-val">
|
||||
{worker.level?.permissions.maxActiveOrders || 0} 单
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="worker-profile-progress-bar-wrap">
|
||||
<div className="worker-profile-progress-header">
|
||||
<span className="worker-profile-progress-title">
|
||||
已完成 <strong>{summary?.acceptedOrderCount || 0}</strong> 单
|
||||
</span>
|
||||
{levelProgress && levelProgress.nextThreshold ? (
|
||||
<span className="worker-profile-progress-sub">距下一级还需 {nextRequired} 单</span>
|
||||
) : (
|
||||
<span className="worker-profile-progress-sub">当前已是最高等级</span>
|
||||
)}
|
||||
</div>
|
||||
<Progress
|
||||
percent={levelProgress ? levelProgress.progressPercent : 100}
|
||||
strokeColor={{ '0%': '#ff6a00', '100%': '#ff944d' }}
|
||||
size={['100%', 8]}
|
||||
showInfo={false}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function WorkerProfileDesktopWallet({ worker }: { worker: WorkerUser }) {
|
||||
const items = [
|
||||
['可用余额', worker.wallet.availableAmount, '可用于抢单冻结或提现申请'],
|
||||
['冻结押金', worker.wallet.frozenDepositAmount, '抢单后冻结,验收后进入待解冻'],
|
||||
[
|
||||
'待解冻金额',
|
||||
worker.wallet.pendingUnfreezeAmount,
|
||||
'验收报酬与押金按配置天数解冻到账,期间不可提现',
|
||||
],
|
||||
['累计结算', worker.wallet.totalSettledAmount, '已结算入账的报酬合计'],
|
||||
] as const
|
||||
{
|
||||
key: 'available',
|
||||
label: '可用余额',
|
||||
amount: worker.wallet.availableAmount,
|
||||
note: '可用于抢单冻结与提现',
|
||||
icon: <WalletOutlined />,
|
||||
cls: 'kpi-wallet',
|
||||
},
|
||||
{
|
||||
key: 'frozen',
|
||||
label: '冻结押金',
|
||||
amount: worker.wallet.frozenDepositAmount,
|
||||
note: '抢单后暂扣,验收后解冻',
|
||||
icon: <SafetyCertificateOutlined />,
|
||||
cls: 'kpi-quota',
|
||||
},
|
||||
{
|
||||
key: 'pending',
|
||||
label: '待解冻金额',
|
||||
amount: worker.wallet.pendingUnfreezeAmount,
|
||||
note: '按配置天数释放到可用余额',
|
||||
icon: <ClockCircleOutlined />,
|
||||
cls: 'kpi-tasks',
|
||||
},
|
||||
{
|
||||
key: 'settled',
|
||||
label: '累计结算收益',
|
||||
amount: worker.wallet.totalSettledAmount,
|
||||
note: '已结算入账的报酬合计',
|
||||
icon: <TrophyOutlined />,
|
||||
cls: 'kpi-pool',
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<Card size="small" className="worker-profile-wallet-card">
|
||||
<div className="worker-profile-wallet-strip">
|
||||
{items.map(([label, amount, note]) => (
|
||||
<div key={label} className="worker-profile-wallet-item">
|
||||
<span className="worker-profile-wallet-label">{label}</span>
|
||||
<strong className="worker-profile-wallet-value">{formatMoney(amount)}</strong>
|
||||
<small className="worker-profile-wallet-note">{note}</small>
|
||||
<div className="worker-profile-wallet-grid">
|
||||
{items.map((item) => (
|
||||
<div key={item.key} className="worker-profile-wallet-kpi-card">
|
||||
<div className="worker-profile-kpi-top">
|
||||
<div className={`worker-profile-kpi-icon ${item.cls}`}>{item.icon}</div>
|
||||
<div className="worker-profile-kpi-info">
|
||||
<span className="worker-profile-kpi-label">{item.label}</span>
|
||||
<strong className="worker-profile-kpi-val">{formatMoney(item.amount)}</strong>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
<div className="worker-profile-kpi-bottom">
|
||||
<span className="worker-profile-kpi-note">{item.note}</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -152,60 +220,77 @@ export function WorkerProfileDesktopActions({
|
||||
onLogout: () => void
|
||||
}) {
|
||||
return (
|
||||
<Card title="快捷操作" size="small">
|
||||
<Space wrap size={[12, 12]}>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<WalletOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onRecharge}
|
||||
>
|
||||
充值申请
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<BankOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onWithdraw}
|
||||
>
|
||||
提现申请
|
||||
</Button>
|
||||
{canAddWithdrawalAccount ? (
|
||||
<Button
|
||||
icon={<BankOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onAddWithdrawalAccount}
|
||||
>
|
||||
添加提现信息
|
||||
</Button>
|
||||
) : null}
|
||||
{needsAlipayQrCode ? (
|
||||
<Button
|
||||
icon={<BankOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onAddAlipayQrCode}
|
||||
>
|
||||
补充支付宝收款码
|
||||
</Button>
|
||||
) : null}
|
||||
<Tooltip title={renameHint}>
|
||||
<Button icon={<UserOutlined />} disabled={renameDisabled} onClick={onRename}>
|
||||
修改昵称
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Button icon={<LockOutlined />} onClick={onChangePassword}>
|
||||
修改密码
|
||||
</Button>
|
||||
<Button icon={<GlobalOutlined />} onClick={onManageDevices}>
|
||||
登录设备
|
||||
</Button>
|
||||
<Button icon={<CustomerServiceOutlined />} onClick={onContact}>
|
||||
联系管理员
|
||||
</Button>
|
||||
<Button danger icon={<LogoutOutlined />} onClick={onLogout}>
|
||||
退出登录
|
||||
</Button>
|
||||
</Space>
|
||||
<Card title="快捷操作与服务" size="small" className="worker-profile-actions-card">
|
||||
<div className="worker-profile-actions-grouped">
|
||||
<div className="worker-profile-actions-group">
|
||||
<span className="worker-profile-group-title">资金管理</span>
|
||||
<Space wrap size={[10, 10]}>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<WalletOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onRecharge}
|
||||
>
|
||||
充值申请
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<BankOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onWithdraw}
|
||||
>
|
||||
提现申请
|
||||
</Button>
|
||||
{canAddWithdrawalAccount ? (
|
||||
<Button
|
||||
icon={<BankOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onAddWithdrawalAccount}
|
||||
>
|
||||
添加提现信息
|
||||
</Button>
|
||||
) : null}
|
||||
{needsAlipayQrCode ? (
|
||||
<Button
|
||||
icon={<BankOutlined />}
|
||||
disabled={!canUseFinanceActions}
|
||||
onClick={onAddAlipayQrCode}
|
||||
>
|
||||
补充支付宝收款码
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<div className="worker-profile-actions-group">
|
||||
<span className="worker-profile-group-title">安全与设置</span>
|
||||
<Space wrap size={[10, 10]}>
|
||||
<Tooltip title={renameHint}>
|
||||
<Button icon={<UserOutlined />} disabled={renameDisabled} onClick={onRename}>
|
||||
修改昵称
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Button icon={<LockOutlined />} onClick={onChangePassword}>
|
||||
修改密码
|
||||
</Button>
|
||||
<Button icon={<GlobalOutlined />} onClick={onManageDevices}>
|
||||
登录设备
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
<div className="worker-profile-actions-group">
|
||||
<span className="worker-profile-group-title">其他服务</span>
|
||||
<Space wrap size={[10, 10]}>
|
||||
<Button icon={<CustomerServiceOutlined />} onClick={onContact}>
|
||||
联系客服
|
||||
</Button>
|
||||
<Button danger icon={<LogoutOutlined />} onClick={onLogout}>
|
||||
退出登录
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
@@ -226,7 +311,7 @@ export function WorkerProfileDesktopAccountDetails({
|
||||
onAddWithdrawalAccount: () => void
|
||||
}) {
|
||||
return (
|
||||
<Card size="small">
|
||||
<Card size="small" className="worker-profile-details-card">
|
||||
<Descriptions column={{ xs: 1, md: 2 }} bordered size="small">
|
||||
<Descriptions.Item label="账号">{worker.username}</Descriptions.Item>
|
||||
<Descriptions.Item label="昵称">{worker.displayName || '-'}</Descriptions.Item>
|
||||
@@ -260,17 +345,16 @@ export function WorkerProfileDesktopAccountDetails({
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="提现信息" span={2}>
|
||||
{withdrawalAccounts.length > 0 ? (
|
||||
<Space direction="vertical" size={2}>
|
||||
<Space direction="vertical" size={4}>
|
||||
{withdrawalAccounts.map((account) => (
|
||||
<Space key={account.accountChannel} wrap size={4}>
|
||||
<Typography.Text>{formatWithdrawChannel(account.accountChannel)}</Typography.Text>
|
||||
<Typography.Text>{account.accountName}</Typography.Text>
|
||||
<Space key={account.accountChannel} wrap size={6}>
|
||||
<Tag color="blue">{formatWithdrawChannel(account.accountChannel)}</Tag>
|
||||
<Typography.Text strong>{account.accountName}</Typography.Text>
|
||||
<Typography.Text type="secondary">
|
||||
{account.accountChannel === 'wechat'
|
||||
? '已上传收款二维码'
|
||||
: `${account.accountNoMasked} / ${account.alipayQrCodeImage ? '已上传收款二维码' : '未上传收款二维码'}`}
|
||||
? '已上传收款码'
|
||||
: `${account.accountNoMasked} / ${account.alipayQrCodeImage ? '已上传收款码' : '未上传收款码'}`}
|
||||
</Typography.Text>
|
||||
<Typography.Text type="secondary">收款人姓名和账号已锁定</Typography.Text>
|
||||
</Space>
|
||||
))}
|
||||
</Space>
|
||||
|
||||
@@ -87,7 +87,10 @@ export function fetchAdminWorkerHallConfig() {
|
||||
}
|
||||
|
||||
export function saveAdminWorkerHallConfig(
|
||||
payload: Pick<WorkerHallConfig, 'maxVisibleOrders' | 'categoryMaxVisibleOrders'>,
|
||||
payload: Pick<
|
||||
WorkerHallConfig,
|
||||
'maxVisibleOrders' | 'showSubcategories' | 'categoryMaxVisibleOrders' | 'allIconUrl'
|
||||
>,
|
||||
) {
|
||||
return apiPost<WorkerHallConfig>('/api/v1/admin/worker-platform/hall-config', payload)
|
||||
}
|
||||
@@ -146,6 +149,8 @@ export function fetchAdminWorkCategories() {
|
||||
export function saveAdminWorkCategory(payload: {
|
||||
categoryKey: string
|
||||
name: string
|
||||
parentId?: number | null
|
||||
iconUrl?: string | null
|
||||
sortOrder?: number
|
||||
status?: string
|
||||
}) {
|
||||
|
||||
+1960
-67
File diff suppressed because it is too large
Load Diff
@@ -303,6 +303,8 @@ export type WorkerAnnouncementConfig = {
|
||||
|
||||
export type WorkerHallConfig = {
|
||||
maxVisibleOrders: number
|
||||
showSubcategories?: boolean
|
||||
allIconUrl?: string | null
|
||||
categoryMaxVisibleOrders: Record<string, number>
|
||||
visibleOrderCount: number
|
||||
queuedOrderCount: number
|
||||
@@ -356,10 +358,14 @@ export type WorkCategory = {
|
||||
categoryId: number
|
||||
categoryKey: string
|
||||
name: string
|
||||
parentId?: number | null
|
||||
parentName?: string | null
|
||||
iconUrl?: string | null
|
||||
sortOrder: number
|
||||
status: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
children?: WorkCategory[]
|
||||
}
|
||||
|
||||
export type WorkProductRule = {
|
||||
@@ -553,6 +559,8 @@ export type WorkOrder = {
|
||||
productName: string
|
||||
categoryId?: number | null
|
||||
categoryName: string
|
||||
parentCategoryId?: number | null
|
||||
parentCategoryName?: string
|
||||
status: WorkOrderStatus
|
||||
rawStatus?: WorkOrderStatus
|
||||
hallAvailable?: boolean
|
||||
@@ -710,6 +718,8 @@ export type WorkerHallOrdersResponse = {
|
||||
items: WorkOrder[]
|
||||
pagination: Pagination
|
||||
categories: WorkCategory[]
|
||||
showSubcategories?: boolean
|
||||
allIconUrl?: string | null
|
||||
visibleDelaySeconds?: number
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ const IMAGE_UPLOAD_QUALITY: Record<string, number> = {
|
||||
}
|
||||
|
||||
export async function optimizeImageForUpload(file: File, scene: string) {
|
||||
// 分类图标与大厅图标属于透明或矢量UI素材,必须保留原始格式与透明通道,不进行有损压缩与白底填充
|
||||
if (['category_icon', 'hall_icon'].includes(scene)) {
|
||||
return file
|
||||
}
|
||||
|
||||
if (!file.type.startsWith('image/')) return file
|
||||
if (!['image/jpeg', 'image/png', 'image/webp'].includes(file.type)) return file
|
||||
if (typeof document === 'undefined') return file
|
||||
@@ -26,8 +31,13 @@ export async function optimizeImageForUpload(file: File, scene: string) {
|
||||
canvas.height = height
|
||||
const context = canvas.getContext('2d')
|
||||
if (!context) return file
|
||||
context.fillStyle = '#ffffff'
|
||||
context.fillRect(0, 0, width, height)
|
||||
|
||||
// 仅在原图为 JPEG 且不支持透明度时才填充白底;PNG 与 WebP 必须保留透明通道
|
||||
if (file.type === 'image/jpeg') {
|
||||
context.fillStyle = '#ffffff'
|
||||
context.fillRect(0, 0, width, height)
|
||||
}
|
||||
|
||||
context.drawImage(image, 0, 0, width, height)
|
||||
const blob = await canvasToBlob(canvas, 'image/webp', quality)
|
||||
if (!blob || blob.size >= file.size) return file
|
||||
|
||||
Reference in New Issue
Block a user