mirror of
https://github.com/PlayEdu/backend
synced 2025-06-22 13:22:44 +08:00
部门、分类列表存储全局
This commit is contained in:
parent
fd77180c35
commit
3459016134
@ -8,7 +8,8 @@ import type { DataNode, TreeProps } from "antd/es/tree";
|
||||
import { DepartmentCreate } from "./compenents/create";
|
||||
import { DepartmentUpdate } from "./compenents/update";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { saveDepartmentsAction } from "../../store/system/systemConfigSlice";
|
||||
|
||||
const { confirm } = Modal;
|
||||
|
||||
@ -19,6 +20,7 @@ interface Option {
|
||||
}
|
||||
|
||||
const DepartmentPage = () => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const permissions = useSelector(
|
||||
(state: any) => state.loginUser.value.permissions
|
||||
@ -57,6 +59,7 @@ const DepartmentPage = () => {
|
||||
const getData = () => {
|
||||
department.departmentList().then((res: any) => {
|
||||
const departments: DepartmentsBoxModel = res.data.departments;
|
||||
dispatch(saveDepartmentsAction(res.data.departments));
|
||||
if (JSON.stringify(departments) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(departments, 0);
|
||||
setTreeData(new_arr);
|
||||
|
@ -8,7 +8,8 @@ import type { DataNode, TreeProps } from "antd/es/tree";
|
||||
import { ResourceCategoryCreate } from "./compenents/create";
|
||||
import { ResourceCategoryUpdate } from "./compenents/update";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { saveCategoriesAction } from "../../../store/system/systemConfigSlice";
|
||||
|
||||
const { confirm } = Modal;
|
||||
|
||||
@ -19,6 +20,7 @@ interface Option {
|
||||
}
|
||||
|
||||
const ResourceCategoryPage = () => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const permissions = useSelector(
|
||||
(state: any) => state.loginUser.value.permissions
|
||||
@ -53,6 +55,7 @@ const ResourceCategoryPage = () => {
|
||||
setLoading(true);
|
||||
resourceCategory.resourceCategoryList().then((res: any) => {
|
||||
const categories: CategoriesBoxModel = res.data.categories;
|
||||
dispatch(saveCategoriesAction(res.data.categories));
|
||||
if (JSON.stringify(categories) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(categories, 0);
|
||||
setTreeData(new_arr);
|
||||
|
@ -9,23 +9,32 @@ type SystemConfigStoreInterface = {
|
||||
systemName?: string;
|
||||
memberDefaultAvatar?: string;
|
||||
courseDefaultThumbs?: string[];
|
||||
departments: any;
|
||||
resourceCategories: any;
|
||||
departments?: any;
|
||||
resourceCategories?: any;
|
||||
};
|
||||
|
||||
let defaultValue: SystemConfigStoreInterface = {};
|
||||
|
||||
const systemConfigSlice = createSlice({
|
||||
name: "systemConfig",
|
||||
initialState: {
|
||||
value: {},
|
||||
value: defaultValue,
|
||||
},
|
||||
reducers: {
|
||||
saveConfigAction(stage, e) {
|
||||
stage.value = e.payload;
|
||||
},
|
||||
saveDepartmentsAction(stage, e) {
|
||||
stage.value.departments = e.payload;
|
||||
},
|
||||
saveCategoriesAction(stage, e) {
|
||||
stage.value.resourceCategories = e.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default systemConfigSlice.reducer;
|
||||
export const { saveConfigAction } = systemConfigSlice.actions;
|
||||
export const { saveConfigAction, saveDepartmentsAction, saveCategoriesAction } =
|
||||
systemConfigSlice.actions;
|
||||
|
||||
export type { SystemConfigStoreInterface };
|
||||
|
Loading…
x
Reference in New Issue
Block a user