auth-web/src/store/configuration/menuIcon.ts

81 lines
2.0 KiB
TypeScript
Raw Normal View History

2024-09-29 16:52:09 +08:00
import { defineStore } from 'pinia';
2025-04-24 13:43:37 +08:00
import {
2025-04-27 22:16:06 +08:00
createMenuIcon,
deleteMenuIcon,
getIconNameListByIconName,
getMenuIconPage,
updateMenuIcon,
2025-04-24 13:43:37 +08:00
} from '@/api/v1/menu/menuIcon';
import { pageSizes } from '@/enums/baseConstant';
import { storeMessage } from '@/utils/message';
import { storePagination } from '@/store/useStorePagination';
2024-09-29 16:52:09 +08:00
/**
* Store
*/
export const useMenuIconStore = defineStore('menuIconStore', {
2025-04-24 13:43:37 +08:00
state() {
return {
// 系统菜单图标列表
datalist: [],
// 图标名称列表
iconNameList: [],
// 查询表单
form: {
// icon 名称
iconName: undefined,
// 图标码
iconCode: undefined,
},
// 分页查询结果
pagination: {
currentPage: 1,
pageSize: 30,
total: 1,
pageSizes,
},
// 加载
loading: false,
};
},
getters: {},
actions: {
/** 获取系统菜单图标 */
2025-04-27 22:16:06 +08:00
async fetchMenuIconListPage() {
2025-04-24 13:43:37 +08:00
const data = { ...this.pagination, ...this.form };
delete data.pageSizes;
delete data.total;
delete data.background;
2025-04-27 22:16:06 +08:00
const response = await getMenuIconPage(data);
2025-04-24 13:43:37 +08:00
// 公共页面函数hook
const pagination = storePagination.bind(this);
return pagination(response);
},
2025-04-24 13:43:37 +08:00
/** 根据iconName搜索menuIcon */
2025-04-27 22:16:06 +08:00
async getIconNameListByIconName(data: any) {
const result = await getIconNameListByIconName(data);
2025-04-24 13:43:37 +08:00
this.iconNameList = result.data;
},
2024-11-03 21:33:23 +08:00
2025-04-24 13:43:37 +08:00
/** 添加系统菜单图标 */
async addMenuIcon(data: any) {
2025-04-27 22:16:06 +08:00
const result = await createMenuIcon(data);
2025-04-24 13:43:37 +08:00
return storeMessage(result);
},
2025-04-24 13:43:37 +08:00
/** 修改系统菜单图标 */
2025-04-27 22:16:06 +08:00
async editMenuIcon(data: any) {
const result = await updateMenuIcon(data);
2025-04-24 13:43:37 +08:00
return storeMessage(result);
},
2025-04-24 13:43:37 +08:00
/** 删除系统菜单图标 */
2025-04-27 22:16:06 +08:00
async removeMenuIcon(data: any) {
const result = await deleteMenuIcon(data);
2025-04-24 13:43:37 +08:00
return storeMessage(result);
},
},
2024-09-29 16:52:09 +08:00
});