From 4fcad7ab9334897449360194848cec1c998973df Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 18 一月 2021 17:49:16 +0800 Subject: [PATCH] 2021-01-18 --- src/tabviews/zshare/actionList/index.scss | 28 ----- src/tabviews/zshare/mutilform/index.jsx | 56 ++-------- src/templates/zshare/modalform/index.jsx | 6 + src/tabviews/verupmanage/actionList/index.scss | 27 ----- src/components/editor/index.scss | 5 src/tabviews/zshare/mutilform/customTextArea/index.scss | 0 src/templates/zshare/formconfig.jsx | 4 src/components/editor/index.jsx | 38 ++++++- src/tabviews/zshare/mutilform/customTextArea/index.jsx | 72 ++++++++++++++ src/tabviews/scriptmanage/actionList/index.scss | 27 ----- src/assets/css/main.scss | 28 +++++ 11 files changed, 155 insertions(+), 136 deletions(-) diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index 400975a..6deb445 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -301,6 +301,34 @@ background: rgba(0, 0, 0, 0); } } +// 璁剧疆妯℃�佹鏍峰紡锛岃瀹氭渶澶ф渶灏忛珮搴︼紝閲嶇疆婊氬姩鏉� +.action-modal { + .ant-modal { + max-width: 95vw; + top: 70px; + } + .ant-modal-body { + max-height: calc(100vh - 205px); + min-height: 150px; + overflow-y: auto; + padding-bottom: 35px; + } + .ant-modal-body::-webkit-scrollbar { + width: 7px; + height: 7px; + } + .ant-modal-body::-webkit-scrollbar-thumb { + border-radius: 5px; + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); + background: rgba(0, 0, 0, 0.13); + } + .ant-modal-body::-webkit-scrollbar-track { + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); + border-radius: 3px; + border: 1px solid rgba(0, 0, 0, 0.07); + background: rgba(0, 0, 0, 0); + } +} .ant-drawer { z-index: 1080!important; diff --git a/src/components/editor/index.jsx b/src/components/editor/index.jsx index b7745fe..2c0bd2b 100644 --- a/src/components/editor/index.jsx +++ b/src/components/editor/index.jsx @@ -4,7 +4,7 @@ import BraftEditor from 'braft-editor' import 'braft-editor/dist/index.css' import 'braft-extensions/dist/table.css' -import 'braft-editor/dist/output.css' +// import 'braft-editor/dist/output.css' import Table from 'braft-extensions/dist/table' import SparkMD5 from 'spark-md5' import moment from 'moment' @@ -23,31 +23,57 @@ class NormalEditor extends Component { static propTpyes = { - card: PropTypes.object, // 鏉$爜璁剧疆 - value: PropTypes.any, // 鏉$爜鍊� + Item: PropTypes.object, // 琛ㄥ崟鍏冪礌 + onChange: PropTypes.func, // 琛ㄥ崟鏇存柊 } state = { - editorState: '' + editorState: '', + encryption: 'false', } UNSAFE_componentWillMount () { let initVal = null + let encryption = 'false' if (this.props['data-__meta']) { initVal = this.props['data-__meta'].initialValue || null } + + if (this.props.Item && this.props.Item.encryption === 'true') { + encryption = 'true' + if (initVal) { + try { + initVal = window.decodeURIComponent(window.atob(initVal)) + } catch { + initVal = this.props['data-__meta'].initialValue || null + } + } + } - this.setState({editorState: BraftEditor.createEditorState(initVal)}) + this.setState({ + editorState: BraftEditor.createEditorState(initVal), + encryption + }) } shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) } handleEditorChange = (editorState) => { + const { encryption } = this.state + this.setState({ editorState }) if (this.props.onChange) { - this.props.onChange(editorState.toHTML()) + let val = editorState.toHTML() + if (encryption === 'true') { + try { + val = window.btoa(window.encodeURIComponent(val)) + } catch { + val = editorState.toHTML() + } + } + this.props.onChange(val) } } diff --git a/src/components/editor/index.scss b/src/components/editor/index.scss index 1eb137c..4ff4420 100644 --- a/src/components/editor/index.scss +++ b/src/components/editor/index.scss @@ -17,4 +17,7 @@ border: 1px solid rgba(0, 0, 0, 0.07); background: rgba(0, 0, 0, 0); } -} \ No newline at end of file + .mk-braft-delete { + font-size: 16px; + } +} diff --git a/src/tabviews/scriptmanage/actionList/index.scss b/src/tabviews/scriptmanage/actionList/index.scss index 2b7b17b..8f7def9 100644 --- a/src/tabviews/scriptmanage/actionList/index.scss +++ b/src/tabviews/scriptmanage/actionList/index.scss @@ -15,30 +15,3 @@ top: calc(50vh - 70px); } } -// 璁剧疆妯℃�佹鏍峰紡锛岃瀹氭渶澶ф渶灏忛珮搴︼紝閲嶇疆婊氬姩鏉� -.action-modal { - .ant-modal { - max-width: 95vw; - } - .ant-modal-body { - max-height: calc(100vh - 235px); - min-height: 150px; - overflow-y: auto; - padding-bottom: 35px; - } - .ant-modal-body::-webkit-scrollbar { - width: 7px; - height: 7px; - } - .ant-modal-body::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - .ant-modal-body::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } -} \ No newline at end of file diff --git a/src/tabviews/verupmanage/actionList/index.scss b/src/tabviews/verupmanage/actionList/index.scss index 2681842..9751b46 100644 --- a/src/tabviews/verupmanage/actionList/index.scss +++ b/src/tabviews/verupmanage/actionList/index.scss @@ -15,30 +15,3 @@ top: calc(50vh - 70px); } } -// 璁剧疆妯℃�佹鏍峰紡锛岃瀹氭渶澶ф渶灏忛珮搴︼紝閲嶇疆婊氬姩鏉� -.action-modal { - .ant-modal { - max-width: 95vw; - } - .ant-modal-body { - max-height: calc(100vh - 235px); - min-height: 150px; - overflow-y: auto; - padding-bottom: 35px; - } - .ant-modal-body::-webkit-scrollbar { - width: 7px; - height: 7px; - } - .ant-modal-body::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - .ant-modal-body::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } -} \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/index.scss b/src/tabviews/zshare/actionList/index.scss index 844e480..112834c 100644 --- a/src/tabviews/zshare/actionList/index.scss +++ b/src/tabviews/zshare/actionList/index.scss @@ -24,31 +24,3 @@ display: none; } } -// 璁剧疆妯℃�佹鏍峰紡锛岃瀹氭渶澶ф渶灏忛珮搴︼紝閲嶇疆婊氬姩鏉� -.action-modal { - .ant-modal { - max-width: 95vw; - top: 70px; - } - .ant-modal-body { - max-height: calc(100vh - 235px); - min-height: 150px; - overflow-y: auto; - padding-bottom: 35px; - } - .ant-modal-body::-webkit-scrollbar { - width: 7px; - height: 7px; - } - .ant-modal-body::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - .ant-modal-body::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } -} \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/customTextArea/index.jsx b/src/tabviews/zshare/mutilform/customTextArea/index.jsx new file mode 100644 index 0000000..caed9bf --- /dev/null +++ b/src/tabviews/zshare/mutilform/customTextArea/index.jsx @@ -0,0 +1,72 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Input } from 'antd' + +import './index.scss' + +const { TextArea } = Input + +class CustomTextArea extends Component { + static propTpyes = { + Item: PropTypes.bool, // 琛ㄥ崟 + onChange: PropTypes.func // 鏁版嵁鍒囨崲 + } + + state = { + value: '', + encryption: 'false' + } + + UNSAFE_componentWillMount () { + let value = '' + let encryption = 'false' + + if (this.props['data-__meta']) { + value = this.props['data-__meta'].initialValue || '' + } + + if (this.props.Item && this.props.Item.encryption === 'true') { + encryption = 'true' + if (value) { + try { + value = window.decodeURIComponent(window.atob(value)) + } catch { + value = this.props['data-__meta'].initialValue || '' + } + } + } + + this.setState({ + value, + encryption + }) + } + + onChange = (e) => { + const { encryption } = this.state + let val = e.target.value + + this.setState({ value: val }) + + let _val = val + if (encryption === 'true') { + try { + _val = window.btoa(window.encodeURIComponent(_val)) + } catch { + _val = val + } + } + this.props.onChange(_val) + } + + render() { + const { Item } = this.props + const { value } = this.state + + return ( + <TextArea value={value} autoSize={{ minRows: 2, maxRows: Item.maxRows || 6 }} onChange={this.onChange} disabled={Item.readonly === 'true'} /> + ) + } +} + +export default CustomTextArea \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/customTextArea/index.scss b/src/tabviews/zshare/mutilform/customTextArea/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tabviews/zshare/mutilform/customTextArea/index.scss diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index ba0cddb..9f9e96c 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -12,10 +12,10 @@ import './index.scss' const { MonthPicker } = DatePicker -const { TextArea } = Input const CheckCard = asyncComponent(() => import('./checkCard')) const CustomSwitch = asyncComponent(() => import('./customSwitch')) +const CustomTextArea = asyncComponent(() => import('./customTextArea')) const FileUpload = asyncComponent(() => import('../fileupload')) const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) const Editor = asyncComponent(() => import('@/components/editor')) @@ -39,7 +39,6 @@ writein: null, // 鎵ц鏃舵槸鍚﹀~鍏ラ粯璁ql fieldlen: null, // 瀛楁闀垮害 formlist: [], // 琛ㄥ崟椤� - encrypts: [], // 鍔犲瘑瀛楁 intercepts: [], // 鎴彇瀛楁 record: {} // 璁板綍涓嬫媺琛ㄥ崟鍏宠仈瀛楁锛岀敤浜庢暟鎹啓鍏� } @@ -68,7 +67,6 @@ let writein = {} let fieldlen = {} let formlist = [] - let encrypts = [] let intercepts = [] let _inputfields = [] @@ -99,9 +97,6 @@ _inputfields.push(item.field) } else if (item.type === 'textarea') { _inputfields.push(item.field) - if (item.encryption === 'true') { // 鍔犲瘑瀛楁 - encrypts.push(item.field) - } } else if (item.type === 'link') { linkFields[item.linkField] = linkFields[item.linkField] || [] linkFields[item.linkField].push(item.field) @@ -200,14 +195,7 @@ } } - // 鍔犲瘑瀛楁锛岃В瀵嗗鐞� - if (item.type === 'textarea' && item.encryption === 'true' && newval !== '') { - try { - newval = window.decodeURIComponent(window.atob(newval)) - } catch (e) { - console.warn(e) - } - } else if (item.type === 'switch' && newval !== '') { // 寮�鍏冲彧鎺ユ敹鍥哄畾鍊� + if (item.type === 'switch' && newval !== '') { // 寮�鍏冲彧鎺ユ敹鍥哄畾鍊� if (newval !== item.closeVal && newval !== item.openVal) { newval = '' } else if (newval === item.openVal) { @@ -260,14 +248,13 @@ }) this.setState({ - readtype: readtype, - datatype: datatype, - readin: readin, - writein: writein, - fieldlen: fieldlen, - encrypts: encrypts, - intercepts: intercepts, - formlist: formlist + readin, + writein, + readtype, + datatype, + fieldlen, + intercepts, + formlist }, () => { if (action.setting && action.setting.focus) { this.selectInput(action.setting.focus, 'init') @@ -1182,7 +1169,7 @@ }, ..._rules ] - })(<TextArea autoSize={{ minRows: 2, maxRows: item.maxRows || 6 }} disabled={item.readonly === 'true'} />)} + })(<CustomTextArea Item={item} />)} </Form.Item> </Col> ) @@ -1198,7 +1185,7 @@ </Tooltip> : item.label }> {getFieldDecorator(item.field, { - initialValue: item.initval || null, + initialValue: item.initval || '', rules: [ { required: item.required === 'true', @@ -1209,7 +1196,7 @@ message: formRule.input.formMessage.replace('@max', _max) } ] - })(<Editor />)} + })(<Editor Item={item}/>)} </Form.Item> </Col> ) @@ -1221,7 +1208,6 @@ handleConfirm = () => { const { record, intercepts, writein } = this.state - let _encrypts = fromJS(this.state.encrypts).toJS() let _format = { date: 'YYYY-MM-DD', datemonth: 'YYYY-MM', @@ -1252,7 +1238,6 @@ let _val = item.initval if (record.hasOwnProperty(item.field)) { _val = record[item.field] - _encrypts = _encrypts.filter(_field => _field !== item.field) // 闅愯棌瀛楁锛屼笉鍙備笌鍔犲瘑澶勭悊 } _item = { @@ -1353,23 +1338,6 @@ value: _value }) }) - - // 鍚湁鍔犲瘑瀛楁鏃讹紝瀵硅〃鍗曞�艰繘琛屽姞瀵� - if (_encrypts && _encrypts.length > 0) { - search = search.map(item => { - let _value = item.value - if (_encrypts.includes(item.key)) { - try { - _value = window.btoa(window.encodeURIComponent(_value)) - } catch (e) { - console.warn(e) - } - } - item.value = _value - - return item - }) - } resolve(search) } else { diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 0697f18..274a605 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -1851,7 +1851,7 @@ }) } - if (card.type === 'textarea' || card.type === 'fileupload' || card.type === 'multiselect' || card.type === 'checkbox') { + if (['textarea', 'fileupload', 'multiselect', 'checkbox', 'brafteditor'].includes(card.type)) { _fieldlength = 512 } @@ -2346,7 +2346,7 @@ type: 'radio', key: 'encryption', label: '鍔犲瘑浼犺緭', - initVal: card.encryption || 'false', + initVal: card.type === 'brafteditor' ? (card.encryption || 'true') : (card.encryption || 'false'), options: [{ value: 'true', text: Formdict['model.true'] diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index 852f8bb..3a241c3 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -30,7 +30,7 @@ textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'maxRows', 'encryption', 'interception', 'tooltip'], color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], hint: ['label', 'type', 'blacklist', 'message'], - brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'tooltip'], + brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'tooltip', 'encryption'], funcvar: [], linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'entireLine', 'tooltip'] } @@ -256,6 +256,10 @@ if (value === 'hint') { form.required = false } + } else if (form.key === 'encryption') { + if (value === 'brafteditor') { + fieldValue.encryption = 'true' + } } return form -- Gitblit v1.8.0