Merge branch 'dev' into snow
# Conflicts: # backend/app/api/chat.py # backend/app/services/admin/permission_service.py # frontend/src/features/user/views/UserProfilePage.vue
This commit is contained in:
commit
5faf86b184
691 files changed
+55948
-17728
No files matched your search
@@ -4,6 +4,7 @@
|
||||
* 依赖:useChat* composables、shipping(含 openShippingCustomerDialog)、chat.api。
|
||||
* 逻辑:ChatView provide(CHAT_PAGE_KEY);子树经 inject 打开客户确认等叠层。
|
||||
* 兼容:同时编排采购合同审查与货代客户确认能力。
|
||||
* 货代发送禁用态经 hasBlockingNoticeIntake / isOrderExtractionSubmitting 注入 createChatPageSendApi。
|
||||
*/
|
||||
import { computed, markRaw, nextTick, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -446,6 +447,8 @@ export function useChatPage() {
|
||||
tryHandleProcurementContractSend: procurement.tryHandleProcurementContractSend,
|
||||
refreshToolRunProgressAfterSend: toolRun.refreshToolRunProgressAfterSend,
|
||||
prepareToolRunProgressBeforeSend: toolRun.prepareToolRunProgressBeforeSend,
|
||||
hasBlockingNoticeIntake: shipping.hasBlockingNoticeIntake,
|
||||
isOrderExtractionSubmitting: shipping.isOrderExtractionSubmitting,
|
||||
msg,
|
||||
t,
|
||||
copiedIndex,
|
||||
@@ -593,6 +596,7 @@ export function useChatPage() {
|
||||
messageBubbleHandlers: markdown.messageBubbleHandlers,
|
||||
shouldRenderMessage: markdown.shouldRenderMessage,
|
||||
canSendMessage: sendApi.canSendMessage,
|
||||
isOrderExtractionSubmitting: shipping.isOrderExtractionSubmitting,
|
||||
handleSend: sendApi.handleSend,
|
||||
stopActiveGeneration,
|
||||
pushLocalAssistantMessage,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* 逻辑:上游由 ChatView/ChatPage 调用本 composable;本文件维护会话任务摘要 + ui_state 同步,
|
||||
* 以及 focusedConversationTaskNo(提交追加优先级 / 侧栏焦点)。会话恢复唯一使用 task_no;
|
||||
* 批次进度由 shipping-processing projection 承接,不维护已下线 shipping_batches 的本地快照。
|
||||
* 对外暴露 isOrderExtractionSubmitting / hasBlockingNoticeIntake,供发送禁用与输入区 loading。
|
||||
*/
|
||||
|
||||
import {
|
||||
@@ -979,6 +980,8 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
cancelOrderExtractionUnit: shippingOrderExtractionRuns.cancelUnit,
|
||||
reparseOrderExtractionRun: shippingOrderExtractionRuns.reparseRun,
|
||||
getActiveOrderExtractionRunNo: shippingOrderExtractionRuns.getActiveRunNo,
|
||||
isOrderExtractionSubmitting: shippingOrderExtractionRuns.isOrderExtractionSubmitting,
|
||||
hasBlockingNoticeIntake: () => shippingIntakes.hasBlockingUploadOrParse.value,
|
||||
workflowRefreshTrigger,
|
||||
bumpWorkflowRefresh,
|
||||
focusedConversationTaskNo,
|
||||
|
||||
@@ -31,7 +31,7 @@ const summary = {
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 2, not_matured_count: 0, prechecked_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_erp_write_count: 2,
|
||||
estimated_external_write_count: 2,
|
||||
precheck_hash: 'sha256:abc',
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('useChatTransfer', () => {
|
||||
api.getTransferRun.mockResolvedValue({
|
||||
run_no: 'RUN-20260806-1',
|
||||
status: 'success',
|
||||
result: { erp_documents: [], exceptions: [] },
|
||||
result: { external_documents: [], exceptions: [] },
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import type {
|
||||
TransferRunResult,
|
||||
TransferSourceOption,
|
||||
TransferSourceProgress,
|
||||
TransferType,
|
||||
} from '../types/transfer.types';
|
||||
|
||||
export function useChatTransfer() {
|
||||
@@ -59,12 +60,23 @@ export function useChatTransfer() {
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
const estimatedQuantity = computed(() => precheck.value?.estimated_transfer_quantity ?? '0');
|
||||
|
||||
/** 创建预检(缺文件时来源级阶段展示等待/失败) */
|
||||
async function createPrecheck(sourceCodes: string[], businessDate?: string) {
|
||||
/** 创建预检(缺文件时来源级阶段展示等待/失败);transferType 决定收料数据范围,缺省在途仓至HUB仓 */
|
||||
async function createPrecheck(
|
||||
sourceCodes: string[],
|
||||
businessDate?: string,
|
||||
dateRange?: { from?: string; to?: string },
|
||||
transferType?: TransferType,
|
||||
) {
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const summary = await createTransferPrecheck({ source_codes: sourceCodes, business_date: businessDate });
|
||||
const summary = await createTransferPrecheck({
|
||||
source_codes: sourceCodes,
|
||||
business_date: businessDate,
|
||||
receipt_date_from: dateRange?.from,
|
||||
receipt_date_to: dateRange?.to,
|
||||
transfer_type: transferType,
|
||||
});
|
||||
precheckId.value = summary.precheck_id;
|
||||
await refreshPrecheck();
|
||||
return summary;
|
||||
@@ -165,7 +177,7 @@ export function useChatTransfer() {
|
||||
async function downloadErpInventory() {
|
||||
if (!runNo.value) return null;
|
||||
const result = await downloadTransferErpInventory(runNo.value);
|
||||
saveBlob(result.blob, result.filename ?? `erp-inventory-${runNo.value}.csv`);
|
||||
saveBlob(result.blob, result.filename ?? `external-inventory-${runNo.value}.csv`);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
exportTrainingRecords,
|
||||
exportLeanTrainingDashboard,
|
||||
getMyTrainingConfig,
|
||||
getMyTrainingProgress,
|
||||
getMyTrainingTypes,
|
||||
@@ -82,9 +83,26 @@ export interface UseTrainingWorkspaceOptions {
|
||||
|
||||
const DEFAULT_PASS_SCORE = 90;
|
||||
const DEFAULT_TRAINING_VERSION = 'v1.0';
|
||||
const OVERSEAS_REGULATIONS_TRAINING_TYPES = new Set([
|
||||
'overseas_regulations',
|
||||
'overseas_regulations_training',
|
||||
'overseas_training',
|
||||
]);
|
||||
|
||||
const formatDate = (value: Date) => value.toISOString().slice(0, 10);
|
||||
|
||||
/**
|
||||
* 将当前时刻格式化为北京时间(UTC+8)ISO 字符串,如 2026-09-22T18:47:33+08:00。
|
||||
* 用途:精益培训"已观看"的本地即时回显必须与服务端展示口径(北京时间)一致;
|
||||
* 此前用 toISOString()(UTC)回显,观看后立刻显示的时间比实际早 8 小时。
|
||||
* 业务约束:带 +08:00 偏移,后端 save_completion 兜底入库前会归一为 UTC 存储。
|
||||
*/
|
||||
const formatBeijingIso = (value: Date) => {
|
||||
const beijing = new Date(value.getTime() + (8 * 60 + value.getTimezoneOffset()) * 60000);
|
||||
const pad = (num: number) => String(num).padStart(2, '0');
|
||||
return `${beijing.getFullYear()}-${pad(beijing.getMonth() + 1)}-${pad(beijing.getDate())}T${pad(beijing.getHours())}:${pad(beijing.getMinutes())}:${pad(beijing.getSeconds())}+08:00`;
|
||||
};
|
||||
|
||||
/**
|
||||
* 按百分制计算当前答题得分。
|
||||
* AI 触发时机:当题库题量改为后台可配置后,不能再假定“每题固定 5 分”,因此每次答题都要按当前题量重新折算分数。
|
||||
@@ -125,6 +143,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
/** 管理端精益看板当前选中的期次任务 ID;为空表示最新一期,切换后重新拉取对应期看板。 */
|
||||
const leanDashboardTaskId = ref<number | null>(null);
|
||||
const leanReminderLoading = ref<Record<number, boolean>>({});
|
||||
const leanExportLoading = ref(false);
|
||||
/** 按任务 ID 分组的感悟草稿,支持时间树上多期任务并行编辑。 */
|
||||
const leanSummaryByTask = ref<Record<number, string>>({});
|
||||
/** 按任务 ID 分组的观看记录(资源 ID -> 观看时间),提交时随感悟一并交由服务端校验。 */
|
||||
@@ -136,6 +155,10 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
{ code: 'onboarding', name: t('chat.training.safety.tabs.onboarding') },
|
||||
{ code: 'safety', name: t('chat.training.safety.tabs.safety') },
|
||||
]);
|
||||
const isOverseasRegulationsTraining = computed(() => (
|
||||
OVERSEAS_REGULATIONS_TRAINING_TYPES.has(learnerTab.value)
|
||||
|| trainingTypes.value.some((item) => item.code === learnerTab.value && item.name.includes('出国规章'))
|
||||
));
|
||||
const trainingVersion = ref<string>(DEFAULT_TRAINING_VERSION);
|
||||
const examMode = ref<TrainingExamMode>('unified');
|
||||
const safetyStage = ref<SafetyStage>('company');
|
||||
@@ -147,6 +170,11 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
});
|
||||
|
||||
const stage = ref<TrainingStage>('video');
|
||||
watch(isOverseasRegulationsTraining, (isOverseas) => {
|
||||
if (isOverseas) {
|
||||
stage.value = 'video';
|
||||
}
|
||||
});
|
||||
const currentQuestionIndex = ref(0);
|
||||
const score = ref(0);
|
||||
const attemptCount = ref(0);
|
||||
@@ -665,7 +693,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
safetyViewStage.value = record.safetyStage || 'company';
|
||||
}
|
||||
}
|
||||
stage.value = record.stage;
|
||||
stage.value = isOverseasRegulationsTraining.value ? 'video' : record.stage;
|
||||
syncExamQuestionIndex(record.currentQuestionIndex);
|
||||
score.value = Number(record.score || 0);
|
||||
attemptCount.value = Number(record.attempts || 0);
|
||||
@@ -706,7 +734,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
safetyProgress: learnerTab.value === 'safety' ? safetyProgress.value : null,
|
||||
currentQuestionIndex: currentQuestionIndex.value,
|
||||
score: score.value,
|
||||
passed: isPassed.value,
|
||||
passed: isOverseasRegulationsTraining.value && stage.value === 'result' ? true : isPassed.value,
|
||||
attemptCount: attemptCount.value,
|
||||
answerDetails: answerRecords.value,
|
||||
joinDate: currentJoinDate.value || formatDate(new Date()),
|
||||
@@ -749,11 +777,14 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
isHydrated.value = true;
|
||||
return;
|
||||
}
|
||||
const requestedTrainingType = learnerTab.value;
|
||||
try {
|
||||
const record = await getMyTrainingProgress(learnerTab.value);
|
||||
const record = await getMyTrainingProgress(requestedTrainingType);
|
||||
if (learnerTab.value !== requestedTrainingType) return;
|
||||
hasWarnedLoadFailure.value = false;
|
||||
applyProgressRecord(record);
|
||||
} catch (error) {
|
||||
if (learnerTab.value !== requestedTrainingType) return;
|
||||
// 退出登录或登录态失效时,培训页可能尚未卸载;这里静默清空状态,避免把正常 401 提示成“读取失败”。
|
||||
if (error instanceof BusinessError && error.status === 401) {
|
||||
hasWarnedLoadFailure.value = false;
|
||||
@@ -782,15 +813,21 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
trainingConfigLoading.value = false;
|
||||
return;
|
||||
}
|
||||
const requestedTrainingType = learnerTab.value;
|
||||
trainingConfigLoading.value = true;
|
||||
try {
|
||||
publishedConfig.value = await getMyTrainingConfig(learnerTab.value);
|
||||
const config = await getMyTrainingConfig(requestedTrainingType);
|
||||
if (learnerTab.value === requestedTrainingType) {
|
||||
publishedConfig.value = config;
|
||||
}
|
||||
} catch (error) {
|
||||
if (!(error instanceof BusinessError && error.status === 401)) {
|
||||
if (learnerTab.value === requestedTrainingType && !(error instanceof BusinessError && error.status === 401)) {
|
||||
publishedConfig.value = null;
|
||||
}
|
||||
} finally {
|
||||
trainingConfigLoading.value = false;
|
||||
if (learnerTab.value === requestedTrainingType) {
|
||||
trainingConfigLoading.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -841,6 +878,20 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
await loadLeanDashboard();
|
||||
};
|
||||
|
||||
const exportLeanDashboard = async () => {
|
||||
const taskId = leanDashboardTaskId.value ?? leanDashboard.value.task?.id;
|
||||
if (!taskId || leanExportLoading.value) return;
|
||||
leanExportLoading.value = true;
|
||||
try {
|
||||
await exportLeanTrainingDashboard(taskId);
|
||||
msg.success(t('chat.training.lean.dashboard.exportSuccess'));
|
||||
} catch {
|
||||
msg.error(t('chat.training.lean.dashboard.exportFailed'));
|
||||
} finally {
|
||||
leanExportLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 读取学员端全部已发布精益周任务(含状态与播放地址),并以服务端完成记录回填各任务的感悟/观看草稿。 */
|
||||
const loadLeanTraining = async () => {
|
||||
if (!isTrainingAgent.value || !hasAuthenticatedUser.value) return;
|
||||
@@ -869,7 +920,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
const markLeanVideoWatched = (taskId: number, resourceId: number) => {
|
||||
const taskWatched = leanWatchedByTask.value[taskId] || {};
|
||||
if (taskWatched[String(resourceId)]) return;
|
||||
leanWatchedByTask.value = { ...leanWatchedByTask.value, [taskId]: { ...taskWatched, [String(resourceId)]: new Date().toISOString() } };
|
||||
// 本地即时回显用北京时间,与服务端序列化口径一致;持久化失败时该值会经 save_completion 兜底入库(后端归一为 UTC)
|
||||
leanWatchedByTask.value = { ...leanWatchedByTask.value, [taskId]: { ...taskWatched, [String(resourceId)]: formatBeijingIso(new Date()) } };
|
||||
// 持久化失败不阻塞本地状态;下次刷新列表会以服务端记录为准,未持久化的视频需重新完整观看
|
||||
void markMyLeanVideoWatched(taskId, resourceId).catch(() => {});
|
||||
};
|
||||
@@ -966,11 +1018,25 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
);
|
||||
|
||||
const markVideoCompleted = () => {
|
||||
if (!hasPublishedTrainingConfig.value || !videoUrl.value) return;
|
||||
if (!hasPublishedTrainingConfig.value) return;
|
||||
if (!isOverseasRegulationsTraining.value && !videoUrl.value) return;
|
||||
if (learnerTab.value === 'safety') {
|
||||
checkAndAdvanceStage();
|
||||
return;
|
||||
}
|
||||
if (isOverseasRegulationsTraining.value) {
|
||||
stage.value = 'result';
|
||||
score.value = 100;
|
||||
completionDate.value = formatDate(new Date());
|
||||
latestSettledResult.value = {
|
||||
score: 100,
|
||||
correctCount: 0,
|
||||
wrongCount: 0,
|
||||
isPassed: true,
|
||||
};
|
||||
void persistProgress();
|
||||
return;
|
||||
}
|
||||
stage.value = 'summary';
|
||||
void persistProgress();
|
||||
};
|
||||
@@ -1252,6 +1318,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
}
|
||||
void persistProgress();
|
||||
} else {
|
||||
if (isOverseasRegulationsTraining.value) return;
|
||||
const activeStageMaterials = publishedTrainingMaterials.value;
|
||||
if (!activeStageMaterials.length) return;
|
||||
const allCompleted = activeStageMaterials.every(m => {
|
||||
@@ -1357,6 +1424,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
leanStats,
|
||||
leanRows,
|
||||
leanDashboardTaskId,
|
||||
leanExportLoading,
|
||||
exportLeanDashboard,
|
||||
selectLeanDashboardPeriod,
|
||||
learnerChatPrompt,
|
||||
newSessionReminderMessage,
|
||||
@@ -1364,6 +1433,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
||||
learnerAssistantMessage,
|
||||
managementChatPrompt,
|
||||
markVideoCompleted,
|
||||
isOverseasRegulationsTraining,
|
||||
startExam,
|
||||
selectAnswer,
|
||||
submitTextAnswer,
|
||||
|
||||
Reference in new issue
Block a user