mirror of
https://github.com/PlayEdu/backend
synced 2025-06-09 04:35:33 +08:00
选择视频、课件组件重构
This commit is contained in:
parent
8e5c072634
commit
2ce6292f44
@ -8,7 +8,7 @@ const GoLogin = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const GoError = (code: number) => {
|
const GoError = (code: number) => {
|
||||||
window.location.href = "/error?code=" + code;
|
// window.location.href = "/error?code=" + code;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class HttpClient {
|
export class HttpClient {
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Button, Row, Modal, message, Tabs } from "antd";
|
import { Row, Modal, Tabs } from "antd";
|
||||||
import styles from "./index.module.less";
|
import styles from "./index.module.less";
|
||||||
import { UploadCoursewareSub } from "../../compenents";
|
import { UploadCoursewareSub } from "../../compenents";
|
||||||
import type { TabsProps } from "antd";
|
import type { TabsProps } from "antd";
|
||||||
|
|
||||||
interface VideoItem {
|
|
||||||
id: number;
|
|
||||||
category_id: number;
|
|
||||||
name: string;
|
|
||||||
duration: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PropsInterface {
|
interface PropsInterface {
|
||||||
defaultKeys: any[];
|
defaultKeys: any[];
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -24,6 +17,10 @@ export const SelectAttachment = (props: PropsInterface) => {
|
|||||||
const [selectKeys, setSelectKeys] = useState<any>([]);
|
const [selectKeys, setSelectKeys] = useState<any>([]);
|
||||||
const [selectVideos, setSelectVideos] = useState<any>([]);
|
const [selectVideos, setSelectVideos] = useState<any>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setRefresh(!refresh);
|
||||||
|
}, [props.open]);
|
||||||
|
|
||||||
const items: TabsProps["items"] = [
|
const items: TabsProps["items"] = [
|
||||||
{
|
{
|
||||||
key: "1",
|
key: "1",
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Button, Row, Modal, message, Tabs } from "antd";
|
import { Row, Modal, Tabs } from "antd";
|
||||||
import styles from "./index.module.less";
|
import styles from "./index.module.less";
|
||||||
import { UploadVideoSub } from "../../compenents";
|
import { UploadVideoSub } from "../../compenents";
|
||||||
import type { TabsProps } from "antd";
|
import type { TabsProps } from "antd";
|
||||||
|
|
||||||
interface VideoItem {
|
|
||||||
id: number;
|
|
||||||
category_id: number;
|
|
||||||
name: string;
|
|
||||||
duration: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PropsInterface {
|
interface PropsInterface {
|
||||||
defaultKeys: any[];
|
defaultKeys: any[];
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -24,6 +17,10 @@ export const SelectResource = (props: PropsInterface) => {
|
|||||||
const [selectKeys, setSelectKeys] = useState<any>([]);
|
const [selectKeys, setSelectKeys] = useState<any>([]);
|
||||||
const [selectVideos, setSelectVideos] = useState<any>([]);
|
const [selectVideos, setSelectVideos] = useState<any>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setRefresh(!refresh);
|
||||||
|
}, [props.open]);
|
||||||
|
|
||||||
const items: TabsProps["items"] = [
|
const items: TabsProps["items"] = [
|
||||||
{
|
{
|
||||||
key: "1",
|
key: "1",
|
||||||
|
@ -1,17 +1,32 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Checkbox, Row, Col, Empty, message, Pagination } from "antd";
|
import { Row, Col, Empty, Table, Pagination } from "antd";
|
||||||
|
import type { ColumnsType } from "antd/es/table";
|
||||||
import { resource } from "../../api";
|
import { resource } from "../../api";
|
||||||
import styles from "./index.module.less";
|
import styles from "./index.module.less";
|
||||||
import { TreeCategory, UploadCoursewareButton } from "../../compenents";
|
import { TreeCategory, UploadCoursewareButton } from "../../compenents";
|
||||||
import type { CheckboxChangeEvent } from "antd/es/checkbox";
|
|
||||||
import type { CheckboxValueType } from "antd/es/checkbox/Group";
|
|
||||||
|
|
||||||
const CheckboxGroup = Checkbox.Group;
|
|
||||||
|
|
||||||
interface VideoItem {
|
interface VideoItem {
|
||||||
id: number;
|
id: number;
|
||||||
category_id: number;
|
|
||||||
name: string;
|
name: string;
|
||||||
|
created_at: string;
|
||||||
|
type: string;
|
||||||
|
url: string;
|
||||||
|
path: string;
|
||||||
|
size: number;
|
||||||
|
extension: string;
|
||||||
|
admin_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DataType {
|
||||||
|
id: React.Key;
|
||||||
|
name: string;
|
||||||
|
created_at: string;
|
||||||
|
type: string;
|
||||||
|
url: string;
|
||||||
|
path: string;
|
||||||
|
size: number;
|
||||||
|
extension: string;
|
||||||
|
admin_id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PropsInterface {
|
interface PropsInterface {
|
||||||
@ -30,14 +45,21 @@ export const UploadCoursewareSub = (props: PropsInterface) => {
|
|||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [size, setSize] = useState(10);
|
const [size, setSize] = useState(10);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
|
const [selectedRowKeys, setSelectedRowKeys] = useState<any>([]);
|
||||||
|
|
||||||
const [plainOptions, setPlainOptions] = useState<any>([]);
|
// 加载列表
|
||||||
const [checkedList, setCheckedList] = useState<CheckboxValueType[]>([]);
|
useEffect(() => {
|
||||||
const [indeterminate, setIndeterminate] = useState(false);
|
getvideoList();
|
||||||
const [checkAll, setCheckAll] = useState(false);
|
}, [props.open, category_ids, refresh, page, size]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (props.defaultCheckedList.length > 0) {
|
||||||
|
setSelectedRowKeys(props.defaultCheckedList);
|
||||||
|
}
|
||||||
|
}, [props.defaultCheckedList]);
|
||||||
|
|
||||||
// 获取列表
|
// 获取列表
|
||||||
const getvideoList = (defaultKeys: any[]) => {
|
const getvideoList = () => {
|
||||||
let categoryIds = category_ids.join(",");
|
let categoryIds = category_ids.join(",");
|
||||||
resource
|
resource
|
||||||
.resourceList(
|
.resourceList(
|
||||||
@ -53,42 +75,12 @@ export const UploadCoursewareSub = (props: PropsInterface) => {
|
|||||||
setTotal(res.data.result.total);
|
setTotal(res.data.result.total);
|
||||||
setExistingTypes(res.data.existing_types);
|
setExistingTypes(res.data.existing_types);
|
||||||
setVideoList(res.data.result.data);
|
setVideoList(res.data.result.data);
|
||||||
let data = res.data.result.data;
|
|
||||||
const arr = [];
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
arr.push({
|
|
||||||
label: (
|
|
||||||
<div className="d-flex">
|
|
||||||
<i
|
|
||||||
className="iconfont icon-icon-file"
|
|
||||||
style={{
|
|
||||||
fontSize: 16,
|
|
||||||
color: "rgba(0,0,0,0.3)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="video-title ml-8">{data[i].name}</div>
|
|
||||||
<div className="video-time">{data[i].type}</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
value: data[i].id,
|
|
||||||
disabled: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (defaultKeys.length > 0 && arr.length > 0) {
|
|
||||||
for (let i = 0; i < defaultKeys.length; i++) {
|
|
||||||
for (let j = 0; j < arr.length; j++) {
|
|
||||||
if (arr[j].value === defaultKeys[i]) {
|
|
||||||
arr[j].disabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setPlainOptions(arr);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log("错误,", err);
|
console.log("错误,", err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置列表
|
// 重置列表
|
||||||
const resetVideoList = () => {
|
const resetVideoList = () => {
|
||||||
setPage(1);
|
setPage(1);
|
||||||
@ -96,76 +88,64 @@ export const UploadCoursewareSub = (props: PropsInterface) => {
|
|||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载列表
|
const paginationProps = {
|
||||||
useEffect(() => {
|
current: page, //当前页码
|
||||||
const arr = [...props.defaultCheckedList];
|
pageSize: size,
|
||||||
setCheckedList(arr);
|
total: total, // 总条数
|
||||||
if (arr.length === 0) {
|
onChange: (page: number, pageSize: number) =>
|
||||||
setIndeterminate(false);
|
handlePageChange(page, pageSize), //改变页码的函数
|
||||||
setCheckAll(false);
|
showSizeChanger: true,
|
||||||
}
|
|
||||||
getvideoList(arr);
|
|
||||||
}, [props.open, props.defaultCheckedList, category_ids, refresh, page, size]);
|
|
||||||
|
|
||||||
const onChange = (list: CheckboxValueType[]) => {
|
|
||||||
setCheckedList(list);
|
|
||||||
setIndeterminate(!!list.length && list.length < plainOptions.length);
|
|
||||||
setCheckAll(list.length === plainOptions.length);
|
|
||||||
const defalut = [...props.defaultCheckedList];
|
|
||||||
let localKeys: any = [];
|
|
||||||
list.map((item: any) => {
|
|
||||||
if (defalut.indexOf(item) === -1) {
|
|
||||||
localKeys.push(item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let arrVideos: any = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < localKeys.length; i++) {
|
|
||||||
videoList.map((item: any, index: number) => {
|
|
||||||
if (item.id === localKeys[i]) {
|
|
||||||
arrVideos.push({
|
|
||||||
name: item.name,
|
|
||||||
type: item.type,
|
|
||||||
rid: item.id,
|
|
||||||
disabled: plainOptions[index].disabled,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
props.onSelected(localKeys, arrVideos);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCheckAllChange = (e: CheckboxChangeEvent) => {
|
const handlePageChange = (page: number, pageSize: number) => {
|
||||||
const arr = plainOptions.map((item: any) => item.value);
|
setPage(page);
|
||||||
setCheckedList(e.target.checked ? arr : []);
|
setSize(pageSize);
|
||||||
setIndeterminate(false);
|
};
|
||||||
setCheckAll(e.target.checked);
|
|
||||||
const defalut = [...props.defaultCheckedList];
|
const columns: ColumnsType<DataType> = [
|
||||||
let localKeys: any = [];
|
{
|
||||||
arr.map((item: any) => {
|
title: "课件",
|
||||||
if (defalut.indexOf(item) === -1) {
|
render: (_, record: any) => (
|
||||||
localKeys.push(item);
|
<div className="d-flex">
|
||||||
}
|
<i
|
||||||
});
|
className="iconfont icon-icon-file"
|
||||||
|
style={{
|
||||||
|
fontSize: 14,
|
||||||
|
color: "rgba(0,0,0,0.3)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="video-title ml-8">{record.name}</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "类型",
|
||||||
|
render: (_, record: any) => <span>{record.type}</span>,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const rowSelection = {
|
||||||
|
selectedRowKeys: selectedRowKeys,
|
||||||
|
onChange: (selectedRowKeys: React.Key[], selectedRows: DataType[]) => {
|
||||||
|
let row: any = selectedRows;
|
||||||
let arrVideos: any = [];
|
let arrVideos: any = [];
|
||||||
for (let i = 0; i < localKeys.length; i++) {
|
if (row) {
|
||||||
videoList.map((item: any, index: number) => {
|
for (var i = 0; i < row.length; i++) {
|
||||||
if (item.id === localKeys[i]) {
|
if (props.defaultCheckedList.indexOf(row[i].id) === -1) {
|
||||||
arrVideos.push({
|
arrVideos.push({
|
||||||
name: item.name,
|
name: row[i].name,
|
||||||
type: item.type,
|
type: row[i].type,
|
||||||
rid: item.id,
|
rid: row[i].id,
|
||||||
disabled: plainOptions[index].disabled,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (e.target.checked) {
|
props.onSelected(selectedRowKeys, arrVideos);
|
||||||
props.onSelected(localKeys, arrVideos);
|
|
||||||
} else {
|
|
||||||
props.onSelected([], []);
|
|
||||||
}
|
}
|
||||||
|
setSelectedRowKeys(selectedRowKeys);
|
||||||
|
},
|
||||||
|
getCheckboxProps: (record: any) => ({
|
||||||
|
disabled: props.defaultCheckedList.indexOf(record.id) !== -1, //禁用的条件
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -198,18 +178,16 @@ export const UploadCoursewareSub = (props: PropsInterface) => {
|
|||||||
)}
|
)}
|
||||||
{videoList.length > 0 && (
|
{videoList.length > 0 && (
|
||||||
<div className="list-select-column-box c-flex">
|
<div className="list-select-column-box c-flex">
|
||||||
<Checkbox
|
<Table
|
||||||
indeterminate={indeterminate}
|
rowSelection={{
|
||||||
onChange={onCheckAllChange}
|
type: "checkbox",
|
||||||
checked={checkAll}
|
...rowSelection,
|
||||||
>
|
}}
|
||||||
全选
|
columns={columns}
|
||||||
</Checkbox>
|
dataSource={videoList}
|
||||||
<CheckboxGroup
|
loading={loading}
|
||||||
className="c-flex"
|
pagination={paginationProps}
|
||||||
options={plainOptions}
|
rowKey={(record) => record.id}
|
||||||
value={checkedList}
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -1,19 +1,33 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Checkbox, Row, Col, Empty, message, Pagination } from "antd";
|
import { Row, Col, Empty, Table, Pagination } from "antd";
|
||||||
|
import type { ColumnsType } from "antd/es/table";
|
||||||
import { resource } from "../../api";
|
import { resource } from "../../api";
|
||||||
import styles from "./index.module.less";
|
import styles from "./index.module.less";
|
||||||
import { UploadVideoButton } from "../upload-video-button";
|
import { UploadVideoButton } from "../upload-video-button";
|
||||||
import { DurationText, TreeCategory } from "../../compenents";
|
import { DurationText, TreeCategory } from "../../compenents";
|
||||||
import type { CheckboxChangeEvent } from "antd/es/checkbox";
|
|
||||||
import type { CheckboxValueType } from "antd/es/checkbox/Group";
|
|
||||||
|
|
||||||
const CheckboxGroup = Checkbox.Group;
|
|
||||||
|
|
||||||
interface VideoItem {
|
interface VideoItem {
|
||||||
id: number;
|
id: number;
|
||||||
category_id: number;
|
|
||||||
name: string;
|
name: string;
|
||||||
duration: number;
|
created_at: string;
|
||||||
|
type: string;
|
||||||
|
url: string;
|
||||||
|
path: string;
|
||||||
|
size: number;
|
||||||
|
extension: string;
|
||||||
|
admin_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DataType {
|
||||||
|
id: React.Key;
|
||||||
|
name: string;
|
||||||
|
created_at: string;
|
||||||
|
type: string;
|
||||||
|
url: string;
|
||||||
|
path: string;
|
||||||
|
size: number;
|
||||||
|
extension: string;
|
||||||
|
admin_id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PropsInterface {
|
interface PropsInterface {
|
||||||
@ -32,14 +46,21 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
|||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [size, setSize] = useState(10);
|
const [size, setSize] = useState(10);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
|
const [selectedRowKeys, setSelectedRowKeys] = useState<any>([]);
|
||||||
|
|
||||||
const [plainOptions, setPlainOptions] = useState<any>([]);
|
// 加载列表
|
||||||
const [checkedList, setCheckedList] = useState<CheckboxValueType[]>([]);
|
useEffect(() => {
|
||||||
const [indeterminate, setIndeterminate] = useState(false);
|
getvideoList();
|
||||||
const [checkAll, setCheckAll] = useState(false);
|
}, [props.open, category_ids, refresh, page, size]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (props.defaultCheckedList.length > 0) {
|
||||||
|
setSelectedRowKeys(props.defaultCheckedList);
|
||||||
|
}
|
||||||
|
}, [props.defaultCheckedList]);
|
||||||
|
|
||||||
// 获取列表
|
// 获取列表
|
||||||
const getvideoList = (defaultKeys: any[]) => {
|
const getvideoList = () => {
|
||||||
let categoryIds = category_ids.join(",");
|
let categoryIds = category_ids.join(",");
|
||||||
resource
|
resource
|
||||||
.resourceList(page, size, "", "", "", "VIDEO", categoryIds)
|
.resourceList(page, size, "", "", "", "VIDEO", categoryIds)
|
||||||
@ -47,46 +68,12 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
|||||||
setTotal(res.data.result.total);
|
setTotal(res.data.result.total);
|
||||||
setVideoExtra(res.data.videos_extra);
|
setVideoExtra(res.data.videos_extra);
|
||||||
setVideoList(res.data.result.data);
|
setVideoList(res.data.result.data);
|
||||||
let data = res.data.result.data;
|
|
||||||
const arr = [];
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
|
||||||
arr.push({
|
|
||||||
label: (
|
|
||||||
<div className="d-flex">
|
|
||||||
<i
|
|
||||||
className="iconfont icon-icon-video"
|
|
||||||
style={{
|
|
||||||
fontSize: 16,
|
|
||||||
color: "rgba(0,0,0,0.3)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="video-title ml-8">{data[i].name}</div>
|
|
||||||
<div className="video-time">
|
|
||||||
<DurationText
|
|
||||||
duration={res.data.videos_extra[data[i].id].duration}
|
|
||||||
></DurationText>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
value: data[i].id,
|
|
||||||
disabled: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (defaultKeys.length > 0 && arr.length > 0) {
|
|
||||||
for (let i = 0; i < defaultKeys.length; i++) {
|
|
||||||
for (let j = 0; j < arr.length; j++) {
|
|
||||||
if (arr[j].value === defaultKeys[i]) {
|
|
||||||
arr[j].disabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setPlainOptions(arr);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log("错误,", err);
|
console.log("错误,", err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置列表
|
// 重置列表
|
||||||
const resetVideoList = () => {
|
const resetVideoList = () => {
|
||||||
setPage(1);
|
setPage(1);
|
||||||
@ -94,78 +81,71 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
|||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载列表
|
const paginationProps = {
|
||||||
useEffect(() => {
|
current: page, //当前页码
|
||||||
const arr = [...props.defaultCheckedList];
|
pageSize: size,
|
||||||
setCheckedList(arr);
|
total: total, // 总条数
|
||||||
if (arr.length === 0) {
|
onChange: (page: number, pageSize: number) =>
|
||||||
setIndeterminate(false);
|
handlePageChange(page, pageSize), //改变页码的函数
|
||||||
setCheckAll(false);
|
showSizeChanger: true,
|
||||||
}
|
|
||||||
getvideoList(arr);
|
|
||||||
}, [props.open, props.defaultCheckedList, category_ids, refresh, page, size]);
|
|
||||||
|
|
||||||
const onChange = (list: CheckboxValueType[]) => {
|
|
||||||
setCheckedList(list);
|
|
||||||
setIndeterminate(!!list.length && list.length < plainOptions.length);
|
|
||||||
setCheckAll(list.length === plainOptions.length);
|
|
||||||
const defalut = [...props.defaultCheckedList];
|
|
||||||
let localKeys: any = [];
|
|
||||||
list.map((item: any) => {
|
|
||||||
if (defalut.indexOf(item) === -1) {
|
|
||||||
localKeys.push(item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let arrVideos: any = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < localKeys.length; i++) {
|
|
||||||
videoList.map((item: any, index: number) => {
|
|
||||||
if (item.id === localKeys[i]) {
|
|
||||||
arrVideos.push({
|
|
||||||
name: item.name,
|
|
||||||
type: item.type,
|
|
||||||
rid: item.id,
|
|
||||||
duration: videosExtra[item.id].duration,
|
|
||||||
disabled: plainOptions[index].disabled,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
props.onSelected(localKeys, arrVideos);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCheckAllChange = (e: CheckboxChangeEvent) => {
|
const handlePageChange = (page: number, pageSize: number) => {
|
||||||
const arr = plainOptions.map((item: any) => item.value);
|
setPage(page);
|
||||||
setCheckedList(e.target.checked ? arr : []);
|
setSize(pageSize);
|
||||||
setIndeterminate(false);
|
};
|
||||||
setCheckAll(e.target.checked);
|
|
||||||
const defalut = [...props.defaultCheckedList];
|
const columns: ColumnsType<DataType> = [
|
||||||
let localKeys: any = [];
|
{
|
||||||
arr.map((item: any) => {
|
title: "视频",
|
||||||
if (defalut.indexOf(item) === -1) {
|
render: (_, record: any) => (
|
||||||
localKeys.push(item);
|
<div className="d-flex">
|
||||||
}
|
<i
|
||||||
});
|
className="iconfont icon-icon-video"
|
||||||
|
style={{
|
||||||
|
fontSize: 14,
|
||||||
|
color: "rgba(0,0,0,0.3)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<div className="video-title ml-8">{record.name}</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "时长",
|
||||||
|
render: (_, record: any) => (
|
||||||
|
<div>
|
||||||
|
<DurationText
|
||||||
|
duration={videosExtra[record.id].duration}
|
||||||
|
></DurationText>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const rowSelection = {
|
||||||
|
selectedRowKeys: selectedRowKeys,
|
||||||
|
onChange: (selectedRowKeys: React.Key[], selectedRows: DataType[]) => {
|
||||||
|
let row: any = selectedRows;
|
||||||
let arrVideos: any = [];
|
let arrVideos: any = [];
|
||||||
for (let i = 0; i < localKeys.length; i++) {
|
if (row) {
|
||||||
videoList.map((item: any, index: number) => {
|
for (var i = 0; i < row.length; i++) {
|
||||||
if (item.id === localKeys[i]) {
|
if (props.defaultCheckedList.indexOf(row[i].id) === -1) {
|
||||||
arrVideos.push({
|
arrVideos.push({
|
||||||
name: item.name,
|
name: row[i].name,
|
||||||
type: item.type,
|
type: row[i].type,
|
||||||
rid: item.id,
|
rid: row[i].id,
|
||||||
duration: videosExtra[item.id].duration,
|
duration: videosExtra[row[i].id].duration,
|
||||||
disabled: plainOptions[index].disabled,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (e.target.checked) {
|
props.onSelected(selectedRowKeys, arrVideos);
|
||||||
props.onSelected(localKeys, arrVideos);
|
|
||||||
} else {
|
|
||||||
props.onSelected([], []);
|
|
||||||
}
|
}
|
||||||
|
setSelectedRowKeys(selectedRowKeys);
|
||||||
|
},
|
||||||
|
getCheckboxProps: (record: any) => ({
|
||||||
|
disabled: props.defaultCheckedList.indexOf(record.id) !== -1, //禁用的条件
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -198,18 +178,16 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
|||||||
)}
|
)}
|
||||||
{videoList.length > 0 && (
|
{videoList.length > 0 && (
|
||||||
<div className="list-select-column-box c-flex">
|
<div className="list-select-column-box c-flex">
|
||||||
<Checkbox
|
<Table
|
||||||
indeterminate={indeterminate}
|
rowSelection={{
|
||||||
onChange={onCheckAllChange}
|
type: "checkbox",
|
||||||
checked={checkAll}
|
...rowSelection,
|
||||||
>
|
}}
|
||||||
全选
|
columns={columns}
|
||||||
</Checkbox>
|
dataSource={videoList}
|
||||||
<CheckboxGroup
|
loading={loading}
|
||||||
className="c-flex"
|
pagination={paginationProps}
|
||||||
options={plainOptions}
|
rowKey={(record) => record.id}
|
||||||
value={checkedList}
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -593,23 +593,18 @@ textarea.ant-input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.list-select-column-box {
|
.list-select-column-box {
|
||||||
.ant-checkbox-wrapper {
|
width: 100%;
|
||||||
display: flex;
|
height: auto;
|
||||||
height: 38px !important;
|
float: left;
|
||||||
align-items: center;
|
.ant-table-cell {
|
||||||
|
padding: 0px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-title {
|
.video-title {
|
||||||
width: 390px;
|
width: 360px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.video-time {
|
|
||||||
width: 80px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row-reverse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-list-box {
|
.image-list-box {
|
||||||
|
@ -69,7 +69,6 @@ export const CourseAttachmentUpdate: React.FC<PropInterface> = ({
|
|||||||
const selectAttachmentData = (arr: any, videos: any) => {
|
const selectAttachmentData = (arr: any, videos: any) => {
|
||||||
const hours: any = [];
|
const hours: any = [];
|
||||||
for (let i = 0; i < videos.length; i++) {
|
for (let i = 0; i < videos.length; i++) {
|
||||||
if (videos[i].disabled === false) {
|
|
||||||
hours.push({
|
hours.push({
|
||||||
sort: attachmentData.length + i,
|
sort: attachmentData.length + i,
|
||||||
title: videos[i].name,
|
title: videos[i].name,
|
||||||
@ -77,11 +76,12 @@ export const CourseAttachmentUpdate: React.FC<PropInterface> = ({
|
|||||||
rid: videos[i].rid,
|
rid: videos[i].rid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (hours.length === 0) {
|
if (hours.length === 0) {
|
||||||
message.error("请选择视频");
|
message.error("请选择课件");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(hours);
|
||||||
|
|
||||||
courseAttachment
|
courseAttachment
|
||||||
.storeCourseAttachmentMulti(id, hours)
|
.storeCourseAttachmentMulti(id, hours)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
|
@ -100,7 +100,6 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
|||||||
const selectData = (arr: any, videos: any) => {
|
const selectData = (arr: any, videos: any) => {
|
||||||
const hours: any = [];
|
const hours: any = [];
|
||||||
for (let i = 0; i < videos.length; i++) {
|
for (let i = 0; i < videos.length; i++) {
|
||||||
if (videos[i].disabled === false) {
|
|
||||||
hours.push({
|
hours.push({
|
||||||
chapter_id: 0,
|
chapter_id: 0,
|
||||||
sort: treeData.length + i,
|
sort: treeData.length + i,
|
||||||
@ -110,7 +109,6 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
|||||||
rid: videos[i].rid,
|
rid: videos[i].rid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (hours.length === 0) {
|
if (hours.length === 0) {
|
||||||
message.error("请选择视频");
|
message.error("请选择视频");
|
||||||
return;
|
return;
|
||||||
@ -135,7 +133,6 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
|||||||
}
|
}
|
||||||
const hours: any = [];
|
const hours: any = [];
|
||||||
for (let i = 0; i < videos.length; i++) {
|
for (let i = 0; i < videos.length; i++) {
|
||||||
if (videos[i].disabled === false) {
|
|
||||||
hours.push({
|
hours.push({
|
||||||
chapter_id: data[addvideoCurrent].id,
|
chapter_id: data[addvideoCurrent].id,
|
||||||
sort: data[addvideoCurrent].hours.length + i,
|
sort: data[addvideoCurrent].hours.length + i,
|
||||||
@ -145,7 +142,6 @@ export const CourseHourUpdate: React.FC<PropInterface> = ({
|
|||||||
rid: videos[i].rid,
|
rid: videos[i].rid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (hours.length === 0) {
|
if (hours.length === 0) {
|
||||||
message.error("请选择视频");
|
message.error("请选择视频");
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user