feat: add params

This commit is contained in:
Methapon Metanipat 2024-10-29 08:49:27 +07:00
parent 0fb882b308
commit 0c3eeef35e

View file

@ -46,23 +46,14 @@ const useEmployeeStore = defineStore('api-employee', () => {
query?: string;
gender?: string;
status?: Status;
passport?: boolean;
visa: boolean;
zipCode?: string;
customerId?: string;
}) {
const params = new URLSearchParams();
for (const [k, v] of Object.entries(opts || {})) {
v !== undefined && params.append(k, v.toString());
}
const query = params.toString();
const res = await api.get<Pagination<Employee[]>>(
`/employee${(params && '?'.concat(query)) || ''}`,
{
headers: { 'X-Rtid': flowStore.rtid },
},
);
const res = await api.get<Pagination<Employee[]>>(`/employee`, {
params: opts,
});
if (res && res.status === 200) {
data.value = res.data;