From 1d395e6d750fe91082c99a15e355ab2841ed65c6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 04 一月 2024 17:49:21 +0800 Subject: [PATCH] 2024-01-04 --- src/menu/components/share/sourcecomponent/inputform/index.jsx | 75 ++++++++++++++++++++++--------------- 1 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/menu/components/share/sourcecomponent/inputform/index.jsx b/src/menu/components/share/sourcecomponent/inputform/index.jsx index f178a9e..0a06300 100644 --- a/src/menu/components/share/sourcecomponent/inputform/index.jsx +++ b/src/menu/components/share/sourcecomponent/inputform/index.jsx @@ -2,6 +2,7 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Input, Form, Row, Col, Pagination, Empty, Button, Modal, notification } from 'antd' +import { PlusOutlined } from '@ant-design/icons' import Api from '@/api' import Utils from '@/utils/utils.js' @@ -17,9 +18,7 @@ class PopSource extends Component { static propTpyes = { - btnlog: PropTypes.array, - keyword: PropTypes.string, - handlelog: PropTypes.func + keyword: PropTypes.string } state = { @@ -37,7 +36,7 @@ UNSAFE_componentWillMount () { if (this.props.keyword === 'system') { - this.init() + this.preInit() } } @@ -48,33 +47,47 @@ if (_form && _form.focus) { _form.focus() } - } catch {} + } catch (e) {} } shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.state), fromJS(nextState)) } - init = () => { + preInit = () => { const { type } = this.props - let originlist = [] - if (type === 'video') { - let videos = sessionStorage.getItem('app_videos') - try { - originlist = JSON.parse(videos) - } catch { - originlist = [] - } - } else { - let pictures = sessionStorage.getItem('app_pictures') - try { - originlist = JSON.parse(pictures) - } catch { - originlist = [] - } - } + let _type = type === 'video' ? 'video' : 'image' + let _sname = type === 'video' ? 'app_videos' : 'app_pictures' + this.getSource(_type, _sname).then(res => { + this.init(res) + }) + } + + getSource = (type, sessionName) => { + return new Promise(resolve => { + if (window.GLOB[sessionName]) { + resolve(window.GLOB[sessionName]) + } else { + let param = { + func: 's_url_db_adduptdel', + PageIndex: 0, // 0 浠h〃鍏ㄩ儴 + PageSize: 0, // 0 浠h〃鍏ㄩ儴 + type: 'search', + typecharone: type + } + Api.getCloudConfig(param).then(res => { + let data = res.data || [] + window.GLOB[sessionName] = data + + resolve(data) + }) + } + }) + } + + init = (originlist) => { let list = originlist let pagelist = list.filter((item, index) => index < this.state.pageSize) @@ -125,7 +138,7 @@ res.id = Utils.getuuid() } - Api.getSystemConfig({ + Api.getCloudConfig({ func: 's_url_db_adduptdel', id: res.id, PageIndex: 0, // 0 浠h〃鍏ㄩ儴 @@ -137,11 +150,11 @@ }).then(result => { if (result.status) { if (card.typecharone === 'image') { - sessionStorage.setItem('app_pictures', JSON.stringify(result.data || [])) - this.init() + window.GLOB.app_pictures = result.data || [] + this.init(result.data || []) } else { - sessionStorage.setItem('app_videos', JSON.stringify(result.data || [])) - this.init() + window.GLOB.app_videos = result.data || [] + this.init(result.data || []) } this.setState({editvisible: false}) } else { @@ -161,21 +174,21 @@ return ( <div className="mk-source-pop-wrap"> - {keyword === 'input' ? <Form.Item label="鍦板潃" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={{xs: { span: 24 }, sm: { span: 20 }}}> + {keyword === 'input' ? <Form.Item label="鍦板潃" help="鍙娇鐢ˊmywebsite@浠f浛鍩熷悕锛堝惈铏氭嫙鐩綍锛夛紝濡傦細@mywebsite@/Content/images/xxx.jpg" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={{xs: { span: 24 }, sm: { span: 20 }}}> <TextArea id="source-input" value={url} rows={4} onChange={this.changeValue}/> </Form.Item> : null} {keyword === 'upload' ? <Form.Item label="涓婁紶" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={{xs: { span: 24 }, sm: { span: 20 }}}> <FileUpload config={{ initval: '', - suffix: type === 'video' ? '.mp4,.webm,.ogg' : '.jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp', + suffix: type === 'video' ? '.mp4,.webm,.ogg' : '.jpg,.png,.gif,.pjp,.pjpeg,.jpeg,.jfif,.webp,.ico', maxfile: 1, fileType: type === 'video' ? 'text' : 'picture' }} onChange={this.changeFile} /> </Form.Item> : null} {keyword === 'system' ? <Search value={searchKey} placeholder="" onChange={(e) => this.setState({searchKey: e.target.value})} onSearch={this.changeSearch} enterButton/> : null} - {keyword === 'system' ? <Button className="picture-plus mk-green" icon="plus" onClick={() => this.handleSource({typecharone: type})}> - 娣诲姞 + {keyword === 'system' ? <Button className="picture-plus mk-green" onClick={() => this.handleSource({typecharone: type})}> + <PlusOutlined /> 娣诲姞 </Button> : null} {keyword === 'system' && list.length ? <Row gutter={16} style={{minHeight: '250px'}}> -- Gitblit v1.8.0