diff --git a/src/App.vue b/src/App.vue
index fbadac3..7afa170 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,21 +1,21 @@
-
-
-
-
+
+
+
+
diff --git a/src/api/service/mockRequest.ts b/src/api/service/mockRequest.ts
index 2f435c2..9e39446 100644
--- a/src/api/service/mockRequest.ts
+++ b/src/api/service/mockRequest.ts
@@ -2,7 +2,7 @@ import Axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
import type { PureHttpError, PureHttpRequestConfig, PureHttpResponse, RequestMethods } from './types';
import NProgress from '../../utils/progress';
import { formatToken, getToken } from '@/utils/auth';
-import { useUserStoreHook } from '@/store/modules/user';
+import { useUserStoreHook } from '@/store/system/user';
import { defaultMockConfig } from '@/api/service/config';
class PureHttp {
diff --git a/src/api/service/request.ts b/src/api/service/request.ts
index 0e021c2..f9519e2 100644
--- a/src/api/service/request.ts
+++ b/src/api/service/request.ts
@@ -2,7 +2,7 @@ import Axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
import type { PureHttpError, PureHttpRequestConfig, PureHttpResponse, RequestMethods } from './types';
import NProgress from '@/utils/progress';
import { formatToken, getToken, removeToken } from '@/utils/auth';
-import { useUserStoreHook } from '@/store/modules/user';
+import { useUserStoreHook } from '@/store/system/user';
import { message } from '@/utils/message';
import { router } from '@/store/utils';
import { defaultConfig, whiteList } from '@/api/service/config';
diff --git a/src/api/v1/role.ts b/src/api/v1/role.ts
new file mode 100644
index 0000000..bdd050b
--- /dev/null
+++ b/src/api/v1/role.ts
@@ -0,0 +1,30 @@
+import { http } from '@/api/service/request';
+import type { BaseResult, ResultTable } from '@/api/service/types';
+
+/**
+ * 角色---获取角色列表
+ */
+export const fetchGetRoleList = (data: any) => {
+ return http.request>('get', `role/getRoleList/${data.currentPage}/${data.pageSize}`, { params: data });
+};
+
+/**
+ * 角色---添加角色
+ */
+export const fetchAddRole = (data: any) => {
+ return http.request>('post', 'role/addRole', { data });
+};
+
+/**
+ * 角色---更新角色
+ */
+export const fetchUpdateRole = (data: any) => {
+ return http.request>('put', 'role/updateRole', { data });
+};
+
+/**
+ * 角色---删除角色
+ */
+export const fetchDeleteRole = (data: any) => {
+ return http.request>('delete', 'role/deleteRole', { data });
+};
diff --git a/src/layout/hooks/useNav.ts b/src/layout/hooks/useNav.ts
index d8b5d3f..17a681f 100644
--- a/src/layout/hooks/useNav.ts
+++ b/src/layout/hooks/useNav.ts
@@ -9,7 +9,7 @@ import type { routeMetaType } from '../types';
import { remainingPaths, router } from '@/router';
import { computed, type CSSProperties } from 'vue';
import { useAppStoreHook } from '@/store/modules/app';
-import { useUserStoreHook } from '@/store/modules/user';
+import { useUserStoreHook } from '@/store/system/user';
import { isAllEmpty, useGlobal } from '@pureadmin/utils';
import { useEpThemeStoreHook } from '@/store/epTheme';
import { usePermissionStoreHook } from '@/store/permission';
diff --git a/src/store/modules/menuIcon.ts b/src/store/system/menuIcon.ts
similarity index 100%
rename from src/store/modules/menuIcon.ts
rename to src/store/system/menuIcon.ts
diff --git a/src/store/system/role.ts b/src/store/system/role.ts
new file mode 100644
index 0000000..7de9e50
--- /dev/null
+++ b/src/store/system/role.ts
@@ -0,0 +1,77 @@
+import { defineStore } from 'pinia';
+import { fetchAddRole, fetchDeleteRole, fetchGetRoleList, fetchUpdateRole } from '@/api/v1/role';
+import { pageSizes } from '@/enums/baseConstant';
+import { storeMessage } from '@/utils/message';
+import { storePagination } from '@/store/useStorePagination';
+
+/**
+ * 角色 Store
+ */
+export const useRoleStore = defineStore('roleStore', {
+ state() {
+ return {
+ // 角色列表
+ datalist: [],
+ // 查询表单
+ form: {
+ // 角色代码
+ roleCode: undefined,
+ // 描述
+ description: undefined,
+ },
+ // 分页查询结果
+ pagination: {
+ currentPage: 1,
+ pageSize: 150,
+ total: 100,
+ pageSizes,
+ },
+ // 加载
+ loading: false,
+ };
+ },
+ getters: {},
+ actions: {
+ /**
+ * * 获取角色
+ */
+ async getRoleList() {
+ // 整理请求参数
+ const data = { ...this.pagination, ...this.form };
+ delete data.pageSizes;
+ delete data.total;
+ delete data.background;
+
+ // 获取角色列表
+ const result = await fetchGetRoleList(data);
+
+ // 公共页面函数hook
+ const pagination = storePagination.bind(this);
+ return pagination(result);
+ },
+
+ /**
+ * * 添加角色
+ */
+ async addRole(data: any) {
+ const result = await fetchAddRole(data);
+ return storeMessage(result);
+ },
+
+ /**
+ * * 修改角色
+ */
+ async updateRole(data: any) {
+ const result = await fetchUpdateRole(data);
+ return storeMessage(result);
+ },
+
+ /**
+ * * 删除角色
+ */
+ async deleteRole(data: any) {
+ const result = await fetchDeleteRole(data);
+ return storeMessage(result);
+ },
+ },
+});
diff --git a/src/store/modules/router.ts b/src/store/system/router.ts
similarity index 100%
rename from src/store/modules/router.ts
rename to src/store/system/router.ts
diff --git a/src/store/modules/user.ts b/src/store/system/user.ts
similarity index 98%
rename from src/store/modules/user.ts
rename to src/store/system/user.ts
index 5277505..97403f2 100644
--- a/src/store/modules/user.ts
+++ b/src/store/system/user.ts
@@ -33,8 +33,6 @@ export const useUserStore = defineStore({
setToken(result.data);
return true;
}
-
- message(result.message, { type: 'error' });
return false;
},
diff --git a/src/utils/auth.ts b/src/utils/auth.ts
index c218bb0..6c97c73 100644
--- a/src/utils/auth.ts
+++ b/src/utils/auth.ts
@@ -1,5 +1,5 @@
import Cookies from 'js-cookie';
-import { useUserStore, useUserStoreHook } from '@/store/modules/user';
+import { useUserStore, useUserStoreHook } from '@/store/system/user';
import { isIncludeAllChildren, isString, storageLocal } from '@pureadmin/utils';
export interface DataInfo {
diff --git a/src/views/i18n/i18n-setting/index.vue b/src/views/i18n/i18n-setting/index.vue
index e3b8557..97668fc 100644
--- a/src/views/i18n/i18n-setting/index.vue
+++ b/src/views/i18n/i18n-setting/index.vue
@@ -1,7 +1,7 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('search') }}
+ {{ $t('buttons.reset') }}
+
+
+
+
+
+ 添加角色
+
+
+
+
+
+ {{ $t('table.createUser') }}
+
+
+
+ {{ $t('table.updateUser') }}
+
+
+
+ {{ $t('modify') }}
+ {{ $t('add_new') }}
+
+
+
+
+ {{ $t('delete') }}
+
+
+
+
+
+
+
+
+
diff --git a/src/views/system/role/role-dialog.vue b/src/views/system/role/role-dialog.vue
new file mode 100644
index 0000000..b5ca8f8
--- /dev/null
+++ b/src/views/system/role/role-dialog.vue
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/system/role/utils/columns.ts b/src/views/system/role/utils/columns.ts
new file mode 100644
index 0000000..f9cc0c5
--- /dev/null
+++ b/src/views/system/role/utils/columns.ts
@@ -0,0 +1,26 @@
+import { reactive } from 'vue';
+import { $t } from '@/plugins/i18n';
+
+// 表格列
+export const columns: TableColumnList = [
+ { type: 'index', index: (index: number) => index + 1 },
+ // { type: 'selection', align: 'left' },
+ { label: $t('id'), prop: 'id' },
+ // 角色代码
+ { label: $t('role_roleCode'), prop: 'roleCode' },
+ // 描述
+ { label: $t('role_description'), prop: 'description' },
+ { label: $t('table.updateTime'), prop: 'updateTime', sortable: true },
+ { label: $t('table.createTime'), prop: 'createTime', sortable: true },
+ { label: $t('table.createUser'), prop: 'createUser', slot: 'createUser' },
+ { label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser' },
+ { label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' },
+];
+
+// 添加规则
+export const rules = reactive({
+ // 角色代码
+ roleCode: [{ required: true, message: `${$t('input')}${$t('role_roleCode')}`, trigger: 'blur' }],
+ // 描述
+ description: [{ required: true, message: `${$t('input')}${$t('role_description')}`, trigger: 'blur' }],
+});
diff --git a/src/views/system/role/utils/hooks.ts b/src/views/system/role/utils/hooks.ts
new file mode 100644
index 0000000..f49fcd9
--- /dev/null
+++ b/src/views/system/role/utils/hooks.ts
@@ -0,0 +1,105 @@
+import { deviceDetection } from '@pureadmin/utils';
+import { addDialog } from '@/components/BaseDialog/index';
+import RoleDialog from '@/views/system/role/role-dialog.vue';
+import { useRoleStore } from '@/store/system/role';
+import { h, ref } from 'vue';
+import { messageBox } from '@/utils/message';
+import type { FormItemProps } from '@/views/system/role/utils/types';
+import { $t } from '@/plugins/i18n';
+
+export const formRef = ref();
+const roleStore = useRoleStore();
+
+/**
+ * * 搜索初始化角色
+ */
+export async function onSearch() {
+ roleStore.loading = true;
+ await roleStore.getRoleList();
+ roleStore.loading = false;
+}
+
+/**
+ * * 添加角色
+ */
+export function onAdd() {
+ addDialog({
+ title: `${$t('add_new')}${$t('role')}`,
+ width: '30%',
+ props: {
+ formInline: {
+ roleCode: undefined,
+ description: undefined,
+ },
+ },
+ draggable: true,
+ fullscreen: deviceDetection(),
+ fullscreenIcon: true,
+ closeOnClickModal: false,
+ contentRenderer: () => h(RoleDialog, { ref: formRef }),
+ beforeSure: (done, { options }) => {
+ const form = options.props.formInline as FormItemProps;
+ formRef.value.formRef.validate(async (valid: any) => {
+ if (!valid) return;
+
+ const result = await roleStore.addRole(form);
+ if (!result) return;
+ done();
+ await onSearch();
+ });
+ },
+ });
+}
+
+/**
+ * * 更新角色
+ * @param row
+ */
+export function onUpdate(row: any) {
+ addDialog({
+ title: `${$t('modify')}${$t('role')}`,
+ width: '30%',
+ props: {
+ formInline: {
+ roleCode: row.roleCode,
+ description: row.description,
+ },
+ },
+ draggable: true,
+ fullscreen: deviceDetection(),
+ fullscreenIcon: true,
+ closeOnClickModal: false,
+ contentRenderer: () => h(RoleDialog, { ref: formRef }),
+ beforeSure: (done, { options }) => {
+ const form = options.props.formInline as FormItemProps;
+ formRef.value.formRef.validate(async (valid: any) => {
+ if (!valid) return;
+
+ const result = await roleStore.updateRole({ ...form, id: row.id });
+ if (!result) return;
+ done();
+ await onSearch();
+ });
+ },
+ });
+}
+
+/**
+ * * 删除角色
+ */
+export const onDelete = async (row: any) => {
+ const id = row.id;
+
+ // 是否确认删除
+ const result = await messageBox({
+ title: $t('confirm_delete'),
+ showMessage: false,
+ confirmMessage: undefined,
+ cancelMessage: $t('cancel_delete'),
+ });
+ if (!result) return;
+
+ // 删除数据
+ await roleStore.deleteRole([id]);
+ await onSearch();
+};
diff --git a/src/views/system/role/utils/types.ts b/src/views/system/role/utils/types.ts
new file mode 100644
index 0000000..4b3a0a1
--- /dev/null
+++ b/src/views/system/role/utils/types.ts
@@ -0,0 +1,12 @@
+// 添加或者修改表单元素
+export interface FormItemProps {
+ // 角色代码
+ roleCode: string;
+ // 描述
+ description: string;
+}
+
+// 添加或修改表单Props
+export interface FormProps {
+ formInline: FormItemProps;
+}