From c8dec113736cc78c47cd63377d756d364b42a94e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 23 四月 2025 16:39:15 +0800
Subject: [PATCH] Merge branch 'develop'
---
src/menu/components/share/sourcecomponent/inputform/index.jsx | 193 ++++++++++++++++++++++++++++++-----------------
1 files changed, 122 insertions(+), 71 deletions(-)
diff --git a/src/menu/components/share/sourcecomponent/inputform/index.jsx b/src/menu/components/share/sourcecomponent/inputform/index.jsx
index 7652431..4d4a477 100644
--- a/src/menu/components/share/sourcecomponent/inputform/index.jsx
+++ b/src/menu/components/share/sourcecomponent/inputform/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
-import { Input, Form, Row, Col, Pagination, Empty, Button, Modal, notification } from 'antd'
+import { Input, Form, Row, Col, Empty, Button, Modal, notification } from 'antd'
import { PlusOutlined } from '@ant-design/icons'
import Api from '@/api'
@@ -13,7 +13,6 @@
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 {
@@ -23,12 +22,9 @@
state = {
url: '',
- originlist: [],
list: [],
- pagelist: [],
+ icons: [],
searchKey: '',
- pageSize: 12,
- pageIndex: 1,
selectId: '',
editvisible: false,
card: null
@@ -36,7 +32,7 @@
UNSAFE_componentWillMount () {
if (this.props.keyword === 'system') {
- this.init()
+ this.preInit()
}
}
@@ -54,48 +50,74 @@
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 (e) {
- originlist = []
- }
- } else {
- let pictures = sessionStorage.getItem('app_pictures')
- try {
- originlist = JSON.parse(pictures)
- } catch (e) {
- originlist = []
- }
- }
+ let _type = type === 'video' ? 'video' : 'image'
+ let _sname = type === 'video' ? 'app_videos' : 'app_pictures'
- let list = originlist
- let pagelist = list.filter((item, index) => index < this.state.pageSize)
-
- this.setState({originlist, list, url: '', searchKey: '', pageIndex: 1, pagelist})
+ this.getSource(_type, _sname).then(res => {
+ this.init(res)
+ })
}
- changeSearch = () => {
- const { originlist, pageSize, searchKey } = this.state
- let list = originlist.filter(item => item.remark.indexOf(searchKey) > -1)
- let pagelist = list.filter((item, index) => index < pageSize)
+ 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
- this.setState({list, pagelist, pageIndex: 1})
+ resolve(data)
+ })
+ }
+ })
+ }
+
+ init = (originlist) => {
+ 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) => {
this.setState({url: e.target.value})
- }
-
- changeSize = (page) => {
- const { list, pageSize } = this.state
- let pagelist = list.filter((item, index) => index < pageSize * page && index >= pageSize * (page - 1))
- this.setState({pageIndex: page, pagelist})
}
changeFile = (val) => {
@@ -103,8 +125,15 @@
}
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})
+ }
}
}
@@ -124,7 +153,7 @@
res.id = Utils.getuuid()
}
- Api.getSystemConfig({
+ Api.getCloudConfig({
func: 's_url_db_adduptdel',
id: res.id,
PageIndex: 0, // 0 浠h〃鍏ㄩ儴
@@ -136,11 +165,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 {
@@ -156,43 +185,65 @@
render () {
const { type, keyword } = this.props
- const { list, url, pagelist, searchKey, pageIndex, pageSize, selectId, editvisible, card } = this.state
+ const { list, icons, url, searchKey, selectId, editvisible, card } = this.state
- 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 }}}>
+ if (keyword === 'input') {
+ return <div className="mk-source-pop-wrap">
+ <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 }}}>
+ </Form.Item>
+ </div>
+ } else if (keyword === 'upload') {
+ return <div className="mk-source-pop-wrap">
+ <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,.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" onClick={() => this.handleSource({typecharone: type})}>
+ </Form.Item>
+ </div>
+ }
+
+ 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 (
+ <div className="mk-source-pop-wrap">
+ <Search value={searchKey} placeholder="" onChange={(e) => this.setState({searchKey: e.target.value})}/>
+ <Button className="picture-plus mk-green" onClick={() => this.handleSource({typecharone: type})}>
<PlusOutlined /> 娣诲姞
- </Button> : null}
- {keyword === 'system' && list.length ?
- <Row gutter={16} style={{minHeight: '250px'}}>
- {pagelist.map(item => (
- <Col span={4} 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} /> : null}
- {type === 'video' ? <Video value={item.linkurl} /> : null}
- </div>
+ </Button>
+ <Row gutter={16} className="mk-scrollbar">
+ {pagelist.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">
+ {type !== 'video' ? <img src={item.linkurl} alt=""/> : <Video value={item.linkurl} />}
</div>
- </Col>
- ))}
- </Row> : null}
- {keyword === 'system' && list.length === 0 ? <Empty description={null}/> : null}
- {keyword === 'system' && list.length > pageSize ? <Pagination size="small" current={pageIndex} pageSize={pageSize} onChange={this.changeSize} total={list.length} /> : null}
+ </div>
+ </Col>
+ ))}
+ {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={'鏂板缓'}
+ title="鏂板缓"
wrapClassName="picture-edit-model"
visible={editvisible}
width={600}
--
Gitblit v1.8.0