dev-v2
Joe 5 months ago
parent 20f03721da
commit 391033b601

@ -92,7 +92,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
formRef={formRef}
onFinish={async (value: any) => {
let pbcPicAddress = ""
let pbcThumbNail = ""
let pbcThumbNail = "https://oss-xfc.popshejie.com/pop-b2b2c/pdf_fac16828-ea35-4034-9ad8-263605611960.png"
if (value.pbcType === 1 && value.pbcImage.length > 0) {
pbcThumbNail = value.pbcImage[0].url || value.pbcImage[0].response.data;
pbcPicAddress = value.pbcImage.map((e: any) => {
@ -103,7 +103,9 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
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";
if (value.pbcThumbNail.length > 0) {
pbcThumbNail = value.pbcThumbNail[0].url || value.pbcThumbNail[0].response.data;
}
}
return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcContent: value.pbcType === 3 ? '预览文件' : value.pbcContent, pbcId: props.values.pbcId })
}}
@ -133,6 +135,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
status: 'done',
url: props.values.pbcPicAddress,
}] : [],
pbcThumbNail: props.values.pbcType === 3 && props.values.pbcThumbNail ? [{
uid: '-1',
name: props.values.pbcThumbNail.substring(props.values.pbcThumbNail.lastIndexOf('/') + 1),
status: 'done',
url: props.values.pbcThumbNail,
}] : [],
pbcContent: props.values.pbcContent
}}
onOpenChange={(visible) => {
@ -181,11 +189,57 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
onChange: (e) => {
setPbcType(e.target.value)
formRef.current?.setFieldValue('pbcImage', []);
formRef.current?.setFieldValue('pbcThumbNail', []);
formRef.current?.setFieldValue('pbcVideo', []);
formRef.current?.setFieldValue('pbcFile', []);
},
}}
/>
{pbcType === 3 ? <ProFormUploadButton
label="缩略图"
name="pbcThumbNail"
max={1}
fieldProps={{
name: 'file',
accept: 'image/*',
multiple: true,
headers: {
authorization: localStorage.getItem('token') ?? '',
},
onChange: (info: any) => {
switch (info.file.status) {
case 'done':
if (info.file.response.retcode === 0) {
message.error(info.file.response.retmsg);
formRef.current?.setFieldValue('pbcThumbNail', [])
}
break;
default:
break;
}
},
action: process.env.BASE_URL + '/oss/imgUpload',
beforeUpload(file: RcFile) {
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
message.error('图片大小不能超过10MB!');
}
return isLt10M || Upload.LIST_IGNORE;
},
onPreview: async (file) => {
if (file.uid.includes('-')) {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
}
},
listType: 'picture-card',
}}
rules={[
{ required: true, message: '请上传缩略图' },
]}
/> : null}
{pbcType === 1 ? <ProFormUploadButton
label="上传图片"
name="pbcImage"
@ -264,11 +318,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
},
action: process.env.BASE_URL + '/oss/imgUpload',
beforeUpload(file: RcFile) {
const isLt30M = file.size / 1024 / 1024 < 30;
if (!isLt30M) {
message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过30MB!`);
const isLt300M = file.size / 1024 / 1024 < 300;
if (!isLt300M) {
message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过300MB!`);
}
return isLt30M || Upload.LIST_IGNORE;
return isLt300M || Upload.LIST_IGNORE;
},
onPreview: async (file) => {
if (file.uid === '-1') {

@ -92,7 +92,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
formRef={formRef}
onFinish={async (value: any) => {
let pbcPicAddress = ""
let pbcThumbNail = ""
let pbcThumbNail = "https://oss-xfc.popshejie.com/pop-b2b2c/pdf_fac16828-ea35-4034-9ad8-263605611960.png";
if (value.pbcType === 1 && value.pbcImage.length > 0) {
pbcThumbNail = value.pbcImage[0].url || value.pbcImage[0].response.data;
pbcPicAddress = value.pbcImage.map((e: any) => {
@ -103,7 +103,9 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
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";
if (value.pbcThumbNail.length > 0) {
pbcThumbNail = value.pbcThumbNail[0].url || value.pbcThumbNail[0].response.data;
}
}
return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcContent: value.pbcType === 3 ? '预览文件' : value.pbcContent, pbcId: props.values.pbcId })
}}
@ -133,6 +135,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
status: 'done',
url: props.values.pbcPicAddress,
}] : [],
pbcThumbNail: props.values.pbcType === 3 && props.values.pbcThumbNail ? [{
uid: '-1',
name: props.values.pbcThumbNail.substring(props.values.pbcThumbNail.lastIndexOf('/') + 1),
status: 'done',
url: props.values.pbcThumbNail,
}] : [],
pbcContent: props.values.pbcContent
}}
onOpenChange={(visible) => {
@ -181,11 +189,57 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
onChange: (e) => {
setPbcType(e.target.value)
formRef.current?.setFieldValue('pbcImage', []);
formRef.current?.setFieldValue('pbcThumbNail', [])
formRef.current?.setFieldValue('pbcVideo', []);
formRef.current?.setFieldValue('pbcFile', []);
},
}}
/>
{pbcType === 3 ? <ProFormUploadButton
label="缩略图"
name="pbcThumbNail"
max={1}
fieldProps={{
name: 'file',
accept: 'image/*',
multiple: true,
headers: {
authorization: localStorage.getItem('token') ?? '',
},
onChange: (info: any) => {
switch (info.file.status) {
case 'done':
if (info.file.response.retcode === 0) {
message.error(info.file.response.retmsg);
formRef.current?.setFieldValue('pbcThumbNail', [])
}
break;
default:
break;
}
},
action: process.env.BASE_URL + '/oss/imgUpload',
beforeUpload(file: RcFile) {
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
message.error('图片大小不能超过10MB!');
}
return isLt10M || Upload.LIST_IGNORE;
},
onPreview: async (file) => {
if (file.uid.includes('-')) {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
}
},
listType: 'picture-card',
}}
rules={[
{ required: true, message: '请上传缩略图' },
]}
/> : null}
{pbcType === 1 ? <ProFormUploadButton
label="上传图片"
name="pbcImage"
@ -265,11 +319,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
},
action: process.env.BASE_URL + '/oss/imgUpload',
beforeUpload(file: RcFile) {
const isLt30M = file.size / 1024 / 1024 < 30;
if (!isLt30M) {
message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过30MB!`);
const isLt300M = file.size / 1024 / 1024 < 300;
if (!isLt300M) {
message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过300MB!`);
}
return isLt30M || Upload.LIST_IGNORE;
return isLt300M || Upload.LIST_IGNORE;
},
onPreview: async (file) => {
if (file.uid === '-1') {

Loading…
Cancel
Save