2024-09-29 16:52:09 +08:00
|
|
|
import { defineStore } from 'pinia';
|
2024-10-03 13:44:52 +08:00
|
|
|
import { fetchAddMenuIcon, fetchDeleteMenuIcon, fetchGetMenuIconList, fetchUpdateMenuIcon } from '@/api/v1/menuIcon';
|
|
|
|
import { pageSizes } from '@/enums/baseConstant';
|
|
|
|
import { storeMessage } from '@/utils/message';
|
|
|
|
import { storePagination } from '@/store/useStorePagination';
|
2024-09-29 16:52:09 +08:00
|
|
|
|
2024-10-03 13:44:52 +08:00
|
|
|
/**
|
|
|
|
* 系统菜单图标 Store
|
|
|
|
*/
|
|
|
|
export const useMenuIconStore = defineStore('menuIconStore', {
|
2024-09-29 16:52:09 +08:00
|
|
|
state() {
|
|
|
|
return {
|
2024-10-03 13:44:52 +08:00
|
|
|
// 系统菜单图标列表
|
|
|
|
datalist: [],
|
|
|
|
// 查询表单
|
|
|
|
form: {
|
|
|
|
// icon 名称
|
|
|
|
iconName: undefined,
|
2024-10-17 15:07:45 +08:00
|
|
|
// 图标码
|
|
|
|
iconCode: undefined,
|
2024-10-03 13:44:52 +08:00
|
|
|
},
|
|
|
|
// 分页查询结果
|
|
|
|
pagination: {
|
|
|
|
currentPage: 1,
|
2024-10-23 13:46:46 +08:00
|
|
|
pageSize: 30,
|
|
|
|
total: 1,
|
2024-10-03 13:44:52 +08:00
|
|
|
pageSizes,
|
|
|
|
},
|
|
|
|
// 加载
|
|
|
|
loading: false,
|
2024-09-29 16:52:09 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
getters: {},
|
|
|
|
actions: {
|
|
|
|
/**
|
2024-10-03 13:44:52 +08:00
|
|
|
* * 获取系统菜单图标
|
2024-09-29 16:52:09 +08:00
|
|
|
*/
|
|
|
|
async getMenuIconList() {
|
2024-10-03 13:44:52 +08:00
|
|
|
const data = { ...this.pagination, ...this.form };
|
|
|
|
delete data.pageSizes;
|
|
|
|
delete data.total;
|
|
|
|
delete data.background;
|
|
|
|
const response = await fetchGetMenuIconList(data);
|
|
|
|
|
|
|
|
// 公共页面函数hook
|
|
|
|
const pagination = storePagination.bind(this);
|
|
|
|
return pagination(response);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* * 添加系统菜单图标
|
|
|
|
*/
|
|
|
|
async addMenuIcon(data: any) {
|
|
|
|
const result = await fetchAddMenuIcon(data);
|
|
|
|
return storeMessage(result);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* * 修改系统菜单图标
|
|
|
|
*/
|
|
|
|
async updateMenuIcon(data: any) {
|
|
|
|
const result = await fetchUpdateMenuIcon(data);
|
|
|
|
return storeMessage(result);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* * 删除系统菜单图标
|
|
|
|
*/
|
|
|
|
async deleteMenuIcon(data: any) {
|
|
|
|
const result = await fetchDeleteMenuIcon(data);
|
|
|
|
return storeMessage(result);
|
2024-09-29 16:52:09 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|