修复:NL 向导拖拽上传按文件名精确匹配输入槽,避免序列文件误填 samples.tsv 槽

This commit is contained in:
potaser
2026-08-27 10:03:32 +08:00
parent 214eb11490
commit 5f406180dc
+17 -10
View File
@@ -20869,18 +20869,25 @@ compare: [[flesh, peel]]`;
if (!response.ok) throw new Error(await extensionApiError(response, '文件上传失败'));
const data = await response.json();
const uploaded = (data.files || []).map(name => `input/${jobId}/${name}`);
const targetInput = lightweightNlRun.inputs.find(item => !String(item.value || '').trim()) || lightweightNlRun.inputs[0];
if (targetInput) {
targetInput.value = uploaded.shift() || '';
const rest = uploaded.filter(Boolean);
if (rest.length) {
const emptyInputs = lightweightNlRun.inputs.filter(item => !String(item.value || '').trim());
for (let i = 0; i < rest.length && i < emptyInputs.length; i++) {
emptyInputs[i].value = rest[i];
}
// 优先按文件名与输入槽名精确匹配填入,避免把序列文件误填进 samples.tsv 等槽位
const remaining = [...uploaded];
for (const input of lightweightNlRun.inputs) {
if (String(input.value || '').trim()) continue;
const slotName = String(input.key || '').trim().toLowerCase();
const hitIndex = remaining.findIndex(path => {
const base = String(path || '').split('/').pop().toLowerCase();
return slotName && (base === slotName || base.endsWith('.' + slotName));
});
if (hitIndex >= 0) {
input.value = remaining.splice(hitIndex, 1)[0];
}
}
ElMessage.success(`已上传 ${uploaded.length} 个文件`);
const emptyInputs = lightweightNlRun.inputs.filter(item => !String(item.value || '').trim());
for (let i = 0; i < remaining.length && i < emptyInputs.length; i++) {
emptyInputs[i].value = remaining[i];
}
const matched = uploaded.length - remaining.length;
ElMessage.success(`已上传 ${uploaded.length} 个文件${matched ? `,已自动匹配 ${matched} 个输入槽` : ''}`);
} catch (err) {
ElMessage.error(err.message || '文件上传失败');
} finally {