feat(system): add Excel export for dept and menu tree lists
Export flattened filtered or selected rows via backend xlsx and ListExportDropdown. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b3b6ec187a
commit
ee56dad875
4 files changed
+170
-1
No files matched your search
@@ -346,6 +346,14 @@ export function fetchDeptTree(params?: { keyword?: string }) {
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchExportDepts(data: Record<string, any>) {
|
||||
return request.post({
|
||||
url: '/web/admin/depts/export',
|
||||
data,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchCreateDept(data: {
|
||||
parentId?: string
|
||||
deptName: string
|
||||
@@ -505,6 +513,14 @@ export function fetchMenuTree(params?: { keyword?: string }) {
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchExportMenus(data: Record<string, any>) {
|
||||
return request.post({
|
||||
url: '/web/admin/menus/export',
|
||||
data,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchCreateMenu(data: {
|
||||
menuName: string
|
||||
parentId?: string
|
||||
|
||||
@@ -66,6 +66,15 @@
|
||||
{{ isExpandAll ? '全部折叠' : '全部展开' }}
|
||||
</el-button>
|
||||
|
||||
<ListExportDropdown
|
||||
:export-fn="fetchExportDepts"
|
||||
:get-filter-params="getDeptExportFilterParams"
|
||||
:has-selection="true"
|
||||
:selected-ids="selectedRows.map((r) => r.id)"
|
||||
:visible-columns="deptExportColumns"
|
||||
filename="组织列表.xlsx"
|
||||
/>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
:column-defs="listColumnDefs"
|
||||
@@ -304,6 +313,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, watch, onMounted, nextTick } from 'vue'
|
||||
@@ -323,6 +333,7 @@ import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import {
|
||||
fetchDeptTree,
|
||||
fetchExportDepts,
|
||||
fetchCreateDept,
|
||||
fetchUpdateDept,
|
||||
fetchDeleteDept,
|
||||
@@ -356,6 +367,19 @@ const dictStore = useDictStore()
|
||||
|
||||
const searchForm = reactive<{ keyword: string }>({ keyword: '' })
|
||||
const quickSearchKeyword = ref('')
|
||||
|
||||
function getDeptExportFilterParams() {
|
||||
const quickKeyword = quickSearchKeyword.value?.trim()
|
||||
return {
|
||||
keyword: quickKeyword || searchForm.keyword || undefined
|
||||
}
|
||||
}
|
||||
|
||||
const deptExportColumns = computed(() => {
|
||||
const cols = [...visibleColumns.value]
|
||||
if (!cols.includes('deptName')) cols.unshift('deptName')
|
||||
return cols
|
||||
})
|
||||
const tableData = ref<Api.Dept.DeptItem[]>([])
|
||||
/** 弹窗上级组织:全量树(不受列表关键词筛选影响) */
|
||||
const deptTreeForSelect = ref<Api.Dept.DeptItem[]>([])
|
||||
|
||||
@@ -65,6 +65,15 @@
|
||||
{{ isExpandAll ? '全部折叠' : '全部展开' }}
|
||||
</el-button>
|
||||
|
||||
<ListExportDropdown
|
||||
:export-fn="fetchExportMenus"
|
||||
:get-filter-params="getMenuExportFilterParams"
|
||||
:has-selection="true"
|
||||
:selected-ids="selectedRows.map((r) => r.id)"
|
||||
:visible-columns="menuExportColumns"
|
||||
filename="菜单列表.xlsx"
|
||||
/>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
:column-defs="listColumnDefs"
|
||||
@@ -314,6 +323,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'
|
||||
@@ -331,7 +341,7 @@ import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
Search
|
||||
} from '@element-plus/icons-vue'
|
||||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||||
import { fetchMenuTree, fetchCreateMenu, fetchUpdateMenu, fetchDeleteMenu } from '@/api/admin'
|
||||
import { fetchMenuTree, fetchExportMenus, fetchCreateMenu, fetchUpdateMenu, fetchDeleteMenu } from '@/api/admin'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
|
||||
defineOptions({ name: 'SystemMenu' })
|
||||
@@ -363,6 +373,19 @@ import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
const isExpandAll = ref(true)
|
||||
const tableRef = ref()
|
||||
|
||||
function getMenuExportFilterParams() {
|
||||
const quickKeyword = quickSearchKeyword.value?.trim()
|
||||
return {
|
||||
keyword: quickKeyword || searchForm.keyword || undefined
|
||||
}
|
||||
}
|
||||
|
||||
const menuExportColumns = computed(() => {
|
||||
const cols = [...visibleColumns.value]
|
||||
if (!cols.includes('menuName')) cols.unshift('menuName')
|
||||
return cols
|
||||
})
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('新增菜单')
|
||||
const isEdit = ref(false)
|
||||
|
||||
Reference in new issue
Block a user