| | |
| | | const { Search } = Input |
| | | const FileUpload = asyncComponent(() => import('@/tabviews/zshare/fileupload')) |
| | | const Video = asyncComponent(() => import('@/menu/picturecontroller/video')) |
| | | const Image = asyncComponent(() => import('@/components/Image')) |
| | | const EditForm = asyncComponent(() => import('@/menu/picturecontroller/editform')) |
| | | |
| | | class PopSource extends Component { |
| | |
| | | state = { |
| | | url: '', |
| | | list: [], |
| | | icons: [], |
| | | searchKey: '', |
| | | selectId: '', |
| | | editvisible: false, |
| | |
| | | } |
| | | |
| | | init = (originlist) => { |
| | | this.setState({list: originlist, url: '', searchKey: ''}) |
| | | const { type } = this.props |
| | | this.setState({list: originlist, icons: window.GLOB.sIcons || [], url: '', searchKey: ''}) |
| | | |
| | | if (type !== 'video' && !window.GLOB.sIcons && sessionStorage.getItem('getIcons') !== 'fail') { |
| | | fetch(window.GLOB.baseurl + 'Content/static/data.json') |
| | | .then(response => response.json()) |
| | | .catch(() => { |
| | | sessionStorage.setItem('getIcons', 'fail') |
| | | }) |
| | | .then(res => { |
| | | if (res && res.list) { |
| | | let icons = [] |
| | | res.list.forEach(item => { |
| | | if (!item.url) return |
| | | |
| | | icons.push({ |
| | | linkurl: window.GLOB.baseurl + 'Content/static/' + item.url, |
| | | remark: item.remark || '', |
| | | id: Utils.getuuid() |
| | | }) |
| | | }) |
| | | |
| | | window.GLOB.sIcons = icons |
| | | |
| | | this.setState({icons}) |
| | | } else { |
| | | sessionStorage.setItem('getIcons', 'fail') |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | changeValue = (e) => { |
| | |
| | | } |
| | | |
| | | selectItem = (item) => { |
| | | const { type } = this.props |
| | | const { icons } = this.state |
| | | |
| | | if (item.linkurl) { |
| | | this.setState({url: item.linkurl, selectId: item.id}) |
| | | if (type !== 'video' && icons.findIndex(n => n.id === item.id) > -1) { |
| | | this.setState({url: item.linkurl.replace(window.GLOB.baseurl, '@mywebsite@/'), selectId: item.id}) |
| | | } else { |
| | | this.setState({url: item.linkurl, selectId: item.id}) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | render () { |
| | | const { type, keyword } = this.props |
| | | const { list, url, searchKey, selectId, editvisible, card } = this.state |
| | | const { list, icons, url, searchKey, selectId, editvisible, card } = this.state |
| | | |
| | | if (keyword === 'input') { |
| | | return <div className="mk-source-pop-wrap"> |
| | |
| | | } |
| | | |
| | | let pagelist = list |
| | | let iconlist = icons |
| | | |
| | | if (searchKey) { |
| | | pagelist = list.filter(item => item.remark && item.remark.indexOf(searchKey) > -1) |
| | | iconlist = icons.filter(item => item.remark && item.remark.indexOf(searchKey) > -1) |
| | | } |
| | | |
| | | return ( |
| | |
| | | <Col span={3} key={item.id}> |
| | | <div className={'image-video-box' + (selectId === item.id ? ' active' : '')} onClick={() => this.selectItem(item)}> |
| | | <div className="image-video-box-body"> |
| | | {type !== 'video' ? <Image url={item.linkurl} /> : <Video value={item.linkurl} />} |
| | | {type !== 'video' ? <img src={item.linkurl} alt=""/> : <Video value={item.linkurl} />} |
| | | </div> |
| | | </div> |
| | | </Col> |
| | | ))} |
| | | {!pagelist.length ? <Empty description={null}/> : null} |
| | | {iconlist.length ? <div className="static-source">静态资源</div> : null} |
| | | {iconlist.map(item => ( |
| | | <Col span={3} key={item.id}> |
| | | <div className={'image-video-box' + (selectId === item.id ? ' active' : '')} onClick={() => this.selectItem(item)}> |
| | | <div className="image-video-box-body"> |
| | | <img src={item.linkurl} alt=""/> |
| | | </div> |
| | | </div> |
| | | </Col> |
| | | ))} |
| | | {!pagelist.length && !iconlist.length ? <Empty description={null}/> : null} |
| | | </Row> |
| | | <Modal |
| | | title="新建" |