feat: table 接口 对接
This commit is contained in:
parent
84a022e862
commit
50fe6619c8
|
@ -1 +1,2 @@
|
||||||
VITE_API_BASE_URL= 'http://localhost:8080'
|
VITE_API_BASE_URL= 'http://192.168.200.10:8081'
|
||||||
|
VUE_APP_Access_Control_Allow_Origin= '*'
|
|
@ -11,6 +11,12 @@ export default mergeConfig(
|
||||||
fs: {
|
fs: {
|
||||||
strict: true,
|
strict: true,
|
||||||
},
|
},
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://192.168.200.10:8081',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
eslint({
|
eslint({
|
||||||
|
|
|
@ -76,12 +76,12 @@ const transform: AxiosTransform = {
|
||||||
throw new Error(t('api.apiRequestFailed'));
|
throw new Error(t('api.apiRequestFailed'));
|
||||||
}
|
}
|
||||||
// 这里 code,result,message为 后台统一的字段
|
// 这里 code,result,message为 后台统一的字段
|
||||||
const { code, result, message } = data;
|
const { code, data: dataResult, message } = data;
|
||||||
|
|
||||||
// TODO:定义完成功code后需要重写
|
// TODO:定义完成功code后需要重写
|
||||||
const hasSuccess = data && Reflect.has(data, 'code') && Number(code) === ResultEnum.SUCCESS;
|
const hasSuccess = data && Reflect.has(data, 'code') && Number(code) === ResultEnum.SUCCESS;
|
||||||
if (hasSuccess) {
|
if (hasSuccess) {
|
||||||
return result;
|
return dataResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在此处根据自己项目的实际情况对不同的code执行不同的操作
|
// 在此处根据自己项目的实际情况对不同的code执行不同的操作
|
||||||
|
|
|
@ -2,13 +2,15 @@ import MSR from '@/api/http/index';
|
||||||
import { GetApiTestList, GetApiTestListUrl } from '@/api/requrls/api-test';
|
import { GetApiTestList, GetApiTestListUrl } from '@/api/requrls/api-test';
|
||||||
import { QueryParams } from '@/components/ms-table/useTable';
|
import { QueryParams } from '@/components/ms-table/useTable';
|
||||||
import { ApiTestListI } from '@/models/api-test';
|
import { ApiTestListI } from '@/models/api-test';
|
||||||
import CommonReponse from '@/models/common';
|
|
||||||
|
|
||||||
export function getTableList(params: QueryParams) {
|
export function getTableList(params: QueryParams) {
|
||||||
const { current, pageSize } = params;
|
const { current, pageSize } = params;
|
||||||
return MSR.get<CommonReponse<ApiTestListI>>({ url: `${GetApiTestList}/${current}/${pageSize}` });
|
return MSR.post<ApiTestListI>({
|
||||||
|
url: GetApiTestList,
|
||||||
|
data: { current, pageSize, projectId: 'test-project-id' },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getlist() {
|
export function getlist() {
|
||||||
return MSR.get<CommonReponse<ApiTestListI>>({ url: GetApiTestListUrl });
|
return MSR.get<ApiTestListI>({ url: GetApiTestListUrl });
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export const GetApiTestListUrl = '/mock/list/menu';
|
export const GetApiTestListUrl = '/mock/list/menu';
|
||||||
export const GetApiTestList = '/mock/api-test/define/list/';
|
export const GetApiTestList = '/api/definition/page';
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
.arco-reset {
|
||||||
/** 表格样式 **/
|
/** 表格样式 **/
|
||||||
.arco-table-cell {
|
.arco-table-cell {
|
||||||
.circle {
|
.circle {
|
||||||
|
@ -17,3 +18,4 @@
|
||||||
.arco-tabs-nav-add-btn {
|
.arco-tabs-nav-add-btn {
|
||||||
font-size: var(--font-size-base);
|
font-size: var(--font-size-base);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ export interface MsTabelProps extends MsPaginationI {
|
||||||
// 表格数据 - 详见 TableData https://arco.design/web-vue/components/table-data;
|
// 表格数据 - 详见 TableData https://arco.design/web-vue/components/table-data;
|
||||||
data: TableData[];
|
data: TableData[];
|
||||||
// 表格尺寸
|
// 表格尺寸
|
||||||
size?: 'small' | 'default' | 'large';
|
size?: 'mini' | 'small' | 'default' | 'large';
|
||||||
// 表格是否可滚动
|
// 表格是否可滚动
|
||||||
scroll?: {
|
scroll?: {
|
||||||
x?: number | string;
|
x?: number | string;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { MsTabelProps, MsTableData, MsTableColumn } from './type';
|
import { MsTabelProps, MsTableData, MsTableColumn } from './type';
|
||||||
import CommonReponse from '@/models/common';
|
|
||||||
import { ApiTestListI } from '@/models/api-test';
|
import { ApiTestListI } from '@/models/api-test';
|
||||||
|
|
||||||
export interface Pagination {
|
export interface Pagination {
|
||||||
|
@ -19,11 +18,11 @@ export interface QueryParams {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetListFunc = (v: QueryParams) => Promise<CommonReponse<ApiTestListI>>;
|
type GetListFunc = (v: QueryParams) => Promise<ApiTestListI>;
|
||||||
export default function useTbleProps(loadListFunc: GetListFunc, props?: Partial<MsTabelProps>) {
|
export default function useTbleProps(loadListFunc: GetListFunc, props?: Partial<MsTabelProps>) {
|
||||||
const defaultProps: MsTabelProps = {
|
const defaultProps: MsTabelProps = {
|
||||||
'bordered': true,
|
'bordered': true,
|
||||||
'size': 'small',
|
'size': 'mini',
|
||||||
'scroll': { y: 550, x: '1400px' },
|
'scroll': { y: 550, x: '1400px' },
|
||||||
'expandable': false,
|
'expandable': false,
|
||||||
'loading': true,
|
'loading': true,
|
||||||
|
@ -85,7 +84,7 @@ export default function useTbleProps(loadListFunc: GetListFunc, props?: Partial<
|
||||||
const loadList = async () => {
|
const loadList = async () => {
|
||||||
const { current, pageSize } = propsRes.value.pagination as Pagination;
|
const { current, pageSize } = propsRes.value.pagination as Pagination;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const { data } = await loadListFunc({
|
const data = await loadListFunc({
|
||||||
current,
|
current,
|
||||||
pageSize,
|
pageSize,
|
||||||
...loadListParams.value,
|
...loadListParams.value,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<a-layout class="layout" :class="{ mobile: appStore.hideMenu }">
|
<a-layout class="layout arco-reset" :class="{ mobile: appStore.hideMenu }">
|
||||||
<div v-if="navbar" class="layout-navbar">
|
<div v-if="navbar" class="layout-navbar">
|
||||||
<NavBar />
|
<NavBar />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export default interface CommonReponse<T> {
|
export default interface CommonReponse<T> {
|
||||||
code: number;
|
code: number;
|
||||||
message: string;
|
message: string;
|
||||||
|
messageDetail: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,18 @@ export default ({ mock, setup }: { mock?: boolean; setup: () => void }) => {
|
||||||
if (mock !== false && debug) setup();
|
if (mock !== false && debug) setup();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const successResponseWrap = (result: unknown) => {
|
export const successResponseWrap = (data: unknown) => {
|
||||||
return {
|
return {
|
||||||
result,
|
data,
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
message: '请求成功',
|
message: '请求成功',
|
||||||
code: 0,
|
code: 0,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const failResponseWrap = (result: unknown, message: string, code = 50000) => {
|
export const failResponseWrap = (data: unknown, message: string, code = 50000) => {
|
||||||
return {
|
return {
|
||||||
result,
|
data,
|
||||||
status: 'fail',
|
status: 'fail',
|
||||||
message,
|
message,
|
||||||
code,
|
code,
|
||||||
|
|
|
@ -18,10 +18,11 @@ export interface RequestOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Result<T = any> {
|
export interface Result<T = any> {
|
||||||
code: string;
|
code: number;
|
||||||
type: 'success' | 'error' | 'warning';
|
type: 'success' | 'error' | 'warning';
|
||||||
message: string;
|
message: string;
|
||||||
result: T;
|
messageDetail?: string;
|
||||||
|
data: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
// multipart/form-data: upload file
|
// multipart/form-data: upload file
|
||||||
|
|
Loading…
Reference in New Issue