mirror of
https://github.com/PlayEdu/backend
synced 2025-07-23 10:43:28 +08:00
数据结构重构优化
This commit is contained in:
parent
8c52461558
commit
2348cfb54d
@ -11,12 +11,18 @@ interface PropsInterface {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type selAttachmentModel = {
|
||||||
|
name: string;
|
||||||
|
rid: number;
|
||||||
|
type: string;
|
||||||
|
};
|
||||||
|
|
||||||
export const SelectAttachment = (props: PropsInterface) => {
|
export const SelectAttachment = (props: PropsInterface) => {
|
||||||
const [refresh, setRefresh] = useState(true);
|
const [refresh, setRefresh] = useState(true);
|
||||||
|
|
||||||
const [tabKey, setTabKey] = useState(1);
|
const [tabKey, setTabKey] = useState(1);
|
||||||
const [selectKeys, setSelectKeys] = useState<any>([]);
|
const [selectKeys, setSelectKeys] = useState<number[]>([]);
|
||||||
const [selectVideos, setSelectVideos] = useState<any>([]);
|
const [selectVideos, setSelectVideos] = useState<selAttachmentModel[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
|
@ -11,11 +11,18 @@ interface PropsInterface {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type selVideosModel = {
|
||||||
|
name: string;
|
||||||
|
rid: number;
|
||||||
|
type: string;
|
||||||
|
duration: number;
|
||||||
|
};
|
||||||
|
|
||||||
export const SelectResource = (props: PropsInterface) => {
|
export const SelectResource = (props: PropsInterface) => {
|
||||||
const [refresh, setRefresh] = useState(true);
|
const [refresh, setRefresh] = useState(true);
|
||||||
const [tabKey, setTabKey] = useState(1);
|
const [tabKey, setTabKey] = useState(1);
|
||||||
const [selectKeys, setSelectKeys] = useState<any>([]);
|
const [selectKeys, setSelectKeys] = useState<number[]>([]);
|
||||||
const [selectVideos, setSelectVideos] = useState<any>([]);
|
const [selectVideos, setSelectVideos] = useState<selVideosModel[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
@ -62,6 +69,7 @@ export const SelectResource = (props: PropsInterface) => {
|
|||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
onOk={() => {
|
onOk={() => {
|
||||||
props.onSelected(selectKeys, selectVideos);
|
props.onSelected(selectKeys, selectVideos);
|
||||||
|
console.log(selectKeys, selectVideos);
|
||||||
setSelectKeys([]);
|
setSelectKeys([]);
|
||||||
setSelectVideos([]);
|
setSelectVideos([]);
|
||||||
}}
|
}}
|
||||||
|
@ -18,7 +18,7 @@ interface PropInterface {
|
|||||||
export const TreeCategory = (props: PropInterface) => {
|
export const TreeCategory = (props: PropInterface) => {
|
||||||
const [treeData, setTreeData] = useState<any>([]);
|
const [treeData, setTreeData] = useState<any>([]);
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [selectKey, setSelectKey] = useState<any>([]);
|
const [selectKey, setSelectKey] = useState<number[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.selected && props.selected.length > 0) {
|
if (props.selected && props.selected.length > 0) {
|
||||||
@ -28,7 +28,7 @@ export const TreeCategory = (props: PropInterface) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
resourceCategory.resourceCategoryList().then((res: any) => {
|
resourceCategory.resourceCategoryList().then((res: any) => {
|
||||||
const categories = res.data.categories;
|
const categories: CategoriesBoxModel = 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);
|
||||||
if (props.type === "no-cate") {
|
if (props.type === "no-cate") {
|
||||||
@ -43,7 +43,7 @@ export const TreeCategory = (props: PropInterface) => {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const checkArr = (categories: any[], id: number) => {
|
const checkArr = (categories: CategoriesBoxModel, id: number) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
for (let i = 0; i < categories[id].length; i++) {
|
for (let i = 0; i < categories[id].length; i++) {
|
||||||
if (!categories[categories[id][i].id]) {
|
if (!categories[categories[id][i].id]) {
|
||||||
|
@ -32,8 +32,8 @@ export const TreeDepartment = (props: PropInterface) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
department.departmentList().then((res: any) => {
|
department.departmentList().then((res: any) => {
|
||||||
const departments = res.data.departments;
|
const departments: DepartmentsBoxModel = res.data.departments;
|
||||||
const departCount = res.data.dep_user_count;
|
const departCount: DepIdsModel = res.data.dep_user_count;
|
||||||
setUserTotal(res.data.user_total);
|
setUserTotal(res.data.user_total);
|
||||||
if (JSON.stringify(departments) !== "{}") {
|
if (JSON.stringify(departments) !== "{}") {
|
||||||
if (props.showNum) {
|
if (props.showNum) {
|
||||||
@ -57,7 +57,11 @@ export const TreeDepartment = (props: PropInterface) => {
|
|||||||
});
|
});
|
||||||
}, [props.refresh]);
|
}, [props.refresh]);
|
||||||
|
|
||||||
const checkNewArr = (departments: any[], id: number, counts: any) => {
|
const checkNewArr = (
|
||||||
|
departments: DepartmentsBoxModel,
|
||||||
|
id: number,
|
||||||
|
counts: any
|
||||||
|
) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
for (let i = 0; i < departments[id].length; i++) {
|
for (let i = 0; i < departments[id].length; i++) {
|
||||||
if (!departments[departments[id][i].id]) {
|
if (!departments[departments[id][i].id]) {
|
||||||
@ -89,7 +93,7 @@ export const TreeDepartment = (props: PropInterface) => {
|
|||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkArr = (departments: any[], id: number) => {
|
const checkArr = (departments: DepartmentsBoxModel, id: number) => {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
for (let i = 0; i < departments[id].length; i++) {
|
for (let i = 0; i < departments[id].length; i++) {
|
||||||
if (!departments[departments[id][i].id]) {
|
if (!departments[departments[id][i].id]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user