refactor: ♻️ 重构API为静态方法实现模块化管理,并将types.ts重命名为model.ts用于存放接口模型定义
This commit is contained in:
@@ -1,44 +1,48 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { CaptchaResult, LoginData, LoginResult } from "./types";
|
import { CaptchaResult, LoginData, LoginResult } from "./model";
|
||||||
|
|
||||||
/**
|
class AuthAPI {
|
||||||
* 登录API
|
/**
|
||||||
*
|
* 登录API
|
||||||
* @param data {LoginData}
|
*
|
||||||
* @returns
|
* @param data {LoginData}
|
||||||
*/
|
* @returns
|
||||||
export function loginApi(data: LoginData) {
|
*/
|
||||||
const formData = new FormData();
|
static login(data: LoginData) {
|
||||||
formData.append("username", data.username);
|
const formData = new FormData();
|
||||||
formData.append("password", data.password);
|
formData.append("username", data.username);
|
||||||
formData.append("captchaKey", data.captchaKey || "");
|
formData.append("password", data.password);
|
||||||
formData.append("captchaCode", data.captchaCode || "");
|
formData.append("captchaKey", data.captchaKey || "");
|
||||||
return request<any, ResponseData<LoginResult>>({
|
formData.append("captchaCode", data.captchaCode || "");
|
||||||
url: "/api/v1/auth/login",
|
return request<any, LoginResult>({
|
||||||
method: "post",
|
url: "/api/v1/auth/login",
|
||||||
data: formData,
|
method: "post",
|
||||||
headers: {
|
data: formData,
|
||||||
"Content-Type": "multipart/form-data",
|
headers: {
|
||||||
},
|
"Content-Type": "multipart/form-data",
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销API
|
||||||
|
*/
|
||||||
|
static logout() {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/auth/logout",
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取验证码
|
||||||
|
*/
|
||||||
|
static getCaptcha() {
|
||||||
|
return request<any, CaptchaResult>({
|
||||||
|
url: "/api/v1/auth/captcha",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default AuthAPI;
|
||||||
* 注销API
|
|
||||||
*/
|
|
||||||
export function logoutApi() {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/auth/logout",
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取验证码
|
|
||||||
*/
|
|
||||||
export function getCaptchaApi() {
|
|
||||||
return request<any, ResponseData<CaptchaResult>>({
|
|
||||||
url: "/api/v1/auth/captcha",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,76 +1,80 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { DeptForm, DeptQuery, DeptVO } from "./types";
|
import { DeptForm, DeptQuery, DeptVO } from "./model";
|
||||||
|
|
||||||
/**
|
class DeptAPI {
|
||||||
* 部门树形表格
|
/**
|
||||||
*
|
* 部门树形表格
|
||||||
* @param queryParams
|
*
|
||||||
*/
|
* @param queryParams
|
||||||
export function listDepts(queryParams?: DeptQuery) {
|
*/
|
||||||
return request<any, ResponseData<DeptVO[]>>({
|
static getList(queryParams?: DeptQuery) {
|
||||||
url: "/api/v1/dept",
|
return request<any, DeptVO[]>({
|
||||||
method: "get",
|
url: "/api/v1/dept",
|
||||||
params: queryParams,
|
method: "get",
|
||||||
});
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门下拉列表
|
||||||
|
*/
|
||||||
|
static getOptions() {
|
||||||
|
return request<any, OptionType[]>({
|
||||||
|
url: "/api/v1/dept/options",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取部门详情
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
static getFormData(id: number) {
|
||||||
|
return request<any, DeptForm>({
|
||||||
|
url: "/api/v1/dept/" + id + "/form",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增部门
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static add(data: DeptForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dept",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改部门
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static update(id: number, data: DeptForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dept/" + id,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除部门
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
static deleteByIds(ids: string) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dept/" + ids,
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default DeptAPI;
|
||||||
* 部门下拉列表
|
|
||||||
*/
|
|
||||||
export function getDeptOptions() {
|
|
||||||
return request<any, ResponseData<OptionType[]>>({
|
|
||||||
url: "/api/v1/dept/options",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取部门详情
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
export function getDeptForm(id: number) {
|
|
||||||
return request<any, ResponseData<DeptForm>>({
|
|
||||||
url: "/api/v1/dept/" + id + "/form",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增部门
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function addDept(data: DeptForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dept",
|
|
||||||
method: "post",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改部门
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function updateDept(id: number, data: DeptForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dept/" + id,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除部门
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
*/
|
|
||||||
export function deleteDept(ids: string) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dept/" + ids,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,140 +6,144 @@ import {
|
|||||||
DictQuery,
|
DictQuery,
|
||||||
DictForm,
|
DictForm,
|
||||||
DictPageResult,
|
DictPageResult,
|
||||||
} from "./types";
|
} from "./model";
|
||||||
|
|
||||||
/**
|
class DictAPI {
|
||||||
* 字典类型分页列表
|
/**
|
||||||
*
|
* 字典类型分页列表
|
||||||
* @param queryParams
|
*
|
||||||
*/
|
* @param queryParams
|
||||||
export function getDictTypePage(queryParams: DictTypeQuery) {
|
*/
|
||||||
return request<any, ResponseData<DictTypePageResult>>({
|
static getDictTypePage(queryParams: DictTypeQuery) {
|
||||||
url: "/api/v1/dict/types/page",
|
return request<any, DictTypePageResult>({
|
||||||
method: "get",
|
url: "/api/v1/dict/types/page",
|
||||||
params: queryParams,
|
method: "get",
|
||||||
});
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典类型表单数据
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
static getDictTypeForm(id: number) {
|
||||||
|
return request<any, ResponseData<DictTypeForm>>({
|
||||||
|
url: "/api/v1/dict/types/" + id + "/form",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典类型
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static addDictType(data: DictTypeForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dict/types",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典类型
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static updateDictType(id: number, data: DictTypeForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dict/types/" + id,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典类型
|
||||||
|
*/
|
||||||
|
static deleteDictTypes(ids: string) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dict/types/" + ids,
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典类型的数据项
|
||||||
|
*
|
||||||
|
* @param typeCode 字典类型编码
|
||||||
|
*/
|
||||||
|
static getDictOptions(typeCode: string) {
|
||||||
|
return request<any, OptionType[]>({
|
||||||
|
url: "/api/v1/dict/" + typeCode + "/options",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典分页列表
|
||||||
|
*/
|
||||||
|
static getDictPage(queryParams: DictQuery) {
|
||||||
|
return request<any, DictPageResult>({
|
||||||
|
url: "/api/v1/dict/page",
|
||||||
|
method: "get",
|
||||||
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典表单数据
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
static getDictFormData(id: number) {
|
||||||
|
return request<any, DictForm>({
|
||||||
|
url: "/api/v1/dict/" + id + "/form",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增字典
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static addDict(data: DictForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dict",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改字典项
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static updateDict(id: number, data: DictForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dict/" + id,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除字典
|
||||||
|
*
|
||||||
|
* @param ids 字典项ID,多个以英文逗号(,)分割
|
||||||
|
*/
|
||||||
|
static deleteDictByIds(ids: string) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/dict/" + ids,
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default DictAPI;
|
||||||
* 字典类型表单数据
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
export function getDictTypeForm(id: number) {
|
|
||||||
return request<any, ResponseData<DictTypeForm>>({
|
|
||||||
url: "/api/v1/dict/types/" + id + "/form",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增字典类型
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function addDictType(data: DictTypeForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dict/types",
|
|
||||||
method: "post",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改字典类型
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function updateDictType(id: number, data: DictTypeForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dict/types/" + id,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除字典类型
|
|
||||||
*/
|
|
||||||
export function deleteDictTypes(ids: string) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dict/types/" + ids,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字典类型的数据项
|
|
||||||
*
|
|
||||||
* @param typeCode 字典类型编码
|
|
||||||
*/
|
|
||||||
export function getDictOptions(typeCode: string) {
|
|
||||||
return request<any, ResponseData<OptionType[]>>({
|
|
||||||
url: "/api/v1/dict/" + typeCode + "/options",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字典分页列表
|
|
||||||
*/
|
|
||||||
export function getDictPage(queryParams: DictQuery) {
|
|
||||||
return request<any, ResponseData<DictPageResult>>({
|
|
||||||
url: "/api/v1/dict/page",
|
|
||||||
method: "get",
|
|
||||||
params: queryParams,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取字典表单数据
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
export function getDictFormData(id: number) {
|
|
||||||
return request<any, ResponseData<DictForm>>({
|
|
||||||
url: "/api/v1/dict/" + id + "/form",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增字典
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function addDict(data: DictForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dict",
|
|
||||||
method: "post",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改字典项
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function updateDict(id: number, data: DictForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dict/" + id,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除字典
|
|
||||||
*
|
|
||||||
* @param ids 字典项ID,多个以英文逗号(,)分割
|
|
||||||
*/
|
|
||||||
export function deleteDict(ids: string) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/dict/" + ids,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,33 +1,37 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { FileInfo } from "./types";
|
import { FileInfo } from "./model";
|
||||||
|
|
||||||
/**
|
class FileAPI {
|
||||||
* 上传文件
|
/**
|
||||||
*
|
* 上传文件
|
||||||
* @param file
|
*
|
||||||
*/
|
* @param file
|
||||||
export function uploadFileApi(file: File) {
|
*/
|
||||||
const formData = new FormData();
|
static upload(file: File) {
|
||||||
formData.append("file", file);
|
const formData = new FormData();
|
||||||
return request<any, ResponseData<FileInfo>>({
|
formData.append("file", file);
|
||||||
url: "/api/v1/files",
|
return request<any, FileInfo>({
|
||||||
method: "post",
|
url: "/api/v1/files",
|
||||||
data: formData,
|
method: "post",
|
||||||
headers: {
|
data: formData,
|
||||||
"Content-Type": "multipart/form-data",
|
headers: {
|
||||||
},
|
"Content-Type": "multipart/form-data",
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*
|
||||||
|
* @param filePath 文件完整路径
|
||||||
|
*/
|
||||||
|
static deleteByPath(filePath?: string) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/files",
|
||||||
|
method: "delete",
|
||||||
|
params: { filePath: filePath },
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default FileAPI;
|
||||||
* 删除文件
|
|
||||||
*
|
|
||||||
* @param filePath 文件完整路径
|
|
||||||
*/
|
|
||||||
export function deleteFileApi(filePath?: string) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/files",
|
|
||||||
method: "delete",
|
|
||||||
params: { filePath: filePath },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,87 +1,90 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import type { RouteRecordRaw } from "vue-router";
|
import { MenuQuery, MenuVO, MenuForm, RouteVO } from "./model";
|
||||||
import { MenuQuery, MenuVO, MenuForm } from "./types";
|
|
||||||
|
|
||||||
/**
|
class MenuAPI {
|
||||||
* 获取路由列表
|
/**
|
||||||
*/
|
* 获取路由列表
|
||||||
export function listRoutes() {
|
*/
|
||||||
return request<any, ResponseData<RouteRecordRaw[]>>({
|
static getRoutes() {
|
||||||
url: "/api/v1/menus/routes",
|
return request<any, RouteVO[]>({
|
||||||
method: "get",
|
url: "/api/v1/menus/routes",
|
||||||
});
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单树形列表
|
||||||
|
*
|
||||||
|
* @param queryParams
|
||||||
|
*/
|
||||||
|
static getList(queryParams: MenuQuery) {
|
||||||
|
return request<any, MenuVO[]>({
|
||||||
|
url: "/api/v1/menus",
|
||||||
|
method: "get",
|
||||||
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单下拉数据源
|
||||||
|
*/
|
||||||
|
static getOptions() {
|
||||||
|
return request<any, OptionType[]>({
|
||||||
|
url: "/api/v1/menus/options",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取菜单表单数据
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
static getFormData(id: number) {
|
||||||
|
return request<any, MenuForm>({
|
||||||
|
url: "/api/v1/menus/" + id + "/form",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加菜单
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static add(data: MenuForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/menus",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改菜单
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static update(id: string, data: MenuForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/menus/" + id,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除菜单
|
||||||
|
*
|
||||||
|
* @param id 菜单ID
|
||||||
|
*/
|
||||||
|
static deleteById(id: number) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/menus/" + id,
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default MenuAPI;
|
||||||
* 获取菜单树形列表
|
|
||||||
*
|
|
||||||
* @param queryParams
|
|
||||||
*/
|
|
||||||
export function listMenus(queryParams: MenuQuery) {
|
|
||||||
return request<any, ResponseData<MenuVO[]>>({
|
|
||||||
url: "/api/v1/menus",
|
|
||||||
method: "get",
|
|
||||||
params: queryParams,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取菜单下拉树形列表
|
|
||||||
*/
|
|
||||||
export function getMenuOptions() {
|
|
||||||
return request<any, ResponseData<OptionType[]>>({
|
|
||||||
url: "/api/v1/menus/options",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取菜单表单数据
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
export function getMenuForm(id: number) {
|
|
||||||
return request<any, ResponseData<MenuForm>>({
|
|
||||||
url: "/api/v1/menus/" + id + "/form",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加菜单
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function addMenu(data: MenuForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/menus",
|
|
||||||
method: "post",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改菜单
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function updateMenu(id: string, data: MenuForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/menus/" + id,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除菜单
|
|
||||||
*
|
|
||||||
* @param id 菜单ID
|
|
||||||
*/
|
|
||||||
export function deleteMenu(id: number) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/menus/" + id,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -122,3 +122,60 @@ export interface MenuForm {
|
|||||||
*/
|
*/
|
||||||
alwaysShow?: number;
|
alwaysShow?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RouteVO,路由对象
|
||||||
|
*/
|
||||||
|
export interface RouteVO {
|
||||||
|
/**
|
||||||
|
* 子路由列表
|
||||||
|
*/
|
||||||
|
children: RouteVO[];
|
||||||
|
/**
|
||||||
|
* 组件路径
|
||||||
|
*/
|
||||||
|
component?: string;
|
||||||
|
meta?: Meta;
|
||||||
|
/**
|
||||||
|
* 路由名称
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
/**
|
||||||
|
* 路由路径
|
||||||
|
*/
|
||||||
|
path?: string;
|
||||||
|
/**
|
||||||
|
* 跳转链接
|
||||||
|
*/
|
||||||
|
redirect?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meta,路由属性类型
|
||||||
|
*/
|
||||||
|
export interface Meta {
|
||||||
|
/**
|
||||||
|
* 【目录】只有一个子路由是否始终显示
|
||||||
|
*/
|
||||||
|
alwaysShow?: boolean;
|
||||||
|
/**
|
||||||
|
* 是否隐藏(true-是 false-否)
|
||||||
|
*/
|
||||||
|
hidden?: boolean;
|
||||||
|
/**
|
||||||
|
* ICON
|
||||||
|
*/
|
||||||
|
icon?: string;
|
||||||
|
/**
|
||||||
|
* 【菜单】是否开启页面缓存
|
||||||
|
*/
|
||||||
|
keepAlive?: boolean;
|
||||||
|
/**
|
||||||
|
* 拥有路由权限的角色编码
|
||||||
|
*/
|
||||||
|
roles?: string[];
|
||||||
|
/**
|
||||||
|
* 路由title
|
||||||
|
*/
|
||||||
|
title?: string;
|
||||||
|
}
|
||||||
@@ -1,104 +1,108 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { RoleQuery, RolePageResult, RoleForm } from "./types";
|
import { RoleQuery, RolePageResult, RoleForm } from "./model";
|
||||||
|
|
||||||
/**
|
class RoleAPI {
|
||||||
* 获取角色分页数据
|
/**
|
||||||
*
|
* 获取角色分页数据
|
||||||
* @param queryParams
|
*
|
||||||
*/
|
* @param queryParams
|
||||||
export function getRolePage(queryParams?: RoleQuery) {
|
*/
|
||||||
return request<any, ResponseData<RolePageResult>>({
|
static getPage(queryParams?: RoleQuery) {
|
||||||
url: "/api/v1/roles/page",
|
return request<any, RolePageResult>({
|
||||||
method: "get",
|
url: "/api/v1/roles/page",
|
||||||
params: queryParams,
|
method: "get",
|
||||||
});
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色下拉数据源
|
||||||
|
*
|
||||||
|
* @param queryParams
|
||||||
|
*/
|
||||||
|
static getOptions(queryParams?: RoleQuery) {
|
||||||
|
return request<any, OptionType[]>({
|
||||||
|
url: "/api/v1/roles/options",
|
||||||
|
method: "get",
|
||||||
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色的菜单ID集合
|
||||||
|
*
|
||||||
|
* @param queryParams
|
||||||
|
*/
|
||||||
|
static getRoleMenuIds(roleId: number) {
|
||||||
|
return request<any, number[]>({
|
||||||
|
url: "/api/v1/roles/" + roleId + "/menuIds",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配菜单权限给角色
|
||||||
|
*
|
||||||
|
* @param queryParams
|
||||||
|
*/
|
||||||
|
static updateRoleMenus(roleId: number, data: number[]) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/roles/" + roleId + "/menus",
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取角色表单数据
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
static getFormData(id: number) {
|
||||||
|
return request<any, RoleForm>({
|
||||||
|
url: "/api/v1/roles/" + id + "/form",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加角色
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static add(data: RoleForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/roles",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新角色
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static update(id: number, data: RoleForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/roles/" + id,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除角色,多个以英文逗号(,)分割
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
static deleteByIds(ids: string) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/roles/" + ids,
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default RoleAPI;
|
||||||
* 获取角色下拉数据
|
|
||||||
*
|
|
||||||
* @param queryParams
|
|
||||||
*/
|
|
||||||
export function getRoleOptions(queryParams?: RoleQuery) {
|
|
||||||
return request<any, ResponseData<OptionType[]>>({
|
|
||||||
url: "/api/v1/roles/options",
|
|
||||||
method: "get",
|
|
||||||
params: queryParams,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色的菜单ID集合
|
|
||||||
*
|
|
||||||
* @param queryParams
|
|
||||||
*/
|
|
||||||
export function getRoleMenuIds(roleId: number) {
|
|
||||||
return request<any, ResponseData<number[]>>({
|
|
||||||
url: "/api/v1/roles/" + roleId + "/menuIds",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分配菜单权限给角色
|
|
||||||
*
|
|
||||||
* @param queryParams
|
|
||||||
*/
|
|
||||||
export function updateRoleMenus(roleId: number, data: number[]) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/roles/" + roleId + "/menus",
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色详情
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
export function getRoleForm(id: number) {
|
|
||||||
return request<any, ResponseData<RoleForm>>({
|
|
||||||
url: "/api/v1/roles/" + id + "/form",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加角色
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function addRole(data: RoleForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/roles",
|
|
||||||
method: "post",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新角色
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function updateRole(id: number, data: RoleForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/roles/" + id,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除角色,多个以英文逗号(,)分割
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
*/
|
|
||||||
export function deleteRoles(ids: string) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/roles/" + ids,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,137 +1,141 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { UserForm, UserInfo, UserPageVO, UserQuery } from "./types";
|
import { UserForm, UserInfo, UserPageVO, UserQuery } from "./model";
|
||||||
|
|
||||||
/**
|
class UserAPI {
|
||||||
* 登录成功后获取用户信息(昵称、头像、权限集合和角色集合)
|
/**
|
||||||
*/
|
* 登录成功后获取用户信息(昵称、头像、权限集合和角色集合)
|
||||||
export function getUserInfoApi() {
|
*/
|
||||||
return request<any, ResponseData<UserInfo>>({
|
static getInfo() {
|
||||||
url: "/api/v1/users/me",
|
return request<any, UserInfo>({
|
||||||
method: "get",
|
url: "/api/v1/users/me",
|
||||||
});
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户分页列表
|
||||||
|
*
|
||||||
|
* @param queryParams
|
||||||
|
*/
|
||||||
|
static getPage(queryParams: UserQuery) {
|
||||||
|
return request<any, PageResult<UserPageVO[]>>({
|
||||||
|
url: "/api/v1/users/page",
|
||||||
|
method: "get",
|
||||||
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户表单详情
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
static getFormData(userId: number) {
|
||||||
|
return request<any, UserForm>({
|
||||||
|
url: "/api/v1/users/" + userId + "/form",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static add(data: UserForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/users",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
static update(id: number, data: UserForm) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/users/" + id,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户密码
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param password
|
||||||
|
*/
|
||||||
|
static updatePassword(id: number, password: string) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/users/" + id + "/password",
|
||||||
|
method: "patch",
|
||||||
|
params: { password: password },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
*/
|
||||||
|
static deleteByIds(ids: string) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/users/" + ids,
|
||||||
|
method: "delete",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载用户导入模板
|
||||||
|
*
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
static downloadTemplate() {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/users/template",
|
||||||
|
method: "get",
|
||||||
|
responseType: "arraybuffer",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出用户
|
||||||
|
*
|
||||||
|
* @param queryParams
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
static export(queryParams: UserQuery) {
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/users/export",
|
||||||
|
method: "get",
|
||||||
|
params: queryParams,
|
||||||
|
responseType: "arraybuffer",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入用户
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
*/
|
||||||
|
static import(deptId: number, file: File) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("file", file);
|
||||||
|
return request({
|
||||||
|
url: "/api/v1/users/import",
|
||||||
|
method: "post",
|
||||||
|
params: { deptId: deptId },
|
||||||
|
data: formData,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "multipart/form-data",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export default UserAPI;
|
||||||
* 获取用户分页列表
|
|
||||||
*
|
|
||||||
* @param queryParams
|
|
||||||
*/
|
|
||||||
export function getUserPage(queryParams: UserQuery) {
|
|
||||||
return request<any, ResponseData<PageResult<UserPageVO[]>>>({
|
|
||||||
url: "/api/v1/users/page",
|
|
||||||
method: "get",
|
|
||||||
params: queryParams,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户表单详情
|
|
||||||
*
|
|
||||||
* @param userId
|
|
||||||
*/
|
|
||||||
export function getUserForm(userId: number) {
|
|
||||||
return request<any, ResponseData<UserForm>>({
|
|
||||||
url: "/api/v1/users/" + userId + "/form",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加用户
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function addUser(data: UserForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/users",
|
|
||||||
method: "post",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改用户
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export function updateUser(id: number, data: UserForm) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/users/" + id,
|
|
||||||
method: "put",
|
|
||||||
data: data,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改用户密码
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param password
|
|
||||||
*/
|
|
||||||
export function updateUserPassword(id: number, password: string) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/users/" + id + "/password",
|
|
||||||
method: "patch",
|
|
||||||
params: { password: password },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除用户
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
*/
|
|
||||||
export function deleteUsers(ids: string) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/users/" + ids,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载用户导入模板
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function downloadTemplateApi() {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/users/template",
|
|
||||||
method: "get",
|
|
||||||
responseType: "arraybuffer",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出用户
|
|
||||||
*
|
|
||||||
* @param queryParams
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function exportUser(queryParams: UserQuery) {
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/users/_export",
|
|
||||||
method: "get",
|
|
||||||
params: queryParams,
|
|
||||||
responseType: "arraybuffer",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入用户
|
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
*/
|
|
||||||
export function importUser(deptId: number, file: File) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("file", file);
|
|
||||||
return request({
|
|
||||||
url: "/api/v1/users/_import",
|
|
||||||
method: "post",
|
|
||||||
params: { deptId: deptId },
|
|
||||||
data: formData,
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "multipart/form-data",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getDictOptions } from "@/api/dict";
|
import DictAPI from "@/api/dict";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
/**
|
/**
|
||||||
@@ -66,8 +66,8 @@ function handleChange(val?: string | number | undefined) {
|
|||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
// 根据字典类型编码(typeCode)获取字典选项
|
// 根据字典类型编码(typeCode)获取字典选项
|
||||||
getDictOptions(props.typeCode).then((response) => {
|
DictAPI.getDictOptions(props.typeCode).then((data) => {
|
||||||
options.value = response.data;
|
options.value = data;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ function fetchPageData(formData: IObject = {}, isRestart = false) {
|
|||||||
}
|
}
|
||||||
props.contentConfig
|
props.contentConfig
|
||||||
.indexAction({ ...queryParams, ...formData })
|
.indexAction({ ...queryParams, ...formData })
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
total.value = data.total;
|
total.value = data.total;
|
||||||
pageData.value = data.list;
|
pageData.value = data.list;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
<!--
|
<!-- 多图上传组件 -->
|
||||||
多图上传组件
|
|
||||||
@author: youlaitech
|
|
||||||
@date 2022/11/20
|
|
||||||
-->
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-upload
|
<el-upload
|
||||||
v-model:file-list="fileList"
|
v-model:file-list="fileList"
|
||||||
@@ -30,7 +25,7 @@ import {
|
|||||||
UploadFile,
|
UploadFile,
|
||||||
UploadProps,
|
UploadProps,
|
||||||
} from "element-plus";
|
} from "element-plus";
|
||||||
import { uploadFileApi, deleteFileApi } from "@/api/file";
|
import FileAPI from "@/api/file";
|
||||||
|
|
||||||
const emit = defineEmits(["update:modelValue"]);
|
const emit = defineEmits(["update:modelValue"]);
|
||||||
|
|
||||||
@@ -83,7 +78,7 @@ watch(
|
|||||||
*/
|
*/
|
||||||
async function handleUpload(options: UploadRequestOptions): Promise<any> {
|
async function handleUpload(options: UploadRequestOptions): Promise<any> {
|
||||||
// 上传API调用
|
// 上传API调用
|
||||||
const { data: fileInfo } = await uploadFileApi(options.file);
|
const { data: fileInfo } = await FileAPI.upload(options.file);
|
||||||
|
|
||||||
// 上传成功需手动替换文件路径为远程URL,否则图片地址为预览地址 blob:http://
|
// 上传成功需手动替换文件路径为远程URL,否则图片地址为预览地址 blob:http://
|
||||||
const fileIndex = fileList.value.findIndex(
|
const fileIndex = fileList.value.findIndex(
|
||||||
@@ -108,7 +103,7 @@ function handleRemove(removeFile: UploadFile) {
|
|||||||
const filePath = removeFile.url;
|
const filePath = removeFile.url;
|
||||||
|
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
deleteFileApi(filePath).then(() => {
|
FileAPI.deleteByPath(filePath).then(() => {
|
||||||
// 删除成功回调
|
// 删除成功回调
|
||||||
emit(
|
emit(
|
||||||
"update:modelValue",
|
"update:modelValue",
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { UploadRawFile, UploadRequestOptions } from "element-plus";
|
import { UploadRawFile, UploadRequestOptions } from "element-plus";
|
||||||
import { uploadFileApi } from "@/api/file";
|
import FileAPI from "@/api/file";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@@ -33,7 +33,7 @@ const imgUrl = useVModel(props, "modelValue", emit);
|
|||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
async function uploadFile(options: UploadRequestOptions): Promise<any> {
|
async function uploadFile(options: UploadRequestOptions): Promise<any> {
|
||||||
const { data: fileInfo } = await uploadFileApi(options.file);
|
const { data: fileInfo } = await FileAPI.update(options.file);
|
||||||
imgUrl.value = fileInfo.url;
|
imgUrl.value = fileInfo.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
src/enums/CacheEnum.ts
Normal file
4
src/enums/CacheEnum.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 令牌缓存Key
|
||||||
|
*/
|
||||||
|
export const TOKEN_KEY = "accessToken";
|
||||||
18
src/enums/ResultEnum.ts
Normal file
18
src/enums/ResultEnum.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* 响应码枚举
|
||||||
|
*/
|
||||||
|
export const enum ResultEnum {
|
||||||
|
/**
|
||||||
|
* 成功
|
||||||
|
*/
|
||||||
|
SUCCESS = "00000",
|
||||||
|
/**
|
||||||
|
* 错误
|
||||||
|
*/
|
||||||
|
ERROR = "B0001",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 令牌无效或过期
|
||||||
|
*/
|
||||||
|
TOKEN_INVALID = "A0230",
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import router from "@/router";
|
|||||||
import { useUserStore, usePermissionStore } from "@/store";
|
import { useUserStore, usePermissionStore } from "@/store";
|
||||||
import NProgress from "@/utils/nprogress";
|
import NProgress from "@/utils/nprogress";
|
||||||
import { RouteRecordRaw } from "vue-router";
|
import { RouteRecordRaw } from "vue-router";
|
||||||
|
import { TOKEN_KEY } from "@/enums/CacheEnum";
|
||||||
|
|
||||||
export function setupPermission() {
|
export function setupPermission() {
|
||||||
// 白名单路由
|
// 白名单路由
|
||||||
@@ -9,7 +10,7 @@ export function setupPermission() {
|
|||||||
|
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
const hasToken = localStorage.getItem("accessToken");
|
const hasToken = localStorage.getItem(TOKEN_KEY);
|
||||||
if (hasToken) {
|
if (hasToken) {
|
||||||
if (to.path === "/login") {
|
if (to.path === "/login") {
|
||||||
// 如果已登录,跳转首页
|
// 如果已登录,跳转首页
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { RouteRecordRaw } from "vue-router";
|
import { RouteRecordRaw } from "vue-router";
|
||||||
import { constantRoutes } from "@/router";
|
import { constantRoutes } from "@/router";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import { listRoutes } from "@/api/menu";
|
import MenuAPI from "@/api/menu";
|
||||||
|
import { RouteVO } from "@/api/menu/model";
|
||||||
|
|
||||||
const modules = import.meta.glob("../../views/**/**.vue");
|
const modules = import.meta.glob("../../views/**/**.vue");
|
||||||
const Layout = () => import("@/layout/index.vue");
|
const Layout = () => import("@/layout/index.vue");
|
||||||
@@ -29,25 +30,22 @@ const hasPermission = (roles: string[], route: RouteRecordRaw) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归过滤有权限的异步(动态)路由
|
* 递归过滤有权限的动态路由
|
||||||
*
|
*
|
||||||
* @param routes 接口返回的异步(动态)路由
|
* @param routes 接口返回所有的动态路由
|
||||||
* @param roles 用户角色集合
|
* @param roles 用户角色集合
|
||||||
* @returns 返回用户有权限的异步(动态)路由
|
* @returns 返回用户有权限的动态路由
|
||||||
*/
|
*/
|
||||||
const filterAsyncRoutes = (routes: RouteRecordRaw[], roles: string[]) => {
|
const filterAsyncRoutes = (routes: RouteVO[], roles: string[]) => {
|
||||||
const asyncRoutes: RouteRecordRaw[] = [];
|
const asyncRoutes: RouteRecordRaw[] = [];
|
||||||
|
|
||||||
routes.forEach((route) => {
|
routes.forEach((route) => {
|
||||||
const tmpRoute = { ...route }; // ES6扩展运算符复制新对象
|
const tmpRoute = { ...route } as RouteRecordRaw; // 深拷贝 route 对象 避免污染
|
||||||
if (!route.name) {
|
|
||||||
tmpRoute.name = route.path;
|
|
||||||
}
|
|
||||||
// 判断用户(角色)是否有该路由的访问权限
|
|
||||||
if (hasPermission(roles, tmpRoute)) {
|
if (hasPermission(roles, tmpRoute)) {
|
||||||
|
// 如果是顶级目录,替换为 Layout 组件
|
||||||
if (tmpRoute.component?.toString() == "Layout") {
|
if (tmpRoute.component?.toString() == "Layout") {
|
||||||
tmpRoute.component = Layout;
|
tmpRoute.component = Layout;
|
||||||
} else {
|
} else {
|
||||||
|
// 如果是子目录,动态加载组件
|
||||||
const component = modules[`../../views/${tmpRoute.component}.vue`];
|
const component = modules[`../../views/${tmpRoute.component}.vue`];
|
||||||
if (component) {
|
if (component) {
|
||||||
tmpRoute.component = component;
|
tmpRoute.component = component;
|
||||||
@@ -57,7 +55,7 @@ const filterAsyncRoutes = (routes: RouteRecordRaw[], roles: string[]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tmpRoute.children) {
|
if (tmpRoute.children) {
|
||||||
tmpRoute.children = filterAsyncRoutes(tmpRoute.children, roles);
|
tmpRoute.children = filterAsyncRoutes(route.children, roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
asyncRoutes.push(tmpRoute);
|
asyncRoutes.push(tmpRoute);
|
||||||
@@ -66,7 +64,6 @@ const filterAsyncRoutes = (routes: RouteRecordRaw[], roles: string[]) => {
|
|||||||
|
|
||||||
return asyncRoutes;
|
return asyncRoutes;
|
||||||
};
|
};
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
export const usePermissionStore = defineStore("permission", () => {
|
export const usePermissionStore = defineStore("permission", () => {
|
||||||
// state
|
// state
|
||||||
@@ -76,6 +73,7 @@ export const usePermissionStore = defineStore("permission", () => {
|
|||||||
function setRoutes(newRoutes: RouteRecordRaw[]) {
|
function setRoutes(newRoutes: RouteRecordRaw[]) {
|
||||||
routes.value = constantRoutes.concat(newRoutes);
|
routes.value = constantRoutes.concat(newRoutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成动态路由
|
* 生成动态路由
|
||||||
*
|
*
|
||||||
@@ -85,10 +83,10 @@ export const usePermissionStore = defineStore("permission", () => {
|
|||||||
function generateRoutes(roles: string[]) {
|
function generateRoutes(roles: string[]) {
|
||||||
return new Promise<RouteRecordRaw[]>((resolve, reject) => {
|
return new Promise<RouteRecordRaw[]>((resolve, reject) => {
|
||||||
// 接口获取所有路由
|
// 接口获取所有路由
|
||||||
listRoutes()
|
MenuAPI.getRoutes()
|
||||||
.then(({ data: asyncRoutes }) => {
|
.then((data) => {
|
||||||
// 根据角色获取有访问权限的路由
|
// 过滤有权限的动态路由
|
||||||
const accessedRoutes = filterAsyncRoutes(asyncRoutes, roles);
|
const accessedRoutes = filterAsyncRoutes(data, roles);
|
||||||
setRoutes(accessedRoutes);
|
setRoutes(accessedRoutes);
|
||||||
resolve(accessedRoutes);
|
resolve(accessedRoutes);
|
||||||
})
|
})
|
||||||
@@ -97,6 +95,7 @@ export const usePermissionStore = defineStore("permission", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取与激活的顶部菜单项相关的混合模式左侧菜单集合
|
* 获取与激活的顶部菜单项相关的混合模式左侧菜单集合
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { loginApi, logoutApi } from "@/api/auth";
|
import AuthAPI from "@/api/auth";
|
||||||
import { getUserInfoApi } from "@/api/user";
|
import UserAPI from "@/api/user";
|
||||||
import { resetRouter } from "@/router";
|
import { resetRouter } from "@/router";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
|
|
||||||
import { LoginData } from "@/api/auth/types";
|
import { LoginData } from "@/api/auth/model";
|
||||||
import { UserInfo } from "@/api/user/types";
|
import { UserInfo } from "@/api/user/model";
|
||||||
|
import { TOKEN_KEY } from "@/enums/CacheEnum";
|
||||||
|
|
||||||
export const useUserStore = defineStore("user", () => {
|
export const useUserStore = defineStore("user", () => {
|
||||||
const user = ref<UserInfo>({
|
const user = ref<UserInfo>({
|
||||||
@@ -20,10 +21,10 @@ export const useUserStore = defineStore("user", () => {
|
|||||||
*/
|
*/
|
||||||
function login(loginData: LoginData) {
|
function login(loginData: LoginData) {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
loginApi(loginData)
|
AuthAPI.login(loginData)
|
||||||
.then((response) => {
|
.then((data) => {
|
||||||
const { tokenType, accessToken } = response.data;
|
const { tokenType, accessToken } = data;
|
||||||
localStorage.setItem("accessToken", tokenType + " " + accessToken); // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx
|
localStorage.setItem(TOKEN_KEY, tokenType + " " + accessToken); // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@@ -35,8 +36,8 @@ export const useUserStore = defineStore("user", () => {
|
|||||||
// 获取信息(用户昵称、头像、角色集合、权限集合)
|
// 获取信息(用户昵称、头像、角色集合、权限集合)
|
||||||
function getUserInfo() {
|
function getUserInfo() {
|
||||||
return new Promise<UserInfo>((resolve, reject) => {
|
return new Promise<UserInfo>((resolve, reject) => {
|
||||||
getUserInfoApi()
|
UserAPI.getInfo()
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
reject("Verification failed, please Login again.");
|
reject("Verification failed, please Login again.");
|
||||||
return;
|
return;
|
||||||
@@ -57,9 +58,9 @@ export const useUserStore = defineStore("user", () => {
|
|||||||
// user logout
|
// user logout
|
||||||
function logout() {
|
function logout() {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
logoutApi()
|
AuthAPI.logout()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
localStorage.setItem("accessToken", "");
|
localStorage.setItem(TOKEN_KEY, "");
|
||||||
location.reload(); // 清空路由
|
location.reload(); // 清空路由
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
@@ -73,7 +74,7 @@ export const useUserStore = defineStore("user", () => {
|
|||||||
function resetToken() {
|
function resetToken() {
|
||||||
console.log("resetToken");
|
console.log("resetToken");
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
localStorage.setItem("accessToken", "");
|
localStorage.setItem(TOKEN_KEY, "");
|
||||||
resetRouter();
|
resetRouter();
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from "axios";
|
import axios, { InternalAxiosRequestConfig, AxiosResponse } from "axios";
|
||||||
import { useUserStoreHook } from "@/store/modules/user";
|
import { useUserStoreHook } from "@/store/modules/user";
|
||||||
|
import { ResultEnum } from "@/enums/ResultEnum";
|
||||||
|
import { TOKEN_KEY } from "@/enums/CacheEnum";
|
||||||
|
|
||||||
// 创建 axios 实例
|
// 创建 axios 实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
@@ -11,7 +13,7 @@ const service = axios.create({
|
|||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
service.interceptors.request.use(
|
service.interceptors.request.use(
|
||||||
(config: InternalAxiosRequestConfig) => {
|
(config: InternalAxiosRequestConfig) => {
|
||||||
const accessToken = localStorage.getItem("accessToken");
|
const accessToken = localStorage.getItem(TOKEN_KEY);
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
config.headers.Authorization = accessToken;
|
config.headers.Authorization = accessToken;
|
||||||
}
|
}
|
||||||
@@ -25,23 +27,27 @@ service.interceptors.request.use(
|
|||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
(response: AxiosResponse) => {
|
(response: AxiosResponse) => {
|
||||||
const { code, msg } = response.data;
|
// 检查配置的响应类型是否为二进制类型('blob' 或 'arraybuffer'), 如果是,直接返回响应对象
|
||||||
if (code === "00000") {
|
if (
|
||||||
return response.data;
|
response.config.responseType === "blob" ||
|
||||||
}
|
response.config.responseType === "arraybuffer"
|
||||||
// 响应数据为二进制流处理(Excel导出)
|
) {
|
||||||
if (response.data instanceof ArrayBuffer) {
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { code, data, msg } = response.data;
|
||||||
|
if (code === ResultEnum.SUCCESS) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
ElMessage.error(msg || "系统出错");
|
ElMessage.error(msg || "系统出错");
|
||||||
return Promise.reject(new Error(msg || "Error"));
|
return Promise.reject(new Error(msg || "Error"));
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
|
// 异常处理
|
||||||
if (error.response.data) {
|
if (error.response.data) {
|
||||||
const { code, msg } = error.response.data;
|
const { code, msg } = error.response.data;
|
||||||
// token 过期,重新登录
|
if (code === ResultEnum.TOKEN_INVALID) {
|
||||||
if (code === "A0230") {
|
|
||||||
ElMessageBox.confirm("当前页面已失效,请重新登录", "提示", {
|
ElMessageBox.confirm("当前页面已失效,请重新登录", "提示", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { addUser } from "@/api/user";
|
import UserAPI from "@/api/user";
|
||||||
import type { UserForm } from "@/api/user/types";
|
import type { UserForm } from "@/api/user/model";
|
||||||
import type { IModalConfig } from "@/components/PageModal/index.vue";
|
import type { IModalConfig } from "@/components/PageModal/index.vue";
|
||||||
|
|
||||||
const modalConfig: IModalConfig<UserForm> = {
|
const modalConfig: IModalConfig<UserForm> = {
|
||||||
@@ -13,7 +13,7 @@ const modalConfig: IModalConfig<UserForm> = {
|
|||||||
form: {
|
form: {
|
||||||
labelWidth: 100,
|
labelWidth: 100,
|
||||||
},
|
},
|
||||||
formAction: addUser,
|
formAction: UserAPI.add,
|
||||||
beforeSubmit(data) {
|
beforeSubmit(data) {
|
||||||
console.log("提交之前处理", data);
|
console.log("提交之前处理", data);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { deleteUsers, exportUser, getUserPage } from "@/api/user";
|
import UserAPI from "@/api/user";
|
||||||
import type { UserQuery } from "@/api/user/types";
|
import type { UserQuery } from "@/api/user/model";
|
||||||
import type { IContentConfig } from "@/components/PageContent/index.vue";
|
import type { IContentConfig } from "@/components/PageContent/index.vue";
|
||||||
|
|
||||||
const contentConfig: IContentConfig<UserQuery> = {
|
const contentConfig: IContentConfig<UserQuery> = {
|
||||||
@@ -15,10 +15,10 @@ const contentConfig: IContentConfig<UserQuery> = {
|
|||||||
params.endTime = createAt[1];
|
params.endTime = createAt[1];
|
||||||
delete params.createAt;
|
delete params.createAt;
|
||||||
}
|
}
|
||||||
return getUserPage(params);
|
return UserAPI.getPage(params);
|
||||||
},
|
},
|
||||||
deleteAction: deleteUsers,
|
deleteAction: UserAPI.deleteByIds,
|
||||||
exportAction: exportUser,
|
exportAction: UserAPI.export,
|
||||||
pk: "id",
|
pk: "id",
|
||||||
toolbar: [
|
toolbar: [
|
||||||
"refresh",
|
"refresh",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { updateUser } from "@/api/user";
|
import UserAPI from "@/api/user";
|
||||||
import type { UserForm } from "@/api/user/types";
|
import type { UserForm } from "@/api/user/model";
|
||||||
import type { IModalConfig } from "@/components/PageModal/index.vue";
|
import type { IModalConfig } from "@/components/PageModal/index.vue";
|
||||||
|
|
||||||
const modalConfig: IModalConfig<UserForm> = {
|
const modalConfig: IModalConfig<UserForm> = {
|
||||||
@@ -11,7 +11,7 @@ const modalConfig: IModalConfig<UserForm> = {
|
|||||||
appendToBody: true,
|
appendToBody: true,
|
||||||
},
|
},
|
||||||
formAction: function (data) {
|
formAction: function (data) {
|
||||||
return updateUser(data.id as number, data);
|
return UserAPI.update(data.id as number, data);
|
||||||
},
|
},
|
||||||
beforeSubmit(data) {
|
beforeSubmit(data) {
|
||||||
console.log("提交之前处理", data);
|
console.log("提交之前处理", data);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getUserForm } from "@/api/user";
|
import UserAPI from "@/api/user";
|
||||||
import type { IObject, IOperatData } from "@/hooks/usePage";
|
import type { IObject, IOperatData } from "@/hooks/usePage";
|
||||||
import usePage from "@/hooks/usePage";
|
import usePage from "@/hooks/usePage";
|
||||||
import addModalConfig from "./config/add";
|
import addModalConfig from "./config/add";
|
||||||
@@ -65,7 +65,7 @@ const {
|
|||||||
// 编辑
|
// 编辑
|
||||||
async function handleEditClick(row: IObject) {
|
async function handleEditClick(row: IObject) {
|
||||||
// 根据id获取数据进行填充
|
// 根据id获取数据进行填充
|
||||||
const response = await getUserForm(row.id);
|
const response = await UserAPI.getFormData(row.id);
|
||||||
editModalRef.value?.setModalVisible(response.data);
|
editModalRef.value?.setModalVisible(response.data);
|
||||||
}
|
}
|
||||||
// 其他工具栏
|
// 其他工具栏
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import SockJS from "sockjs-client";
|
|||||||
import Stomp from "stompjs";
|
import Stomp from "stompjs";
|
||||||
|
|
||||||
import { useUserStoreHook } from "@/store/modules/user";
|
import { useUserStoreHook } from "@/store/modules/user";
|
||||||
|
import { TOKEN_KEY } from "@/enums/CacheEnum";
|
||||||
|
|
||||||
const userStore = useUserStoreHook();
|
const userStore = useUserStoreHook();
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ function connectWebSocket() {
|
|||||||
stompClient = Stomp.over(socket);
|
stompClient = Stomp.over(socket);
|
||||||
|
|
||||||
stompClient.connect(
|
stompClient.connect(
|
||||||
{ Authorization: localStorage.getItem("accessToken") },
|
{ Authorization: localStorage.getItem(TOKEN_KEY) },
|
||||||
() => {
|
() => {
|
||||||
isConnected.value = true;
|
isConnected.value = true;
|
||||||
messages.value.push({
|
messages.value.push({
|
||||||
|
|||||||
@@ -115,8 +115,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSettingsStore, useUserStore } from "@/store";
|
import { useSettingsStore, useUserStore } from "@/store";
|
||||||
import { getCaptchaApi } from "@/api/auth";
|
import AuthAPI from "@/api/auth";
|
||||||
import { LoginData } from "@/api/auth/types";
|
import { LoginData } from "@/api/auth/model";
|
||||||
import { Sunny, Moon } from "@element-plus/icons-vue";
|
import { Sunny, Moon } from "@element-plus/icons-vue";
|
||||||
import { LocationQuery, LocationQueryValue, useRoute } from "vue-router";
|
import { LocationQuery, LocationQueryValue, useRoute } from "vue-router";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
@@ -175,19 +175,15 @@ const loginRules = computed(() => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/** 获取验证码 */
|
||||||
* 获取验证码
|
|
||||||
*/
|
|
||||||
function getCaptcha() {
|
function getCaptcha() {
|
||||||
getCaptchaApi().then(({ data }) => {
|
AuthAPI.getCaptcha().then((data) => {
|
||||||
loginData.value.captchaKey = data.captchaKey;
|
loginData.value.captchaKey = data.captchaKey;
|
||||||
captchaBase64.value = data.captchaBase64;
|
captchaBase64.value = data.captchaBase64;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 登录 */
|
||||||
* 登录
|
|
||||||
*/
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
function handleLogin() {
|
function handleLogin() {
|
||||||
loginFormRef.value.validate((valid: boolean) => {
|
loginFormRef.value.validate((valid: boolean) => {
|
||||||
@@ -220,19 +216,14 @@ function handleLogin() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 主题切换 */
|
||||||
* 主题切换
|
|
||||||
*/
|
|
||||||
|
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
const newTheme =
|
const newTheme =
|
||||||
settingsStore.theme === ThemeEnum.DARK ? ThemeEnum.LIGHT : ThemeEnum.DARK;
|
settingsStore.theme === ThemeEnum.DARK ? ThemeEnum.LIGHT : ThemeEnum.DARK;
|
||||||
settingsStore.changeTheme(newTheme);
|
settingsStore.changeTheme(newTheme);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* 根据屏幕宽度切换设备模式
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/** 根据屏幕宽度切换设备模式 */
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (height.value < 600) {
|
if (height.value < 600) {
|
||||||
icpVisible.value = false;
|
icpVisible.value = false;
|
||||||
@@ -241,9 +232,7 @@ watchEffect(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/** 检查输入大小写 */
|
||||||
* 检查输入大小写
|
|
||||||
*/
|
|
||||||
function checkCapslock(event: KeyboardEvent) {
|
function checkCapslock(event: KeyboardEvent) {
|
||||||
// 防止浏览器密码自动填充时报错
|
// 防止浏览器密码自动填充时报错
|
||||||
if (event instanceof KeyboardEvent) {
|
if (event instanceof KeyboardEvent) {
|
||||||
@@ -296,3 +285,4 @@ html.dark .login-container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@/api/auth/model
|
||||||
|
|||||||
@@ -151,22 +151,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
|
||||||
getDeptForm,
|
|
||||||
deleteDept,
|
|
||||||
updateDept,
|
|
||||||
addDept,
|
|
||||||
getDeptOptions,
|
|
||||||
listDepts,
|
|
||||||
} from "@/api/dept";
|
|
||||||
|
|
||||||
import { DeptVO, DeptForm, DeptQuery } from "@/api/dept/types";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "Dept",
|
name: "Dept",
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
import DeptAPI from "@/api/dept";
|
||||||
|
import { DeptVO, DeptForm, DeptQuery } from "@/api/dept/model";
|
||||||
|
|
||||||
const queryFormRef = ref(ElForm);
|
const queryFormRef = ref(ElForm);
|
||||||
const deptFormRef = ref(ElForm);
|
const deptFormRef = ref(ElForm);
|
||||||
|
|
||||||
@@ -197,7 +189,7 @@ const rules = reactive({
|
|||||||
/** 查询 */
|
/** 查询 */
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listDepts(queryParams).then(({ data }) => {
|
DeptAPI.getList(queryParams).then((data) => {
|
||||||
deptList.value = data;
|
deptList.value = data;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
@@ -216,12 +208,12 @@ function handleSelectionChange(selection: any) {
|
|||||||
|
|
||||||
/** 获取部门下拉数据 */
|
/** 获取部门下拉数据 */
|
||||||
async function loadDeptOptions() {
|
async function loadDeptOptions() {
|
||||||
getDeptOptions().then((response) => {
|
DeptAPI.getOptions().then((data) => {
|
||||||
deptOptions.value = [
|
deptOptions.value = [
|
||||||
{
|
{
|
||||||
value: 0,
|
value: 0,
|
||||||
label: "顶级部门",
|
label: "顶级部门",
|
||||||
children: response.data,
|
children: data,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
@@ -238,7 +230,7 @@ async function openDialog(parentId?: number, deptId?: number) {
|
|||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
if (deptId) {
|
if (deptId) {
|
||||||
dialog.title = "修改部门";
|
dialog.title = "修改部门";
|
||||||
getDeptForm(deptId).then(({ data }) => {
|
DeptAPI.getFormData(deptId).then((data) => {
|
||||||
Object.assign(formData, data);
|
Object.assign(formData, data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -254,7 +246,7 @@ function handleSubmit() {
|
|||||||
const deptId = formData.id;
|
const deptId = formData.id;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
if (deptId) {
|
if (deptId) {
|
||||||
updateDept(deptId, formData)
|
DeptAPI.update(deptId, formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("修改成功");
|
ElMessage.success("修改成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -262,7 +254,7 @@ function handleSubmit() {
|
|||||||
})
|
})
|
||||||
.finally(() => (loading.value = false));
|
.finally(() => (loading.value = false));
|
||||||
} else {
|
} else {
|
||||||
addDept(formData)
|
DeptAPI.update(formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("新增成功");
|
ElMessage.success("新增成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -288,7 +280,7 @@ function handleDelete(deptId?: number) {
|
|||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
deleteDept(deptIds).then(() => {
|
DeptAPI.deleteByIds(deptIds).then(() => {
|
||||||
ElMessage.success("删除成功");
|
ElMessage.success("删除成功");
|
||||||
resetQuery();
|
resetQuery();
|
||||||
});
|
});
|
||||||
@@ -316,3 +308,4 @@ onMounted(() => {
|
|||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@/api/dept/model
|
||||||
|
|||||||
@@ -129,20 +129,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
|
||||||
getDictPage,
|
|
||||||
getDictFormData,
|
|
||||||
addDict,
|
|
||||||
updateDict,
|
|
||||||
deleteDict,
|
|
||||||
} from "@/api/dict";
|
|
||||||
import { DictPageVO, DictForm, DictQuery } from "@/api/dict/types";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "DictData",
|
name: "DictData",
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
import DictAPI from "@/api/dict";
|
||||||
|
import { DictPageVO, DictForm, DictQuery } from "@/api/dict/model";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
typeCode: {
|
typeCode: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -198,14 +192,12 @@ const rules = reactive({
|
|||||||
value: [{ required: true, message: "请输入字典值", trigger: "blur" }],
|
value: [{ required: true, message: "请输入字典值", trigger: "blur" }],
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/** 查询 */
|
||||||
* 查询
|
|
||||||
*/
|
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
if (queryParams.typeCode) {
|
if (queryParams.typeCode) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
getDictPage(queryParams)
|
DictAPI.getDictPage(queryParams)
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
dictList.value = data.list;
|
dictList.value = data.list;
|
||||||
total.value = data.total;
|
total.value = data.total;
|
||||||
})
|
})
|
||||||
@@ -213,9 +205,7 @@ function handleQuery() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 重置查询 */
|
||||||
* 重置查询
|
|
||||||
*/
|
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
queryFormRef.value.resetFields();
|
queryFormRef.value.resetFields();
|
||||||
queryParams.pageNum = 1;
|
queryParams.pageNum = 1;
|
||||||
@@ -240,7 +230,7 @@ function openDialog(dictId?: number) {
|
|||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
if (dictId) {
|
if (dictId) {
|
||||||
dialog.title = "修改字典";
|
dialog.title = "修改字典";
|
||||||
getDictFormData(dictId).then(({ data }) => {
|
DictAPI.getDictFormData(dictId).then((data) => {
|
||||||
Object.assign(formData, data);
|
Object.assign(formData, data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -248,16 +238,14 @@ function openDialog(dictId?: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 字典表单提交 */
|
||||||
* 字典表单提交
|
|
||||||
*/
|
|
||||||
function handleSubmit() {
|
function handleSubmit() {
|
||||||
dataFormRef.value.validate((isValid: boolean) => {
|
dataFormRef.value.validate((isValid: boolean) => {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
const dictId = formData.id;
|
const dictId = formData.id;
|
||||||
if (dictId) {
|
if (dictId) {
|
||||||
updateDict(dictId, formData)
|
DictAPI.updateDict(dictId, formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("修改成功");
|
ElMessage.success("修改成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -265,7 +253,7 @@ function handleSubmit() {
|
|||||||
})
|
})
|
||||||
.finally(() => (loading.value = false));
|
.finally(() => (loading.value = false));
|
||||||
} else {
|
} else {
|
||||||
addDict(formData)
|
DictAPI.addDict(formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("新增成功");
|
ElMessage.success("新增成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -277,17 +265,13 @@ function handleSubmit() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 关闭弹窗 */
|
||||||
* 关闭弹窗
|
|
||||||
*/
|
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
resetForm();
|
resetForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 重置表单 */
|
||||||
* 重置表单
|
|
||||||
*/
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
dataFormRef.value.resetFields();
|
dataFormRef.value.resetFields();
|
||||||
dataFormRef.value.clearValidate();
|
dataFormRef.value.clearValidate();
|
||||||
@@ -298,9 +282,7 @@ function resetForm() {
|
|||||||
formData.typeCode = props.typeCode;
|
formData.typeCode = props.typeCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 删除字典 */
|
||||||
* 删除字典
|
|
||||||
*/
|
|
||||||
function handleDelete(dictId?: number) {
|
function handleDelete(dictId?: number) {
|
||||||
const dictIds = [dictId || ids.value].join(",");
|
const dictIds = [dictId || ids.value].join(",");
|
||||||
if (!dictIds) {
|
if (!dictIds) {
|
||||||
@@ -313,7 +295,7 @@ function handleDelete(dictId?: number) {
|
|||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
deleteDict(dictIds).then(() => {
|
DictAPI.deleteDictByIds(dictIds).then(() => {
|
||||||
ElMessage.success("删除成功");
|
ElMessage.success("删除成功");
|
||||||
resetQuery();
|
resetQuery();
|
||||||
});
|
});
|
||||||
@@ -324,3 +306,4 @@ onMounted(() => {
|
|||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@/api/dict/model
|
||||||
|
|||||||
@@ -148,21 +148,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
|
||||||
getDictTypePage,
|
|
||||||
getDictTypeForm,
|
|
||||||
addDictType,
|
|
||||||
updateDictType,
|
|
||||||
deleteDictTypes,
|
|
||||||
} from "@/api/dict";
|
|
||||||
|
|
||||||
import { DictTypePageVO, DictTypeQuery, DictTypeForm } from "@/api/dict/types";
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "DictType",
|
name: "DictType",
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
import DictAPI from "@/api/dict";
|
||||||
|
|
||||||
|
import { DictTypePageVO, DictTypeQuery, DictTypeForm } from "@/api/dict/model";
|
||||||
|
|
||||||
const queryFormRef = ref(ElForm);
|
const queryFormRef = ref(ElForm);
|
||||||
const dataFormRef = ref(ElForm);
|
const dataFormRef = ref(ElForm);
|
||||||
|
|
||||||
@@ -194,8 +188,8 @@ const rules = reactive({
|
|||||||
/** 查询 */
|
/** 查询 */
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
getDictTypePage(queryParams)
|
DictAPI.getDictTypePage(queryParams)
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
dictTypeList.value = data.list;
|
dictTypeList.value = data.list;
|
||||||
total.value = data.total;
|
total.value = data.total;
|
||||||
})
|
})
|
||||||
@@ -227,7 +221,7 @@ function openDialog(dicTypeId?: number) {
|
|||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
if (dicTypeId) {
|
if (dicTypeId) {
|
||||||
dialog.title = "修改字典类型";
|
dialog.title = "修改字典类型";
|
||||||
getDictTypeForm(dicTypeId).then(({ data }) => {
|
DictAPI.getDictTypeForm(dicTypeId).then((data) => {
|
||||||
Object.assign(formData, data);
|
Object.assign(formData, data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -242,7 +236,7 @@ function handleSubmit() {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
const dictTypeId = formData.id;
|
const dictTypeId = formData.id;
|
||||||
if (dictTypeId) {
|
if (dictTypeId) {
|
||||||
updateDictType(dictTypeId, formData)
|
DictAPI.updateDictType(dictTypeId, formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("修改成功");
|
ElMessage.success("修改成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -250,7 +244,7 @@ function handleSubmit() {
|
|||||||
})
|
})
|
||||||
.finally(() => (loading.value = false));
|
.finally(() => (loading.value = false));
|
||||||
} else {
|
} else {
|
||||||
addDictType(formData)
|
DictAPI.addDictType(formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("新增成功");
|
ElMessage.success("新增成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -290,7 +284,7 @@ function handleDelete(dictTypeId?: number) {
|
|||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
deleteDictTypes(dictTypeIds).then(() => {
|
DictAPI.deleteDictTypes(dictTypeIds).then(() => {
|
||||||
ElMessage.success("删除成功");
|
ElMessage.success("删除成功");
|
||||||
resetQuery();
|
resetQuery();
|
||||||
});
|
});
|
||||||
@@ -322,3 +316,4 @@ onMounted(() => {
|
|||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@/api/dict/model
|
||||||
|
|||||||
@@ -312,21 +312,12 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
defineOptions({
|
defineOptions({
|
||||||
// eslint-disable-next-line vue/no-reserved-component-names
|
|
||||||
name: "Menu",
|
name: "Menu",
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
import { MenuQuery, MenuForm, MenuVO } from "@/api/menu/types";
|
import MenuAPI from "@/api/menu";
|
||||||
import {
|
import { MenuQuery, MenuForm, MenuVO } from "@/api/menu/model";
|
||||||
listMenus,
|
|
||||||
getMenuForm,
|
|
||||||
getMenuOptions,
|
|
||||||
addMenu,
|
|
||||||
deleteMenu,
|
|
||||||
updateMenu,
|
|
||||||
} from "@/api/menu";
|
|
||||||
|
|
||||||
import { MenuTypeEnum } from "@/enums/MenuTypeEnum";
|
import { MenuTypeEnum } from "@/enums/MenuTypeEnum";
|
||||||
|
|
||||||
const queryFormRef = ref(ElForm);
|
const queryFormRef = ref(ElForm);
|
||||||
@@ -376,8 +367,8 @@ const menuCacheData = reactive({
|
|||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
// 重置父组件
|
// 重置父组件
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listMenus(queryParams)
|
MenuAPI.getList(queryParams)
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
menuList.value = data;
|
menuList.value = data;
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -403,15 +394,15 @@ function onRowClick(row: MenuVO) {
|
|||||||
* @param menuId 菜单ID
|
* @param menuId 菜单ID
|
||||||
*/
|
*/
|
||||||
function openDialog(parentId?: number, menuId?: number) {
|
function openDialog(parentId?: number, menuId?: number) {
|
||||||
getMenuOptions()
|
MenuAPI.getOptions()
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
menuOptions.value = [{ value: 0, label: "顶级菜单", children: data }];
|
menuOptions.value = [{ value: 0, label: "顶级菜单", children: data }];
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
if (menuId) {
|
if (menuId) {
|
||||||
dialog.title = "编辑菜单";
|
dialog.title = "编辑菜单";
|
||||||
getMenuForm(menuId).then(({ data }) => {
|
MenuAPI.getFormData(menuId).then((data) => {
|
||||||
Object.assign(formData, data);
|
Object.assign(formData, data);
|
||||||
menuCacheData.type = data.type;
|
menuCacheData.type = data.type;
|
||||||
menuCacheData.path = data.path ?? "";
|
menuCacheData.path = data.path ?? "";
|
||||||
@@ -439,13 +430,13 @@ function submitForm() {
|
|||||||
if (isValid) {
|
if (isValid) {
|
||||||
const menuId = formData.id;
|
const menuId = formData.id;
|
||||||
if (menuId) {
|
if (menuId) {
|
||||||
updateMenu(menuId, formData).then(() => {
|
MenuAPI.update(menuId, formData).then(() => {
|
||||||
ElMessage.success("修改成功");
|
ElMessage.success("修改成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addMenu(formData).then(() => {
|
MenuAPI.add(formData).then(() => {
|
||||||
ElMessage.success("新增成功");
|
ElMessage.success("新增成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
handleQuery();
|
handleQuery();
|
||||||
@@ -468,7 +459,7 @@ function handleDelete(menuId: number) {
|
|||||||
type: "warning",
|
type: "warning",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
deleteMenu(menuId).then(() => {
|
MenuAPI.deleteById(menuId).then(() => {
|
||||||
ElMessage.success("删除成功");
|
ElMessage.success("删除成功");
|
||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
@@ -503,3 +494,4 @@ onMounted(() => {
|
|||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@/api/menu/model
|
||||||
|
|||||||
@@ -181,18 +181,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {
|
import RoleAPI from "@/api/role";
|
||||||
getRolePage,
|
import MenuAPI from "@/api/menu";
|
||||||
updateRole,
|
|
||||||
getRoleForm,
|
|
||||||
addRole,
|
|
||||||
deleteRoles,
|
|
||||||
getRoleMenuIds,
|
|
||||||
updateRoleMenus,
|
|
||||||
} from "@/api/role";
|
|
||||||
import { getMenuOptions } from "@/api/menu";
|
|
||||||
|
|
||||||
import { RolePageVO, RoleForm, RoleQuery } from "@/api/role/types";
|
import { RolePageVO, RoleForm, RoleQuery } from "@/api/role/model";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "Role",
|
name: "Role",
|
||||||
@@ -246,8 +238,8 @@ let checkedRole: CheckedRole = reactive({});
|
|||||||
/** 查询 */
|
/** 查询 */
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
getRolePage(queryParams)
|
RoleAPI.getPage(queryParams)
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
roleList.value = data.list;
|
roleList.value = data.list;
|
||||||
total.value = data.total;
|
total.value = data.total;
|
||||||
})
|
})
|
||||||
@@ -272,7 +264,7 @@ function openDialog(roleId?: number) {
|
|||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
if (roleId) {
|
if (roleId) {
|
||||||
dialog.title = "修改角色";
|
dialog.title = "修改角色";
|
||||||
getRoleForm(roleId).then(({ data }) => {
|
RoleAPI.getFormData(roleId).then((data) => {
|
||||||
Object.assign(formData, data);
|
Object.assign(formData, data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -287,7 +279,7 @@ function handleSubmit() {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
const roleId = formData.id;
|
const roleId = formData.id;
|
||||||
if (roleId) {
|
if (roleId) {
|
||||||
updateRole(roleId, formData)
|
RoleAPI.update(roleId, formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("修改成功");
|
ElMessage.success("修改成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -295,7 +287,7 @@ function handleSubmit() {
|
|||||||
})
|
})
|
||||||
.finally(() => (loading.value = false));
|
.finally(() => (loading.value = false));
|
||||||
} else {
|
} else {
|
||||||
addRole(formData)
|
RoleAPI.add(formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("新增成功");
|
ElMessage.success("新增成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -337,7 +329,7 @@ function handleDelete(roleId?: number) {
|
|||||||
type: "warning",
|
type: "warning",
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
deleteRoles(roleIds)
|
RoleAPI.deleteByIds(roleIds)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("删除成功");
|
ElMessage.success("删除成功");
|
||||||
resetQuery();
|
resetQuery();
|
||||||
@@ -347,7 +339,7 @@ function handleDelete(roleId?: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 打开分配菜单弹窗 */
|
/** 打开分配菜单弹窗 */
|
||||||
function openMenuDialog(row: RolePageVO) {
|
async function openMenuDialog(row: RolePageVO) {
|
||||||
const roleId = row.id;
|
const roleId = row.id;
|
||||||
if (roleId) {
|
if (roleId) {
|
||||||
checkedRole = {
|
checkedRole = {
|
||||||
@@ -358,20 +350,19 @@ function openMenuDialog(row: RolePageVO) {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
// 获取所有的菜单
|
// 获取所有的菜单
|
||||||
getMenuOptions().then((response) => {
|
menuList.value = await MenuAPI.getOptions();
|
||||||
menuList.value = response.data;
|
|
||||||
// 回显角色已拥有的菜单
|
// 回显角色已拥有的菜单
|
||||||
getRoleMenuIds(roleId)
|
RoleAPI.getRoleMenuIds(roleId)
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
const checkedMenuIds = data;
|
const checkedMenuIds = data;
|
||||||
checkedMenuIds.forEach((menuId) =>
|
checkedMenuIds.forEach((menuId) =>
|
||||||
menuRef.value.setChecked(menuId, true, false)
|
menuRef.value.setChecked(menuId, true, false)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +375,7 @@ function handleRoleMenuSubmit() {
|
|||||||
.map((node: any) => node.value);
|
.map((node: any) => node.value);
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
updateRoleMenus(roleId, checkedMenuIds)
|
RoleAPI.updateRoleMenus(roleId, checkedMenuIds)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("分配权限成功");
|
ElMessage.success("分配权限成功");
|
||||||
menuDialogVisible.value = false;
|
menuDialogVisible.value = false;
|
||||||
@@ -400,3 +391,4 @@ onMounted(() => {
|
|||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@/api/role/model
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getDeptOptions } from "@/api/dept";
|
import DeptAPI from "@/api/dept";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [Number],
|
type: [Number],
|
||||||
@@ -62,8 +61,8 @@ function handleNodeClick(data: { [key: string]: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
getDeptOptions().then((response) => {
|
DeptAPI.getOptions().then((data) => {
|
||||||
deptList.value = response.data;
|
deptList.value = data;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -332,21 +332,11 @@ defineOptions({
|
|||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
import {
|
import UserAPI from "@/api/user";
|
||||||
getUserPage,
|
import DeptAPI from "@/api/dept";
|
||||||
getUserForm,
|
import RoleAPI from "@/api/role";
|
||||||
deleteUsers,
|
|
||||||
addUser,
|
|
||||||
updateUser,
|
|
||||||
updateUserPassword,
|
|
||||||
downloadTemplateApi,
|
|
||||||
exportUser,
|
|
||||||
importUser,
|
|
||||||
} from "@/api/user";
|
|
||||||
import { getDeptOptions } from "@/api/dept";
|
|
||||||
import { getRoleOptions } from "@/api/role";
|
|
||||||
|
|
||||||
import { UserForm, UserQuery, UserPageVO } from "@/api/user/types";
|
import { UserForm, UserQuery, UserPageVO } from "@/api/user/model";
|
||||||
import type { UploadInstance } from "element-plus";
|
import type { UploadInstance } from "element-plus";
|
||||||
import { genFileId } from "element-plus";
|
import { genFileId } from "element-plus";
|
||||||
|
|
||||||
@@ -418,8 +408,9 @@ const rules = reactive({
|
|||||||
/** 查询 */
|
/** 查询 */
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
getUserPage(queryParams)
|
UserAPI.getPage(queryParams)
|
||||||
.then(({ data }) => {
|
.then((data) => {
|
||||||
|
console.log("handleQuery", data);
|
||||||
pageData.value = data.list;
|
pageData.value = data.list;
|
||||||
total.value = data.total;
|
total.value = data.total;
|
||||||
})
|
})
|
||||||
@@ -458,7 +449,7 @@ function resetPassword(row: { [key: string]: any }) {
|
|||||||
ElMessage.warning("请输入新密码");
|
ElMessage.warning("请输入新密码");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
updateUserPassword(row.id, value).then(() => {
|
UserAPI.updatePassword(row.id, value).then(() => {
|
||||||
ElMessage.success("密码重置成功,新密码是:" + value);
|
ElMessage.success("密码重置成功,新密码是:" + value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -466,15 +457,15 @@ function resetPassword(row: { [key: string]: any }) {
|
|||||||
|
|
||||||
/** 加载角色下拉数据源 */
|
/** 加载角色下拉数据源 */
|
||||||
async function loadRoleOptions() {
|
async function loadRoleOptions() {
|
||||||
getRoleOptions().then((response) => {
|
RoleAPI.getOptions().then((data) => {
|
||||||
roleList.value = response.data;
|
roleList.value = data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加载部门下拉数据源 */
|
/** 加载部门下拉数据源 */
|
||||||
async function loadDeptOptions() {
|
async function loadDeptOptions() {
|
||||||
getDeptOptions().then((response) => {
|
DeptAPI.getOptions().then((data) => {
|
||||||
deptList.value = response.data;
|
deptList.value = data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +485,7 @@ async function openDialog(type: string, id?: number) {
|
|||||||
await loadRoleOptions();
|
await loadRoleOptions();
|
||||||
if (id) {
|
if (id) {
|
||||||
dialog.title = "修改用户";
|
dialog.title = "修改用户";
|
||||||
getUserForm(id).then(({ data }) => {
|
UserAPI.getFormData(id).then((data) => {
|
||||||
Object.assign(formData, { ...data });
|
Object.assign(formData, { ...data });
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -535,7 +526,7 @@ const handleSubmit = useThrottleFn(() => {
|
|||||||
const userId = formData.id;
|
const userId = formData.id;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
if (userId) {
|
if (userId) {
|
||||||
updateUser(userId, formData)
|
UserAPI.update(userId, formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("修改用户成功");
|
ElMessage.success("修改用户成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -543,7 +534,7 @@ const handleSubmit = useThrottleFn(() => {
|
|||||||
})
|
})
|
||||||
.finally(() => (loading.value = false));
|
.finally(() => (loading.value = false));
|
||||||
} else {
|
} else {
|
||||||
addUser(formData)
|
UserAPI.add(formData)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success("新增用户成功");
|
ElMessage.success("新增用户成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -562,8 +553,8 @@ const handleSubmit = useThrottleFn(() => {
|
|||||||
ElMessage.warning("上传Excel文件不能为空");
|
ElMessage.warning("上传Excel文件不能为空");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
importUser(importData?.deptId, importData?.file).then((response) => {
|
UserAPI.import(importData?.deptId, importData?.file).then((data) => {
|
||||||
ElMessage.success(response.data);
|
ElMessage.success("导入用户成功");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
resetQuery();
|
resetQuery();
|
||||||
});
|
});
|
||||||
@@ -583,7 +574,7 @@ function handleDelete(id?: number) {
|
|||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
deleteUsers(userIds).then(() => {
|
UserAPI.deleteByIds(userIds).then(() => {
|
||||||
ElMessage.success("删除成功");
|
ElMessage.success("删除成功");
|
||||||
resetQuery();
|
resetQuery();
|
||||||
});
|
});
|
||||||
@@ -592,7 +583,7 @@ function handleDelete(id?: number) {
|
|||||||
|
|
||||||
/** 下载导入模板 */
|
/** 下载导入模板 */
|
||||||
function downloadTemplate() {
|
function downloadTemplate() {
|
||||||
downloadTemplateApi().then((response: any) => {
|
UserAPI.downloadTemplate().then((response: any) => {
|
||||||
const fileData = response.data;
|
const fileData = response.data;
|
||||||
const fileName = decodeURI(
|
const fileName = decodeURI(
|
||||||
response.headers["content-disposition"].split(";")[1].split("=")[1]
|
response.headers["content-disposition"].split(";")[1].split("=")[1]
|
||||||
@@ -631,7 +622,7 @@ function handleFileExceed(files: any) {
|
|||||||
|
|
||||||
/** 导出用户 */
|
/** 导出用户 */
|
||||||
function handleExport() {
|
function handleExport() {
|
||||||
exportUser(queryParams).then((response: any) => {
|
UserAPI.export(queryParams).then((response: any) => {
|
||||||
const fileData = response.data;
|
const fileData = response.data;
|
||||||
const fileName = decodeURI(
|
const fileName = decodeURI(
|
||||||
response.headers["content-disposition"].split(";")[1].split("=")[1]
|
response.headers["content-disposition"].split(";")[1].split("=")[1]
|
||||||
|
|||||||
Reference in New Issue
Block a user