delete admin
This commit is contained in:
Vendored
+17
@@ -10,9 +10,12 @@ export {}
|
|||||||
declare module '@vue/runtime-core' {
|
declare module '@vue/runtime-core' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
_index: typeof import('./src/core/components/_sample/_index.vue')['default']
|
_index: typeof import('./src/core/components/_sample/_index.vue')['default']
|
||||||
|
AAffix: typeof import('ant-design-vue/es')['Affix']
|
||||||
AAvatar: typeof import('ant-design-vue/es')['Avatar']
|
AAvatar: typeof import('ant-design-vue/es')['Avatar']
|
||||||
|
ABadge: typeof import('ant-design-vue/es')['Badge']
|
||||||
AButton: typeof import('ant-design-vue/es')['Button']
|
AButton: typeof import('ant-design-vue/es')['Button']
|
||||||
ACard: typeof import('ant-design-vue/es')['Card']
|
ACard: typeof import('ant-design-vue/es')['Card']
|
||||||
|
ACheckbox: typeof import('ant-design-vue/es')['Checkbox']
|
||||||
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
|
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
|
||||||
ADivider: typeof import('ant-design-vue/es')['Divider']
|
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||||
ADrawer: typeof import('ant-design-vue/es')['Drawer']
|
ADrawer: typeof import('ant-design-vue/es')['Drawer']
|
||||||
@@ -29,9 +32,23 @@ declare module '@vue/runtime-core' {
|
|||||||
AMenuDivider: typeof import('ant-design-vue/es')['MenuDivider']
|
AMenuDivider: typeof import('ant-design-vue/es')['MenuDivider']
|
||||||
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
|
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
|
||||||
AModal: typeof import('ant-design-vue/es')['Modal']
|
AModal: typeof import('ant-design-vue/es')['Modal']
|
||||||
|
APagination: typeof import('ant-design-vue/es')['Pagination']
|
||||||
|
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
|
||||||
|
APopover: typeof import('ant-design-vue/es')['Popover']
|
||||||
|
ARadio: typeof import('ant-design-vue/es')['Radio']
|
||||||
|
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
|
||||||
|
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
|
||||||
|
ASelect: typeof import('ant-design-vue/es')['Select']
|
||||||
|
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
|
||||||
ASpin: typeof import('ant-design-vue/es')['Spin']
|
ASpin: typeof import('ant-design-vue/es')['Spin']
|
||||||
ASubMenu: typeof import('ant-design-vue/es')['SubMenu']
|
ASubMenu: typeof import('ant-design-vue/es')['SubMenu']
|
||||||
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
||||||
|
ATable: typeof import('ant-design-vue/es')['Table']
|
||||||
|
ATabPane: typeof import('ant-design-vue/es')['TabPane']
|
||||||
|
ATabs: typeof import('ant-design-vue/es')['Tabs']
|
||||||
|
ATextarea: typeof import('ant-design-vue/es')['Textarea']
|
||||||
|
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
|
||||||
|
AUpload: typeof import('ant-design-vue/es')['Upload']
|
||||||
BaseButton: typeof import('./src/core/components/BaseButton/index.ts')['default']
|
BaseButton: typeof import('./src/core/components/BaseButton/index.ts')['default']
|
||||||
BaseCard: typeof import('./src/core/components/BaseCard/index.ts')['default']
|
BaseCard: typeof import('./src/core/components/BaseCard/index.ts')['default']
|
||||||
BaseDatePicker: typeof import('./src/core/components/BaseDatePicker/index.ts')['default']
|
BaseDatePicker: typeof import('./src/core/components/BaseDatePicker/index.ts')['default']
|
||||||
|
|||||||
+53
-3
@@ -1,6 +1,6 @@
|
|||||||
import useAxios from '@core/utils/useAxios'
|
import useAxios from '@core/utils/useAxios'
|
||||||
import type { AddId, User } from '@/model/user'
|
import type { AddId, User } from '@/model/user'
|
||||||
import type { TableInput } from '@core/type/baseTable'
|
import type { TableInput, TableOutput } from '@core/type/baseTable'
|
||||||
import type {Referrals} from '@/model/referrals'
|
import type {Referrals} from '@/model/referrals'
|
||||||
import type {Funds} from "@/model/funds";
|
import type {Funds} from "@/model/funds";
|
||||||
|
|
||||||
@@ -23,8 +23,58 @@ export const updateUser = async (id: number, obj: User) =>
|
|||||||
|
|
||||||
export const deleteUser = async (id: number) => await useAxios.delete(`/admin/user/${id}`)
|
export const deleteUser = async (id: number) => await useAxios.delete(`/admin/user/${id}`)
|
||||||
|
|
||||||
export const getUserTable = async (params: TableInput) =>
|
function isUserTableOutput(data: unknown): data is TableOutput<User> {
|
||||||
await useAxios.post<Array<User>>('/admin/user/table', params)
|
if (data === null || typeof data !== 'object') return false
|
||||||
|
const d = data as Record<string, unknown>
|
||||||
|
return Array.isArray(d.rows) && d.query !== null && typeof d.query === 'object'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** BaseTable expects `{ rows, query }`; backend may return a plain array or Laravel paginator. */
|
||||||
|
export const getUserTable = async (params: TableInput): Promise<TableOutput<User>> => {
|
||||||
|
const raw = await useAxios.post<unknown>('/admin/user/table', params)
|
||||||
|
if (isUserTableOutput(raw)) {
|
||||||
|
return raw
|
||||||
|
}
|
||||||
|
// Laravel LengthAwarePaginator
|
||||||
|
if (raw && typeof raw === 'object' && Array.isArray((raw as { data?: unknown }).data)) {
|
||||||
|
const r = raw as {
|
||||||
|
data: User[]
|
||||||
|
current_page?: number
|
||||||
|
per_page?: number
|
||||||
|
total?: number
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
rows: r.data,
|
||||||
|
query: {
|
||||||
|
...params,
|
||||||
|
page: r.current_page ?? params.page,
|
||||||
|
limit: r.per_page ?? params.limit,
|
||||||
|
total: r.total ?? r.data.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Array.isArray(raw)) {
|
||||||
|
return {
|
||||||
|
rows: raw as User[],
|
||||||
|
query: { ...params, total: raw.length }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (raw && typeof raw === 'object' && Array.isArray((raw as { rows?: User[] }).rows)) {
|
||||||
|
const r = raw as { rows: User[]; total?: number }
|
||||||
|
return {
|
||||||
|
rows: r.rows,
|
||||||
|
query: { ...params, total: r.total ?? r.rows.length }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const users = (raw as { users?: User[] })?.users
|
||||||
|
if (Array.isArray(users)) {
|
||||||
|
return {
|
||||||
|
rows: users,
|
||||||
|
query: { ...params, total: users.length }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { rows: [], query: { ...params, total: 0 } }
|
||||||
|
}
|
||||||
|
|
||||||
export const changeUserActivation = async (id: number) =>
|
export const changeUserActivation = async (id: number) =>
|
||||||
await useAxios.get(`/admin/user/active/${id}`)
|
await useAxios.get(`/admin/user/active/${id}`)
|
||||||
|
|||||||
@@ -36,16 +36,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<!-- <a-tooltip
|
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('delete', record.id)">
|
||||||
placement="bottom"
|
|
||||||
class="cursor-pointer"
|
|
||||||
@click="emits('delete', record.id)"
|
|
||||||
>
|
|
||||||
<template #title>
|
<template #title>
|
||||||
<span>حذف</span>
|
<span>حذف مدیر</span>
|
||||||
</template>
|
</template>
|
||||||
<Icon icon="vuesax-linear:trash" color="#EB3535" />
|
<Icon icon="vuesax-linear:user-remove" color="#EB3535" />
|
||||||
</a-tooltip>-->
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</BaseTable>
|
</BaseTable>
|
||||||
|
|||||||
@@ -2,7 +2,14 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- <BasicMainCard>-->
|
<!-- <BasicMainCard>-->
|
||||||
<div class="flex w-full h-full">
|
<div class="flex w-full h-full">
|
||||||
<tbl ref="table" class="w-full h-full" @info="info" @edit="edit" @add="add" />
|
<tbl
|
||||||
|
ref="table"
|
||||||
|
class="w-full h-full"
|
||||||
|
@info="info"
|
||||||
|
@edit="edit"
|
||||||
|
@add="add"
|
||||||
|
@delete="deleteManager"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
|
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
|
||||||
<component :is="selectedComponent" class="mr-5" />-->
|
<component :is="selectedComponent" class="mr-5" />-->
|
||||||
@@ -161,8 +168,8 @@ const resetData = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete
|
//delete — DELETE /admin/user/:id
|
||||||
const deleteItem = (id: number) => confirmDeleteItem('کاربر', id, deleteUser, refreshTable)
|
const deleteManager = (id: number) => confirmDeleteItem('مدیر', id, deleteUser, refreshTable)
|
||||||
|
|
||||||
/* Modal.confirm({
|
/* Modal.confirm({
|
||||||
title: 'آیا از حذف کاربر اطمینان دارید؟',
|
title: 'آیا از حذف کاربر اطمینان دارید؟',
|
||||||
|
|||||||
Reference in New Issue
Block a user