diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index 8385273f..9603b960 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -241,7 +241,6 @@ const local: App.I18n.Schema = { function: 'System Function', alova: 'Alova Example', alova_request: 'Alova Request', - alova_user: 'User List', alova_scenes: 'Scenario Request', 'pro-naive': 'Pro Naive Example', 'pro-naive_form': 'Form', diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index db93898f..9934d37c 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -238,7 +238,6 @@ const local: App.I18n.Schema = { function: '系统功能', alova: 'alova示例', alova_request: 'alova请求', - alova_user: '用户列表', alova_scenes: '场景化请求', 'pro-naive': 'Pro Naive UI 示例', 'pro-naive_form': '表单', diff --git a/src/router/elegant/imports.ts b/src/router/elegant/imports.ts index 1fa448d2..a8520144 100644 --- a/src/router/elegant/imports.ts +++ b/src/router/elegant/imports.ts @@ -23,7 +23,6 @@ export const views: Record Promise import("@/views/about/index.vue"), alova_request: () => import("@/views/alova/request/index.vue"), alova_scenes: () => import("@/views/alova/scenes/index.vue"), - alova_user: () => import("@/views/alova/user/index.vue"), "function_hide-child_one": () => import("@/views/function/hide-child/one/index.vue"), "function_hide-child_three": () => import("@/views/function/hide-child/three/index.vue"), "function_hide-child_two": () => import("@/views/function/hide-child/two/index.vue"), diff --git a/src/router/elegant/routes.ts b/src/router/elegant/routes.ts index 302cc7c6..6adb0e6b 100644 --- a/src/router/elegant/routes.ts +++ b/src/router/elegant/routes.ts @@ -81,17 +81,6 @@ export const generatedRoutes: GeneratedRoute[] = [ icon: 'cbi:scene-dynamic', order: 3 } - }, - { - name: 'alova_user', - path: '/alova/user', - component: 'view.alova_user', - meta: { - title: 'alova_user', - i18nKey: 'route.alova_user', - icon: 'carbon:user-multiple', - order: 2 - } } ] }, diff --git a/src/router/elegant/transform.ts b/src/router/elegant/transform.ts index 731424fe..349e31c1 100644 --- a/src/router/elegant/transform.ts +++ b/src/router/elegant/transform.ts @@ -185,7 +185,6 @@ const routeMap: RouteMap = { "alova": "/alova", "alova_request": "/alova/request", "alova_scenes": "/alova/scenes", - "alova_user": "/alova/user", "function": "/function", "function_hide-child": "/function/hide-child", "function_hide-child_one": "/function/hide-child/one", diff --git a/src/typings/elegant-router.d.ts b/src/typings/elegant-router.d.ts index a0dbf19e..a791ac29 100644 --- a/src/typings/elegant-router.d.ts +++ b/src/typings/elegant-router.d.ts @@ -39,7 +39,6 @@ declare module "@elegant-router/types" { "alova": "/alova"; "alova_request": "/alova/request"; "alova_scenes": "/alova/scenes"; - "alova_user": "/alova/user"; "function": "/function"; "function_hide-child": "/function/hide-child"; "function_hide-child_one": "/function/hide-child/one"; @@ -183,7 +182,6 @@ declare module "@elegant-router/types" { | "about" | "alova_request" | "alova_scenes" - | "alova_user" | "function_hide-child_one" | "function_hide-child_three" | "function_hide-child_two" diff --git a/src/views/alova/user/hooks/use-checked-columns.ts b/src/views/alova/user/hooks/use-checked-columns.ts deleted file mode 100644 index f5dc7f24..00000000 --- a/src/views/alova/user/hooks/use-checked-columns.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { computed, ref } from 'vue'; -import type { DataTableBaseColumn, DataTableColumn } from 'naive-ui'; -import type { TableColumnCheck } from '@sa/hooks'; -import { $t } from '@/locales'; -import type { AlovaGenerics, Method } from '~/packages/alova/src'; - -function isTableColumnHasKey(column: DataTableColumn): column is DataTableBaseColumn { - return Boolean((column as NaiveUI.TableColumnWithKey).key); -} - -type TableAlovaApiFn = ( - params: R -) => Method>>; - -// this hook is used to manage table columns -// if you choose alova, you can move this hook to the `src/hooks` to handle all list page in your project -export default function useCheckedColumns>['records'][number]>( - getColumns: () => DataTableColumn[] -) { - const SELECTION_KEY = '__selection__'; - - const EXPAND_KEY = '__expand__'; - - const getColumnChecks = (cols: DataTableColumn[]) => { - const checks: NaiveUI.TableColumnCheck[] = []; - cols.forEach(column => { - if (isTableColumnHasKey(column)) { - checks.push({ - key: column.key as string, - title: column.title as string, - checked: true - }); - } else if (column.type === 'selection') { - checks.push({ - key: SELECTION_KEY, - title: $t('common.check'), - checked: true - }); - } else if (column.type === 'expand') { - checks.push({ - key: EXPAND_KEY, - title: $t('common.expandColumn'), - checked: true - }); - } - }); - - return checks; - }; - - const columnChecks = ref(getColumnChecks(getColumns())); - - const columns = computed(() => { - const cols = getColumns(); - const columnMap = new Map>(); - - cols.forEach(column => { - if (isTableColumnHasKey(column)) { - columnMap.set(column.key as string, column); - } else if (column.type === 'selection') { - columnMap.set(SELECTION_KEY, column); - } else if (column.type === 'expand') { - columnMap.set(EXPAND_KEY, column); - } - }); - - const filteredColumns = columnChecks.value - .filter(item => item.checked) - .map(check => columnMap.get(check.key) as NaiveUI.TableColumn); - - return filteredColumns; - }); - - return { - columnChecks, - columns - }; -} diff --git a/src/views/alova/user/hooks/use-table-operate.ts b/src/views/alova/user/hooks/use-table-operate.ts deleted file mode 100644 index d66b7a64..00000000 --- a/src/views/alova/user/hooks/use-table-operate.ts +++ /dev/null @@ -1,83 +0,0 @@ -import type { Ref } from 'vue'; -import { ref } from 'vue'; -import { useBoolean } from '@sa/hooks'; -import { jsonClone } from '@sa/utils'; -import { $t } from '@/locales'; - -type TableData = NaiveUI.TableData; -interface Operations { - delete?: (row: T) => Promise; - batchDelete?: (rows: T[]) => Promise; -} - -// this hook is used to handle the table operations -// if you choose alova, you can move this hook to the `src/hooks` to handle all list page in your project -export default function useTableOperate(data: Ref, operations: Operations) { - const { bool: drawerVisible, setTrue: openDrawer, setFalse: closeDrawer } = useBoolean(); - const { bool: deleting, setTrue: deletify, setFalse: antiDelete } = useBoolean(); - const { bool: batchDeleting, setTrue: batchDeletify, setFalse: antiBatchDelete } = useBoolean(); - - const operateType = ref('add'); - - const getRowByDataId = (id: T['id']) => data.value.find(item => item.id === id) || null; - - function handleAdd() { - operateType.value = 'add'; - openDrawer(); - } - - /** the editing row data */ - const editingData: Ref = ref(null); - - function handleEdit(id: T['id']) { - operateType.value = 'edit'; - editingData.value = jsonClone(getRowByDataId(id)); - - openDrawer(); - } - - /** the checked row keys of table */ - const checkedRowKeys = ref([]); - - /** handler to batch delete rows */ - async function handleBatchDelete() { - batchDeletify(); - try { - const rows = checkedRowKeys.value.map(id => getRowByDataId(id)).filter(Boolean); - await operations.batchDelete?.(rows as T[]); - window.$message?.success($t('common.deleteSuccess')); - checkedRowKeys.value = []; - } finally { - antiBatchDelete(); - } - } - - /** handler to delete row */ - async function handleDelete(id: T['id']) { - deletify(); - const row = getRowByDataId(id); - if (!row) return; - try { - await operations.delete?.(row); - window.$message?.success($t('common.deleteSuccess')); - checkedRowKeys.value = []; - } finally { - antiDelete(); - } - } - - return { - drawerVisible, - openDrawer, - closeDrawer, - operateType, - handleAdd, - editingData, - handleEdit, - checkedRowKeys, - deleting, - handleDelete, - batchDeleting, - handleBatchDelete - }; -} diff --git a/src/views/alova/user/index.vue b/src/views/alova/user/index.vue deleted file mode 100644 index 84b5ce2d..00000000 --- a/src/views/alova/user/index.vue +++ /dev/null @@ -1,226 +0,0 @@ - - - - - diff --git a/src/views/alova/user/modules/user-operate-drawer.vue b/src/views/alova/user/modules/user-operate-drawer.vue deleted file mode 100644 index 703e59c7..00000000 --- a/src/views/alova/user/modules/user-operate-drawer.vue +++ /dev/null @@ -1,169 +0,0 @@ - - - - - diff --git a/src/views/alova/user/modules/user-search.vue b/src/views/alova/user/modules/user-search.vue deleted file mode 100644 index 20fae5be..00000000 --- a/src/views/alova/user/modules/user-search.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - - diff --git a/src/views/manage/menu/index.vue b/src/views/manage/menu/index.vue index ee9060ae..7679a219 100644 --- a/src/views/manage/menu/index.vue +++ b/src/views/manage/menu/index.vue @@ -7,7 +7,7 @@ import { yesOrNoRecord } from '@/constants/common'; import { enableStatusRecord, menuTypeRecord } from '@/constants/business'; import { fetchGetAllPages, fetchGetMenuList } from '@/service/api'; import { useAppStore } from '@/store/modules/app'; -import { useTable, useTableOperate } from '@/hooks/common/table'; +import { defaultTransform, useNaivePaginatedTable, useTableOperate } from '@/hooks/common/table'; import { $t } from '@/locales'; import SvgIcon from '@/components/custom/svg-icon.vue'; import MenuOperateModal, { type OperateType } from './modules/menu-operate-modal.vue'; @@ -18,8 +18,9 @@ const { bool: visible, setTrue: openModal } = useBoolean(); const wrapperRef = ref(null); -const { columns, columnChecks, data, loading, pagination, getData, getDataByPage } = useTable({ - apiFn: fetchGetMenuList, +const { columns, columnChecks, data, loading, pagination, getData, getDataByPage } = useNaivePaginatedTable({ + api: () => fetchGetMenuList(), + transform: response => defaultTransform(response), columns: () => [ { type: 'selection', @@ -170,7 +171,7 @@ const { columns, columnChecks, data, loading, pagination, getData, getDataByPage ] }); -const { checkedRowKeys, onBatchDeleted, onDeleted } = useTableOperate(data, getData); +const { checkedRowKeys, onBatchDeleted, onDeleted } = useTableOperate(data, 'id', getData); const operateType = ref('add'); diff --git a/src/views/manage/role/index.vue b/src/views/manage/role/index.vue index c6cc82c5..230e0a8f 100644 --- a/src/views/manage/role/index.vue +++ b/src/views/manage/role/index.vue @@ -1,35 +1,30 @@