优化订单列表ui, 增加任务关闭
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
getAdminTaskDetail,
|
getAdminTaskDetail,
|
||||||
getAdminTasks,
|
getAdminTasks,
|
||||||
} from "../../services/admin/admin-read-service.js";
|
} from "../../services/admin/admin-read-service.js";
|
||||||
|
import { closeAdminTask } from "../../services/admin/write/task-actions.js";
|
||||||
import {
|
import {
|
||||||
dispatchAdminTaskKuaishouCloudFulfillment,
|
dispatchAdminTaskKuaishouCloudFulfillment,
|
||||||
prepareAdminTaskKuaishouCloudFulfillment,
|
prepareAdminTaskKuaishouCloudFulfillment,
|
||||||
@@ -53,6 +54,20 @@ router.get(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/tasks/:taskId/close",
|
||||||
|
requireAdminRoles(["admin", "operator", "support"]),
|
||||||
|
createJsonHandler(
|
||||||
|
(req) => closeAdminTask(getTaskId(req), req.adminSession || null),
|
||||||
|
{
|
||||||
|
successMessage: "任务已关闭",
|
||||||
|
errorMessage: "关闭任务失败",
|
||||||
|
scope: "[admin/tasks/:taskId/close]",
|
||||||
|
audit: (req, data) => buildTaskAudit("task_closed", req, data),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/tasks/:taskId/kuaishou-cloud/prepare",
|
"/tasks/:taskId/kuaishou-cloud/prepare",
|
||||||
requireAdminRoles(["admin", "operator"]),
|
requireAdminRoles(["admin", "operator"]),
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { updateClaimToken } from '../../../repositories/claim-token-repo.js'
|
||||||
|
import { updateTask } from '../../../repositories/task-repo.js'
|
||||||
|
import { createTaskEvent } from '../../../repositories/task-event-repo.js'
|
||||||
|
import { createHttpError } from '../../../utils/http.js'
|
||||||
|
import { nowIso } from '../../../utils/time.js'
|
||||||
|
import {
|
||||||
|
canViewerCloseTask,
|
||||||
|
createAdminViewerContext,
|
||||||
|
} from '../admin-read-shared-helpers.js'
|
||||||
|
import {
|
||||||
|
getRequiredTask,
|
||||||
|
mapTaskActionPayload,
|
||||||
|
} from '../admin-task-read-helpers.js'
|
||||||
|
|
||||||
|
import type {
|
||||||
|
AdminEntityIdInput,
|
||||||
|
AdminViewerSessionInput,
|
||||||
|
} from '../../../types/admin/read-inputs.js'
|
||||||
|
import type { AdminTaskActionResponse } from '../../../types/admin/write-models.js'
|
||||||
|
|
||||||
|
export async function closeAdminTask(
|
||||||
|
taskId: AdminEntityIdInput,
|
||||||
|
session: AdminViewerSessionInput | null = null,
|
||||||
|
): Promise<AdminTaskActionResponse> {
|
||||||
|
const task = await getRequiredTask(taskId)
|
||||||
|
const viewerContext = createAdminViewerContext(session)
|
||||||
|
|
||||||
|
if (!canViewerCloseTask(task, viewerContext)) {
|
||||||
|
throw createHttpError('当前任务不可关闭', {
|
||||||
|
statusCode: 409,
|
||||||
|
errorCode: 'admin_task_close_not_allowed',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = nowIso()
|
||||||
|
const claimTokenId = Number(task.primary_claim_token_id || 0)
|
||||||
|
|
||||||
|
if (claimTokenId > 0 && String(task.primary_claim_token_status || '').trim() !== 'closed') {
|
||||||
|
await updateClaimToken(claimTokenId, {
|
||||||
|
status: 'closed',
|
||||||
|
expired_at: now,
|
||||||
|
updated_at: now,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedTask = await updateTask(task.id, {
|
||||||
|
task_status: 'closed',
|
||||||
|
delivery_status: 'closed',
|
||||||
|
result_code: 'closed_by_admin',
|
||||||
|
result_message: '任务已关闭,领取链接已失效',
|
||||||
|
user_action_status: 'closed',
|
||||||
|
last_error: '',
|
||||||
|
claim_expires_at: now,
|
||||||
|
updated_at: now,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!updatedTask) {
|
||||||
|
throw createHttpError('任务关闭失败', {
|
||||||
|
statusCode: 500,
|
||||||
|
errorCode: 'admin_task_close_failed',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
await createTaskEvent(task.id, 'task_closed', {
|
||||||
|
closedBy: session
|
||||||
|
? {
|
||||||
|
userId: session.userId,
|
||||||
|
username: session.username,
|
||||||
|
role: session.role,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
claimTokenClosed: claimTokenId > 0,
|
||||||
|
}, now)
|
||||||
|
|
||||||
|
return {
|
||||||
|
task: mapTaskActionPayload(updatedTask),
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 329 KiB |
@@ -84,11 +84,6 @@ function resolveItemSummary(item: AdminOrderListItem) {
|
|||||||
return item.itemSummary || "未识别商品";
|
return item.itemSummary || "未识别商品";
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveBindingTone(completedCount: number, totalCount: number) {
|
|
||||||
if (completedCount <= 0) return "warning";
|
|
||||||
return completedCount === totalCount ? "success" : "primary";
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveBindingSummary(item: AdminOrderListItem) {
|
function resolveBindingSummary(item: AdminOrderListItem) {
|
||||||
return `共 ${item.totalBindingCount} 条 · 预占 ${item.reservedBindingCount} · 已消耗 ${item.consumedBindingCount} · 已释放 ${item.releasedBindingCount}`;
|
return `共 ${item.totalBindingCount} 条 · 预占 ${item.reservedBindingCount} · 已消耗 ${item.consumedBindingCount} · 已释放 ${item.releasedBindingCount}`;
|
||||||
}
|
}
|
||||||
@@ -297,53 +292,31 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="交付状态" min-width="230">
|
<el-table-column label="交付状态" min-width="260">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div class="delivery-status-panel">
|
<div class="delivery-status-panel">
|
||||||
<div class="delivery-status-grid">
|
|
||||||
<div class="status-line">
|
|
||||||
<span class="status-label">系统</span>
|
|
||||||
<AdminStatusTag
|
|
||||||
:status="row.systemBindingStatus"
|
|
||||||
:show-raw="false"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="status-line">
|
|
||||||
<span class="status-label">完整</span>
|
|
||||||
<AdminStatusTag
|
|
||||||
:status="row.userBindingStatus"
|
|
||||||
:show-raw="false"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span
|
<span
|
||||||
class="follow-up-chip"
|
class="follow-up-chip"
|
||||||
:data-tone="resolveFollowUpTone(row)"
|
:data-tone="resolveFollowUpTone(row)"
|
||||||
>{{ resolveFollowUpText(row) }}</span
|
>{{ resolveFollowUpText(row) }}</span
|
||||||
>
|
>
|
||||||
<div class="progress-row-stack">
|
<div class="delivery-track-list">
|
||||||
<span
|
<div class="delivery-track">
|
||||||
class="progress-chip"
|
<span class="delivery-track-label">完整绑定</span>
|
||||||
:data-tone="
|
<strong>{{ row.completedBindingTaskCount }}/{{ row.taskCount }}</strong>
|
||||||
resolveBindingTone(
|
<AdminStatusTag
|
||||||
row.completedBindingTaskCount,
|
:status="row.userBindingStatus"
|
||||||
row.taskCount
|
:show-raw="false"
|
||||||
)
|
/>
|
||||||
"
|
</div>
|
||||||
>
|
<div class="delivery-track">
|
||||||
完整 <strong>{{ row.completedBindingTaskCount }}/{{ row.taskCount }}</strong>
|
<span class="delivery-track-label">系统绑定</span>
|
||||||
</span>
|
<strong>{{ row.systemBoundTaskCount }}/{{ row.taskCount }}</strong>
|
||||||
<span
|
<AdminStatusTag
|
||||||
class="progress-chip"
|
:status="row.systemBindingStatus"
|
||||||
:data-tone="
|
:show-raw="false"
|
||||||
resolveBindingTone(
|
/>
|
||||||
row.systemBoundTaskCount,
|
</div>
|
||||||
row.taskCount
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
系统 <strong>{{ row.systemBoundTaskCount }}/{{ row.taskCount }}</strong>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -438,12 +411,6 @@ onMounted(() => {
|
|||||||
align-content: start;
|
align-content: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
.delivery-status-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, minmax(112px, 1fr));
|
|
||||||
gap: var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-line {
|
.status-line {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 34px minmax(0, 1fr);
|
grid-template-columns: 34px minmax(0, 1fr);
|
||||||
@@ -483,54 +450,70 @@ onMounted(() => {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-row-stack {
|
.delivery-track-list {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, minmax(112px, 1fr));
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delivery-track {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 64px 42px minmax(0, 1fr);
|
||||||
gap: var(--space-2);
|
gap: var(--space-2);
|
||||||
margin-top: 2px;
|
align-items: center;
|
||||||
|
min-height: 28px;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 3px 6px;
|
||||||
|
border: 1px solid var(--border-default);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: var(--bg-subtle);
|
||||||
|
}
|
||||||
|
|
||||||
|
.delivery-track-label {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
font-weight: 700;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delivery-track strong {
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
font-weight: 800;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delivery-track :deep(.el-tag),
|
||||||
|
.delivery-track :deep(.el-tag__content) {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delivery-track :deep(.el-tag) {
|
||||||
|
justify-content: center;
|
||||||
|
background: var(--bg-card);
|
||||||
|
}
|
||||||
|
|
||||||
|
.delivery-track :deep(.el-tag__content) {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-align: center;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-chip,
|
|
||||||
.follow-up-chip {
|
.follow-up-chip {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-height: 26px;
|
width: 100%;
|
||||||
|
min-height: 30px;
|
||||||
padding: 0 9px;
|
padding: 0 9px;
|
||||||
border-radius: var(--radius-full);
|
border-radius: var(--radius-sm);
|
||||||
font-size: var(--text-xs);
|
font-size: var(--text-xs);
|
||||||
font-weight: 700;
|
font-weight: 800;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-chip {
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.follow-up-chip {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-chip strong {
|
|
||||||
color: inherit;
|
|
||||||
font-weight: 800;
|
|
||||||
}
|
|
||||||
.progress-chip[data-tone="success"] {
|
|
||||||
color: #0f766e;
|
|
||||||
background: var(--color-success-light);
|
|
||||||
border-color: #a6f4c5;
|
|
||||||
}
|
|
||||||
.progress-chip[data-tone="primary"] {
|
|
||||||
color: var(--color-primary-dark);
|
|
||||||
background: var(--color-primary-light);
|
|
||||||
border-color: #b2ddff;
|
|
||||||
}
|
|
||||||
.progress-chip[data-tone="warning"] {
|
|
||||||
color: #b54708;
|
|
||||||
background: var(--color-warning-light);
|
|
||||||
border-color: #fedf89;
|
|
||||||
}
|
|
||||||
.follow-up-chip[data-tone="success"] {
|
.follow-up-chip[data-tone="success"] {
|
||||||
color: #0f766e;
|
color: #0f766e;
|
||||||
background: var(--color-success-light);
|
background: var(--color-success-light);
|
||||||
|
|||||||
Reference in New Issue
Block a user