管理页批量导入处新增模板下载按钮(CSV 带 BOM,Excel 直接打开不乱码)
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
<div class="hint">支持逗号或 Tab 分隔(Excel 复制出来直接粘贴即可);重复工号会覆盖原账号(姓名与密码重置、状态恢复为启用)。</div>
|
||||
<div class="row" style="margin-top:10px">
|
||||
<button onclick="doImport()">导入</button>
|
||||
<button class="ghost" onclick="downloadTemplate()">下载导入模板</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -149,6 +150,17 @@ async function doImport() {
|
||||
loadList();
|
||||
} catch (e) { show(e.message, false); }
|
||||
}
|
||||
|
||||
// 下载 CSV 导入模板(加 BOM 让 Excel 正确识别中文)
|
||||
function downloadTemplate() {
|
||||
const csv = '\uFEFF工号,姓名,初始密码\n10001,张三,abc123456\n10002,李四,abc123456\n';
|
||||
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8' });
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = '员工导入模板.csv';
|
||||
a.click();
|
||||
URL.revokeObjectURL(a.href);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user