| | |
| | | const Video = asyncComponent(() => import('./video')) |
| | | const Image = asyncComponent(() => import('@/components/Image')) |
| | | |
| | | class PasteController extends Component { |
| | | class SourceController extends Component { |
| | | state = { |
| | | visible: false, |
| | | editvisible: false, |
| | |
| | | } |
| | | |
| | | trigger = () => { |
| | | let pictures = sessionStorage.getItem('app_pictures') |
| | | let videos = sessionStorage.getItem('app_videos') |
| | | let colorlist = sessionStorage.getItem('app_colors') |
| | | let deffers = [] |
| | | |
| | | if (!pictures) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未获取到资源信息,请稍后或刷新重试。', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | deffers.push(this.getSource('image', 'app_pictures', 0)) |
| | | deffers.push(this.getSource('video', 'app_videos', 50)) |
| | | deffers.push(this.getSource('color', 'app_colors', 100)) |
| | | |
| | | Promise.all(deffers).then(result => { |
| | | this.open(...result) |
| | | }) |
| | | } |
| | | |
| | | try { |
| | | pictures = JSON.parse(pictures) |
| | | videos = JSON.parse(videos) |
| | | colorlist = JSON.parse(colorlist) |
| | | } catch (e) { |
| | | pictures = [] |
| | | videos = [] |
| | | colorlist = [] |
| | | } |
| | | getSource = (type, sessionName, delay) => { |
| | | return new Promise(resolve => { |
| | | if (window.GLOB[sessionName]) { |
| | | resolve(window.GLOB[sessionName]) |
| | | } else { |
| | | let param = { |
| | | func: 's_url_db_adduptdel', |
| | | PageIndex: 0, // 0 代表全部 |
| | | PageSize: 0, // 0 代表全部 |
| | | type: 'search', |
| | | typecharone: type |
| | | } |
| | | setTimeout(() => { |
| | | Api.getCloudConfig(param).then(res => { |
| | | let data = res.data || [] |
| | | window.GLOB[sessionName] = data |
| | | |
| | | resolve(data) |
| | | }) |
| | | }, delay) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | open = (pictures, videos, colorlist) => { |
| | | let filpictures = pictures |
| | | let filvideos = videos |
| | | |
| | |
| | | }).then(result => { |
| | | if (result.status) { |
| | | if (card.typecharone === 'image') { |
| | | sessionStorage.setItem('app_pictures', JSON.stringify(result.data || [])) |
| | | window.GLOB.app_pictures = result.data || [] |
| | | this.resetPicture(result.data || []) |
| | | } else if (card.typecharone === 'video') { |
| | | sessionStorage.setItem('app_videos', JSON.stringify(result.data || [])) |
| | | window.GLOB.app_videos = result.data || [] |
| | | this.resetVideo(result.data || []) |
| | | } else if (card.typecharone === 'color') { |
| | | window.GLOB.app_colors = result.data || [] |
| | | sessionStorage.setItem('app_colors', JSON.stringify(result.data || [])) |
| | | this.resetColor(result.data || []) |
| | | } |
| | |
| | | } |
| | | |
| | | deleteSource = (item) => { |
| | | const _this = this |
| | | const that = this |
| | | |
| | | confirm({ |
| | | title: '确定删除吗?', |
| | |
| | | }).then(res => { |
| | | if (res.status) { |
| | | if (item.typecharone === 'image') { |
| | | sessionStorage.setItem('app_pictures', JSON.stringify(res.data || [])) |
| | | _this.resetPicture(res.data || []) |
| | | window.GLOB.app_pictures = res.data || [] |
| | | that.resetPicture(res.data || []) |
| | | } else if (item.typecharone === 'video') { |
| | | sessionStorage.setItem('app_videos', JSON.stringify(res.data || [])) |
| | | _this.resetVideo(res.data || []) |
| | | window.GLOB.app_videos = res.data || [] |
| | | that.resetVideo(res.data || []) |
| | | } else if (item.typecharone === 'color') { |
| | | window.GLOB.app_colors = res.data || [] |
| | | sessionStorage.setItem('app_colors', JSON.stringify(res.data || [])) |
| | | _this.resetColor(res.data || []) |
| | | that.resetColor(res.data || []) |
| | | } |
| | | } else { |
| | | notification.warning({ |
| | |
| | | const { visible, editvisible, card, filpictures, filvideos, piclist, vidlist, imageKey, videoKey, pageSize, picIndex, vidIndex, colorlist, iconlist } = this.state |
| | | |
| | | return ( |
| | | <div style={{display: 'inline-block'}}> |
| | | <> |
| | | <Button className="mk-border-purple" onClick={this.trigger}><PictureOutlined /> 资源管理</Button> |
| | | <Modal |
| | | wrapClassName="mk-pop-modal picture-control-model" |
| | |
| | | > |
| | | <EditForm card={card} wrappedComponentRef={(inst) => this.editFormRef = inst} inputSubmit={this.save}/> |
| | | </Modal> |
| | | </div> |
| | | </> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | export default PasteController |
| | | export default SourceController |