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