This commit is contained in:
何美荣 2026-03-26 11:16:19 +08:00
commit 2a18728085
2 changed files with 11 additions and 12 deletions

View File

@ -803,7 +803,7 @@ params【字段属性】=值
if (tempVal.length < minLen) { if (tempVal.length < minLen) {
errors.push(errVerifyMsg || `至少输入${minLen}个字符`) errors.push(errVerifyMsg || `至少输入${minLen}个字符`)
} else if (tempVal.length > maxLen && maxLen !== 0) { } else if (tempVal.length > maxLen && maxLen !== 0) {
errors.push(errVerifyMsg || `最多允许${maxLen}个字符`) errors.push(errVerifyMsg || `最多允许${maxLen}个字符,现已输入${tempVal.length}个字符`)
} }
break; break;
case 7: case 7:

View File

@ -48,18 +48,15 @@ export default {
// if (params.record.Nav_Files && params.record.Nav_Files.length > 0) { // if (params.record.Nav_Files && params.record.Nav_Files.length > 0) {
// params.record['Files'] = params.record.Nav_Files // params.record['Files'] = params.record.Nav_Files
// } // }
// 2. 上传前校验函数(核心) // 2. 上传前校验函数(核心)
const beforeUpload = (file) => { // 1. 定义文件大小限制示例限制最大2MB const beforeUpload = (file) => { // 1. 定义文件大小限制示例限制最大2MB
const MAX_FILE_SIZE = 30 * 1024 * 1024; // 2MB = 2*1024*1024 Byte const MAX_FILE_SIZE = 500 * 1024 * 1024; // 2MB = 2*1024*1024 Byte
// 校验文件大小 // 校验文件大小
if (file.size > MAX_FILE_SIZE) { if (file.size > MAX_FILE_SIZE) {
message.error(`文件大小不能超过 30MB当前文件大小${(file.size / 1024 / 1024).toFixed(2)}MB`); message.error(`文件大小不能超过 500MB当前文件大小${(file.size / 1024 / 1024).toFixed(2)}MB`);
return false; // 返回false阻止上传 return false; // 返回false阻止上传
// 也可使用Promise方式return Promise.reject(new Error('文件大小超过限制')); // 也可使用Promise方式return Promise.reject(new Error('文件大小超过限制'));
} }
// 校验通过,允许上传 // 校验通过,允许上传
return true; return true;
}; };
@ -129,11 +126,13 @@ export default {
} }
if (info.file.status != 'done') { if (info.file.status != 'done') {
//上传成功回调不处理数据赋值 //上传成功回调不处理数据赋值
if (info.file.size < 500 * 1024 * 1024) {
const temps2 = []; const temps2 = [];
temps2.push({ field: 'Nav_Files', value: params.record['Files'] }) temps2.push({ field: 'Nav_Files', value: params.record['Files'] })
temps2.push({ field: 'NAME', value: info.file.name }) temps2.push({ field: 'NAME', value: info.file.name })
params.setFieldValueByBatch(temps2); params.setFieldValueByBatch(temps2);
} }
}
}, },
}; };
return <> return <>
@ -141,7 +140,7 @@ export default {
<div> <div>
<div className="ant-col ant-col-24 ant-form-item-label"> <div className="ant-col ant-col-24 ant-form-item-label">
<label> <label>
<span>上传本地视频</span> <span>上传本地视频限500M</span>
</label> </label>
</div> </div>
<div className="ant-col ant-col-18 ant-form-item-control-wrapper"> <div className="ant-col ant-col-18 ant-form-item-control-wrapper">
@ -149,7 +148,7 @@ export default {
{isShowFile && <Input type="file" style={{ height: '39px' }} key="keyI1" disabled={true} />} {isShowFile && <Input type="file" style={{ height: '39px' }} key="keyI1" disabled={true} />}
{isShowFile && <a key="keyA21" href={config.picServerHost + params.record.FILE_PATH} target="_blank">{params.record.NAME}</a>} {isShowFile && <a key="keyA21" href={config.picServerHost + params.record.FILE_PATH} target="_blank">{params.record.NAME}</a>}
{isEditFile && <Upload {...uploadSopProps}> {isEditFile && <Upload {...uploadSopProps}>
<Button disabled={(params.record.NAME == null || params.record.NAME.length == 0) ? false : true}> <Button disabled={(params.record.Nav_Files == null || params.record.Nav_Files.length == 0) ? false : true}>
<Icon type="upload" />上传视频如果视频较大请耐心等待上传完毕再保存 <Icon type="upload" />上传视频如果视频较大请耐心等待上传完毕再保存
</Button> </Button>
</Upload>} </Upload>}