mirror of
https://github.com/PlayEdu/backend
synced 2025-06-28 17:07:16 +08:00
数据结构重构优化
This commit is contained in:
parent
2a6e451417
commit
0cda0e0a73
@ -34,8 +34,8 @@ export function storeCourse(
|
||||
isRequired: number,
|
||||
depIds: number[],
|
||||
categoryIds: number[],
|
||||
chapters: number[],
|
||||
hours: number[],
|
||||
chapters: any[],
|
||||
hours: any[],
|
||||
attachments: any[]
|
||||
) {
|
||||
return client.post("/backend/v1/course/create", {
|
||||
|
@ -22,8 +22,10 @@ export const CourseAttachmentUpdate: React.FC<PropInterface> = ({
|
||||
const [form] = Form.useForm();
|
||||
const [init, setInit] = useState(true);
|
||||
const [attachmentVisible, setAttachmentVisible] = useState<boolean>(false);
|
||||
const [attachmentData, setAttachmentData] = useState<any>([]);
|
||||
const [attachments, setAttachments] = useState<any>([]);
|
||||
const [attachmentData, setAttachmentData] = useState<AttachmentDataModel[]>(
|
||||
[]
|
||||
);
|
||||
const [attachments, setAttachments] = useState<number[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
setInit(true);
|
||||
|
@ -1,20 +1,20 @@
|
||||
import { message, Tree, Tooltip } from "antd";
|
||||
import { Tree, Tooltip } from "antd";
|
||||
import { useState, useEffect } from "react";
|
||||
import type { DataNode, TreeProps } from "antd/es/tree";
|
||||
|
||||
interface Option {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface PropInterface {
|
||||
data: Option[];
|
||||
data: AttachmentDataModel[];
|
||||
onRemoveItem: (id: number) => void;
|
||||
onUpdate: (arr: any[]) => void;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
key: string | number;
|
||||
title: any;
|
||||
}
|
||||
|
||||
export const TreeAttachments = (props: PropInterface) => {
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [treeData, setTreeData] = useState<Option[]>([]);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
useEffect(() => {
|
||||
const hours = props.data;
|
||||
|
@ -57,16 +57,18 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
const [thumb, setThumb] = useState("");
|
||||
const [type, setType] = useState("open");
|
||||
const [chapterType, setChapterType] = useState(0);
|
||||
const [chapters, setChapters] = useState<any>([]);
|
||||
const [hours, setHours] = useState<any>([]);
|
||||
const [chapters, setChapters] = useState<CourseChaptersModel[]>([]);
|
||||
const [hours, setHours] = useState<number[]>([]);
|
||||
const [chapterHours, setChapterHours] = useState<any>([]);
|
||||
const [videoVisible, setVideoVisible] = useState(false);
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [treeData, setTreeData] = useState<CourseHourModel[]>([]);
|
||||
const [addvideoCurrent, setAddvideoCurrent] = useState(0);
|
||||
const [showDrop, setShowDrop] = useState(false);
|
||||
const [attachmentVisible, setAttachmentVisible] = useState(false);
|
||||
const [attachmentData, setAttachmentData] = useState<any>([]);
|
||||
const [attachments, setAttachments] = useState<any>([]);
|
||||
const [attachmentData, setAttachmentData] = useState<AttachmentDataModel[]>(
|
||||
[]
|
||||
);
|
||||
const [attachments, setAttachments] = useState<number[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
@ -265,6 +267,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
setHours(keys);
|
||||
setTreeData(data);
|
||||
setVideoVisible(false);
|
||||
console.log(keys, data);
|
||||
};
|
||||
|
||||
const selectChapterData = (arr: any, videos: any) => {
|
||||
@ -444,7 +447,6 @@ export const CourseCreate: React.FC<PropInterface> = ({
|
||||
const keys = [...chapterHours];
|
||||
keys[index] = arr;
|
||||
setChapterHours(keys);
|
||||
|
||||
const data = [...chapters];
|
||||
const newArr: any = [];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
|
@ -22,11 +22,11 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
||||
const [form] = Form.useForm();
|
||||
const [init, setInit] = useState(true);
|
||||
const [chapterType, setChapterType] = useState(0);
|
||||
const [chapters, setChapters] = useState<any>([]);
|
||||
const [hours, setHours] = useState<any>([]);
|
||||
const [chapters, setChapters] = useState<CourseChaptersModel[]>([]);
|
||||
const [hours, setHours] = useState<number[]>([]);
|
||||
const [chapterHours, setChapterHours] = useState<any>([]);
|
||||
const [videoVisible, setVideoVisible] = useState<boolean>(false);
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [treeData, setTreeData] = useState<CourseHourModel[]>([]);
|
||||
const [addvideoCurrent, setAddvideoCurrent] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
@ -234,7 +234,7 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
||||
const arr = [...chapters];
|
||||
if (arr[index].id) {
|
||||
courseChapter
|
||||
.updateCourseChapter(id, arr[index].id, value, arr.length)
|
||||
.updateCourseChapter(id, Number(arr[index].id), value, arr.length)
|
||||
.then((res: any) => {
|
||||
console.log("ok");
|
||||
getDetail();
|
||||
@ -262,7 +262,7 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
||||
onOk() {
|
||||
if (arr[index].id) {
|
||||
courseChapter
|
||||
.destroyCourseChapter(id, arr[index].id)
|
||||
.destroyCourseChapter(id, Number(arr[index].id))
|
||||
.then((res: any) => {
|
||||
console.log("ok");
|
||||
getDetail();
|
||||
|
@ -3,18 +3,18 @@ import { useState, useEffect } from "react";
|
||||
import type { DataNode, TreeProps } from "antd/es/tree";
|
||||
|
||||
interface Option {
|
||||
id: number;
|
||||
name: string;
|
||||
key: string | number;
|
||||
title: any;
|
||||
}
|
||||
|
||||
interface PropInterface {
|
||||
data: Option[];
|
||||
data: CourseHourModel[];
|
||||
onRemoveItem: (id: number) => void;
|
||||
onUpdate: (arr: any[]) => void;
|
||||
}
|
||||
|
||||
export const TreeHours = (props: PropInterface) => {
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [treeData, setTreeData] = useState<Option[]>([]);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
useEffect(() => {
|
||||
const hours = props.data;
|
||||
|
21
src/playedu.d.ts
vendored
21
src/playedu.d.ts
vendored
@ -116,6 +116,27 @@ declare global {
|
||||
interface RoleIdsModel {
|
||||
[key: number]: number[];
|
||||
}
|
||||
|
||||
interface CourseChaptersModel {
|
||||
id?: number;
|
||||
hours: CourseHourModel[];
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface CourseHourModel {
|
||||
id?: number;
|
||||
duration: number;
|
||||
name: string;
|
||||
rid: number;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface AttachmentDataModel {
|
||||
id?: number;
|
||||
name: string;
|
||||
rid: number;
|
||||
type: string;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user