import React from 'react'; import { Icon, message, Tooltip } from 'antd'; import { saveAs } from 'file-saver'; import styles from './detail.less'; import { checkoutFileType, handleName } from './utils/utils'; import Preview from './preview'; import { renderTxt } from '@/utils/hoverPopover'; import { CDN_HOST } from './config'; /* * listType = 'text' 以文本展示 * listType = 'picture' 以圖文展示 */ /* eslint-disable */ export default class uploadDetail extends React.Component { model: any; onPreview = (item: any) => { if (this.model && this.model.onPreview) { const url = `${item.domain ? 'https://' + item.domain : CDN_HOST}/${item.value}`; this.model.onPreview(url); } }; onDownLoad = (item: any) => { // debugger if (!item.value) { message('下载异常'); return; } const url = `${item.domain ? 'https://' + item.domain : CDN_HOST}/${item.value}`; // const typeArr = url.match(/\.[a-zA-Z]+$/); // const type = typeArr && typeArr[0] ? typeArr[0].replace('.', '') : ''; saveAs(url, item.name); // let a = document.createElement('a'); // a.href = url; // a.target = '_blank'; // a.download = item.name; // a.click(); // a = null; }; handleCancel = () => { this.setState({ showDialog: false }); }; checkoutDetailType = () => { const listType = this.props.listType; switch (listType) { case 'picture': // 单纯图片 return this.renderUpload(); case 'text': // 淡村文本 return this.rendertextUpload(); case 'picture-text': // 图文混排 return this.renderPictureText(); default: return this.renderUpload(); } }; renderPictureText = (item = this.props.data || []) => { if (!Array.isArray(item)) return item; return ( ); }; rendertextUpload = (item = this.props.data || []) => { if (!Array.isArray(item)) return item; return ( ); }; renderUpload = (item = this.props.data || []) => { if (!Array.isArray(item)) return item; return item.map((ls, index) => { return (
(this.img = img)} className={styles.fileStyle} src={ checkoutFileType(`${ls.domain ? 'https://' + ls.domain : CDN_HOST}/${ls.value}`) .thumbUrl } /> {ls.name}
); }); }; render() { const { stylePosition } = this.props; return ( <> (this.model = dom)} />
{this.checkoutDetailType()}
); } }