fix(mobile): converge work report confirmation
This commit is contained in:
@@ -251,6 +251,7 @@ import {
|
||||
isCurrentWorkReportRequest,
|
||||
isDefinitiveWorkReportRejection,
|
||||
organizeWorkReport,
|
||||
prepareWorkReportOrganizeInput,
|
||||
stableWorkReportRequestId,
|
||||
submitWorkReport,
|
||||
uploadWorkReportAttachment,
|
||||
@@ -430,6 +431,7 @@ const organizeInput = async (
|
||||
const transcript = text.trim();
|
||||
if (!transcript || organizing.value || draftLocked.value || submittedReport.value) return;
|
||||
const previousDraft = draftPayload();
|
||||
const organizeRequest = prepareWorkReportOrganizeInput(transcript, previousDraft);
|
||||
pushMessage<UserMessage>({
|
||||
role: 'user',
|
||||
text: transcript,
|
||||
@@ -443,8 +445,8 @@ const organizeInput = async (
|
||||
speechPlayback.stop();
|
||||
try {
|
||||
const result = await organizeWorkReport({
|
||||
transcript,
|
||||
currentDraft: previousDraft,
|
||||
transcript: organizeRequest.transcript,
|
||||
currentDraft: organizeRequest.currentDraft,
|
||||
attachmentOssId: attachment.value?.ossId,
|
||||
attachmentName: attachment.value?.fileName
|
||||
});
|
||||
|
||||
@@ -52,6 +52,29 @@ export const isCurrentWorkReportRequest = (
|
||||
currentAccountKey: string
|
||||
) => generation === currentGeneration && accountKey === currentAccountKey;
|
||||
|
||||
export const prepareWorkReportOrganizeInput = (
|
||||
transcript: string,
|
||||
currentDraft?: WorkReportDraft
|
||||
): { transcript: string; currentDraft?: WorkReportDraft } => {
|
||||
const addition = transcript.trim();
|
||||
if (!currentDraft) return { transcript: addition };
|
||||
|
||||
const currentContent = currentDraft.content.trim();
|
||||
const content = !currentContent
|
||||
? addition
|
||||
: !addition || currentContent === addition
|
||||
? currentContent
|
||||
: `${currentContent}\n${addition}`;
|
||||
|
||||
return {
|
||||
transcript: '',
|
||||
currentDraft: {
|
||||
...currentDraft,
|
||||
content
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const workReportTypes: Array<{ value: WorkReportType; label: string; desc: string; icon: string }> = [
|
||||
{ value: 'CASE', label: '优秀案例', desc: '现场处理得好的真实案例', icon: '⭐' },
|
||||
{ value: 'VIDEO', label: '操作视频', desc: '值得推广的操作演示视频', icon: '🎬' },
|
||||
|
||||
@@ -36,7 +36,8 @@ test('语音转写、文字和附件补充都进入无状态整理', async () =>
|
||||
assert.match(page, /transcribeSpeechFile/);
|
||||
assert.match(page, /organizeWorkReport\(/);
|
||||
assert.match(page, /const previousDraft = draftPayload\(\)/);
|
||||
assert.match(page, /currentDraft:\s*previousDraft/);
|
||||
assert.match(page, /prepareWorkReportOrganizeInput\(transcript, previousDraft\)/);
|
||||
assert.match(page, /currentDraft:\s*organizeRequest\.currentDraft/);
|
||||
assert.match(page, /attachmentOssId:\s*attachment\.value\?\.ossId/);
|
||||
assert.match(page, /void organizeInput\(text, \{ voice: false \}\)/);
|
||||
assert.match(page, /void addMediaAttachment\(\)/);
|
||||
@@ -171,4 +172,26 @@ test('幂等键与异步账号守卫是可执行行为,不只是源码字符
|
||||
assert.equal(state.isCurrentWorkReportRequest(3, 3, 'account-a', 'account-a'), true);
|
||||
assert.equal(state.isCurrentWorkReportRequest(2, 3, 'account-a', 'account-a'), false);
|
||||
assert.equal(state.isCurrentWorkReportRequest(3, 3, 'account-a', 'account-b'), false);
|
||||
|
||||
const firstTurn = state.prepareWorkReportOrganizeInput(' 首轮原话 ');
|
||||
assert.deepEqual(firstTurn, { transcript: '首轮原话' });
|
||||
|
||||
const existingDraft = {
|
||||
suggestedType: 'CASE',
|
||||
title: '真机验收',
|
||||
content: '已完成文件选择和 ASR'
|
||||
};
|
||||
const followUp = state.prepareWorkReportOrganizeInput(' 补充设备和结果 ', existingDraft);
|
||||
assert.deepEqual(followUp, {
|
||||
transcript: '',
|
||||
currentDraft: {
|
||||
suggestedType: 'CASE',
|
||||
title: '真机验收',
|
||||
content: '已完成文件选择和 ASR\n补充设备和结果'
|
||||
}
|
||||
});
|
||||
assert.equal(existingDraft.content, '已完成文件选择和 ASR');
|
||||
|
||||
const duplicate = state.prepareWorkReportOrganizeInput(' 已完成文件选择和 ASR ', existingDraft);
|
||||
assert.equal(duplicate.currentDraft.content, '已完成文件选择和 ASR');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user