|
@@ -14,9 +14,9 @@ import {
|
|
|
import { CheckCircleFilled, CaretRightFilled } from '@ant-design/icons';
|
|
|
import { VideoItem, VideoListResponse } from '../types';
|
|
|
import http from '@src/http';
|
|
|
-import { getVideoContentListApi } from '@src/http/api';
|
|
|
+import { getVideoContentListApi, getUploadVideoContentListApi } from '@src/http/api';
|
|
|
import { useVideoCategoryOptions } from '../../hooks/useVideoCategoryOptions';
|
|
|
-import { VideoSortType } from '@src/views/publishContent/weCom/components/videoSelectModal';
|
|
|
+import { VideoSortType, VideoLibraryType } from '@src/views/publishContent/weCom/components/videoSelectModal';
|
|
|
import { GzhPlanType } from '../../hooks/useGzhPlanList';
|
|
|
import { VideoSearchPlanType } from '@src/views/publishContent/weCom/type';
|
|
|
import { enumToOptions } from '@src/utils/helper';
|
|
@@ -45,6 +45,7 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
const [videoListAll, setVideoListAll] = useState<VideoItem[]>([]);
|
|
|
const [selectedVideoIds, setSelectedVideoIds] = useState<Set<number>>(new Set(initialSelectedIds));
|
|
|
const [playingVideo, setPlayingVideo] = useState<VideoItem | null>(null);
|
|
|
+ const [videoLibraryType, setVideoLibraryType] = useState<VideoLibraryType>(VideoLibraryType.平台视频库);
|
|
|
const MAX_SELECTION = 3;
|
|
|
|
|
|
const getVideoListType = (planType: GzhPlanType) => {
|
|
@@ -61,14 +62,19 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
setLoading(true);
|
|
|
setCurrentPage(pageNum || currentPage);
|
|
|
setPageSize(_pageSize || pageSize);
|
|
|
- const res = await http.post<VideoListResponse>(getVideoContentListApi, {
|
|
|
+ // 根据视频库类型选择不同的API
|
|
|
+ const apiUrl = videoLibraryType === VideoLibraryType.平台视频库 ? getVideoContentListApi : getUploadVideoContentListApi;
|
|
|
+
|
|
|
+ const requestParams = {
|
|
|
category,
|
|
|
title: searchTerm,
|
|
|
sort,
|
|
|
type: getVideoListType(planType),
|
|
|
pageNum: pageNum || currentPage,
|
|
|
pageSize: _pageSize || pageSize,
|
|
|
- }).catch(() => {
|
|
|
+ };
|
|
|
+
|
|
|
+ const res = await http.post<VideoListResponse>(apiUrl, requestParams).catch(() => {
|
|
|
message.error('获取视频列表失败');
|
|
|
}).finally(() => {
|
|
|
setLoading(false);
|
|
@@ -80,6 +86,13 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 监听视频库类型变化,重新加载数据
|
|
|
+ useEffect(() => {
|
|
|
+ if (visible) {
|
|
|
+ getVideoList();
|
|
|
+ }
|
|
|
+ }, [videoLibraryType, visible]);
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
if (visible) {
|
|
|
setVideoList(selectedVideos);
|
|
@@ -134,10 +147,10 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
return (
|
|
|
<>
|
|
|
<Drawer
|
|
|
- title="内容选取"
|
|
|
+ title="选择视频"
|
|
|
open={visible}
|
|
|
onClose={onClose}
|
|
|
- width={800}
|
|
|
+ width={900}
|
|
|
placement="right"
|
|
|
loading={loading}
|
|
|
styles={{ footer: { textAlign: 'right', padding: '10px 24px' } }}
|
|
@@ -165,21 +178,30 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
</div>
|
|
|
}
|
|
|
>
|
|
|
- <div className="flex flex-wrap gap-4 mb-6">
|
|
|
- <div className="flex items-center gap-2">
|
|
|
- <span className="text-gray-600">排序选项:</span>
|
|
|
- <Select
|
|
|
- style={{ width: 120 }}
|
|
|
- value={sort}
|
|
|
- onChange={setSort}
|
|
|
- options={enumToOptions(VideoSortType)}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <div className="flex flex-wrap gap-2 mb-6">
|
|
|
+ <div className="flex items-center gap-2">
|
|
|
+ <span className="text-gray-600">视频来源:</span>
|
|
|
+ <Select
|
|
|
+ style={{ width: 120 }}
|
|
|
+ value={videoLibraryType}
|
|
|
+ onChange={setVideoLibraryType}
|
|
|
+ options={enumToOptions(VideoLibraryType)}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div className="flex items-center gap-2">
|
|
|
+ <span className="text-gray-600">排序选项:</span>
|
|
|
+ <Select
|
|
|
+ style={{ width: 120 }}
|
|
|
+ value={sort}
|
|
|
+ onChange={setSort}
|
|
|
+ options={enumToOptions(VideoSortType)}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
<div className="flex items-center gap-2">
|
|
|
<span className="text-gray-600">品类:</span>
|
|
|
<Select
|
|
|
placeholder="选择品类"
|
|
|
- style={{ width: 160 }}
|
|
|
+ style={{ width: 120 }}
|
|
|
value={category}
|
|
|
allowClear
|
|
|
onChange={setCategory}
|
|
@@ -190,7 +212,7 @@ const VideoSelectModal: React.FC<VideoSelectModalProps> = ({ planType, visible,
|
|
|
<span className="text-gray-600">视频标题:</span>
|
|
|
<Input
|
|
|
placeholder="搜索视频标题"
|
|
|
- style={{ width: 180 }}
|
|
|
+ style={{ width: 120 }}
|
|
|
value={searchTerm}
|
|
|
onPressEnter={handleSearch}
|
|
|
allowClear
|