Commit f8795e4f authored by zhangwenshuai's avatar zhangwenshuai

update

parent a44d57d5
...@@ -73,6 +73,7 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -73,6 +73,7 @@ export default class TableColumn extends PureComponent<ColumnProps> {
showIndex, showIndex,
columnIndex, columnIndex,
questionText, questionText,
remark,
rowSelection, rowSelection,
icon, icon,
required, required,
...@@ -90,6 +91,7 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -90,6 +91,7 @@ export default class TableColumn extends PureComponent<ColumnProps> {
marginLeft = `${leftMargin + 70}px`; marginLeft = `${leftMargin + 70}px`;
} }
} }
const tip = remark || questionText;
return ( return (
<div className={s.colContainer}> <div className={s.colContainer}>
{rowSelection && columnIndex === 0 && <div className={s.checkbox}>{this.getCheckbox()}</div>} {rowSelection && columnIndex === 0 && <div className={s.checkbox}>{this.getCheckbox()}</div>}
...@@ -97,8 +99,8 @@ export default class TableColumn extends PureComponent<ColumnProps> { ...@@ -97,8 +99,8 @@ export default class TableColumn extends PureComponent<ColumnProps> {
{icon && <div className={s.colIcon}>{icon()}</div>} {icon && <div className={s.colIcon}>{icon()}</div>}
<span className={required ? classNames(s.colTitle, s.required) : s.colTitle}> <span className={required ? classNames(s.colTitle, s.required) : s.colTitle}>
{columnChsName} {columnChsName}
{questionText && ( {tip && (
<Tooltip title={questionText}> <Tooltip title={tip}>
<div className={s.tipContainer}>?</div> <div className={s.tipContainer}>?</div>
</Tooltip> </Tooltip>
)} )}
......
...@@ -10,11 +10,17 @@ message.config({ ...@@ -10,11 +10,17 @@ message.config({
maxCount: 1, maxCount: 1,
}); });
const UploadCom = (props) => { const UploadCom = (props: any) => {
const { const { onChange, CDN_HOST, getFormat, setFormat, data, maxLength, disabled, fileSize = 5 } = props;
onChange, CDN_HOST, getFormat, setFormat, data, maxLength, disabled, const selfProps = antiAssign(props, [
} = props; 'onChange',
const selfProps = antiAssign(props, ['onChange', 'CDN_HOST', 'data']); 'CDN_HOST',
'data',
'fileSize',
'maxLength',
'getFormat',
'setFormat',
]);
const getFormatFileList = (fileList = []) => { const getFormatFileList = (fileList = []) => {
if (!fileList) { if (!fileList) {
return []; return [];
...@@ -37,7 +43,7 @@ const UploadCom = (props) => { ...@@ -37,7 +43,7 @@ const UploadCom = (props) => {
}; };
}); });
}; };
const setFormatFile = (file) => { const setFormatFile = (file: any) => {
if (!file) { if (!file) {
return {}; return {};
} }
...@@ -68,7 +74,7 @@ const UploadCom = (props) => { ...@@ -68,7 +74,7 @@ const UploadCom = (props) => {
const time = moment().format('YYYYMMDDHHmmss'); const time = moment().format('YYYYMMDDHHmmss');
return time + rand6 + suffix; return time + rand6 + suffix;
}; };
const [extraData, setExtraData] = useState({}); const [extraData, setExtraData] = useState<any>({});
// 七牛上传额外数据,token和key // 七牛上传额外数据,token和key
const getToken = async () => { const getToken = async () => {
let extData = data || {}; let extData = data || {};
...@@ -93,22 +99,22 @@ const UploadCom = (props) => { ...@@ -93,22 +99,22 @@ const UploadCom = (props) => {
} }
}; };
const changeFileList = ({ file, fileList }) => { const changeFileList = ({ file, fileList }: any) => {
let newList = fileList; let newList = fileList;
if (maxLength) { if (maxLength) {
newList = fileList.slice(-maxLength); newList = fileList.slice(-maxLength);
} }
if (file.status === 'done' && file.response) { if (file.status === 'done' && file.response) {
const itemObj = setFormatFile(file); const itemObj = setFormatFile(file);
newList = fileList.map((item) => { newList = fileList.map((item: any) => {
return item.uid === itemObj.uid ? itemObj : item; return item.uid === itemObj.uid ? itemObj : item;
}); });
onSaveFileList(newList); onSaveFileList(newList);
} }
setFileList(newList); setFileList(newList);
}; };
const previewFile = (file) => { const previewFile = (file: any) => {
return new Promise((res, rej) => { return new Promise((res) => {
const obj = checkoutFileType(file.name); const obj = checkoutFileType(file.name);
const typeArr = file.name.match(/\.[a-zA-Z0-9]+$/); const typeArr = file.name.match(/\.[a-zA-Z0-9]+$/);
const type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : ''; const type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : '';
...@@ -117,23 +123,27 @@ const UploadCom = (props) => { ...@@ -117,23 +123,27 @@ const UploadCom = (props) => {
} }
}); });
}; };
const onPreview = (file) => { const onPreview = (file: any) => {
if (previewModel.current && previewModel.current.onPreview) { if (previewModel.current && previewModel.current.onPreview) {
previewModel.current.onPreview(file.value, file.name); previewModel.current.onPreview(file.value, file.name);
} }
}; };
const onRemove = (file) => { const onRemove = (file: any) => {
const newFileList = fileList.filter((item) => { const newFileList = fileList.filter((item: any) => {
return item.uid !== file.uid; return item.uid !== file.uid;
}); });
onSaveFileList(newFileList); onSaveFileList(newFileList);
}; };
const onDownload = (file) => { const onDownload = (file: any) => {
window.open(file.value); 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(); await getToken();
return true; return true;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment