fix 分页字段配置问题

This commit is contained in:
xiaoma
2021-08-28 11:18:33 +08:00
parent a0490e3b97
commit ae001fc7bd
2 changed files with 7 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import type { BasicTableProps } from '../types/table';
import { computed, unref, ref, ComputedRef } from 'vue';
import { isBoolean } from '@/utils/is';
import { DEFAULTPAGESIZE, PAGESIZES } from '../const';
import { APISETTING, DEFAULTPAGESIZE, PAGESIZES } from '../const';
export function usePagination(refProps: ComputedRef<BasicTableProps>) {
const configRef = ref<PaginationProps>({});
@@ -14,6 +14,7 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) {
if (!unref(show) || (isBoolean(pagination) && !pagination)) {
return false;
}
const { pageField, totalField } = APISETTING;
return {
pageSize: DEFAULTPAGESIZE,
pageSizes: PAGESIZES,
@@ -21,6 +22,8 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) {
showQuickJumper: true,
...(isBoolean(pagination) ? {} : pagination),
...unref(configRef),
page: unref(configRef)[pageField],
pageCount: unref(configRef)[totalField],
};
});

View File

@@ -20,6 +20,7 @@ const urlPrefix = globSetting.urlPrefix || '';
import router from '@/router';
import { storage } from '@/utils/Storage';
import { APISETTING } from '@/components/Table/src/const';
/**
* @description: 数据处理,方便区分多种处理方式
@@ -60,7 +61,8 @@ const transform: AxiosTransform = {
return reject(data);
}
// 这里 coderesultmessage为 后台统一的字段,需要在 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;
// 是否显示提示信息