✓
操作成功
📁
点击上传Excel文件
支持 .xlsx, .xls 格式
try {
const data = await file.arrayBuffer();
const workbook = XLSX.read(data);
const sheet = workbook.Sheets[workbook.SheetNames[0]];
const rows = XLSX.utils.sheet_to_json(sheet);
for (const row of rows) {
if (row['条码'] && row['数量']) {
await addToPendingListWithQty(row['条码'], parseInt(row['数量']) || 1);
}
}
closeExcelModal();
showToast(`已导入 ${rows.length} 条数据`);
} catch (error) {
console.error('Excel解析失败:', error);
showToast('Excel解析失败');
}
*/
}
function downloadTemplate() {
// 创建简单的CSV模板
const template = '条码,数量\n1234567890123,10\n9876543210987,5';
const blob = new Blob(['\ufeff' + template], { type: 'text/csv;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = '补货导入模板.csv';
a.click();
URL.revokeObjectURL(url);
}
// ESC键返回
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
if (document.getElementById('excelModal').classList.contains('active')) {
closeExcelModal();
} else {
window.location.href = 'pos.html';
}
}
});
// 弹窗点击外部关闭
document.getElementById('excelModal').addEventListener('click', function(e) {
if (e.target === this) closeExcelModal();
});