| | |
| | | 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 |
| | | |
| | |
| | | res.id = Utils.getuuid() |
| | | } |
| | | |
| | | Api.getSystemConfig({ |
| | | Api.getCloudConfig({ |
| | | func: 's_url_db_adduptdel', |
| | | id: res.id, |
| | | PageIndex: 0, // 0 代表全部 |
| | |
| | | }).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') { |
| | | sessionStorage.setItem('app_colors', JSON.stringify(result.data || [])) |
| | | window.GLOB.app_colors = result.data || [] |
| | | this.resetColor(result.data || []) |
| | | } |
| | | this.setState({editvisible: false}) |
| | |
| | | content: '', |
| | | onOk() { |
| | | return new Promise((resolve) => { |
| | | Api.getSystemConfig({ |
| | | Api.getCloudConfig({ |
| | | func: 's_url_db_adduptdel', |
| | | id: item.id, |
| | | PageIndex: 0, // 0 代表全部 |
| | |
| | | }).then(res => { |
| | | if (res.status) { |
| | | if (item.typecharone === 'image') { |
| | | sessionStorage.setItem('app_pictures', JSON.stringify(res.data || [])) |
| | | window.GLOB.app_pictures = res.data || [] |
| | | _this.resetPicture(res.data || []) |
| | | } else if (item.typecharone === 'video') { |
| | | sessionStorage.setItem('app_videos', JSON.stringify(res.data || [])) |
| | | window.GLOB.app_videos = res.data || [] |
| | | _this.resetVideo(res.data || []) |
| | | } else if (item.typecharone === 'color') { |
| | | sessionStorage.setItem('app_colors', JSON.stringify(res.data || [])) |
| | | window.GLOB.app_colors = res.data || [] |
| | | _this.resetColor(res.data || []) |
| | | } |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | export default PasteController |
| | | export default SourceController |