mirror of
https://github.com/PlayEdu/backend
synced 2026-02-02 21:30:39 +08:00
数据结构重构优化
This commit is contained in:
@@ -51,7 +51,7 @@ const DepartmentPage = () => {
|
||||
const getData = () => {
|
||||
setLoading(true);
|
||||
department.departmentList().then((res: any) => {
|
||||
const departments = res.data.departments;
|
||||
const departments: DepartmentsBoxModel = res.data.departments;
|
||||
if (JSON.stringify(departments) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(departments, 0);
|
||||
setTreeData(new_arr);
|
||||
@@ -61,7 +61,7 @@ const DepartmentPage = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const checkArr = (departments: any[], id: number) => {
|
||||
const checkArr = (departments: DepartmentsBoxModel, id: number) => {
|
||||
const arr = [];
|
||||
for (let i = 0; i < departments[id].length; i++) {
|
||||
if (!departments[departments[id][i].id]) {
|
||||
|
||||
@@ -50,7 +50,7 @@ const ResourceCategoryPage = () => {
|
||||
const getData = () => {
|
||||
setLoading(true);
|
||||
resourceCategory.resourceCategoryList().then((res: any) => {
|
||||
const categories = res.data.categories;
|
||||
const categories: CategoriesBoxModel = res.data.categories;
|
||||
if (JSON.stringify(categories) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(categories, 0);
|
||||
setTreeData(new_arr);
|
||||
@@ -59,7 +59,7 @@ const ResourceCategoryPage = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const checkArr = (categories: any[], id: number) => {
|
||||
const checkArr = (categories: CategoriesBoxModel, id: number) => {
|
||||
const arr = [];
|
||||
for (let i = 0; i < categories[id].length; i++) {
|
||||
if (!categories[categories[id][i].id]) {
|
||||
|
||||
Reference in New Issue
Block a user