| | |
| | | // const MKColor = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkColor')) |
| | | const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) |
| | | const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent')) |
| | | const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) |
| | | |
| | | class ModalForm extends Component { |
| | | static propTpyes = { |
| | |
| | | return |
| | | } else if (item.type === 'printTemps') { |
| | | content = <MkPrintTemps onChange={(val) => this.recordChange({[item.field]: val})}/> |
| | | } else if (item.type === 'codemirror') { |
| | | content = <CodeMirror mode="text/javascript" theme="cobalt" onChange={(val) => this.recordChange({[item.field]: val})}/> |
| | | } |
| | | |
| | | if (!content) return |
| | |
| | | background-color: #f0f0f0; |
| | | } |
| | | td, th { |
| | | padding: 5px 14px; |
| | | padding: 5px 10px; |
| | | font-size: 16px; |
| | | border: 1px solid #ddd; |
| | | } |
| | |
| | | <NormalHeader hideSearch="true" config={card} updateComponent={this.updateComponent}/> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | | <NormalForm title="富文本设置" width={850} update={this.updateWrap} getForms={this.getWrapForms}> |
| | | <NormalForm title="富文本设置" width={900} update={this.updateWrap} getForms={this.getWrapForms}> |
| | | <EditOutlined style={{color: '#1890ff'}} title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="editor" card={card}/> |
| | |
| | | } trigger="hover"> |
| | | <ToolOutlined /> |
| | | </Popover> |
| | | <BraftContent |
| | | value={card.wrap.datatype !== 'static' ? '<p class="empty-content">富文本</p>' : card.html} |
| | | encryption="false" |
| | | /> |
| | | <BraftContent value={card.wrap.datatype !== 'static' ? '<p class="empty-content">富文本</p>' : card.html}/> |
| | | <div className="component-name"> |
| | | <div className="center"> |
| | | <div className="title">{card.name}</div> |
| | |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'loaded', |
| | | label: '布局调整', |
| | | initval: wrap.loaded || 'false', |
| | | required: false, |
| | | options: [ |
| | | {value: 'false', label: '关闭'}, |
| | | {value: 'true', label: '开启'}, |
| | | ], |
| | | controlFields: [ |
| | | {field: 'loadedfunc', values: ['true']}, |
| | | ] |
| | | }, |
| | | { |
| | | type: 'codemirror', |
| | | field: 'loadedfunc', |
| | | label: '处理脚本', |
| | | initval: wrap.loadedfunc || '', |
| | | required: true, |
| | | span: 24 |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | field: 'permission', |
| | | label: '权限验证', |
| | | initval: wrap.permission || 'false', |
| | |
| | | orderType: 'asc', |
| | | readonly: 'false', |
| | | required: 'true', |
| | | readin: 'top', |
| | | focus: true |
| | | } |
| | | |
| | |
| | | orderType: 'asc', |
| | | readonly: 'false', |
| | | required: 'true', |
| | | readin: 'top', |
| | | focus: true |
| | | } |
| | | |
| | |
| | | orderType: 'asc', |
| | | readonly: 'false', |
| | | required: 'true', |
| | | readin: 'top', |
| | | focus: true |
| | | } |
| | | |
| | |
| | | newcard.options = [] |
| | | newcard.readonly = 'false' |
| | | newcard.required = 'true' |
| | | newcard.readin = 'top' |
| | | newcard.span = 24 |
| | | newcard.focus = true |
| | | |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | data: _data, |
| | | data: this.decodeHtml(_data, _config.wrap), |
| | | BID: BID || '', |
| | | config: _config, |
| | | }) |
| | |
| | | |
| | | let _data = window.GLOB.SyncData.get(config.dataName) || [] |
| | | |
| | | this.setState({data: _data}) |
| | | this.setState({data: this.decodeHtml(_data, config.wrap)}) |
| | | |
| | | window.GLOB.SyncData.delete(config.dataName) |
| | | |
| | |
| | | _data = [_data] |
| | | } |
| | | |
| | | this.setState({data: _data}) |
| | | this.setState({data: this.decodeHtml(_data, config.wrap)}) |
| | | } |
| | | } |
| | | |
| | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | | this.setState({ |
| | | data: result.data || [], |
| | | data: this.decodeHtml(result.data, config.wrap), |
| | | loading: false |
| | | }) |
| | | |
| | |
| | | |
| | | UtilsDM.queryFail(result) |
| | | } |
| | | } |
| | | |
| | | decodeHtml = (data, wrap) => { |
| | | if (!data || data.length === 0) return [] |
| | | |
| | | data.forEach(item => { |
| | | item.$html = item[wrap.field] || '' |
| | | if (item.$html) { |
| | | if (wrap.encryption === 'true') { |
| | | try { |
| | | item.$html = window.decodeURIComponent(window.atob(item.$html)) |
| | | } catch (e) { |
| | | item.$html = item[wrap.field] || '' |
| | | } |
| | | } |
| | | |
| | | delete item[wrap.field] |
| | | |
| | | if (/\$[\s\S]+\$/.test(item.$html)) { |
| | | Object.keys(item).forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | let reg = new RegExp('\\$' + key + '\\$', 'ig') |
| | | item.$html = item.$html.replace(reg, item[key]) |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | return data |
| | | } |
| | | |
| | | render() { |
| | |
| | | <NormalHeader config={config}/> |
| | | {config.wrap.datatype === 'static' ? <BraftContent |
| | | value={config.html} |
| | | encryption={'false'} |
| | | /> : data.map((item, index) => <BraftContent |
| | | key={index} |
| | | value={item[config.wrap.field] || ''} |
| | | encryption={config.wrap.encryption} |
| | | value={item.$html} |
| | | script={config.wrap.loaded === 'true' ? config.wrap.loadedfunc : ''} |
| | | />)} |
| | | </div> |
| | | ) |
| | |
| | | import React, {Component} from 'react' |
| | | import React, { Component } from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | |
| | | import './index.scss' |
| | | |
| | | class BraftContent extends Component { |
| | | static propTpyes = { |
| | | value: PropTypes.any, // 内容 |
| | | encryption: PropTypes.any, // 是否解码 |
| | | script: PropTypes.any // 自定义脚本 |
| | | } |
| | | |
| | | state = { |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { encryption, value } = this.props |
| | | let html = value |
| | | |
| | | if (encryption === 'true' && html) { |
| | | try { |
| | | html = window.decodeURIComponent(window.atob(html)) |
| | | } catch (e) { |
| | | html = value |
| | | } |
| | | } |
| | | const { value } = this.props |
| | | |
| | | this.setState({html}) |
| | | this.setState({html: value}) |
| | | } |
| | | |
| | | componentDidMount() { |
| | | this.loadScript() |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (!is(fromJS(this.props), fromJS(nextProps))) { |
| | | const { encryption, value } = nextProps |
| | | let html = value |
| | | if (this.props.value !== nextProps.value) { |
| | | this.setState({html: nextProps.value}, () => { |
| | | this.loadScript() |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (encryption === 'true' && html) { |
| | | try { |
| | | html = window.decodeURIComponent(window.atob(html)) |
| | | } catch (e) { |
| | | html = value |
| | | } |
| | | loadScript = () => { |
| | | const { script } = this.props |
| | | const { html } = this.state |
| | | |
| | | if (script && html) { |
| | | const that = this |
| | | let _html = '' |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('that', 'html', script) |
| | | _html = func(that, html) |
| | | } catch (e) { |
| | | _html = '' |
| | | console.warn(e) |
| | | } |
| | | |
| | | this.setState({html}) |
| | | |
| | | if (_html) { |
| | | this.setState({html: _html}) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | background-color: #f0f0f0; |
| | | } |
| | | td, th { |
| | | padding: 5px 14px; |
| | | padding: 5px 10px; |
| | | font-size: 16px; |
| | | border: 1px solid #ddd; |
| | | } |
| | |
| | | */ |
| | | getModels = () => { |
| | | const { BID, btn, BData } = this.props |
| | | const { btnconfig, visible, dict, confirmLoading, submitType } = this.state |
| | | const { btnconfig, visible, dict, confirmLoading, submitType, loadingNumber, loadingTotal } = this.state |
| | | |
| | | if (!btnconfig || !btnconfig.setting) return null |
| | | |
| | | let title = btn.label |
| | | let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw' |
| | | let clickouter = btnconfig.setting.clickouter === 'close' |
| | | let num = loadingNumber && !loadingTotal ? `(${loadingNumber}) ` : '' |
| | | |
| | | if (btnconfig.setting.display === 'drawer') { |
| | | let height = '100vh' |
| | |
| | | onCancel={this.handleCancel} |
| | | footer={[ |
| | | <Button key="cancel" onClick={this.handleCancel}>{dict['cancel'] || '取消'}</Button>, |
| | | btn.extBtn === 'true' ? <Button key="extend" className={'extend-btn ' + (btn.extStyle || '')} disabled={confirmLoading && submitType !== btn.extValue} loading={confirmLoading && submitType === btn.extValue} onClick={() => this.handleOk(btn.extValue)}>{btn.extLabel}</Button> : null, |
| | | btn.extBtn === 'true' ? <Button key="confirm" className={'confirm-btn ' + (btn.confStyle || '')} disabled={confirmLoading && submitType !== ''} loading={confirmLoading && submitType === ''} onClick={() => this.handleOk()}>{btn.confLabel || dict['ok'] || '确定'}</Button> : null, |
| | | btn.extBtn !== 'true' ? <Button key="confirm" type="primary" loading={confirmLoading} onClick={() => this.handleOk()}>{dict['ok'] || '确定'}</Button> : null |
| | | btn.extBtn === 'true' ? <Button key="extend" className={'extend-btn ' + (btn.extStyle || '')} disabled={confirmLoading && submitType !== btn.extValue} loading={confirmLoading && submitType === btn.extValue} onClick={() => this.handleOk(btn.extValue)}>{submitType === btn.extValue ? num : ''}{btn.extLabel}</Button> : null, |
| | | btn.extBtn === 'true' ? <Button key="confirm" className={'confirm-btn ' + (btn.confStyle || '')} disabled={confirmLoading && submitType !== ''} loading={confirmLoading && submitType === ''} onClick={() => this.handleOk()}>{submitType === '' ? num : ''}{btn.confLabel || dict['ok'] || '确定'}</Button> : null, |
| | | btn.extBtn !== 'true' ? <Button key="confirm" type="primary" loading={confirmLoading} onClick={() => this.handleOk()}>{num}{dict['ok'] || '确定'}</Button> : null |
| | | ]} |
| | | destroyOnClose |
| | | > |
| | |
| | | newcard.options = [] |
| | | newcard.readonly = 'false' |
| | | newcard.required = 'true' |
| | | newcard.readin = 'top' |
| | | newcard.focus = true |
| | | |
| | | if (item.subType === 'linkMain') { |
| | |
| | | decimal: item.decimal, |
| | | orderType: 'asc', |
| | | readonly: 'false', |
| | | required: 'true' |
| | | required: 'true', |
| | | readin: 'top' |
| | | } |
| | | |
| | | if (/^icon|images?$/ig.test(item.field)) { |