add data export
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
@left-click="$router.back()"
|
||||
>
|
||||
<template #right>
|
||||
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
|
||||
<navbar-actions :actions="actionList" :visible="canCreateStore || canSortStore" />
|
||||
</template>
|
||||
</t-navbar>
|
||||
<main v-can="permissionCodes.store.read" class="page-content column scroll list">
|
||||
@@ -73,7 +73,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { NavbarAction } from "@/types/NavbarAction.ts";
|
||||
import { Message } from "@/utils/message";
|
||||
import { Time, WebToolkit } from "timi-web";
|
||||
import { type Page, type PageResult, useUserStore } from "timi-web-api";
|
||||
import StoreAPI from "@/api/StoreAPI";
|
||||
import StoreRemoveDialog from "@/components/StoreRemoveDialog.vue";
|
||||
@@ -92,9 +91,6 @@ const isStoreManagerScope = computed(() => userStore.hasRoles(gaoRoleCodes.store
|
||||
const canCreateStore = computed(() => userStore.hasPermissions(permissionCodes.store.create));
|
||||
const canSortStore = computed(() => userStore.hasPermissions(permissionCodes.store.update));
|
||||
const canDeleteStore = computed(() => !isStoreManagerScope.value && userStore.hasPermissions(permissionCodes.store.delete));
|
||||
const canExportStore = computed(() => userStore.hasPermissions(permissionCodes.store.export));
|
||||
const canShowActionMenu = computed(() => canCreateStore.value || canSortStore.value || canExportStore.value);
|
||||
const isExporting = ref(false);
|
||||
const isRemoving = ref(false);
|
||||
const removeDialogVisible = ref(false);
|
||||
const removeTarget = ref<Store>();
|
||||
@@ -119,15 +115,6 @@ const actionList = computed<NavbarAction[]>(() => {
|
||||
text: "排序"
|
||||
});
|
||||
}
|
||||
if (canExportStore.value) {
|
||||
list.push({
|
||||
action: exportExcel,
|
||||
icon: "download",
|
||||
key: "export",
|
||||
loading: isExporting.value,
|
||||
text: "导出 Excel"
|
||||
});
|
||||
}
|
||||
return list;
|
||||
});
|
||||
|
||||
@@ -180,24 +167,6 @@ async function fetch(): Promise<void> {
|
||||
|
||||
// ---------- 操作 ----------
|
||||
|
||||
async function exportExcel(): Promise<void> {
|
||||
if (isExporting.value) {
|
||||
return;
|
||||
}
|
||||
isExporting.value = true;
|
||||
try {
|
||||
const blob = await StoreAPI.exportXSSF({
|
||||
index: 0,
|
||||
size: 10000,
|
||||
orderMap: page.orderMap
|
||||
});
|
||||
WebToolkit.downloadBlob(blob, `门店列表-${Time.toDate(new Date())}.xlsx`);
|
||||
Message.success("导出已开始");
|
||||
} finally {
|
||||
isExporting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function toEdit(item: Store): Promise<void> {
|
||||
if (!item.id) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user