mirror of
https://github.com/PlayEdu/backend
synced 2025-07-23 19:29:37 +08:00
资源视频列表增加批量删除
This commit is contained in:
parent
097cbe6b63
commit
7cb408a1cb
@ -61,3 +61,7 @@ export function destroyResourceMulti(ids: number[]) {
|
|||||||
ids: ids,
|
ids: ids,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function videoUpdate(id: number, params: any) {
|
||||||
|
return client.put(`/backend/v1/resource/${id}`, params);
|
||||||
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Modal, Table, message, Space } from "antd";
|
import { Modal, Table, message, Space, Dropdown, Button } from "antd";
|
||||||
|
import type { MenuProps } from "antd";
|
||||||
import { resource } from "../../../api";
|
import { resource } from "../../../api";
|
||||||
// import styles from "./index.module.less";
|
// import styles from "./index.module.less";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { ExclamationCircleFilled } from "@ant-design/icons";
|
import { DownOutlined, ExclamationCircleFilled } from "@ant-design/icons";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
import type { ColumnsType } from "antd/es/table";
|
||||||
import { dateFormat } from "../../../utils/index";
|
import { dateFormat } from "../../../utils/index";
|
||||||
import { TreeCategory, DurationText, PerButton } from "../../../compenents";
|
import { TreeCategory, DurationText, PerButton } from "../../../compenents";
|
||||||
@ -29,10 +30,15 @@ const ResourceVideosPage = () => {
|
|||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [category_ids, setCategoryIds] = useState<any>([]);
|
const [category_ids, setCategoryIds] = useState<any>([]);
|
||||||
|
const [selectedRowKeys, setSelectedRowKeys] = useState<any>([]);
|
||||||
const [selLabel, setLabel] = useState<string>(
|
const [selLabel, setLabel] = useState<string>(
|
||||||
result.get("label") ? String(result.get("label")) : "全部视频"
|
result.get("label") ? String(result.get("label")) : "全部视频"
|
||||||
);
|
);
|
||||||
const [cateId, setCateId] = useState(Number(result.get("cid")));
|
const [cateId, setCateId] = useState(Number(result.get("cid")));
|
||||||
|
const [updateVisible, setUpdateVisible] = useState<boolean>(false);
|
||||||
|
const [playVisible, setPlayeVisible] = useState<boolean>(false);
|
||||||
|
const [multiConfig, setMultiConfig] = useState<boolean>(false);
|
||||||
|
const [updateId, setUpdateId] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCateId(Number(result.get("cid")));
|
setCateId(Number(result.get("cid")));
|
||||||
@ -44,18 +50,6 @@ const ResourceVideosPage = () => {
|
|||||||
}, [result.get("cid")]);
|
}, [result.get("cid")]);
|
||||||
|
|
||||||
const columns: ColumnsType<DataType> = [
|
const columns: ColumnsType<DataType> = [
|
||||||
// {
|
|
||||||
// title: "封面",
|
|
||||||
// dataIndex: "id",
|
|
||||||
// render: (id: string) => (
|
|
||||||
// <Image
|
|
||||||
// preview={false}
|
|
||||||
// width={120}
|
|
||||||
// height={80}
|
|
||||||
// src={videosExtra[id].poster}
|
|
||||||
// ></Image>
|
|
||||||
// ),
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
title: "视频名称",
|
title: "视频名称",
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
@ -94,20 +88,70 @@ const ResourceVideosPage = () => {
|
|||||||
title: "操作",
|
title: "操作",
|
||||||
key: "action",
|
key: "action",
|
||||||
fixed: "right",
|
fixed: "right",
|
||||||
width: 100,
|
width: 160,
|
||||||
render: (_, record: any) => (
|
render: (_, record: any) => {
|
||||||
<Space size="small">
|
const items: MenuProps["items"] = [
|
||||||
<PerButton
|
{
|
||||||
type="link"
|
key: "1",
|
||||||
text="删除"
|
label: (
|
||||||
class="b-link c-red"
|
<PerButton
|
||||||
icon={null}
|
type="link"
|
||||||
p="resource-destroy"
|
text="编辑"
|
||||||
onClick={() => removeResource(record.id)}
|
class="b-link c-red"
|
||||||
disabled={null}
|
icon={null}
|
||||||
/>
|
p="resource-update"
|
||||||
</Space>
|
onClick={() => {
|
||||||
),
|
setUpdateId(record.id);
|
||||||
|
setUpdateVisible(true);
|
||||||
|
}}
|
||||||
|
disabled={null}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "2",
|
||||||
|
label: (
|
||||||
|
<PerButton
|
||||||
|
type="link"
|
||||||
|
text="删除"
|
||||||
|
class="b-link c-red"
|
||||||
|
icon={null}
|
||||||
|
p="resource-destroy"
|
||||||
|
onClick={() => removeResource(record.id)}
|
||||||
|
disabled={null}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Space size="small">
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
size="small"
|
||||||
|
className="b-n-link c-red"
|
||||||
|
onClick={() => {
|
||||||
|
setPlayeVisible(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
预览
|
||||||
|
</Button>
|
||||||
|
<div className="form-column"></div>
|
||||||
|
<Dropdown menu={{ items }}>
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
className="b-link c-red"
|
||||||
|
onClick={(e) => e.preventDefault()}
|
||||||
|
>
|
||||||
|
<Space size="small" align="center">
|
||||||
|
更多
|
||||||
|
<DownOutlined />
|
||||||
|
</Space>
|
||||||
|
</Button>
|
||||||
|
</Dropdown>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -119,7 +163,7 @@ const ResourceVideosPage = () => {
|
|||||||
confirm({
|
confirm({
|
||||||
title: "操作确认",
|
title: "操作确认",
|
||||||
icon: <ExclamationCircleFilled />,
|
icon: <ExclamationCircleFilled />,
|
||||||
content: "确认删除此视频?",
|
content: "删除前请检查选中视频文件无关联课程,确认删除?",
|
||||||
centered: true,
|
centered: true,
|
||||||
okText: "确认",
|
okText: "确认",
|
||||||
cancelText: "取消",
|
cancelText: "取消",
|
||||||
@ -135,6 +179,29 @@ const ResourceVideosPage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const removeResourceMulti = () => {
|
||||||
|
if (selectedRowKeys.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
confirm({
|
||||||
|
title: "操作确认",
|
||||||
|
icon: <ExclamationCircleFilled />,
|
||||||
|
content: "删除前请检查选中视频文件无关联课程,确认删除?",
|
||||||
|
centered: true,
|
||||||
|
okText: "确认",
|
||||||
|
cancelText: "取消",
|
||||||
|
onOk() {
|
||||||
|
resource.destroyResourceMulti(selectedRowKeys).then(() => {
|
||||||
|
message.success("删除成功");
|
||||||
|
resetVideoList();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onCancel() {
|
||||||
|
console.log("Cancel");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 获取视频列表
|
// 获取视频列表
|
||||||
const getVideoList = () => {
|
const getVideoList = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@ -152,11 +219,13 @@ const ResourceVideosPage = () => {
|
|||||||
console.log("错误,", err);
|
console.log("错误,", err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置列表
|
// 重置列表
|
||||||
const resetVideoList = () => {
|
const resetVideoList = () => {
|
||||||
setPage(1);
|
setPage(1);
|
||||||
setSize(10);
|
setSize(10);
|
||||||
setVideoList([]);
|
setVideoList([]);
|
||||||
|
setSelectedRowKeys([]);
|
||||||
setRefresh(!refresh);
|
setRefresh(!refresh);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -179,6 +248,12 @@ const ResourceVideosPage = () => {
|
|||||||
setSize(pageSize);
|
setSize(pageSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const rowSelection = {
|
||||||
|
onChange: (selectedRowKeys: React.Key[], selectedRows: DataType[]) => {
|
||||||
|
setSelectedRowKeys(selectedRowKeys);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="tree-main-body">
|
<div className="tree-main-body">
|
||||||
@ -202,22 +277,59 @@ const ResourceVideosPage = () => {
|
|||||||
<div className="d-flex playedu-main-title float-left mb-24">
|
<div className="d-flex playedu-main-title float-left mb-24">
|
||||||
视频 | {selLabel}
|
视频 | {selLabel}
|
||||||
</div>
|
</div>
|
||||||
<div className="float-left mb-24">
|
<div className="float-left j-b-flex mb-24">
|
||||||
<UploadVideoButton
|
<div>
|
||||||
categoryIds={category_ids}
|
<UploadVideoButton
|
||||||
onUpdate={() => {
|
categoryIds={category_ids}
|
||||||
resetVideoList();
|
onUpdate={() => {
|
||||||
}}
|
resetVideoList();
|
||||||
></UploadVideoButton>
|
}}
|
||||||
|
></UploadVideoButton>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex">
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
className="mr-16"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedRowKeys([]);
|
||||||
|
setMultiConfig(!multiConfig);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{multiConfig ? "取消操作" : "批量操作"}
|
||||||
|
</Button>
|
||||||
|
<PerButton
|
||||||
|
type="default"
|
||||||
|
text="删除"
|
||||||
|
class=""
|
||||||
|
icon={null}
|
||||||
|
p="resource-destroy"
|
||||||
|
onClick={() => removeResourceMulti()}
|
||||||
|
disabled={selectedRowKeys.length === 0}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="float-left">
|
<div className="float-left">
|
||||||
<Table
|
{multiConfig ? (
|
||||||
columns={columns}
|
<Table
|
||||||
dataSource={videoList}
|
rowSelection={{
|
||||||
loading={loading}
|
type: "checkbox",
|
||||||
pagination={paginationProps}
|
...rowSelection,
|
||||||
rowKey={(record) => record.id}
|
}}
|
||||||
/>
|
columns={columns}
|
||||||
|
dataSource={videoList}
|
||||||
|
loading={loading}
|
||||||
|
pagination={paginationProps}
|
||||||
|
rowKey={(record) => record.id}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Table
|
||||||
|
columns={columns}
|
||||||
|
dataSource={videoList}
|
||||||
|
loading={loading}
|
||||||
|
pagination={paginationProps}
|
||||||
|
rowKey={(record) => record.id}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user