|
|
|
@ -101,8 +101,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
} else if (value.pbcType === 2 && value.pbcVideo.length > 0) {
|
|
|
|
|
pbcPicAddress = value.pbcVideo[0].url || value.pbcVideo[0].response.data;
|
|
|
|
|
pbcThumbNail = videoThumbnail;
|
|
|
|
|
} else if (value.pbcType === 3 && value.pbcFile.length > 0) {
|
|
|
|
|
pbcPicAddress = value.pbcFile[0].url || value.pbcFile[0].response.data;
|
|
|
|
|
pbcThumbNail = "https://oss-xfc.popshejie.com/pop-b2b2c/pdf_fac16828-ea35-4034-9ad8-263605611960.png";
|
|
|
|
|
}
|
|
|
|
|
return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcId: props.values.pbcId })
|
|
|
|
|
return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcContent: value.pbcType === 3 ? '预览文件' : value.pbcContent, pbcId: props.values.pbcId })
|
|
|
|
|
}}
|
|
|
|
|
drawerProps={{
|
|
|
|
|
destroyOnClose: true,
|
|
|
|
@ -124,6 +127,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
status: 'done',
|
|
|
|
|
url: props.values.pbcPicAddress,
|
|
|
|
|
}] : [],
|
|
|
|
|
pbcFile: props.values.pbcType === 3 && props.values.pbcPicAddress ? [{
|
|
|
|
|
uid: '-1',
|
|
|
|
|
name: props.values.pbcPicAddress.substring(props.values.pbcPicAddress.lastIndexOf('/') + 1),
|
|
|
|
|
status: 'done',
|
|
|
|
|
url: props.values.pbcPicAddress,
|
|
|
|
|
}] : [],
|
|
|
|
|
pbcContent: props.values.pbcContent
|
|
|
|
|
}}
|
|
|
|
|
onOpenChange={(visible) => {
|
|
|
|
@ -157,6 +166,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
label: '视频',
|
|
|
|
|
value: 2,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '文件',
|
|
|
|
|
value: 3,
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
rules={[
|
|
|
|
|
{
|
|
|
|
@ -169,6 +182,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
setPbcType(e.target.value)
|
|
|
|
|
formRef.current?.setFieldValue('pbcImage', []);
|
|
|
|
|
formRef.current?.setFieldValue('pbcVideo', []);
|
|
|
|
|
formRef.current?.setFieldValue('pbcFile', []);
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
@ -218,12 +232,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
]}
|
|
|
|
|
/> :
|
|
|
|
|
<ProFormUploadButton
|
|
|
|
|
label="上传视频"
|
|
|
|
|
name="pbcVideo"
|
|
|
|
|
label={pbcType === 2 ? "上传视频" : "上传文件"}
|
|
|
|
|
name={pbcType === 2 ? "pbcVideo" : "pbcFile"}
|
|
|
|
|
max={1}
|
|
|
|
|
fieldProps={{
|
|
|
|
|
name: 'file',
|
|
|
|
|
accept: 'video/mp4',
|
|
|
|
|
accept: pbcType === 2 ? 'video/mp4' : '.pdf',
|
|
|
|
|
multiple: true,
|
|
|
|
|
headers: {
|
|
|
|
|
authorization: localStorage.getItem('token') ?? '',
|
|
|
|
@ -233,8 +247,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
case 'done':
|
|
|
|
|
if (info.file.response.retcode === 0) {
|
|
|
|
|
message.error(info.file.response.retmsg);
|
|
|
|
|
formRef.current?.setFieldValue('pbcVideo', [])
|
|
|
|
|
} else if (info.file.response && info.file.response.retcode) {
|
|
|
|
|
if (pbcType === 2) {
|
|
|
|
|
formRef.current?.setFieldValue('pbcVideo', [])
|
|
|
|
|
} else {
|
|
|
|
|
formRef.current?.setFieldValue('pbcFile', [])
|
|
|
|
|
}
|
|
|
|
|
} else if (info.file.response && info.file.response.retcode && pbcType === 2) {
|
|
|
|
|
// 视频上传成功后,获取视频首帧作为缩略图
|
|
|
|
|
const videoUrl = info.file.response.data;
|
|
|
|
|
generateVideoThumbnail(videoUrl);
|
|
|
|
@ -248,7 +266,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
beforeUpload(file: RcFile) {
|
|
|
|
|
const isLt30M = file.size / 1024 / 1024 < 30;
|
|
|
|
|
if (!isLt30M) {
|
|
|
|
|
message.error('视频大小不能超过30MB!');
|
|
|
|
|
message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过30MB!`);
|
|
|
|
|
}
|
|
|
|
|
return isLt30M || Upload.LIST_IGNORE;
|
|
|
|
|
},
|
|
|
|
@ -263,10 +281,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
listType: 'picture-card',
|
|
|
|
|
}}
|
|
|
|
|
rules={[
|
|
|
|
|
{ required: true, message: '请上传视频' },
|
|
|
|
|
{ required: true, message: `请上传${pbcType === 2 ? '视频' : '文件'}'` },
|
|
|
|
|
]}
|
|
|
|
|
/>}
|
|
|
|
|
<ProForm.Item
|
|
|
|
|
{pbcType !== 3 ? <ProForm.Item
|
|
|
|
|
name="pbcContent"
|
|
|
|
|
label="趋势内容"
|
|
|
|
|
rules={[
|
|
|
|
@ -277,7 +295,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Editor />
|
|
|
|
|
</ProForm.Item>
|
|
|
|
|
</ProForm.Item>:null}
|
|
|
|
|
</DrawerForm>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|