diff --git a/src/pages/FashionTrend/components/UpdateForm.tsx b/src/pages/FashionTrend/components/UpdateForm.tsx index 2ecc967..ad635f2 100644 --- a/src/pages/FashionTrend/components/UpdateForm.tsx +++ b/src/pages/FashionTrend/components/UpdateForm.tsx @@ -92,7 +92,7 @@ const UpdateForm: React.FC = (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 = (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 = (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 = (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 ? { + 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 ? = (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') { diff --git a/src/pages/InnovativeService/components/UpdateForm.tsx b/src/pages/InnovativeService/components/UpdateForm.tsx index 3e863d3..4705590 100644 --- a/src/pages/InnovativeService/components/UpdateForm.tsx +++ b/src/pages/InnovativeService/components/UpdateForm.tsx @@ -92,7 +92,7 @@ const UpdateForm: React.FC = (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 = (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 = (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 = (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 ? { + 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 ? = (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') {