feat(system): add Excel export for tenant, role, post and site lists
Reuse list filters with ids/columns support and ListExportDropdown UX. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5c7210facc
commit
82d8cb7f64
10 files changed
+356
-6
No files matched your search
@@ -52,6 +52,15 @@ export function fetchTenantList(params?: { page?: number; pageSize?: number; key
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function fetchExportTenants(data: Record<string, any>) {
|
||||
return request.post({
|
||||
url: '/web/admin/tenants/export',
|
||||
data,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchCreateTenant(data: {
|
||||
tenantNo: string
|
||||
tenantName: string
|
||||
@@ -374,6 +383,15 @@ export function fetchSiteList(params?: { page?: number; pageSize?: number; keywo
|
||||
totalPages: number
|
||||
}>({ url: '/web/admin/sites', params })
|
||||
}
|
||||
|
||||
|
||||
export function fetchExportSites(data: Record<string, any>) {
|
||||
return request.post({
|
||||
url: '/web/admin/sites/export',
|
||||
data,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
export function fetchCreateSite(data: {
|
||||
siteName: string
|
||||
siteCode: string
|
||||
@@ -422,6 +440,15 @@ export function fetchPostList(params?: { page?: number; pageSize?: number; keywo
|
||||
totalPages: number
|
||||
}>({ url: '/web/admin/posts', params })
|
||||
}
|
||||
|
||||
|
||||
export function fetchExportPosts(data: Record<string, any>) {
|
||||
return request.post({
|
||||
url: '/web/admin/posts/export',
|
||||
data,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
export function fetchCreatePost(data: {
|
||||
postName: string
|
||||
postCode: string
|
||||
@@ -522,6 +549,15 @@ export function fetchRoleList(params?: { page?: number; pageSize?: number; keywo
|
||||
totalPages: number
|
||||
}>({ url: '/web/admin/role-management', params })
|
||||
}
|
||||
|
||||
|
||||
export function fetchExportRoles(data: Record<string, any>) {
|
||||
return request.post({
|
||||
url: '/web/admin/role-management/export',
|
||||
data,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
export function fetchRoleDetail(id: string) {
|
||||
return request.get<Api.Role.RoleItem>({ url: `/web/admin/role-management/${id}` })
|
||||
}
|
||||
|
||||
@@ -73,6 +73,15 @@
|
||||
批量删除
|
||||
</el-button>
|
||||
|
||||
<ListExportDropdown
|
||||
:export-fn="fetchExportPosts"
|
||||
:get-filter-params="getPostExportFilterParams"
|
||||
:has-selection="true"
|
||||
:selected-ids="selectedRows.map((r) => r.id)"
|
||||
:visible-columns="postExportColumns"
|
||||
filename="职位列表.xlsx"
|
||||
/>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
:column-defs="listColumnDefs"
|
||||
@@ -353,6 +362,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
|
||||
@@ -377,6 +387,7 @@ import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import {
|
||||
fetchPostList,
|
||||
fetchExportPosts,
|
||||
fetchCreatePost,
|
||||
fetchUpdatePost,
|
||||
fetchDeletePost,
|
||||
@@ -411,6 +422,20 @@ import { useDictStore } from '@/store/modules/dict'
|
||||
const selectedRows = ref<Api.Post.PostItem[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
|
||||
function getPostExportFilterParams() {
|
||||
const quickKeyword = quickSearchKeyword.value?.trim()
|
||||
return {
|
||||
keyword: quickKeyword || searchForm.keyword || undefined
|
||||
}
|
||||
}
|
||||
|
||||
const postExportColumns = computed(() => {
|
||||
const cols = [...visibleColumns.value]
|
||||
if (!cols.includes('postName')) cols.unshift('postName')
|
||||
return cols
|
||||
})
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增职位')
|
||||
const isEdit = ref(false)
|
||||
|
||||
@@ -85,6 +85,15 @@
|
||||
批量删除
|
||||
</el-button>
|
||||
|
||||
<ListExportDropdown
|
||||
:export-fn="fetchExportRoles"
|
||||
:get-filter-params="getRoleExportFilterParams"
|
||||
:has-selection="true"
|
||||
:selected-ids="selectedRows.map((r) => r.id)"
|
||||
:visible-columns="roleExportColumns"
|
||||
filename="角色列表.xlsx"
|
||||
/>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
:column-defs="listColumnDefs"
|
||||
@@ -189,10 +198,11 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import RoleManageDialogs from '@/components/business/role-manage-dialogs/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import {
|
||||
canDeleteByCreator,
|
||||
filterDeletableByCreator,
|
||||
@@ -211,7 +221,7 @@
|
||||
} from '@element-plus/icons-vue'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { fetchRoleList, fetchDeleteRole } from '@/api/admin'
|
||||
import { fetchRoleList, fetchExportRoles, fetchDeleteRole } from '@/api/admin'
|
||||
|
||||
defineOptions({ name: 'SystemRole' })
|
||||
|
||||
@@ -235,6 +245,19 @@
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
const roleDialogsRef = ref<InstanceType<typeof RoleManageDialogs> | null>(null)
|
||||
|
||||
function getRoleExportFilterParams() {
|
||||
const quickKeyword = quickSearchKeyword.value?.trim()
|
||||
return {
|
||||
keyword: quickKeyword || searchForm.keyword || undefined
|
||||
}
|
||||
}
|
||||
|
||||
const roleExportColumns = computed(() => {
|
||||
const cols = [...visibleColumns.value]
|
||||
if (!cols.includes('roleName')) cols.unshift('roleName')
|
||||
return cols
|
||||
})
|
||||
|
||||
const handleSelectionChange = (rows: Api.Role.RoleItem[]) => {
|
||||
selectedRows.value = rows
|
||||
}
|
||||
|
||||
@@ -41,6 +41,14 @@
|
||||
批量删除
|
||||
</el-button>
|
||||
|
||||
<ListExportDropdown
|
||||
:export-fn="fetchExportSites"
|
||||
:get-filter-params="getSiteExportFilterParams"
|
||||
:has-selection="true"
|
||||
:selected-ids="selectedRows.map((r) => r.id)"
|
||||
filename="站点列表.xlsx"
|
||||
/>
|
||||
|
||||
<ListToolbarEndActions :loading="loading" @refresh="loadData" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -302,6 +310,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
|
||||
import { canDeleteByCreator, filterDeletableByCreator, allRowsDeletableByCreator, CREATOR_DELETE_TIP } from '@/utils/creator-delete'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
@@ -311,6 +320,7 @@ import { useDictStore } from '@/store/modules/dict'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import {
|
||||
fetchSiteList,
|
||||
fetchExportSites,
|
||||
fetchCreateSite,
|
||||
fetchUpdateSite,
|
||||
fetchDeleteSite,
|
||||
@@ -377,6 +387,13 @@ const dictStore = useDictStore()
|
||||
const selectedRows = ref<Api.Site.SiteItem[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
|
||||
function getSiteExportFilterParams() {
|
||||
return {
|
||||
keyword: searchForm.keyword || undefined
|
||||
}
|
||||
}
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增站点')
|
||||
const isEdit = ref(false)
|
||||
|
||||
@@ -75,6 +75,15 @@
|
||||
批量删除
|
||||
</el-button>
|
||||
|
||||
<ListExportDropdown
|
||||
:export-fn="fetchExportTenants"
|
||||
:get-filter-params="getTenantExportFilterParams"
|
||||
:has-selection="true"
|
||||
:selected-ids="selectedRows.map((r) => r.id)"
|
||||
:visible-columns="tenantExportColumns"
|
||||
filename="租户列表.xlsx"
|
||||
/>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
:column-defs="listColumnDefs"
|
||||
@@ -274,6 +283,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
@@ -294,6 +304,7 @@ import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
import { withFullscreenLoading, fullscreenLoadingText } from '@/utils/fullscreen-loading'
|
||||
import {
|
||||
fetchTenantList,
|
||||
fetchExportTenants,
|
||||
fetchCreateTenant,
|
||||
fetchUpdateTenant,
|
||||
fetchDeleteTenant
|
||||
@@ -325,6 +336,20 @@ import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
const selectedRows = ref<Api.Tenant.TenantItem[]>([])
|
||||
const loading = ref(false)
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
|
||||
function getTenantExportFilterParams() {
|
||||
const quickKeyword = quickSearchKeyword.value?.trim()
|
||||
return {
|
||||
keyword: quickKeyword || searchForm.keyword || undefined
|
||||
}
|
||||
}
|
||||
|
||||
const tenantExportColumns = computed(() => {
|
||||
const cols = [...visibleColumns.value]
|
||||
if (!cols.includes('tenantName')) cols.unshift('tenantName')
|
||||
return cols
|
||||
})
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增租户')
|
||||
const isEdit = ref(false)
|
||||
|
||||
Reference in new issue
Block a user