|
|
|
@ -26,7 +26,7 @@ const uuid = uuidv4();
|
|
|
|
|
const handleAdd = async (fields: TableListItem) => {
|
|
|
|
|
const hide = message.loading('正在添加');
|
|
|
|
|
try {
|
|
|
|
|
await saveCourse({ ...fields, attachment_filesize:0, attachment_json: `{"img":"", "url": "down/M3u8/${uuid?.substr(0,2)}/${uuid}.m3u8"}` });
|
|
|
|
|
await saveCourse({ ...fields, attachment_filesize:0, });
|
|
|
|
|
hide();
|
|
|
|
|
message.success('添加成功');
|
|
|
|
|
return true;
|
|
|
|
@ -61,14 +61,14 @@ const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) =
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除课程
|
|
|
|
|
*
|
|
|
|
|
* 删除课程(接口不支持批量)
|
|
|
|
|
* 参数为记录数组
|
|
|
|
|
* @param selectedRows
|
|
|
|
|
*/
|
|
|
|
|
const handleRemove = async (selectedRows: TableListItem[]) => {
|
|
|
|
|
const hide = message.loading('正在删除');
|
|
|
|
|
if (!selectedRows) return true;
|
|
|
|
|
|
|
|
|
|
console.log('key', selectedRows);
|
|
|
|
|
try {
|
|
|
|
|
await removeCourse({
|
|
|
|
|
key: selectedRows.map((row) => row.key),
|
|
|
|
@ -77,6 +77,7 @@ const handleRemove = async (selectedRows: TableListItem[]) => {
|
|
|
|
|
message.success('删除成功,即将刷新');
|
|
|
|
|
return true;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('error', error)
|
|
|
|
|
hide();
|
|
|
|
|
message.error('删除失败,请重试');
|
|
|
|
|
return false;
|
|
|
|
@ -236,14 +237,15 @@ const CourseList: React.FC = () => {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '视频',
|
|
|
|
|
dataIndex: 'attachment_filesize',
|
|
|
|
|
dataIndex: 'attachment_json',
|
|
|
|
|
sorter: false,
|
|
|
|
|
hideInTable: true,
|
|
|
|
|
hideInForm: false,
|
|
|
|
|
hideInSearch: true,
|
|
|
|
|
renderFormItem: () => (
|
|
|
|
|
renderFormItem: (item, { defaultRender, ...rest }, form) => (
|
|
|
|
|
<Upload
|
|
|
|
|
action='/dsideal_yy/res/plupload/'
|
|
|
|
|
defaultFileList={item.initialValue?[item.initialValue]:[]}
|
|
|
|
|
beforeUpload={(file)=>{
|
|
|
|
|
console.log('file', file)
|
|
|
|
|
// 获取文件名
|
|
|
|
@ -329,7 +331,9 @@ const CourseList: React.FC = () => {
|
|
|
|
|
<a
|
|
|
|
|
key="remove"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
handleRemove(record);
|
|
|
|
|
handleRemove([{key: record?.course_id}]); // 调用批量删除函数(如果接口不支持批量需要在service中处理)
|
|
|
|
|
setSelectedRows([]);
|
|
|
|
|
actionRef.current?.reloadAndRest?.();
|
|
|
|
|
}}>
|
|
|
|
|
删除
|
|
|
|
|
</a>,
|
|
|
|
@ -479,7 +483,7 @@ const CourseList: React.FC = () => {
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
onReady={(play: any) => {
|
|
|
|
|
console.log('play====', play);
|
|
|
|
|
//console.log('play====', play);
|
|
|
|
|
playerRef.current = play
|
|
|
|
|
play.play();
|
|
|
|
|
play.on("timeupdate", function (event) {
|
|
|
|
@ -548,8 +552,14 @@ const CourseList: React.FC = () => {
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
// 表单处理
|
|
|
|
|
//console.log('columns:', columns);
|
|
|
|
|
//console.log('values:', values);
|
|
|
|
|
await handleAdd(values);
|
|
|
|
|
console.log('values:', values);
|
|
|
|
|
console.log('uploadFileName',uploadFileName)
|
|
|
|
|
//return false;
|
|
|
|
|
// values.attachment_json.response.file.response.url
|
|
|
|
|
await handleAdd({
|
|
|
|
|
...values,
|
|
|
|
|
attachment_json: `{"img":"", "name": "${values.attachment_json.file.name}", "url": "down/M3u8/${uuid?.substr(0,2)}/${uuid}.m3u8"}`
|
|
|
|
|
});
|
|
|
|
|
handleCreateModalVisible(false);
|
|
|
|
|
actionRef.current?.reloadAndRest?.();
|
|
|
|
|
}}
|
|
|
|
|