Merge branch 'dev/net' into develop
This commit is contained in:
commit
92a3d03cde
1 changed files with 7 additions and 4 deletions
|
|
@ -2,17 +2,19 @@ import { ref } from 'vue';
|
|||
import { defineStore } from 'pinia';
|
||||
import { Pagination } from '../types';
|
||||
import { api } from 'src/boot/axios';
|
||||
import { Branch, BranchCreate } from './types';
|
||||
import { Branch, BranchCreate, BranchWithChildren } from './types';
|
||||
|
||||
const useBranchStore = defineStore('api-branch', () => {
|
||||
const data = ref<Pagination<Branch[]>>();
|
||||
|
||||
async function fetchList(
|
||||
async function fetchList<T extends Branch>(
|
||||
opts?: {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
zipCode?: string;
|
||||
query?: string;
|
||||
tree?: boolean;
|
||||
filter?: 'head' | 'sub';
|
||||
},
|
||||
flow?: {
|
||||
sessionId: string;
|
||||
|
|
@ -28,10 +30,11 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
if (opts?.page && opts.page > 0) params.append('page', `${opts.page}`);
|
||||
if (opts?.zipCode) params.append('zipCode', opts.zipCode);
|
||||
if (opts?.query) params.append('query', opts.query);
|
||||
if (opts?.tree) params.append('tree', 'true');
|
||||
|
||||
const query = params.toString();
|
||||
|
||||
const res = await api.get<Pagination<Branch[]>>(
|
||||
const res = await api.get<Pagination<T[]>>(
|
||||
`/branch${(params && '?'.concat(query)) || ''}`,
|
||||
{
|
||||
headers: {
|
||||
|
|
@ -44,7 +47,7 @@ const useBranchStore = defineStore('api-branch', () => {
|
|||
|
||||
if (res && res.status === 200) {
|
||||
data.value = res.data;
|
||||
return data.value;
|
||||
return data.value as Pagination<T[]>;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue