fix(projects): fix example code

This commit is contained in:
Soybean
2025-08-27 18:33:16 +08:00
parent 30b5e6e96a
commit e46b02d5a9
17 changed files with 99 additions and 777 deletions

View File

@@ -1,39 +1,33 @@
<script setup lang="tsx">
import { reactive } from 'vue';
import { NButton, NPopconfirm, NTag } from 'naive-ui';
import { enableStatusRecord, userGenderRecord } from '@/constants/business';
import { fetchGetUserList } 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 UserOperateDrawer from './modules/user-operate-drawer.vue';
import UserSearch from './modules/user-search.vue';
const appStore = useAppStore();
const {
columns,
columnChecks,
data,
getData,
getDataByPage,
loading,
mobilePagination,
searchParams,
resetSearchParams
} = useTable({
apiFn: fetchGetUserList,
showTotal: true,
apiParams: {
current: 1,
size: 10,
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
// the value can not be undefined, otherwise the property in Form will not be reactive
status: null,
userName: null,
userGender: null,
nickName: null,
userPhone: null,
userEmail: null
const searchParams: Api.SystemManage.UserSearchParams = reactive({
current: 1,
size: 10,
status: null,
userName: null,
userGender: null,
nickName: null,
userPhone: null,
userEmail: null
});
const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagination } = useNaivePaginatedTable({
api: () => fetchGetUserList(searchParams),
transform: response => defaultTransform(response),
onPaginationParamsChange: params => {
searchParams.current = params.page;
searchParams.size = params.pageSize;
},
columns: () => [
{
@@ -45,7 +39,8 @@ const {
key: 'index',
title: $t('common.index'),
align: 'center',
width: 64
width: 64,
render: (_, index) => index + 1
},
{
key: 'userName',
@@ -147,7 +142,7 @@ const {
onBatchDeleted,
onDeleted
// closeDrawer
} = useTableOperate(data, getData);
} = useTableOperate(data, 'id', getData);
async function handleBatchDelete() {
// request
@@ -170,7 +165,7 @@ function edit(id: number) {
<template>
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
<UserSearch v-model:model="searchParams" @reset="resetSearchParams" @search="getDataByPage" />
<UserSearch v-model:model="searchParams" @search="getDataByPage" />
<NCard :title="$t('page.manage.user.title')" :bordered="false" size="small" class="card-wrapper sm:flex-1-hidden">
<template #header-extra>
<TableHeaderOperation