From f8795e4fb6811b9af19985f3dfa5d61119fb9a69 Mon Sep 17 00:00:00 2001 From: zhangwenshuai Date: Thu, 10 Sep 2020 19:37:28 +0800 Subject: [PATCH] update --- components/apolloTable/component/Column.tsx | 6 ++- .../component/base/extra/upload/index.tsx | 42 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/components/apolloTable/component/Column.tsx b/components/apolloTable/component/Column.tsx index 2f9dd88..0e1b463 100644 --- a/components/apolloTable/component/Column.tsx +++ b/components/apolloTable/component/Column.tsx @@ -73,6 +73,7 @@ export default class TableColumn extends PureComponent { showIndex, columnIndex, questionText, + remark, rowSelection, icon, required, @@ -90,6 +91,7 @@ export default class TableColumn extends PureComponent { marginLeft = `${leftMargin + 70}px`; } } + const tip = remark || questionText; return (
{rowSelection && columnIndex === 0 &&
{this.getCheckbox()}
} @@ -97,8 +99,8 @@ export default class TableColumn extends PureComponent { {icon &&
{icon()}
} {columnChsName} - {questionText && ( - + {tip && ( +
?
)} diff --git a/components/apolloTable/component/base/extra/upload/index.tsx b/components/apolloTable/component/base/extra/upload/index.tsx index 5877b4e..28a0da8 100644 --- a/components/apolloTable/component/base/extra/upload/index.tsx +++ b/components/apolloTable/component/base/extra/upload/index.tsx @@ -10,11 +10,17 @@ message.config({ maxCount: 1, }); -const UploadCom = (props) => { - const { - onChange, CDN_HOST, getFormat, setFormat, data, maxLength, disabled, - } = props; - const selfProps = antiAssign(props, ['onChange', 'CDN_HOST', 'data']); +const UploadCom = (props: any) => { + const { onChange, CDN_HOST, getFormat, setFormat, data, maxLength, disabled, fileSize = 5 } = props; + const selfProps = antiAssign(props, [ + 'onChange', + 'CDN_HOST', + 'data', + 'fileSize', + 'maxLength', + 'getFormat', + 'setFormat', + ]); const getFormatFileList = (fileList = []) => { if (!fileList) { return []; @@ -37,7 +43,7 @@ const UploadCom = (props) => { }; }); }; - const setFormatFile = (file) => { + const setFormatFile = (file: any) => { if (!file) { return {}; } @@ -68,7 +74,7 @@ const UploadCom = (props) => { const time = moment().format('YYYYMMDDHHmmss'); return time + rand6 + suffix; }; - const [extraData, setExtraData] = useState({}); + const [extraData, setExtraData] = useState({}); // 七牛上传额外数据,token和key const getToken = async () => { let extData = data || {}; @@ -93,22 +99,22 @@ const UploadCom = (props) => { } }; - const changeFileList = ({ file, fileList }) => { + const changeFileList = ({ file, fileList }: any) => { let newList = fileList; if (maxLength) { newList = fileList.slice(-maxLength); } if (file.status === 'done' && file.response) { const itemObj = setFormatFile(file); - newList = fileList.map((item) => { + newList = fileList.map((item: any) => { return item.uid === itemObj.uid ? itemObj : item; }); onSaveFileList(newList); } setFileList(newList); }; - const previewFile = (file) => { - return new Promise((res, rej) => { + const previewFile = (file: any) => { + return new Promise((res) => { const obj = checkoutFileType(file.name); const typeArr = file.name.match(/\.[a-zA-Z0-9]+$/); const type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : ''; @@ -117,23 +123,27 @@ const UploadCom = (props) => { } }); }; - const onPreview = (file) => { + const onPreview = (file: any) => { if (previewModel.current && previewModel.current.onPreview) { previewModel.current.onPreview(file.value, file.name); } }; - const onRemove = (file) => { - const newFileList = fileList.filter((item) => { + const onRemove = (file: any) => { + const newFileList = fileList.filter((item: any) => { return item.uid !== file.uid; }); onSaveFileList(newFileList); }; - const onDownload = (file) => { + const onDownload = (file: any) => { window.open(file.value); }; - const beforeUpload = async () => { + const beforeUpload = async (file: any) => { + if (fileSize && file.size / 1000 > fileSize) { + message.error('文件太大了,请按要求重新上传'); + return Promise.reject(); + } await getToken(); return true; }; -- 2.21.0