标签:conf can erro post cas success error new const
js:
// 规则库上传前检查格式 beforeUploadCheck = (file, fileList) => { return new Promise(function(resolve,reject){ Modal.confirm({ content: intl.get(‘Intl_upload_rule‘), onOk:()=>{ COOKIE.set(‘XSRF-TOKEN‘, DUMMY_TOKEN); let filename = file.name; filename = filename.split(‘.‘); const postfix = filename.pop(); const isExcel = postfix.toLocaleUpperCase() === ‘XLS‘ || postfix.toLocaleUpperCase() === ‘XLSX‘; // const isLt2M = file.size / 1024 / 1024 < 2; // if (!isLt2M) { // message.error(‘规则库大小不能超过2M!‘); // } if (!isExcel) { message.error(intl.get(‘Intl_upload_file_type_is_not_excel_error‘)); }else{ resolve(()=>{ return isExcel; }) } }, onCancel:()=>{ } }) }) } // 上传后得回调 handleUploadChange = (info) => { const { status, response } = info.file; if (status === ‘error‘) { notification.error({ message: response[getLanguageMessage()] || intl.get(‘Intl_fail_upload‘), }); } if (status === ‘done‘) { message.success(response[getLanguageMessage()] || intl.get(‘Intl_upload_success‘)); // 刷新列表 this.props.dispatch({ type: ‘sensitivityModel/getRuleList‘, payload: { language: getLanguage() } }) } }
jsx:
<Upload name="file" accept="aplication/zip" showUploadList={false} // IE10 以上有效 headers={{ ‘X-XSRF-TOKEN‘: DUMMY_TOKEN }} action={`${CONFIG.BASE_URL}/policy/rule-base/upload/${record.id}?language=${getLanguage()}`} beforeUpload={this.beforeUploadCheck} onChange={this.handleUploadChange} > <Button className="operateBtn unlock" icon="upload"> {intl.get("Intl_upload")} </Button> </Upload>
标签:conf can erro post cas success error new const
原文地址:https://www.cnblogs.com/ding-dong/p/14041446.html