diff --git a/src/api/lab/seata.ts b/src/api/lab/seata.ts index 01e819f2..ab1156c8 100644 --- a/src/api/lab/seata.ts +++ b/src/api/lab/seata.ts @@ -1,4 +1,4 @@ -import { SeataFormData } from '@/types'; +import { SeataFormData } from '@/types/api/lab/seata'; import request from '@/utils/request'; /** @@ -9,7 +9,7 @@ export function payOrder(data: SeataFormData) { return request({ url: '/youlai-lab/api/v1/seata/order/_pay', method: 'post', - data: data + data: data, }); } @@ -20,7 +20,7 @@ export function payOrder(data: SeataFormData) { export function getSeataData() { return request({ url: '/youlai-lab/api/v1/seata/data', - method: 'get' + method: 'get', }); } @@ -31,6 +31,6 @@ export function getSeataData() { export function resetSeataData() { return request({ url: '/youlai-lab/api/v1/seata/data/_reset', - method: 'put' + method: 'put', }); } diff --git a/src/api/login/index.ts b/src/api/login/index.ts index 865b428f..b5fbaf8f 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -1,4 +1,8 @@ -import { Captcha, LoginFormData, LoginResponseData } from '@/types'; +import { + Captcha, + LoginFormData, + LoginResponseData, +} from '@/types/api/system/login'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -12,8 +16,8 @@ export function login(data: LoginFormData): AxiosPromise { method: 'post', params: data, headers: { - Authorization: 'Basic bWFsbC1hZG1pbi13ZWI6MTIzNDU2' // 客户端信息Base64明文:mall-admin-web:123456 - } + Authorization: 'Basic bWFsbC1hZG1pbi13ZWI6MTIzNDU2', // 客户端信息Base64明文:mall-admin-web:123456 + }, }); } @@ -23,7 +27,7 @@ export function login(data: LoginFormData): AxiosPromise { export function logout() { return request({ url: '/youlai-auth/oauth/logout', - method: 'delete' + method: 'delete', }); } @@ -33,6 +37,6 @@ export function logout() { export function getCaptcha(): AxiosPromise { return request({ url: '/captcha?t=' + new Date().getTime().toString(), - method: 'get' + method: 'get', }); } diff --git a/src/api/oms/order.ts b/src/api/oms/order.ts index 8a8228d7..be49432b 100644 --- a/src/api/oms/order.ts +++ b/src/api/oms/order.ts @@ -1,4 +1,4 @@ -import { OrderPageResult, OrderQueryParam } from '@/types'; +import { OrderPageResult, OrderQueryParam } from '@/types/api/oms/order'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -13,7 +13,7 @@ export function listOrderPages( return request({ url: '/mall-oms/api/v1/orders', method: 'get', - params: queryParams + params: queryParams, }); } @@ -25,6 +25,6 @@ export function listOrderPages( export function getOrderDetail(orderId: number) { return request({ url: '/mall-oms/api/v1/orders/' + orderId, - method: 'get' + method: 'get', }); } diff --git a/src/api/pms/attribute.ts b/src/api/pms/attribute.ts index 5afb4d69..af4c4403 100644 --- a/src/api/pms/attribute.ts +++ b/src/api/pms/attribute.ts @@ -9,7 +9,7 @@ export function listAttributes(params: object) { return request({ url: '/mall-pms/api/v1/attributes', method: 'get', - params: params + params: params, }); } @@ -22,6 +22,6 @@ export function saveAttributeBatch(data: object) { return request({ url: '/mall-pms/api/v1/attributes/batch', method: 'post', - data: data + data: data, }); } diff --git a/src/api/pms/brand.ts b/src/api/pms/brand.ts index 0cc8b68e..ca35a384 100644 --- a/src/api/pms/brand.ts +++ b/src/api/pms/brand.ts @@ -2,8 +2,8 @@ import { BrandFormData, BrandItem, BrandPageResult, - BrandQueryParam -} from '@/types'; + BrandQueryParam, +} from '@/types/api/pms/brand'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -18,7 +18,7 @@ export function listBrandPages( return request({ url: '/mall-pms/api/v1/brands/page', method: 'get', - params: queryParams + params: queryParams, }); } @@ -33,7 +33,7 @@ export function listBrands( return request({ url: '/mall-pms/api/v1/brands', method: 'get', - params: queryParams + params: queryParams, }); } @@ -45,7 +45,7 @@ export function listBrands( export function getBrandFormDetail(id: number): AxiosPromise { return request({ url: '/mall-pms/api/v1/brands/' + id, - method: 'get' + method: 'get', }); } @@ -58,7 +58,7 @@ export function addBrand(data: BrandFormData) { return request({ url: '/mall-pms/api/v1/brands', method: 'post', - data: data + data: data, }); } @@ -72,7 +72,7 @@ export function updateBrand(id: number, data: BrandFormData) { return request({ url: '/mall-pms/api/v1/brands/' + id, method: 'put', - data: data + data: data, }); } @@ -84,6 +84,6 @@ export function updateBrand(id: number, data: BrandFormData) { export function deleteBrands(ids: string) { return request({ url: '/mall-pms/api/v1/brands/' + ids, - method: 'delete' + method: 'delete', }); } diff --git a/src/api/pms/category.ts b/src/api/pms/category.ts index 04018ba8..43208e47 100644 --- a/src/api/pms/category.ts +++ b/src/api/pms/category.ts @@ -9,7 +9,7 @@ export function listCategories(queryParams: object) { return request({ url: '/mall-pms/api/v1/categories', method: 'get', - params: queryParams + params: queryParams, }); } @@ -22,7 +22,7 @@ export function listCascadeCategories(queryParams?: object) { return request({ url: '/mall-pms/api/v1/categories/cascade', method: 'get', - params: queryParams + params: queryParams, }); } @@ -34,7 +34,7 @@ export function listCascadeCategories(queryParams?: object) { export function getCategoryDetail(id: number) { return request({ url: '/mall-pms/api/v1/categories/' + id, - method: 'get' + method: 'get', }); } @@ -47,7 +47,7 @@ export function addCategory(data: object) { return request({ url: '/mall-pms/api/v1/categories', method: 'post', - data: data + data: data, }); } @@ -61,7 +61,7 @@ export function updateCategory(id: number, data: object) { return request({ url: '/mall-pms/api/v1/categories/' + id, method: 'put', - data: data + data: data, }); } @@ -73,7 +73,7 @@ export function updateCategory(id: number, data: object) { export function deleteCategories(ids: string) { return request({ url: '/mall-pms/api/v1/categories/' + ids, - method: 'delete' + method: 'delete', }); } @@ -87,6 +87,6 @@ export function updateCategoryPart(id: number, data: object) { return request({ url: '/mall-pms/api/v1/categories/' + id, method: 'patch', - data: data + data: data, }); } diff --git a/src/api/pms/goods.ts b/src/api/pms/goods.ts index 9b9b5121..a8b768a6 100644 --- a/src/api/pms/goods.ts +++ b/src/api/pms/goods.ts @@ -1,4 +1,8 @@ -import { GoodsDetail, GoodsPageResult, GoodsQueryParam } from '@/types'; +import { + GoodsDetail, + GoodsPageResult, + GoodsQueryParam, +} from '@/types/api/pms/goods'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -7,13 +11,13 @@ import { AxiosPromise } from 'axios'; * * @param queryParams */ -export function listGoodsPages( +export function listPageGoods( queryParams: GoodsQueryParam ): AxiosPromise { return request({ url: '/mall-pms/api/v1/goods/page', method: 'get', - params: queryParams + params: queryParams, }); } @@ -25,7 +29,7 @@ export function listGoodsPages( export function getGoodsDetail(id: string): AxiosPromise { return request({ url: '/mall-pms/api/v1/goods/' + id, - method: 'get' + method: 'get', }); } @@ -38,7 +42,7 @@ export function addGoods(data: object) { return request({ url: '/mall-pms/api/v1/goods', method: 'post', - data: data + data: data, }); } @@ -52,7 +56,7 @@ export function updateGoods(id: number, data: object) { return request({ url: '/mall-pms/api/v1/goods/' + id, method: 'put', - data: data + data: data, }); } @@ -64,6 +68,6 @@ export function updateGoods(id: number, data: object) { export function deleteGoods(ids: string) { return request({ url: '/mall-pms/api/v1/goods/' + ids, - method: 'delete' + method: 'delete', }); } diff --git a/src/api/sms/advert.ts b/src/api/sms/advert.ts index 3587d8d1..21f18e82 100644 --- a/src/api/sms/advert.ts +++ b/src/api/sms/advert.ts @@ -1,4 +1,8 @@ -import { AdvertFormData, AdvertPageResult, AdvertQueryParam } from '@/types'; +import { + AdvertFormData, + AdvertPageResult, + AdvertQueryParam, +} from '@/types/api/sms/advert'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -7,13 +11,13 @@ import { AxiosPromise } from 'axios'; * * @param queryParams */ -export function listAdvertPages( +export function listAdvertsPage( queryParams: AdvertQueryParam ): AxiosPromise { return request({ url: '/mall-sms/api/v1/adverts', method: 'get', - params: queryParams + params: queryParams, }); } @@ -25,7 +29,7 @@ export function listAdvertPages( export function getAdvertFormDetail(id: number): AxiosPromise { return request({ url: '/mall-sms/api/v1/adverts/' + id, - method: 'get' + method: 'get', }); } @@ -38,7 +42,7 @@ export function addAdvert(data: AdvertFormData) { return request({ url: '/mall-sms/api/v1/adverts', method: 'post', - data: data + data: data, }); } @@ -52,7 +56,7 @@ export function updateAdvert(id: number, data: AdvertFormData) { return request({ url: '/mall-sms/api/v1/adverts/' + id, method: 'put', - data: data + data: data, }); } @@ -64,6 +68,6 @@ export function updateAdvert(id: number, data: AdvertFormData) { export function deleteAdverts(ids: string) { return request({ url: '/mall-sms/api/v1/adverts/' + ids, - method: 'delete' + method: 'delete', }); } diff --git a/src/api/sms/coupon.ts b/src/api/sms/coupon.ts new file mode 100644 index 00000000..898e5b37 --- /dev/null +++ b/src/api/sms/coupon.ts @@ -0,0 +1,73 @@ +import { + CouponQueryParam, + CouponPageResult, + CouponFormData, +} from '@/types/api/sms/coupon'; +import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; + +/** + * 获取优惠券分页列表 + * + * @param queryParams + */ +export function listCouponsPage( + queryParams: CouponQueryParam +): AxiosPromise { + return request({ + url: '/mall-sms/api/v1/coupons/pagelist', + method: 'get', + params: queryParams, + }); +} + +/** + * 获取优惠券详情 + * + * @param id + */ +export function getCouponFormDetail(id: number): AxiosPromise { + return request({ + url: '/mall-sms/api/v1/coupons/' + id, + method: 'get', + }); +} + +/** + * 添加优惠券 + * + * @param data + */ +export function addCoupon(data: CouponFormData) { + return request({ + url: '/mall-sms/api/v1/coupons', + method: 'post', + data: data, + }); +} + +/** + * 修改优惠券 + * + * @param id + * @param data + */ +export function updateCoupon(id: number, data: CouponFormData) { + return request({ + url: '/mall-sms/api/v1/coupons/' + id, + method: 'put', + data: data, + }); +} + +/** + * 删除优惠券 + * + * @param ids + */ +export function deleteCoupons(ids: string) { + return request({ + url: '/mall-sms/api/v1/coupons/' + ids, + method: 'delete', + }); +} diff --git a/src/api/system/client.ts b/src/api/system/client.ts index 6dc26b23..ab22d735 100644 --- a/src/api/system/client.ts +++ b/src/api/system/client.ts @@ -1,7 +1,7 @@ import { ClientFormData, ClientPageResult, - ClientQueryParam + ClientQueryParam, } from '@/types/api/system/client'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -12,14 +12,14 @@ export function listClientPages( return request({ url: '/youlai-admin/api/v1/oauth-clients', method: 'get', - params: queryParams + params: queryParams, }); } export function getClientFormDetial(id: number): AxiosPromise { return request({ url: '/youlai-admin/api/v1/oauth-clients/' + id, - method: 'get' + method: 'get', }); } @@ -27,7 +27,7 @@ export function addClient(data: ClientFormData) { return request({ url: '/youlai-admin/api/v1/oauth-clients', method: 'post', - data: data + data: data, }); } @@ -35,14 +35,14 @@ export function updateClient(id: string, data: ClientFormData) { return request({ url: '/youlai-admin/api/v1/oauth-clients/' + id, method: 'put', - data: data + data: data, }); } export function deleteClients(ids: string) { return request({ url: '/youlai-admin/api/v1/oauth-clients/' + ids, - method: 'delete' + method: 'delete', }); } @@ -50,6 +50,6 @@ export function updateClientPart(id: number, data: object) { return request({ url: '/youlai-admin/api/v1/oauth-clients/' + id, method: 'patch', - data: data + data: data, }); } diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts index 9b5adc62..b1b859f8 100644 --- a/src/api/system/dept.ts +++ b/src/api/system/dept.ts @@ -1,4 +1,9 @@ -import { DeptFormData, DeptItem, DeptQueryParam, Option } from '@/types'; +import { + DeptFormData, + DeptItem, + DeptQueryParam, +} from '@/types/api/system/dept'; +import { Option } from '@/types/common'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -7,13 +12,13 @@ import { AxiosPromise } from 'axios'; * * @param queryParams */ -export function listTableDepartments( +export function listDepartments( queryParams?: DeptQueryParam ): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/depts/table', + url: '/youlai-admin/api/v1/depts', method: 'get', - params: queryParams + params: queryParams, }); } @@ -22,8 +27,8 @@ export function listTableDepartments( */ export function listSelectDepartments(): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/depts/select', - method: 'get' + url: '/youlai-admin/api/v1/depts/select_list', + method: 'get', }); } @@ -32,10 +37,10 @@ export function listSelectDepartments(): AxiosPromise { * * @param id */ -export function getDeptDetail(id: string): AxiosPromise { +export function getDeptForrmData(id: string): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/depts/' + id, - method: 'get' + url: '/youlai-admin/api/v1/depts/' + id + '/form_data', + method: 'get', }); } @@ -48,7 +53,7 @@ export function addDept(data: DeptFormData) { return request({ url: '/youlai-admin/api/v1/depts', method: 'post', - data: data + data: data, }); } @@ -62,7 +67,7 @@ export function updateDept(id: string, data: DeptFormData) { return request({ url: '/youlai-admin/api/v1/depts/' + id, method: 'put', - data: data + data: data, }); } @@ -74,6 +79,6 @@ export function updateDept(id: string, data: DeptFormData) { export function deleteDept(ids: string) { return request({ url: '/youlai-admin/api/v1/depts/' + ids, - method: 'delete' + method: 'delete', }); } diff --git a/src/api/system/dict.ts b/src/api/system/dict.ts index e0b639f5..2ecf000e 100644 --- a/src/api/system/dict.ts +++ b/src/api/system/dict.ts @@ -1,12 +1,12 @@ +import { Option } from '@/types/common'; import { - DictFormData, + DictFormTypeData, DictItemFormData, DictItemPageResult, DictItemQueryParam, DictPageResult, DictQueryParam, - Option -} from '@/types'; +} from '@/types/api/system/dict'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -15,13 +15,13 @@ import { AxiosPromise } from 'axios'; * * @param queryParams */ -export function listDictPages( +export function listPageDictTypes( queryParams: DictQueryParam ): AxiosPromise { return request({ - url: '/youlai-admin/api/v2/dict/page', + url: '/youlai-admin/api/v1/dict-types', method: 'get', - params: queryParams + params: queryParams, }); } @@ -30,48 +30,49 @@ export function listDictPages( * * @param id */ -export function getDictFormDetail(id: number): AxiosPromise { +export function getDictFormData(id: number): AxiosPromise { return request({ - url: '/youlai-admin/api/v2/dict/' + id, - method: 'get' + url: '/youlai-admin/api/v1/dict-types/' + id + '/form_data', + method: 'get', }); } /** - * 新增字典 + * 新增字典类型 * * @param data */ -export function addDict(data: DictFormData) { +export function addDictType(data: DictFormTypeData) { return request({ - url: '/youlai-admin/api/v2/dict', + url: '/youlai-admin/api/v1/dict-types', method: 'post', - data: data + data: data, }); } /** - * 修改字典 + * 修改字典类型 * * @param id * @param data */ -export function updateDict(id: number, data: DictFormData) { +export function updateDictType(id: number, data: DictFormTypeData) { return request({ - url: '/youlai-admin/api/v2/dict/' + id, + url: '/youlai-admin/api/v1/dict-types/' + id, method: 'put', - data: data + data: data, }); } /** - * 批量删除字典 - * @param ids 字典ID,多个以英文逗号(,)分割 + * 批量删除字典类型 + * + * @param ids 字典类型ID,多个以英文逗号(,)分割 */ -export function deleteDict(ids: string) { +export function deleteDictTypes(ids: string) { return request({ - url: '/youlai-admin/api/v2/dict/' + ids, - method: 'delete' + url: '/youlai-admin/api/v1/dict-types/' + ids, + method: 'delete', }); } @@ -80,38 +81,40 @@ export function deleteDict(ids: string) { * * @param queryParams */ -export function listDictItemPages( +export function listPageDictItems( queryParams: DictItemQueryParam ): AxiosPromise { return request({ - url: '/youlai-admin/api/v2/dict/items/page', + url: '/youlai-admin/api/v1/dict-items', method: 'get', - params: queryParams + params: queryParams, }); } /** - * 根据字典编码获取字典项列表 + * 根据字典类型编码获取字典数据项 * - * @param dictCode + * @param typeCode 字典类型编码 */ -export function listDictsByCode(dictCode: string): AxiosPromise { +export function getDictItemsByTypeCode( + typeCode: string +): AxiosPromise { return request({ - url: '/youlai-admin/api/v2/dict/items', + url: '/youlai-admin/api/v1/dict-items/select_list', method: 'get', - params: { dictCode: dictCode } + params: { typeCode: typeCode }, }); } /** - * 获取字典项详情 + * 获取字典数据项表单 * * @param id */ -export function getDictItemDetail(id: number): AxiosPromise { +export function getDictItemData(id: number): AxiosPromise { return request({ - url: '/youlai-admin/api/v2/dict/items/' + id, - method: 'get' + url: '/youlai-admin/api/v1/dict-items/' + id + '/form_data', + method: 'get', }); } @@ -120,11 +123,11 @@ export function getDictItemDetail(id: number): AxiosPromise { * * @param data */ -export function addDictItem(data: any) { +export function addDictItem(data: DictItemFormData) { return request({ - url: '/youlai-admin/api/v2/dict/items', + url: '/youlai-admin/api/v1/dict-items', method: 'post', - data: data + data: data, }); } @@ -134,21 +137,22 @@ export function addDictItem(data: any) { * @param id * @param data */ -export function updateDictItem(id: number, data: any) { +export function updateDictItem(id: number, data: DictItemFormData) { return request({ - url: '/youlai-admin/api/v2/dict/items/' + id, + url: '/youlai-admin/api/v1/dict-items/' + id, method: 'put', - data: data + data: data, }); } /** - * 批量删除字典项 + * 批量删除字典数据项 + * * @param ids 字典项ID,多个以英文逗号(,)分割 */ -export function deleteDictItem(ids: string) { +export function deleteDictItems(ids: string) { return request({ - url: '/youlai-admin/api/v2/dict/items/' + ids, - method: 'delete' + url: '/youlai-admin/api/v1/dict-items/' + ids, + method: 'delete', }); } diff --git a/src/api/system/file.ts b/src/api/system/file.ts index 1b7d14af..8e570541 100644 --- a/src/api/system/file.ts +++ b/src/api/system/file.ts @@ -13,8 +13,8 @@ export function uploadFile(file: File) { method: 'post', data: formData, headers: { - 'Content-Type': 'multipart/form-data' - } + 'Content-Type': 'multipart/form-data', + }, }); } @@ -27,6 +27,6 @@ export function deleteFile(path?: string) { return request({ url: '/youlai-admin/api/v1/files', method: 'delete', - params: { path: path } + params: { path: path }, }); } diff --git a/src/api/system/menu.ts b/src/api/system/menu.ts index a068cb75..91861c91 100644 --- a/src/api/system/menu.ts +++ b/src/api/system/menu.ts @@ -1,4 +1,9 @@ -import { MenuFormData, MenuItem, MenuQueryParam, Option } from '@/types'; +import { + MenuFormData, + MenuItem, + MenuQueryParam, +} from '@/types/api/system/menu'; +import { Option } from '@/types/common'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -7,8 +12,8 @@ import { AxiosPromise } from 'axios'; */ export function listRoutes() { return request({ - url: '/youlai-admin/api/v1/menus/route', - method: 'get' + url: '/youlai-admin/api/v1/menus/route_list', + method: 'get', }); } @@ -17,23 +22,33 @@ export function listRoutes() { * * @param queryParams */ -export function listTableMenus( +export function listMenus( queryParams: MenuQueryParam ): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/menus/table', + url: '/youlai-admin/api/v1/menus', method: 'get', - params: queryParams + params: queryParams, }); } /** - * 获取菜单下拉列表 + * 获取菜单下拉树形列表 */ export function listSelectMenus(): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/menus/select', - method: 'get' + url: '/youlai-admin/api/v1/menus/select_list', + method: 'get', + }); +} + +/** + * 获取菜单权限树形列表 + */ +export function getResource(): AxiosPromise { + return request({ + url: '/youlai-admin/api/v1/menus/resources', + method: 'get', }); } @@ -44,7 +59,7 @@ export function listSelectMenus(): AxiosPromise { export function getMenuDetail(id: number): AxiosPromise { return request({ url: '/youlai-admin/api/v1/menus/' + id, - method: 'get' + method: 'get', }); } @@ -57,7 +72,7 @@ export function addMenu(data: MenuFormData) { return request({ url: '/youlai-admin/api/v1/menus', method: 'post', - data: data + data: data, }); } @@ -71,7 +86,7 @@ export function updateMenu(id: string, data: MenuFormData) { return request({ url: '/youlai-admin/api/v1/menus/' + id, method: 'put', - data: data + data: data, }); } @@ -83,6 +98,6 @@ export function updateMenu(id: string, data: MenuFormData) { export function deleteMenus(ids: string) { return request({ url: '/youlai-admin/api/v1/menus/' + ids, - method: 'delete' + method: 'delete', }); } diff --git a/src/api/system/perm.ts b/src/api/system/perm.ts index 35b9393d..48491680 100644 --- a/src/api/system/perm.ts +++ b/src/api/system/perm.ts @@ -2,8 +2,8 @@ import { PermFormData, PermItem, PermPageResult, - PermQueryParam -} from '@/types'; + PermQueryParam, +} from '@/types/api/system/perm'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -18,7 +18,7 @@ export function listPermPages( return request({ url: '/youlai-admin/api/v1/permissions/page', method: 'get', - params: queryParams + params: queryParams, }); } @@ -33,7 +33,7 @@ export function listPerms( return request({ url: '/youlai-admin/api/v1/permissions', method: 'get', - params: queryParams + params: queryParams, }); } @@ -45,7 +45,7 @@ export function listPerms( export function getPermFormDetail(id: number): AxiosPromise { return request({ url: '/youlai-admin/api/v1/permissions/' + id, - method: 'get' + method: 'get', }); } @@ -58,7 +58,7 @@ export function addPerm(data: PermFormData) { return request({ url: '/youlai-admin/api/v1/permissions', method: 'post', - data: data + data: data, }); } @@ -72,7 +72,7 @@ export function updatePerm(id: number, data: PermFormData) { return request({ url: '/youlai-admin/api/v1/permissions/' + id, method: 'put', - data: data + data: data, }); } @@ -84,6 +84,6 @@ export function updatePerm(id: number, data: PermFormData) { export function deletePerms(ids: string) { return request({ url: '/youlai-admin/api/v1/permissions/' + ids, - method: 'delete' + method: 'delete', }); } diff --git a/src/api/system/role.ts b/src/api/system/role.ts index c78a0e85..4bb3809d 100644 --- a/src/api/system/role.ts +++ b/src/api/system/role.ts @@ -1,39 +1,69 @@ import { RoleFormData, - RoleItem, RolePageResult, - RoleQueryParam -} from '@/types'; + RoleQueryParam, + RoleResourceData, +} from '@/types/api/system/role'; + +import { Option } from '@/types/common'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; /** - * 获取角色分页列表 + * 获取角色分页数据 * * @param queryParams */ -export function listRolePages( +export function listPageRoles( queryParams?: RoleQueryParam ): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/roles/page', + url: '/youlai-admin/api/v1/roles', method: 'get', - params: queryParams + params: queryParams, }); } /** - * 获取角色列表 + * 获取角色下拉数据 * * @param queryParams */ -export function listRoles( +export function listSelectRoles( queryParams?: RoleQueryParam -): AxiosPromise { +): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/roles', + url: '/youlai-admin/api/v1/roles/select_list', method: 'get', - params: queryParams + params: queryParams, + }); +} + +/** + * 获取角色拥有的资源ID集合 + * + * @param queryParams + */ +export function getRoleResourceIds(roleId: string): AxiosPromise { + return request({ + url: '/youlai-admin/api/v1/roles/' + roleId + '/resource_ids', + method: 'get', + }); +} + +/** + * 修改角色资源权限 + * + * @param queryParams + */ +export function updateRoleResource( + roleId: string, + data: RoleResourceData +): AxiosPromise { + return request({ + url: '/youlai-admin/api/v1/roles/' + roleId + '/resources', + method: 'put', + data: data, }); } @@ -45,7 +75,7 @@ export function listRoles( export function getRoleFormDetail(id: number): AxiosPromise { return request({ url: '/youlai-admin/api/v1/roles/' + id, - method: 'get' + method: 'get', }); } @@ -58,7 +88,7 @@ export function addRole(data: RoleFormData) { return request({ url: '/youlai-admin/api/v1/roles', method: 'post', - data: data + data: data, }); } @@ -72,7 +102,7 @@ export function updateRole(id: number, data: RoleFormData) { return request({ url: '/youlai-admin/api/v1/roles/' + id, method: 'put', - data: data + data: data, }); } @@ -84,64 +114,6 @@ export function updateRole(id: number, data: RoleFormData) { export function deleteRoles(ids: string) { return request({ url: '/youlai-admin/api/v1/roles/' + ids, - method: 'delete' - }); -} - -/** - * 获取角色的菜单列表 - * - * @param roleId - */ -export function listRoleMenuIds(roleId: number): AxiosPromise { - return request({ - url: '/youlai-admin/api/v1/roles/' + roleId + '/menu_ids', - method: 'get' - }); -} - -/** - * 修改角色的菜单 - * - * @param roleId - * @param menuIds - */ -export function updateRoleMenu(roleId: number, menuIds: Array) { - return request({ - url: '/youlai-admin/api/v1/roles/' + roleId + '/menus', - method: 'put', - data: { menuIds: menuIds } - }); -} - -/** - * 获取角色的权限列表 - * - * @param roleId - */ -export function listRolePerms(roleId: number, menuId: number) { - return request({ - url: '/youlai-admin/api/v1/roles/' + roleId + '/permissions', - method: 'get', - params: { menuId: menuId } - }); -} - -/** - * 保存角色权限 - * - * @param menuId 菜单ID,归类权限 - * @param roleId - * @param permIds - */ -export function saveRolePerms( - roleId: number, - menuId: number, - permIds: Array -) { - return request({ - url: '/youlai-admin/api/v1/roles/' + roleId + '/permissions', - method: 'put', - data: { menuId: menuId, permIds: permIds } + method: 'delete', }); } diff --git a/src/api/system/user.ts b/src/api/system/user.ts index b019de5f..1b832d5c 100644 --- a/src/api/system/user.ts +++ b/src/api/system/user.ts @@ -4,8 +4,8 @@ import { UserFormData, UserInfo, UserPageResult, - UserQueryParam -} from '@/types'; + UserQueryParam, +} from '@/types/api/system/user'; /** * 登录成功后获取用户信息(昵称、头像、权限集合和角色集合) @@ -13,7 +13,7 @@ import { export function getUserInfo(): AxiosPromise { return request({ url: '/youlai-admin/api/v1/users/me', - method: 'get' + method: 'get', }); } @@ -26,9 +26,9 @@ export function listUsersPage( queryParams: UserQueryParam ): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/users/page', + url: '/youlai-admin/api/v1/users', method: 'get', - params: queryParams + params: queryParams, }); } @@ -37,10 +37,10 @@ export function listUsersPage( * * @param userId */ -export function getUserDetail(userId: number): AxiosPromise { +export function getUserFormData(userId: number): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/users/' + userId, - method: 'get' + url: '/youlai-admin/api/v1/users/' + userId + '/form_data', + method: 'get', }); } @@ -53,7 +53,7 @@ export function addUser(data: any) { return request({ url: '/youlai-admin/api/v1/users', method: 'post', - data: data + data: data, }); } @@ -67,7 +67,7 @@ export function updateUser(id: number, data: UserFormData) { return request({ url: '/youlai-admin/api/v1/users/' + id, method: 'put', - data: data + data: data, }); } @@ -81,7 +81,7 @@ export function updateUserPart(id: number, data: any) { return request({ url: '/youlai-admin/api/v1/users/' + id, method: 'patch', - data: data + data: data, }); } @@ -93,7 +93,7 @@ export function updateUserPart(id: number, data: any) { export function deleteUsers(ids: string) { return request({ url: '/youlai-admin/api/v1/users/' + ids, - method: 'delete' + method: 'delete', }); } @@ -106,7 +106,7 @@ export function downloadTemplate() { return request({ url: '/youlai-admin/api/v1/users/template', method: 'get', - responseType: 'arraybuffer' + responseType: 'arraybuffer', }); } @@ -121,7 +121,7 @@ export function exportUser(queryParams: UserQueryParam) { url: '/youlai-admin/api/v1/users/_export', method: 'get', params: queryParams, - responseType: 'arraybuffer' + responseType: 'arraybuffer', }); } @@ -140,7 +140,7 @@ export function importUser(deptId: number, roleIds: string, file: File) { method: 'post', data: formData, headers: { - 'Content-Type': 'multipart/form-data' - } + 'Content-Type': 'multipart/form-data', + }, }); } diff --git a/src/api/ums/member.ts b/src/api/ums/member.ts index d54e6bf0..8d1da0e4 100644 --- a/src/api/ums/member.ts +++ b/src/api/ums/member.ts @@ -1,4 +1,4 @@ -import { MemberPageResult, MemberQueryParam } from '@/types'; +import { MemberPageResult, MemberQueryParam } from '@/types/api/ums/member'; import request from '@/utils/request'; import { AxiosPromise } from 'axios'; @@ -13,7 +13,7 @@ export function listMemebersPage( return request({ url: '/mall-ums/api/v1/members', method: 'get', - params: queryParams + params: queryParams, }); } @@ -25,7 +25,7 @@ export function listMemebersPage( export function getMemberDetail(id: number) { return request({ url: '/mall-ums/api/v1/members/' + id, - method: 'get' + method: 'get', }); } @@ -38,7 +38,7 @@ export function addMember(data: object) { return request({ url: '/mall-ums/api/v1/members', method: 'post', - data: data + data: data, }); } @@ -52,6 +52,6 @@ export function updateMember(id: number, data: object) { return request({ url: '/mall-ums/api/v1/members/' + id, method: 'put', - data: data + data: data, }); } diff --git a/src/assets/icons/build.svg b/src/assets/icons/build.svg deleted file mode 100644 index 97c46886..00000000 --- a/src/assets/icons/build.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/checkbox.svg b/src/assets/icons/checkbox.svg deleted file mode 100644 index 013fd3a2..00000000 --- a/src/assets/icons/checkbox.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/clipboard.svg b/src/assets/icons/clipboard.svg deleted file mode 100644 index 90923ff6..00000000 --- a/src/assets/icons/clipboard.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/code.svg b/src/assets/icons/code.svg deleted file mode 100644 index ed4d23cf..00000000 --- a/src/assets/icons/code.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/color.svg b/src/assets/icons/color.svg deleted file mode 100644 index 44a81aab..00000000 --- a/src/assets/icons/color.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/component.svg b/src/assets/icons/component.svg deleted file mode 100644 index 29c34580..00000000 --- a/src/assets/icons/component.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/date-range.svg b/src/assets/icons/date-range.svg deleted file mode 100644 index fda571e7..00000000 --- a/src/assets/icons/date-range.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/date.svg b/src/assets/icons/date.svg deleted file mode 100644 index 52dc73ee..00000000 --- a/src/assets/icons/date.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/dict.svg b/src/assets/icons/dict.svg index 48493773..22a82781 100644 --- a/src/assets/icons/dict.svg +++ b/src/assets/icons/dict.svg @@ -1 +1,18 @@ - \ No newline at end of file + + + + + + + diff --git a/src/assets/icons/dict_item.svg b/src/assets/icons/dict_item.svg new file mode 100644 index 00000000..903109a7 --- /dev/null +++ b/src/assets/icons/dict_item.svg @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/src/assets/icons/education.svg b/src/assets/icons/education.svg deleted file mode 100644 index 7bfb01d1..00000000 --- a/src/assets/icons/education.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/email.svg b/src/assets/icons/email.svg deleted file mode 100644 index 74d25e21..00000000 --- a/src/assets/icons/email.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/example.svg b/src/assets/icons/example.svg deleted file mode 100644 index 46f42b53..00000000 --- a/src/assets/icons/example.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/excel.svg b/src/assets/icons/excel.svg deleted file mode 100644 index 74d97b80..00000000 --- a/src/assets/icons/excel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/form.svg b/src/assets/icons/form.svg deleted file mode 100644 index 9ab55a03..00000000 --- a/src/assets/icons/form.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/icons/icon.svg b/src/assets/icons/icon.svg deleted file mode 100644 index 82be8eee..00000000 --- a/src/assets/icons/icon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/input.svg b/src/assets/icons/input.svg deleted file mode 100644 index ab91381e..00000000 --- a/src/assets/icons/input.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/international.svg b/src/assets/icons/international.svg deleted file mode 100644 index e9b56eee..00000000 --- a/src/assets/icons/international.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/ip.svg b/src/assets/icons/ip.svg deleted file mode 100644 index e59f29b3..00000000 --- a/src/assets/icons/ip.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/icons/job.svg b/src/assets/icons/job.svg deleted file mode 100644 index 2a93a251..00000000 --- a/src/assets/icons/job.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/list.svg b/src/assets/icons/list.svg deleted file mode 100644 index 20259edd..00000000 --- a/src/assets/icons/list.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/lock.svg b/src/assets/icons/lock.svg deleted file mode 100644 index 74fee543..00000000 --- a/src/assets/icons/lock.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/log.svg b/src/assets/icons/log.svg deleted file mode 100644 index d879d33b..00000000 --- a/src/assets/icons/log.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/logininfor.svg b/src/assets/icons/logininfor.svg deleted file mode 100644 index 267f8447..00000000 --- a/src/assets/icons/logininfor.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/offline.svg b/src/assets/icons/offline.svg deleted file mode 100644 index d09cb16c..00000000 --- a/src/assets/icons/offline.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/icons/online.svg b/src/assets/icons/online.svg deleted file mode 100644 index 330a2029..00000000 --- a/src/assets/icons/online.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/pdf.svg b/src/assets/icons/pdf.svg deleted file mode 100644 index 957aa0cc..00000000 --- a/src/assets/icons/pdf.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/people.svg b/src/assets/icons/people.svg deleted file mode 100644 index 2bd54aeb..00000000 --- a/src/assets/icons/people.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/perm.svg b/src/assets/icons/perm.svg index 8ed624b9..b38d0657 100644 --- a/src/assets/icons/perm.svg +++ b/src/assets/icons/perm.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/src/assets/icons/phone.svg b/src/assets/icons/phone.svg deleted file mode 100644 index ab8e8c4e..00000000 --- a/src/assets/icons/phone.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/post.svg b/src/assets/icons/post.svg deleted file mode 100644 index 2922c613..00000000 --- a/src/assets/icons/post.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/qq.svg b/src/assets/icons/qq.svg deleted file mode 100644 index ee13d4ec..00000000 --- a/src/assets/icons/qq.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/question.svg b/src/assets/icons/question.svg deleted file mode 100644 index cf75bd4b..00000000 --- a/src/assets/icons/question.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/radio.svg b/src/assets/icons/radio.svg deleted file mode 100644 index 0cde3452..00000000 --- a/src/assets/icons/radio.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/route.svg b/src/assets/icons/route.svg deleted file mode 100644 index b2071244..00000000 --- a/src/assets/icons/route.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/icons/row.svg b/src/assets/icons/row.svg deleted file mode 100644 index 07809922..00000000 --- a/src/assets/icons/row.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/search.svg b/src/assets/icons/search.svg deleted file mode 100644 index 84233dda..00000000 --- a/src/assets/icons/search.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/select.svg b/src/assets/icons/select.svg deleted file mode 100644 index d6283828..00000000 --- a/src/assets/icons/select.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/slider.svg b/src/assets/icons/slider.svg deleted file mode 100644 index fbe4f39f..00000000 --- a/src/assets/icons/slider.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/star.svg b/src/assets/icons/star.svg deleted file mode 100644 index 6cf86e66..00000000 --- a/src/assets/icons/star.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/swagger.svg b/src/assets/icons/swagger.svg deleted file mode 100644 index 05d4e7bc..00000000 --- a/src/assets/icons/swagger.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/switch.svg b/src/assets/icons/switch.svg deleted file mode 100644 index 0ba61e38..00000000 --- a/src/assets/icons/switch.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/tab.svg b/src/assets/icons/tab.svg deleted file mode 100644 index b4b48e48..00000000 --- a/src/assets/icons/tab.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/table.svg b/src/assets/icons/table.svg deleted file mode 100644 index 0e3dc9de..00000000 --- a/src/assets/icons/table.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/textarea.svg b/src/assets/icons/textarea.svg deleted file mode 100644 index 2709f292..00000000 --- a/src/assets/icons/textarea.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/time-range.svg b/src/assets/icons/time-range.svg deleted file mode 100644 index 13c1202b..00000000 --- a/src/assets/icons/time-range.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/time.svg b/src/assets/icons/time.svg deleted file mode 100644 index b376e32a..00000000 --- a/src/assets/icons/time.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/tool.svg b/src/assets/icons/tool.svg deleted file mode 100644 index c813067e..00000000 --- a/src/assets/icons/tool.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/validCode.svg b/src/assets/icons/validCode.svg deleted file mode 100644 index cfb10214..00000000 --- a/src/assets/icons/validCode.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/icons/valid_code.svg b/src/assets/icons/valid_code.svg new file mode 100644 index 00000000..39bf4783 --- /dev/null +++ b/src/assets/icons/valid_code.svg @@ -0,0 +1,9 @@ + + + + diff --git a/src/layout/components/TagsView/ScrollPane.vue b/src/layout/components/TagsView/ScrollPane.vue index 8a586411..9f6aa7a2 100644 --- a/src/layout/components/TagsView/ScrollPane.vue +++ b/src/layout/components/TagsView/ScrollPane.vue @@ -15,9 +15,9 @@ import { computed, onMounted, onBeforeUnmount, - getCurrentInstance + getCurrentInstance, } from 'vue'; -import { TagView } from '@/types'; +import { TagView } from '@/types/store/tagsview'; import useStore from '@/store'; const tagAndTagSpacing = ref(4); @@ -25,8 +25,8 @@ const { proxy } = getCurrentInstance() as any; const emits = defineEmits(['scroll']); const emitScroll = () => { - emits('scroll') -} + emits('scroll'); +}; const { tagsView } = useStore(); @@ -35,12 +35,11 @@ const visitedViews = computed(() => tagsView.visitedViews); const scrollWrapper = computed(() => proxy?.$refs.scrollContainer.$refs.wrap$); onMounted(() => { - scrollWrapper.value.addEventListener('scroll', emitScroll, {passive:true}) -}) + scrollWrapper.value.addEventListener('scroll', emitScroll, true); +}); onBeforeUnmount(() => { - scrollWrapper.value.removeEventListener('scroll', emitScroll) -}) - + scrollWrapper.value.removeEventListener('scroll', emitScroll); +}); function handleScroll(e: WheelEvent) { const eventDelta = (e as any).wheelDelta || -e.deltaY * 40; @@ -69,7 +68,7 @@ function moveToTarget(currentTag: TagView) { } else { const tagListDom = document.getElementsByClassName('tags-view__item'); const currentIndex = visitedViews.value.findIndex( - item => item === currentTag + (item) => item === currentTag ); let prevTag = null; let nextTag = null; @@ -81,7 +80,8 @@ function moveToTarget(currentTag: TagView) { ) { prevTag = tagListDom[k]; } - if ((tagListDom[k] as any).dataset.path === + if ( + (tagListDom[k] as any).dataset.path === visitedViews.value[currentIndex + 1].path ) { nextTag = tagListDom[k]; @@ -107,7 +107,7 @@ function moveToTarget(currentTag: TagView) { } defineExpose({ - moveToTarget + moveToTarget, }); diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index b2b51c6c..ac63fb93 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -65,13 +65,14 @@ import { nextTick, ref, watch, - onMounted + onMounted, + ComponentInternalInstance, } from 'vue'; import path from 'path-browserify'; import { RouteRecordRaw, useRoute, useRouter } from 'vue-router'; -import { TagView } from '@/types'; +import { TagView } from '@/types/store/tagsview'; import ScrollPane from './ScrollPane.vue'; import SvgIcon from '@/components/SvgIcon/index.vue'; @@ -80,7 +81,7 @@ import useStore from '@/store'; const { tagsView, permission } = useStore(); -const { proxy } = getCurrentInstance() as any; +const { proxy } = getCurrentInstance() as ComponentInternalInstance; const router = useRouter(); const route = useRoute(); @@ -102,13 +103,13 @@ watch( }, { //初始化立即执行 - immediate: true + immediate: true, } ); -watch(visible, value => { +watch(visible, (value) => { if (value) { - document.body.addEventListener('click', closeMenu, {passive:true}); + document.body.addEventListener('click', closeMenu); } else { document.body.removeEventListener('click', closeMenu); } @@ -117,14 +118,14 @@ watch(visible, value => { function filterAffixTags(routes: RouteRecordRaw[], basePath = '/') { let tags: TagView[] = []; - routes.forEach(route => { + routes.forEach((route) => { if (route.meta && route.meta.affix) { const tagPath = path.resolve(basePath, route.path); tags.push({ fullPath: tagPath, path: tagPath, name: route.name, - meta: { ...route.meta } + meta: { ...route.meta }, }); } @@ -166,7 +167,7 @@ function moveToCurrentTag() { } } } - }) + }); } function isActive(tag: TagView) { @@ -204,7 +205,7 @@ function refreshSelectedTag(view: TagView) { tagsView.delCachedView(view); const { fullPath } = view; nextTick(() => { - router.replace({ path: '/redirect' + fullPath }).catch(err => { + router.replace({ path: '/redirect' + fullPath }).catch((err) => { console.warn(err); }); }); @@ -254,7 +255,7 @@ function closeRightTags() { } function closeOtherTags() { - router.push(selectedTag.value) + router.push(selectedTag.value); tagsView.delOtherViews(selectedTag.value).then(() => { moveToCurrentTag(); }); @@ -333,8 +334,19 @@ onMounted(() => { } &.active { - background-color: var(--el-color-primary-light-9); - color: var(--el-color-primary); + background-color: var(--el-color-primary); + color: var(--el-color-primary-light-9); + border-color: var(--el-color-primary); + &::before { + content: ''; + background: #fff; + display: inline-block; + width: 8px; + height: 8px; + border-radius: 50%; + position: relative; + margin-right: 5px; + } } .icon-close { diff --git a/src/main.ts b/src/main.ts index 28cb57f8..02e9190e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,7 @@ import 'element-plus/theme-chalk/index.css'; import Pagination from '@/components/Pagination/index.vue'; import '@/permission'; -import 'default-passive-events' +import 'default-passive-events'; // 引入svg注册脚本 import 'virtual:svg-icons-register'; @@ -21,25 +21,25 @@ import i18n from '@/lang/index'; import '@/styles/index.scss'; // 根据字典编码获取字典列表全局方法 -import { listDictsByCode } from '@/api/system/dict'; +import { getDictItemsByTypeCode } from '@/api/system/dict'; const app = createApp(App); // 自定义指令 import * as directive from '@/directive'; -Object.keys(directive).forEach(key => { +Object.keys(directive).forEach((key) => { app.directive(key, (directive as { [key: string]: Directive })[key]); }); // 全局方法 -app.config.globalProperties.$listDictsByCode = listDictsByCode; +app.config.globalProperties.$getDictItemsByTypeCode = getDictItemsByTypeCode; // 注册全局组件 app .component('Pagination', Pagination) - .use(createPinia() as any) - .use(router as any) + .use(createPinia()) + .use(router) .use(ElementPlus) - .use(i18n as any) + .use(i18n) .mount('#app'); diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 09832345..064d3863 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -1,4 +1,4 @@ -import { AppState } from '@/types'; +import { AppState } from '@/types/store/app'; import { localStorage } from '@/utils/storage'; import { defineStore } from 'pinia'; import { getLanguage } from '@/lang/index'; @@ -11,10 +11,10 @@ const useAppStore = defineStore({ opened: localStorage.get('sidebarStatus') ? !!+localStorage.get('sidebarStatus') : true, - withoutAnimation: false + withoutAnimation: false, }, language: getLanguage(), - size: localStorage.get('size') || 'default' + size: localStorage.get('size') || 'default', }), actions: { toggleSidebar() { @@ -41,8 +41,8 @@ const useAppStore = defineStore({ setLanguage(language: string) { this.language = language; localStorage.set('language', language); - } - } + }, + }, }); export default useAppStore; diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 98531af9..e1743e1c 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -1,4 +1,4 @@ -import { PermissionState } from '@/types'; +import { PermissionState } from '@/types/store/permission'; import { RouteRecordRaw } from 'vue-router'; import { defineStore } from 'pinia'; import { constantRoutes } from '@/router'; @@ -12,7 +12,7 @@ const hasPermission = (roles: string[], route: RouteRecordRaw) => { if (roles.includes('ROOT')) { return true; } - return roles.some(role => { + return roles.some((role) => { if (route.meta?.roles !== undefined) { return (route.meta.roles as string[]).includes(role); } @@ -26,7 +26,7 @@ export const filterAsyncRoutes = ( roles: string[] ) => { const res: RouteRecordRaw[] = []; - routes.forEach(route => { + routes.forEach((route) => { const tmp = { ...route } as any; if (hasPermission(roles, tmp)) { if (tmp.component == 'Layout') { @@ -53,7 +53,7 @@ const usePermissionStore = defineStore({ id: 'permission', state: (): PermissionState => ({ routes: [], - addRoutes: [] + addRoutes: [], }), actions: { setRoutes(routes: RouteRecordRaw[]) { @@ -63,18 +63,18 @@ const usePermissionStore = defineStore({ generateRoutes(roles: string[]) { return new Promise((resolve, reject) => { listRoutes() - .then(response => { + .then((response) => { const asyncRoutes = response.data; const accessedRoutes = filterAsyncRoutes(asyncRoutes, roles); this.setRoutes(accessedRoutes); resolve(accessedRoutes); }) - .catch(error => { + .catch((error) => { reject(error); }); }); - } - } + }, + }, }); export default usePermissionStore; diff --git a/src/store/modules/settings.ts b/src/store/modules/settings.ts index 31e9a60e..43ffbe11 100644 --- a/src/store/modules/settings.ts +++ b/src/store/modules/settings.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { SettingState } from '@/types'; +import { SettingState } from '@/types/store/setting'; import defaultSettings from '../../settings'; import { localStorage } from '@/utils/storage'; @@ -18,7 +18,7 @@ export const useSettingStore = defineStore({ ? localStorage.get('tagsView') : tagsView, fixedHeader: fixedHeader, - sidebarLogo: sidebarLogo + sidebarLogo: sidebarLogo, }), actions: { async changeSetting(payload: { key: string; value: any }) { @@ -43,8 +43,8 @@ export const useSettingStore = defineStore({ default: break; } - } - } + }, + }, }); export default useSettingStore; diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts index 45b60424..77c553e9 100644 --- a/src/store/modules/tagsView.ts +++ b/src/store/modules/tagsView.ts @@ -1,38 +1,37 @@ import { defineStore } from 'pinia'; -import { TagsViewState } from '@/types'; +import { TagsViewState } from '@/types/store/tagsview'; const useTagsViewStore = defineStore({ id: 'tagsView', state: (): TagsViewState => ({ visitedViews: [], - cachedViews: [] + cachedViews: [], // keepAlive 缓存页面 }), actions: { addVisitedView(view: any) { - if (this.visitedViews.some(v => v.path === view.path)) return; + if (this.visitedViews.some((v) => v.path === view.path)) return; if (view.meta && view.meta.affix) { this.visitedViews.unshift( Object.assign({}, view, { - title: view.meta?.title || 'no-name' + title: view.meta?.title || 'no-name', }) ); } else { this.visitedViews.push( Object.assign({}, view, { - title: view.meta?.title || 'no-name' + title: view.meta?.title || 'no-name', }) ); } }, addCachedView(view: any) { if (this.cachedViews.includes(view.name)) return; - if (!view.meta.noCache) { + if (view.meta.keepAlive) { this.cachedViews.push(view.name); } }, - delVisitedView(view: any) { - return new Promise(resolve => { + return new Promise((resolve) => { for (const [i, v] of this.visitedViews.entries()) { if (v.path === view.path) { this.visitedViews.splice(i, 1); @@ -43,23 +42,22 @@ const useTagsViewStore = defineStore({ }); }, delCachedView(view: any) { - return new Promise(resolve => { + return new Promise((resolve) => { const index = this.cachedViews.indexOf(view.name); index > -1 && this.cachedViews.splice(index, 1); resolve([...this.cachedViews]); }); }, - delOtherVisitedViews(view: any) { - return new Promise(resolve => { - this.visitedViews = this.visitedViews.filter(v => { + return new Promise((resolve) => { + this.visitedViews = this.visitedViews.filter((v) => { return v.meta?.affix || v.path === view.path; }); resolve([...this.visitedViews]); }); }, delOtherCachedViews(view: any) { - return new Promise(resolve => { + return new Promise((resolve) => { const index = this.cachedViews.indexOf(view.name); if (index > -1) { this.cachedViews = this.cachedViews.slice(index, index + 1); @@ -84,29 +82,29 @@ const useTagsViewStore = defineStore({ this.addCachedView(view); }, delView(view: any) { - return new Promise(resolve => { + return new Promise((resolve) => { this.delVisitedView(view); this.delCachedView(view); resolve({ visitedViews: [...this.visitedViews], - cachedViews: [...this.cachedViews] + cachedViews: [...this.cachedViews], }); }); }, delOtherViews(view: any) { - return new Promise(resolve => { + return new Promise((resolve) => { this.delOtherVisitedViews(view); this.delOtherCachedViews(view); resolve({ visitedViews: [...this.visitedViews], - cachedViews: [...this.cachedViews] + cachedViews: [...this.cachedViews], }); }); }, delLeftViews(view: any) { - return new Promise(resolve => { + return new Promise((resolve) => { const currIndex = this.visitedViews.findIndex( - v => v.path === view.path + (v) => v.path === view.path ); if (currIndex === -1) { return; @@ -124,14 +122,14 @@ const useTagsViewStore = defineStore({ return false; }); resolve({ - visitedViews: [...this.visitedViews] + visitedViews: [...this.visitedViews], }); }); }, delRightViews(view: any) { - return new Promise(resolve => { + return new Promise((resolve) => { const currIndex = this.visitedViews.findIndex( - v => v.path === view.path + (v) => v.path === view.path ); if (currIndex === -1) { return; @@ -149,35 +147,35 @@ const useTagsViewStore = defineStore({ return false; }); resolve({ - visitedViews: [...this.visitedViews] + visitedViews: [...this.visitedViews], }); }); }, delAllViews() { - return new Promise(resolve => { - const affixTags = this.visitedViews.filter(tag => tag.meta?.affix); + return new Promise((resolve) => { + const affixTags = this.visitedViews.filter((tag) => tag.meta?.affix); this.visitedViews = affixTags; this.cachedViews = []; resolve({ visitedViews: [...this.visitedViews], - cachedViews: [...this.cachedViews] + cachedViews: [...this.cachedViews], }); }); }, delAllVisitedViews() { - return new Promise(resolve => { - const affixTags = this.visitedViews.filter(tag => tag.meta?.affix); + return new Promise((resolve) => { + const affixTags = this.visitedViews.filter((tag) => tag.meta?.affix); this.visitedViews = affixTags; resolve([...this.visitedViews]); }); }, delAllCachedViews() { - return new Promise(resolve => { + return new Promise((resolve) => { this.cachedViews = []; resolve([...this.cachedViews]); }); - } - } + }, + }, }); export default useTagsViewStore; diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 55b4a42e..d4c3dbdc 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -1,5 +1,7 @@ import { defineStore } from 'pinia'; -import { LoginFormData, UserState } from '@/types'; +import { LoginFormData } from '@/types/api/system/login'; +import { UserState } from '@/types/store/user'; + import { localStorage } from '@/utils/storage'; import { login, logout } from '@/api/login'; import { getUserInfo } from '@/api/system/user'; @@ -12,38 +14,33 @@ const useUserStore = defineStore({ nickname: '', avatar: '', roles: [], - perms: [] + perms: [], }), actions: { async RESET_STATE() { this.$reset(); }, /** - * 用户登录请求 - * @param userInfo 登录用户信息 - * username: 用户名 - * password: 密码 - * code: 验证码 - * uuid: 匹配正确验证码的 key + * 登录 */ - login(userInfo: LoginFormData) { - const { username, password, code, uuid } = userInfo; + login(loginData: LoginFormData) { + const { username, password, code, uuid } = loginData; return new Promise((resolve, reject) => { login({ username: username.trim(), password: password, grant_type: 'captcha', code: code, - uuid: uuid + uuid: uuid, }) - .then(response => { + .then((response) => { const { access_token, token_type } = response.data; const accessToken = token_type + ' ' + access_token; localStorage.set('token', accessToken); this.token = accessToken; resolve(access_token); }) - .catch(error => { + .catch((error) => { reject(error); }); }); @@ -68,7 +65,7 @@ const useUserStore = defineStore({ this.perms = perms; resolve(data); }) - .catch(error => { + .catch((error) => { reject(error); }); }); @@ -86,7 +83,7 @@ const useUserStore = defineStore({ resetRouter(); resolve(null); }) - .catch(error => { + .catch((error) => { reject(error); }); }); @@ -96,13 +93,13 @@ const useUserStore = defineStore({ * 清除 Token */ resetToken() { - return new Promise(resolve => { + return new Promise((resolve) => { localStorage.remove('token'); this.RESET_STATE(); resolve(null); }); - } - } + }, + }, }); export default useUserStore; diff --git a/src/types/api/sms/coupon.ts b/src/types/api/sms/coupon.ts new file mode 100644 index 00000000..5f81ee6b --- /dev/null +++ b/src/types/api/sms/coupon.ts @@ -0,0 +1,33 @@ +import { PageQueryParam ,PageResult} from '../base'; + +/** + * 优惠券查询参数类型 + */ +export interface CouponQueryParam extends PageQueryParam { + status?: number; +} + +/** + * 优惠券分页列表项 + */ + export interface CouponItem { + id: string; + name: string; + type: string; +} + +/** + *优惠券分页项类型 + */ +export type CouponPageResult = PageResult; + + + +/** + * 广告表单类型声明 + */ + export interface CouponFormData { + id?: number; + name: string; + type: string; +} diff --git a/src/types/api/system/client.d.ts b/src/types/api/system/client.d.ts index 98f97467..4703a42d 100644 --- a/src/types/api/system/client.d.ts +++ b/src/types/api/system/client.d.ts @@ -1,17 +1,14 @@ import { PageQueryParam, PageResult } from '../base'; /** - * 客户端查询参数类型声明 + * 客户端查询参数类型 */ export interface ClientQueryParam extends PageQueryParam { - /** - * 客户端名称 - */ - clientId: string | undefined; + keywords?: string; } /** - * 客户端分页列表项声明 + * 客户端分页列表项 */ export interface ClientItem { clientId: string; @@ -28,12 +25,12 @@ export interface ClientItem { } /** - * 客户端分页项类型声明 + * 客户端分页项类型 */ export type ClientPageResult = PageResult; /** - * 客户端表单类型声明 + * 客户端表单类型 */ export interface ClientFormData { authorizedGrantTypes: string; diff --git a/src/types/api/system/dict.d.ts b/src/types/api/system/dict.d.ts index 53f47f7e..f268a399 100644 --- a/src/types/api/system/dict.d.ts +++ b/src/types/api/system/dict.d.ts @@ -29,7 +29,7 @@ export type DictPageResult = PageResult; /** * 字典表单类型声明 */ -export interface DictFormData { +export interface DictFormTypeData { id: number | undefined; name: string; code: string; @@ -44,11 +44,11 @@ export interface DictItemQueryParam extends PageQueryParam { /** * 字典项名称 */ - name: string | undefined; + name?: string; /** - * 字典编码 + * 字典类型编码 */ - dictCode: string | undefined; + typeCode?: string; } /** @@ -75,8 +75,8 @@ export type DictItemPageResult = PageResult; */ export interface DictItemFormData { id?: number; - dictCode?: string; - dictName?: string; + typeCode?: string; + typeName?: string; name: string; code: string; value: string; diff --git a/src/types/api/system/role.d.ts b/src/types/api/system/role.d.ts index f4dc31b2..3ce9a228 100644 --- a/src/types/api/system/role.d.ts +++ b/src/types/api/system/role.d.ts @@ -1,14 +1,14 @@ import { PageQueryParam, PageResult } from '../base'; /** - * 角色查询参数类型声明 + * 角色查询参数类型 */ export interface RoleQueryParam extends PageQueryParam { name?: string; } /** - * 角色分页列表项声明 + * 角色分页列表项 */ export interface RoleItem { id: string; @@ -22,17 +22,25 @@ export interface RoleItem { } /** - * 角色分页项类型声明 + * 角色分页项类型 */ export type RolePageResult = PageResult; /** - * 角色表单类型声明 + * 角色表单类型 */ export interface RoleFormData { - id: number | undefined; + id: string | undefined; name: string; code: string; sort: number; status: number; } + +/** + * + */ +export interface RoleResourceData { + menuIds: string[]; + permIds: string[]; +} diff --git a/src/types/common.d.ts b/src/types/common.d.ts index 7a00ee13..c2c55b79 100644 --- a/src/types/common.d.ts +++ b/src/types/common.d.ts @@ -1,9 +1,5 @@ /** - * 组件类型声明 - */ - -/** - * 弹窗属性类型声明 + * 弹窗类型 */ export interface Dialog { title: string; @@ -11,10 +7,11 @@ export interface Dialog { } /** - * 通用组件选择项类型声明 + * 通用组件选择项类型 */ export interface Option { value: string; label: string; + checked?: boolean; children?: Option[]; } diff --git a/src/types/index.d.ts b/src/types/index.d.ts deleted file mode 100644 index 3784e446..00000000 --- a/src/types/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -export * from './api/system/login'; -export * from './api/system/user'; -export * from './api/system/role'; -export * from './api/system/menu'; -export * from './api/system/dept'; -export * from './api/system/dict'; -export * from './api/system/perm'; -export * from './api/system/client'; - -export * from './api/pms/goods'; -export * from './api/pms/brand'; -export * from './api/sms/advert'; -export * from './api/oms/order'; -export * from './api/ums/member'; -export * from './api/lab/seata'; - -export * from './store'; - -export * from './common'; diff --git a/src/types/store.d.ts b/src/types/store.d.ts deleted file mode 100644 index 6cc47a8a..00000000 --- a/src/types/store.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { RouteRecordRaw, RouteLocationNormalized } from 'vue-router'; -/** - * 用户状态类型声明 - */ -export interface AppState { - device: string; - sidebar: { - opened: boolean; - withoutAnimation: boolean; - }; - language: string; - size: string; -} - -/** - * 权限类型声明 - */ -export interface PermissionState { - routes: RouteRecordRaw[]; - addRoutes: RouteRecordRaw[]; -} - -/** - * 设置状态类型声明 - */ -export interface SettingState { - theme: string; - tagsView: boolean; - fixedHeader: boolean; - showSettings: boolean; - sidebarLogo: boolean; -} - -/** - * 标签状态类型声明 - */ -export interface TagView extends Partial { - title?: string; -} - -export interface TagsViewState { - visitedViews: TagView[]; - cachedViews: string[]; -} - -/** - * 用户状态类型声明 - */ -export interface UserState { - token: string; - nickname: string; - avatar: string; - roles: string[]; - perms: string[]; -} diff --git a/src/types/store/app.d.ts b/src/types/store/app.d.ts new file mode 100644 index 00000000..569fcf9d --- /dev/null +++ b/src/types/store/app.d.ts @@ -0,0 +1,12 @@ +/** + * 系统类型声明 + */ + export interface AppState { + device: string; + sidebar: { + opened: boolean; + withoutAnimation: boolean; + }; + language: string; + size: string; +} diff --git a/src/types/store/permission.d.ts b/src/types/store/permission.d.ts new file mode 100644 index 00000000..c0ec4dcb --- /dev/null +++ b/src/types/store/permission.d.ts @@ -0,0 +1,7 @@ +/** + * 权限类型声明 + */ + export interface PermissionState { + routes: RouteRecordRaw[]; + addRoutes: RouteRecordRaw[]; +} diff --git a/src/types/store/setting.d.ts b/src/types/store/setting.d.ts new file mode 100644 index 00000000..e83734d0 --- /dev/null +++ b/src/types/store/setting.d.ts @@ -0,0 +1,10 @@ +/** + * 设置状态类型声明 + */ + export interface SettingState { + theme: string; + tagsView: boolean; + fixedHeader: boolean; + showSettings: boolean; + sidebarLogo: boolean; +} diff --git a/src/types/store/tagsview.d.ts b/src/types/store/tagsview.d.ts new file mode 100644 index 00000000..ce388072 --- /dev/null +++ b/src/types/store/tagsview.d.ts @@ -0,0 +1,13 @@ +import { RouteLocationNormalized } from 'vue-router'; + +/** + * 标签状态类型声明 + */ +export interface TagView extends Partial { + title?: string; +} + +export interface TagsViewState { + visitedViews: TagView[]; + cachedViews: string[]; +} diff --git a/src/types/store/user.d.ts b/src/types/store/user.d.ts new file mode 100644 index 00000000..698c7445 --- /dev/null +++ b/src/types/store/user.d.ts @@ -0,0 +1,7 @@ +export interface UserState { + token: string; + nickname: string; + avatar: string; + roles: string[]; + perms: string[]; +} diff --git a/src/views/ums/member/index.vue b/src/views/index.vue similarity index 96% rename from src/views/ums/member/index.vue rename to src/views/index.vue index f597ba7a..0b36312e 100644 --- a/src/views/ums/member/index.vue +++ b/src/views/index.vue @@ -1,7 +1,6 @@ - @@ -11,7 +10,7 @@ import { ElTable } from 'element-plus'; import { Search, Refresh } from '@element-plus/icons-vue'; import { listMemebersPage } from '@/api/ums/member'; -import { MemberQueryParam, MemberItem } from '@/types'; +import { MemberQueryParam, MemberItem } from '@/types/api/ums/member'; const state = reactive({ // 遮罩层 @@ -25,9 +24,9 @@ const state = reactive({ total: 0, queryParams: { pageNum: 1, - pageSize: 10 + pageSize: 10, } as MemberQueryParam, - memberList: [] as MemberItem[] + memberList: [] as MemberItem[], }); const { loading, queryParams, memberList, total } = toRefs(state); @@ -45,7 +44,7 @@ function resetQuery() { state.queryParams = { pageNum: 1, pageSize: 10, - nickName: '' + nickName: '', }; handleQuery(); } diff --git a/src/views/lab/seata/index.vue b/src/views/lab/seata/index.vue index 553180c0..84670087 100644 --- a/src/views/lab/seata/index.vue +++ b/src/views/lab/seata/index.vue @@ -1,7 +1,7 @@ @@ -14,42 +14,42 @@ import { RefreshLeft, Right, CircleCheckFilled, - CircleCloseFilled + CircleCloseFilled, } from '@element-plus/icons-vue'; import { payOrder, getSeataData, resetSeataData } from '@/api/lab/seata'; import { ElMessage, ElMessageBox } from 'element-plus'; -import { SeataFormData } from '@/types'; +import { SeataFormData } from '@/types/api/lab/seata'; const state = reactive({ // 保留改变前数据 cacheSeataData: { status: undefined, stockNum: undefined, - balance: undefined + balance: undefined, }, seataData: { orderInfo: { orderSn: undefined, - status: undefined + status: undefined, }, stockInfo: { name: undefined, picUrl: undefined, - stockNum: undefined + stockNum: undefined, }, accountInfo: { nickName: undefined, avatarUrl: undefined, - balance: undefined - } + balance: undefined, + }, }, loading: false, submitData: { openTx: true, // 是否开启事务 - orderEx: true // 订单修改异常 - } as SeataFormData + orderEx: true, // 订单修改异常 + } as SeataFormData, }); const { cacheSeataData, seataData, loading, submitData } = toRefs(state); @@ -73,7 +73,7 @@ function handleOrderPay() { { confirmButtonText: '重置数据', cancelButtonText: '取消', - type: 'warning' + type: 'warning', } ) .then(() => { @@ -92,7 +92,7 @@ function handleOrderPay() { cacheSeataData.value = { status: seataData.value.orderInfo.status, stockNum: seataData.value.stockInfo.stockNum, - balance: seataData.value.accountInfo.balance + balance: seataData.value.accountInfo.balance, }; loadData(); }); @@ -129,7 +129,7 @@ function handleDataReset() { cacheSeataData.value = { status: undefined, stockNum: undefined, - balance: undefined + balance: undefined, }; loadData(); }); @@ -367,6 +367,7 @@ onMounted(() => { diff --git a/src/views/system/client/index.vue b/src/views/system/client/index.vue index a880a30e..553d31b5 100644 --- a/src/views/system/client/index.vue +++ b/src/views/system/client/index.vue @@ -1,7 +1,7 @@ @@ -11,12 +11,18 @@ import { getClientFormDetial, addClient, updateClient, - deleteClients + deleteClients, } from '@/api/system/client'; import { Search, Plus, Edit, Refresh, Delete } from '@element-plus/icons-vue'; import { onMounted, reactive, getCurrentInstance, ref, toRefs } from 'vue'; import { ElForm, ElMessage, ElMessageBox } from 'element-plus'; -import { ClientFormData, ClientItem, ClientQueryParam, Option } from '@/types'; +import { + ClientFormData, + ClientItem, + ClientQueryParam, +} from '@/types/api/system/client'; +import { Option } from '@/types/common'; + const { proxy }: any = getCurrentInstance(); const queryFormRef = ref(ElForm); @@ -31,21 +37,23 @@ const state = reactive({ multiple: true, queryParams: { pageNum: 1, - pageSize: 10 + pageSize: 10, } as ClientQueryParam, clientList: [] as ClientItem[], total: 0, dialog: { title: '', visible: false, - type: 'create' + type: 'create', }, formData: {} as ClientFormData, rules: { - clientId: [{ required: true, message: '客户端ID不能为空', trigger: 'blur' }] + clientId: [ + { required: true, message: '客户端ID不能为空', trigger: 'blur' }, + ], }, authorizedGrantTypesOptions: [] as Option[], - checkedAuthorizedGrantTypes: [] as string[] + checkedAuthorizedGrantTypes: [] as string[], }); const { @@ -59,7 +67,7 @@ const { formData, rules, authorizedGrantTypesOptions, - checkedAuthorizedGrantTypes + checkedAuthorizedGrantTypes, } = toRefs(state); function handleQuery() { @@ -82,14 +90,14 @@ function handleSelectionChange(selection: any) { } function handleAdd() { - proxy.$listDictsByCode('grant_type').then((response: any) => { + proxy.$getDictItemsByTypeCode('grant_type').then((response: any) => { state.authorizedGrantTypesOptions = response.data; }); state.dialog = { title: '添加客户端', visible: true, - type: 'create' + type: 'create', }; } @@ -97,11 +105,11 @@ function handleUpdate(row: any) { state.dialog = { title: '修改客户端', visible: true, - type: 'edit' + type: 'edit', }; const clientId = row.clientId || ids; - proxy.$listDictsByCode('grant_type').then((res: any) => { + proxy.$getDictItemsByTypeCode('grant_type').then((res: any) => { state.authorizedGrantTypesOptions = res.data; getClientFormDetial(clientId).then(({ data }) => { @@ -149,7 +157,7 @@ function handleDelete(row: any) { ElMessageBox.confirm('确认删除已选中的数据项?', '警告', { confirmButtonText: '确定', cancelButtonText: '取消', - type: 'warning' + type: 'warning', }) .then(() => { deleteClients(clientIds).then(() => { @@ -182,10 +190,10 @@ onMounted(() => { > - + @@ -11,12 +10,12 @@ import { onMounted, reactive, ref, toRefs } from 'vue'; // API依赖 import { - getDeptDetail, + getDeptForrmData, deleteDept, updateDept, addDept, listSelectDepartments, - listTableDepartments + listDepartments, } from '@/api/system/dept'; // 组件依赖 @@ -26,9 +25,8 @@ import { DeptFormData, DeptItem, DeptQueryParam, - Dialog, - Option -} from '@/types'; +} from '@/types/api/system/dept'; +import { Dialog, Option } from '@/types/common'; // DOM元素的引用声明定义 const queryFormRef = ref(ElForm); @@ -51,16 +49,16 @@ const state = reactive({ // 表单数据 formData: { sort: 1, - status: 1 + status: 1, } as DeptFormData, // 表单参数校验 rules: { parentId: [ - { required: true, message: '上级部门不能为空', trigger: 'blur' } + { required: true, message: '上级部门不能为空', trigger: 'blur' }, ], name: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }], - sort: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }] - } + sort: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }], + }, }); const { @@ -71,7 +69,7 @@ const { queryParams, formData, rules, - dialog + dialog, } = toRefs(state); /** @@ -79,7 +77,7 @@ const { */ function handleQuery() { state.loading = true; - listTableDepartments(state.queryParams).then(({ data }) => { + listDepartments(state.queryParams).then(({ data }) => { state.deptList = data; state.loading = false; }); @@ -103,11 +101,11 @@ function handleSelectionChange(selection: any) { */ async function loadDeptData() { const deptOptions: any[] = []; - listSelectDepartments().then(response => { + listSelectDepartments().then((response) => { const rootDeptOption = { value: '0', label: '顶级部门', - children: response.data + children: response.data, }; deptOptions.push(rootDeptOption); state.deptOptions = deptOptions; @@ -123,7 +121,7 @@ function handleAdd(row: any) { state.formData.parentId = row.id; state.dialog = { title: '添加部门', - visible: true + visible: true, }; } @@ -135,9 +133,9 @@ async function handleUpdate(row: any) { const deptId = row.id || state.ids; state.dialog = { title: '修改部门', - visible: true + visible: true, }; - getDeptDetail(deptId).then((response: any) => { + getDeptForrmData(deptId).then((response: any) => { state.formData = response.data; }); } @@ -175,7 +173,7 @@ function handleDelete(row: any) { ElMessageBox.confirm(`确认删除已选中的数据项?`, '警告', { confirmButtonText: '确定', cancelButtonText: '取消', - type: 'warning' + type: 'warning', }) .then(() => { deleteDept(ids) diff --git a/src/views/system/dict/components/DictItem.vue b/src/views/system/dict/components/DictItem.vue index 3b83ff35..33f83c79 100644 --- a/src/views/system/dict/components/DictItem.vue +++ b/src/views/system/dict/components/DictItem.vue @@ -1,3 +1,188 @@ + + + + - - diff --git a/src/views/system/dict/components/Dict.vue b/src/views/system/dict/components/DictType.vue similarity index 90% rename from src/views/system/dict/components/Dict.vue rename to src/views/system/dict/components/DictType.vue index 91c126b8..e2398934 100644 --- a/src/views/system/dict/components/Dict.vue +++ b/src/views/system/dict/components/DictType.vue @@ -1,7 +1,6 @@ - @@ -132,15 +131,21 @@ export default { + - - diff --git a/src/views/system/menu/components/Menu.vue b/src/views/system/menu/components/Menu.vue index 590a3466..13e2f649 100644 --- a/src/views/system/menu/components/Menu.vue +++ b/src/views/system/menu/components/Menu.vue @@ -170,7 +170,7 @@ @click="iconSelectVisible = true" > @@ -220,21 +220,21 @@ import { reactive, ref, onMounted, toRefs } from 'vue'; import { Search, Plus, Edit, Refresh, Delete } from '@element-plus/icons-vue'; import { ElForm, ElMessage, ElMessageBox, ElPopover } from 'element-plus'; +import { Dialog, Option } from '@/types/common'; + import { - Dialog, - Option, MenuFormData, MenuItem, - MenuQueryParam -} from '@/types'; + MenuQueryParam, +} from '@/types/api/system/menu'; // API 依赖 import { - listTableMenus, + listMenus, getMenuDetail, listSelectMenus, addMenu, deleteMenus, - updateMenu + updateMenu, } from '@/api/system/menu'; import SvgIcon from '@/components/SvgIcon/index.vue'; @@ -262,7 +262,7 @@ const state = reactive({ visible: 1, sort: 1, component: 'Layout', - type: 'MENU' + type: 'MENU', } as MenuFormData, rules: { parentId: [{ required: true, message: '请选择顶级菜单', trigger: 'blur' }], @@ -270,8 +270,8 @@ const state = reactive({ type: [{ required: true, message: '请选择菜单类型', trigger: 'blur' }], path: [{ required: true, message: '请输入路由路径', trigger: 'blur' }], component: [ - { required: true, message: '请输入组件完整路径', trigger: 'blur' } - ] + { required: true, message: '请输入组件完整路径', trigger: 'blur' }, + ], }, menuOptions: [] as Option[], currentRow: undefined, @@ -279,8 +279,8 @@ const state = reactive({ iconSelectVisible: false, cacheData: { menuType: '', - menuPath: '' - } + menuPath: '', + }, }); const { @@ -292,7 +292,7 @@ const { rules, menuOptions, iconSelectVisible, - cacheData + cacheData, } = toRefs(state); /** @@ -302,7 +302,7 @@ function handleQuery() { // 重置父组件 emit('menuClick', null); state.loading = true; - listTableMenus(state.queryParams).then(({ data }) => { + listMenus(state.queryParams).then(({ data }) => { state.menuList = data; state.loading = false; }); @@ -338,7 +338,7 @@ async function handleAdd(row: any) { await loadMenuData(); state.dialog = { title: '添加菜单', - visible: true + visible: true, }; if (row.id) { // 行点击新增 @@ -368,7 +368,7 @@ async function handleUpdate(row: any) { await loadMenuData(); state.dialog = { title: '修改菜单', - visible: true + visible: true, }; const id = row.id || state.ids; getMenuDetail(id).then(({ data }) => { @@ -417,7 +417,7 @@ function handleDelete(row: any) { ElMessageBox.confirm('确认删除已选中的数据项?', '警告', { confirmButtonText: '确定', cancelButtonText: '取消', - type: 'warning' + type: 'warning', }) .then(() => { deleteMenus(ids).then(() => { diff --git a/src/views/system/menu/components/Perm.vue b/src/views/system/menu/components/Perm.vue index 4e8444b1..a00e8a24 100644 --- a/src/views/system/menu/components/Perm.vue +++ b/src/views/system/menu/components/Perm.vue @@ -5,7 +5,7 @@ import { reactive, ref, getCurrentInstance, - toRefs + toRefs, } from 'vue'; import { @@ -13,18 +13,18 @@ import { getPermFormDetail, addPerm, updatePerm, - deletePerms + deletePerms, } from '@/api/system/perm'; import { Search, Plus, Edit, Refresh, Delete } from '@element-plus/icons-vue'; import { ElForm, ElMessage, ElMessageBox } from 'element-plus'; +import { Dialog, Option } from '@/types/common'; + import { - Dialog, PermFormData, PermItem, PermQueryParam, - Option -} from '@/types'; +} from '@/types/api/system/perm'; const { proxy }: any = getCurrentInstance(); @@ -34,13 +34,15 @@ const dataFormRef = ref(ElForm); const props = defineProps({ menuId: { type: String, - default: () => {} - } + default: () => { + return ''; + }, + }, }); watch( () => props.menuId, - value => { + (value) => { state.queryParams.menuId = value; handleQuery(); } @@ -56,26 +58,26 @@ const state = reactive({ multiple: true, queryParams: { pageNum: 1, - pageSize: 10 + pageSize: 10, } as PermQueryParam, permList: [] as PermItem[], total: 0, dialog: { - visible: false + visible: false, } as Dialog, formData: {} as PermFormData, rules: { name: [{ required: true, message: '请输入权限名称', trigger: 'blur' }], perm: [{ required: true, message: '请输入权限标识', trigger: 'blur' }], - method: [{ required: true, message: '请选择请求方式', trigger: 'blur' }] + method: [{ required: true, message: '请选择请求方式', trigger: 'blur' }], }, microServiceOptions: [] as Option[], requestMethodOptions: [] as Option[], urlPerm: { requestMethod: '', serviceName: '', - requestPath: '' - } + requestPath: '', + }, }); const { @@ -89,7 +91,7 @@ const { microServiceOptions, requestMethodOptions, urlPerm, - queryParams + queryParams, } = toRefs(state); function handleQuery() { @@ -123,11 +125,11 @@ function handleSelectionChange(selection: any) { * 加载字典数据 */ function loadDictOptions() { - proxy.$listDictsByCode('micro_service').then((response: any) => { + proxy.$getDictItemsByTypeCode('micro_service').then((response: any) => { state.microServiceOptions = response.data; }); - proxy.$listDictsByCode('request_method').then((response: any) => { + proxy.$getDictItemsByTypeCode('request_method').then((response: any) => { state.requestMethodOptions = response.data; }); } @@ -136,7 +138,7 @@ function handleAdd() { loadDictOptions(); state.dialog = { title: '添加权限', - visible: true + visible: true, }; } @@ -144,10 +146,10 @@ function handleUpdate(row: any) { loadDictOptions(); state.dialog = { title: '修改权限', - visible: true + visible: true, }; const id = row.id || state.ids; - getPermFormDetail(id).then(response => { + getPermFormDetail(id).then((response) => { const { data } = response; state.formData = data; if (data && data.urlPerm) { @@ -169,6 +171,7 @@ function submitForm() { dataFormRef.value.validate((isValid: any) => { if (isValid) { // 接口权限和按钮权限必填其一 + console.log(state.urlPerm.requestPath, state.formData.btnPerm); if (!(state.urlPerm.requestPath || state.formData.btnPerm)) { ElMessage.warning('请至少填写一种权限'); return false; @@ -217,7 +220,7 @@ function resetForm() { state.urlPerm = { requestMethod: '', serviceName: '', - requestPath: '' + requestPath: '', }; } @@ -231,7 +234,7 @@ function handleDelete(row: any) { ElMessageBox.confirm('确认删除已选中的数据项?', '警告', { confirmButtonText: '确定', cancelButtonText: '取消', - type: 'warning' + type: 'warning', }) .then(() => { deletePerms(ids).then(() => { diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index e31eb23f..b9df5126 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -4,7 +4,7 @@ @@ -13,7 +13,7 @@