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