feat(M08-B): 补保洁员列表导出
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<el-button :icon="Download" :disabled="items.length === 0" @click="exportCleaners">
|
||||
导出
|
||||
</el-button>
|
||||
<el-button type="primary" :icon="UserPlus" @click="createDialog.open = true">
|
||||
新增
|
||||
</el-button>
|
||||
@@ -140,6 +143,7 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import {
|
||||
Download,
|
||||
Pencil,
|
||||
RefreshCw,
|
||||
ShieldX,
|
||||
@@ -239,4 +243,38 @@ function submitEdit() {
|
||||
function profileComplete(row: ManagedUser) {
|
||||
return row.wechatMiniappBound && row.storeIds.length > 0 && Boolean(row.nickname);
|
||||
}
|
||||
|
||||
function exportCleaners() {
|
||||
downloadCsv(`cleaning-cleaners-${Date.now()}.csv`, [
|
||||
['ID', '姓名', '状态', '微信绑定', '资料完整度', '门店范围', '手机号', '最近登录', '最近 IP', '注册时间', '备注'],
|
||||
...props.items.map((row) => [
|
||||
row.id,
|
||||
row.nickname || '',
|
||||
row.status,
|
||||
row.wechatMiniappBound ? '已绑定微信' : '未绑定微信',
|
||||
profileComplete(row) ? '资料完整' : '待补资料',
|
||||
row.storeIds.join(' / '),
|
||||
row.maskedPhone,
|
||||
row.lastLoginAt || '',
|
||||
row.maskedLastIp,
|
||||
row.registeredAt,
|
||||
row.note
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
function downloadCsv(filename: string, rows: string[][]) {
|
||||
const content = rows.map((row) => row.map(csvCell).join(',')).join('\r\n');
|
||||
const blob = new Blob([`\uFEFF${content}`], { type: 'text/csv;charset=utf-8;' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
function csvCell(value: string) {
|
||||
return `"${String(value ?? '').replace(/"/g, '""')}"`;
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user