feat: 上传文件后不再自动处理,需用户发送'可以开始'触发
- upload.js/sync.js: 移除 checkAutoStart() 自动调用 - config.js: promptMissingConfig 提示用户手动触发;sendUserMessage 识别'可以开始'等指令 - index.html: 更新欢迎消息
This commit is contained in:
+22
-27
@@ -17,34 +17,33 @@ export const CONFIG_FIELDS = {
|
||||
|
||||
/**
|
||||
* 静默检查:仅当配置完整且有文件时自动开始处理。
|
||||
* 注意:上传文件后不再自动触发,需要用户发送"可以开始"等指令。
|
||||
*/
|
||||
export function checkAutoStart() {
|
||||
if (App.isProcessing) return;
|
||||
if (App.processState === 'processing') return;
|
||||
|
||||
if (App.processState === 'done') {
|
||||
// done 状态下有新文件时,走 supplement 流程(手动触发)
|
||||
if (App.processState === 'done' && App.forceStart) {
|
||||
const hasNewFiles = App.allFiles.length > App.lastProcessedFileCount;
|
||||
if (!hasNewFiles && !App.forceStart) return;
|
||||
if (!hasNewFiles) return;
|
||||
App.forceStart = false;
|
||||
// done 状态下有新文件时,走 supplement 流程
|
||||
if (hasNewFiles) {
|
||||
App.isProcessing = true;
|
||||
App.processState = 'processing';
|
||||
if (App.newFilenames.length > 0) {
|
||||
const filenames = App.newFilenames;
|
||||
App.newFilenames = [];
|
||||
handleSupplementUpload(filenames);
|
||||
}
|
||||
return;
|
||||
App.isProcessing = true;
|
||||
App.processState = 'processing';
|
||||
if (App.newFilenames.length > 0) {
|
||||
const filenames = App.newFilenames;
|
||||
App.newFilenames = [];
|
||||
handleSupplementUpload(filenames);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// awaiting_supplement 状态下不自动处理,等待用户补充文件后手动触发
|
||||
if (App.processState === 'awaiting_supplement') {
|
||||
return;
|
||||
}
|
||||
|
||||
// idle 状态下有补充文件时,走 supplement 流程
|
||||
// idle 状态下有补充文件时,走 supplement 流程(手动触发)
|
||||
if (App.processState === 'idle' && App.newFilenames.length > 0) {
|
||||
App.isProcessing = true;
|
||||
App.processState = 'processing';
|
||||
@@ -54,16 +53,7 @@ export function checkAutoStart() {
|
||||
return;
|
||||
}
|
||||
|
||||
const allKeys = Object.keys(CONFIG_FIELDS);
|
||||
const missing = allKeys.filter(k => !App.sessionConfig[k]);
|
||||
|
||||
if (missing.length) return;
|
||||
|
||||
App.pendingConfigKey = null;
|
||||
|
||||
if (!App.allFiles.length) return;
|
||||
|
||||
startProcess();
|
||||
// 不再自动开始处理,需要用户发送"可以开始"等指令
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +79,7 @@ export function promptMissingConfig() {
|
||||
App.pendingConfigKey = null;
|
||||
|
||||
if (App.allFiles.length) {
|
||||
showStatus('配置信息已完整,开始处理发票……');
|
||||
startProcess();
|
||||
showStatus('配置信息已完整,请发送"可以开始"或"处理发票"来启动处理流程');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +105,12 @@ export async function sendUserMessage() {
|
||||
addChatMessage(text, 'user', true);
|
||||
input.value = '';
|
||||
|
||||
// 检查是否是开始处理指令(如"可以开始"、"处理发票"等)
|
||||
if (text.includes('可以开始') || text.includes('开始处理') || text.includes('处理发票') || text.includes('开始')) {
|
||||
startProcess();
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否是强制提交指令
|
||||
if (text.includes('直接提交') || text.includes('强制提交') || text.includes('继续提交')) {
|
||||
await handleForceSubmit();
|
||||
@@ -134,7 +129,7 @@ export async function sendUserMessage() {
|
||||
return;
|
||||
}
|
||||
|
||||
showStatus('请通过上传区补充文件,或输入"直接提交"跳过校验');
|
||||
showStatus('请发送"可以开始"或"处理发票"来启动处理流程');
|
||||
}
|
||||
|
||||
export function handleChatKey(event) {
|
||||
|
||||
@@ -72,7 +72,5 @@ async function syncFiles() {
|
||||
} else {
|
||||
document.getElementById('file-zone').classList.remove('active');
|
||||
}
|
||||
|
||||
checkAutoStart();
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
@@ -20,7 +20,6 @@ export async function handleFiles(input) {
|
||||
await _uploadNewFiles(result.newFilenames);
|
||||
App.newFilenames = result.newFilenames;
|
||||
App.processState = 'idle';
|
||||
checkAutoStart();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,13 +105,12 @@ export function initDragDrop() {
|
||||
App.processState = 'idle';
|
||||
}
|
||||
|
||||
// 在 awaiting_supplement 状态下,只上传新文件并走 supplement 流程
|
||||
// 在 awaiting_supplement 状态下,只上传新文件并走 supplement 流程(手动触发)
|
||||
if (result.hasNewFiles && App.processState === 'awaiting_supplement') {
|
||||
hideAgentRequest();
|
||||
await _uploadNewFiles(result.newFilenames);
|
||||
App.newFilenames = result.newFilenames;
|
||||
App.processState = 'idle';
|
||||
checkAutoStart();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="chat-messages" id="chat-messages">
|
||||
<div class="chat-welcome">
|
||||
<div class="ai-avatar"><img src="/static/icon/agent.svg" alt=""></div>
|
||||
<div class="chat-bubble system">你好!我是财务报销助手。请先上传 <b>config.json</b> 配置文件,然后上传发票 PDF 或支付截图,我将自动为您处理。</div>
|
||||
<div class="chat-bubble system">你好!我是财务报销助手。请先上传 <b>config.json</b> 配置文件和发票文件,然后发送<b>"可以开始"</b>来启动处理流程。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-input-area">
|
||||
|
||||
Reference in New Issue
Block a user