mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-03-01 00:23:11 +08:00
fix 分页字段配置问题
This commit is contained in:
@@ -3,7 +3,7 @@ import type { BasicTableProps } from '../types/table';
|
|||||||
import { computed, unref, ref, ComputedRef } from 'vue';
|
import { computed, unref, ref, ComputedRef } from 'vue';
|
||||||
|
|
||||||
import { isBoolean } from '@/utils/is';
|
import { isBoolean } from '@/utils/is';
|
||||||
import { DEFAULTPAGESIZE, PAGESIZES } from '../const';
|
import { APISETTING, DEFAULTPAGESIZE, PAGESIZES } from '../const';
|
||||||
|
|
||||||
export function usePagination(refProps: ComputedRef<BasicTableProps>) {
|
export function usePagination(refProps: ComputedRef<BasicTableProps>) {
|
||||||
const configRef = ref<PaginationProps>({});
|
const configRef = ref<PaginationProps>({});
|
||||||
@@ -14,6 +14,7 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) {
|
|||||||
if (!unref(show) || (isBoolean(pagination) && !pagination)) {
|
if (!unref(show) || (isBoolean(pagination) && !pagination)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const { pageField, totalField } = APISETTING;
|
||||||
return {
|
return {
|
||||||
pageSize: DEFAULTPAGESIZE,
|
pageSize: DEFAULTPAGESIZE,
|
||||||
pageSizes: PAGESIZES,
|
pageSizes: PAGESIZES,
|
||||||
@@ -21,6 +22,8 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) {
|
|||||||
showQuickJumper: true,
|
showQuickJumper: true,
|
||||||
...(isBoolean(pagination) ? {} : pagination),
|
...(isBoolean(pagination) ? {} : pagination),
|
||||||
...unref(configRef),
|
...unref(configRef),
|
||||||
|
page: unref(configRef)[pageField],
|
||||||
|
pageCount: unref(configRef)[totalField],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const urlPrefix = globSetting.urlPrefix || '';
|
|||||||
|
|
||||||
import router from '@/router';
|
import router from '@/router';
|
||||||
import { storage } from '@/utils/Storage';
|
import { storage } from '@/utils/Storage';
|
||||||
|
import { APISETTING } from '@/components/Table/src/const';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 数据处理,方便区分多种处理方式
|
* @description: 数据处理,方便区分多种处理方式
|
||||||
@@ -60,7 +61,8 @@ const transform: AxiosTransform = {
|
|||||||
return reject(data);
|
return reject(data);
|
||||||
}
|
}
|
||||||
// 这里 code,result,message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式
|
// 这里 code,result,message为 后台统一的字段,需要在 types.ts内修改为项目自己的接口返回格式
|
||||||
const { code, result, message } = data;
|
const { code, message } = data;
|
||||||
|
const result = data[APISETTING.listField];
|
||||||
// 请求成功
|
// 请求成功
|
||||||
const hasSuccess = data && Reflect.has(data, 'code') && code === ResultEnum.SUCCESS;
|
const hasSuccess = data && Reflect.has(data, 'code') && code === ResultEnum.SUCCESS;
|
||||||
// 是否显示提示信息
|
// 是否显示提示信息
|
||||||
|
|||||||
Reference in New Issue
Block a user