diff --git a/components.d.ts b/components.d.ts index bbec505..c554722 100644 --- a/components.d.ts +++ b/components.d.ts @@ -15,7 +15,6 @@ declare module 'vue' { TAvatar: typeof import('tdesign-vue-next')['Avatar'] TButton: typeof import('tdesign-vue-next')['Button'] TCard: typeof import('tdesign-vue-next')['Card'] - TCheckbox: typeof import('tdesign-vue-next')['Checkbox'] TDialog: typeof import('tdesign-vue-next')['Dialog'] TDropdown: typeof import('tdesign-vue-next')['Dropdown'] TForm: typeof import('tdesign-vue-next')['Form'] @@ -23,10 +22,11 @@ declare module 'vue' { THeader: typeof import('tdesign-vue-next')['Header'] TIcon: typeof import('tdesign-vue-next')['Icon'] TInput: typeof import('tdesign-vue-next')['Input'] + TInputNumber: typeof import('tdesign-vue-next')['InputNumber'] TLayout: typeof import('tdesign-vue-next')['Layout'] - TLink: typeof import('tdesign-vue-next')['Link'] TMenu: typeof import('tdesign-vue-next')['Menu'] TMenuItem: typeof import('tdesign-vue-next')['MenuItem'] + TPopconfirm: typeof import('tdesign-vue-next')['Popconfirm'] TSpace: typeof import('tdesign-vue-next')['Space'] TTable: typeof import('tdesign-vue-next')['Table'] TTag: typeof import('tdesign-vue-next')['Tag'] diff --git a/src/api/category.ts b/src/api/category.ts new file mode 100644 index 0000000..20bf5a3 --- /dev/null +++ b/src/api/category.ts @@ -0,0 +1,23 @@ +import httpClient from '@/api/httpClient' +import type { PageResult } from '@/model/base' +import type { Category,CategorySearchFilter,CategoryDeleteRequest } from '@/model/category' + +export const searchCategoryRequest = (categoryFilterParam:CategorySearchFilter ) => { + return httpClient.get>('/categories',categoryFilterParam) +} + +export const createCategoryRequest = (category: Pick) => { + return httpClient.post('/categories',category) +} + +export const deleteCategoryRequest = (categoryDeleteParam:CategoryDeleteRequest) => { + return httpClient.delete(`/categories`,categoryDeleteParam) +} + +export const searchCategoryByIdRequest = (id: string) => { + return httpClient.get(`/categories/${id}`) +} + +export const updateCategoryByIdRequest = (id: string,category: Pick) => { + return httpClient.put(`/categories/${id}`,category) +} \ No newline at end of file diff --git a/src/api/httpClient.ts b/src/api/httpClient.ts index 609c338..7aa0f3a 100644 --- a/src/api/httpClient.ts +++ b/src/api/httpClient.ts @@ -1,5 +1,5 @@ -import axios, { type AxiosInstance } from 'axios' -import type { ErrorResponse } from '@/model/base' +import axios, { type AxiosInstance, } from 'axios' +import type { ErrorResponse,ErrorResponseList } from '@/model/base' import { MessagePlugin } from 'tdesign-vue-next' import { useAppStore } from '@/stores/app' @@ -9,18 +9,22 @@ const client: AxiosInstance = axios.create({ }) const handleError = (errorResponse: ErrorResponse) => { + MessagePlugin.error(errorResponse.message) } client.interceptors.response.use( (response) => { - if (response.data.code) { - handleError(response.data) - return Promise.reject(response.data) - } return response }, (error) => { - const errorResponse = error.response.data as ErrorResponse + let errorResponse: ErrorResponse; + if (Array.isArray(error.response.data)) { + const errorResponseList = error.response.data as ErrorResponseList; + errorResponse = errorResponseList[0]; + } else { + // 否则,将其视为单个 ErrorResponse + errorResponse = error.response.data as ErrorResponse; + } handleError(errorResponse) return Promise.reject(errorResponse) } @@ -43,8 +47,8 @@ export default { const response = await client.post(url, data) return response.data as T }, - delete: async (url: string) => { - await client.delete(url) + delete: async (url: string,params?:any) => { + await client.delete(url,{params}) }, put: async (url: string, data: Record = {}) => { const response = await client.put(url, data) diff --git a/src/composables/useSearchable.ts b/src/composables/useSearchable.ts index 6e99955..265de59 100644 --- a/src/composables/useSearchable.ts +++ b/src/composables/useSearchable.ts @@ -15,9 +15,9 @@ export const useSearchable = ( loading.value = true const result = await api({...filter.value, page: pagination.page, size: pagination.size, ...defaultFilter}) data.value = result.data - pagination.page = result.paging.page - pagination.size = result.paging.size - pagination.total = result.paging.total + pagination.page = result.pagination.page + pagination.size = result.pagination.size + pagination.total = result.pagination.total loading.value = false } diff --git a/src/model/base.ts b/src/model/base.ts index e6adf25..2e9600d 100644 --- a/src/model/base.ts +++ b/src/model/base.ts @@ -5,7 +5,7 @@ export interface ErrorResponse { message: string; } export interface BaseModel { - id: number + id: string createdTime: string updateTime: string } @@ -25,6 +25,8 @@ export interface BaseFilterRequest extends Partial{ } export interface PageResult { - paging: Paging, + pagination: Paging, data: T[] -} \ No newline at end of file +} + +export interface ErrorResponseList extends Array {} \ No newline at end of file diff --git a/src/model/category.ts b/src/model/category.ts new file mode 100644 index 0000000..78e4094 --- /dev/null +++ b/src/model/category.ts @@ -0,0 +1,23 @@ +import type { AuditBaseModel,Paging } from '@/model/base' + + +export interface Category extends AuditBaseModel{ + name: string + code:string + order: number +} + + +export interface CategorySearchFilter extends Partial{ + order?: string +} + +export interface CategoryDeleteRequest{ + id:string +} + +export interface UpdateCategoryRequest{ + name: string + code:string + order: number +} diff --git a/src/model/classify.ts b/src/model/classify.ts deleted file mode 100644 index c1b5d1e..0000000 --- a/src/model/classify.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { BaseModel } from '@/model/base' - -export interface Classify extends BaseModel{ - numbering:string - name: string - sort: string -} - diff --git a/src/pages/classify/components/ClassifyDialog.vue b/src/pages/category/components/CategoryDialog.vue similarity index 65% rename from src/pages/classify/components/ClassifyDialog.vue rename to src/pages/category/components/CategoryDialog.vue index 8d6e8d1..9f81fc5 100644 --- a/src/pages/classify/components/ClassifyDialog.vue +++ b/src/pages/category/components/CategoryDialog.vue @@ -5,36 +5,45 @@ :confirmBtn="confirmBtn" :closeOnOverlayClick="false" @close="handleCloseDialog" - @confirm="fetchSaveClassifyData" + @confirm="SaveCategoryData" > - + - + - - + + - - + + + + + + diff --git a/src/pages/classify/index.vue b/src/pages/classify/index.vue deleted file mode 100644 index ed89e4b..0000000 --- a/src/pages/classify/index.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - - - diff --git a/src/pages/common/login.vue b/src/pages/common/login.vue index 5932965..b2998ff 100644 --- a/src/pages/common/login.vue +++ b/src/pages/common/login.vue @@ -20,6 +20,7 @@ const handleLogin = async () => { return } try { + loading.value = true await appStore.login(loginForm) } finally { loading.value = false diff --git a/src/router/index.ts b/src/router/index.ts index c1a3dd8..da251dd 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -6,9 +6,9 @@ import Layout from '@/layouts/Layout.vue' export const asyncRoutes: RouteRecordRaw[] = [ { - name: 'classify', - path: 'classify', - component: () => import('@/pages/classify/index.vue'), + name: 'category', + path: 'category', + component: () => import('@/pages/category/index.vue'), meta: { title: '分类管理', icon: 'system-3' @@ -24,7 +24,7 @@ const router = createRouter({ component: Layout, path: '/', redirect: { - name: 'classify' + name: 'category' }, children: asyncRoutes },