From 4e570c993e66a47ead0f83de76b63b0a2f8c5446 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 05 六月 2023 17:28:16 +0800 Subject: [PATCH] 2023-06-05 --- src/components/pasteboard/index.scss | 0 src/mob/colorsketch/index.jsx | 2 src/templates/zshare/editTable/index.jsx | 190 +++++++------- src/menu/stylecontroller/index.jsx | 98 ++++++ src/tabviews/zshare/actionList/popupbutton/index.jsx | 12 src/menu/components/share/actioncomponent/formconfig.jsx | 46 +++ src/utils/utils-custom.js | 9 src/menu/components/chart/antv-X6/index.jsx | 9 src/tabviews/zshare/actionList/excelInbutton/index.jsx | 14 src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 12 src/tabviews/custom/popview/index.jsx | 63 ++-- src/menu/components/share/actioncomponent/actionform/index.jsx | 18 + src/tabviews/basetable/index.jsx | 54 +++ src/tabviews/custom/index.jsx | 63 ++-- src/tabviews/zshare/actionList/normalbutton/index.jsx | 12 src/components/pasteboard/index.jsx | 134 ++++++++++ src/menu/datasource/verifycard/index.jsx | 1 17 files changed, 536 insertions(+), 201 deletions(-) diff --git a/src/components/pasteboard/index.jsx b/src/components/pasteboard/index.jsx new file mode 100644 index 0000000..aae3fa1 --- /dev/null +++ b/src/components/pasteboard/index.jsx @@ -0,0 +1,134 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Input, notification, Modal } from 'antd' +import { SnippetsOutlined } from '@ant-design/icons' + +// import './index.scss' + +const { TextArea } = Input + +class PaseComponent extends Component { + static propTpyes = { + inputSubmit: PropTypes.func // 鍥炶溅浜嬩欢 + } + + state = { + visible: false, + value: '' + } + + trigger = () => { + // navigator.clipboard + // .readText() + // .then((val) => { + // this.evalContent(val) + // }) + // .catch((v) => { + // this.setState({visible: true, value: ''}) + // }) + + this.setState({visible: true, value: ''}) + } + + evalContent = (config) => { + let _config = config.replace(/(\n|\s)+/g, '') + + if (!_config) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌閰嶇疆淇℃伅', + duration: 5 + }) + return + } + + try { + _config = JSON.parse(window.decodeURIComponent(window.atob(_config))) + + if (typeof(_config) === 'object' && _config.$srcId) { + let srcid = localStorage.getItem(window.location.href.split('#')[0] + 'srcId') + if (srcid && _config.$srcId !== srcid) { + notification.warning({ + top: 92, + message: '褰撳墠绯荤粺鏃犳潈闄愪娇鐢ㄦ椤归厤缃紒', + duration: 5 + }) + + _config = '' + } else { + delete _config.$srcId + } + } + } catch (e) { + // 閫氳繃sql璇彞娣诲姞瀛楁闆� + if (/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int)/ig.test(config)) { + _config = { + key: 'datasourcefield', + type: 'array', + data: [] + } + + let list = config.match(/[a-zA-Z0-9_]+\s+(nvarchar\(\d+\)|Decimal\(18,\d+\)|Int)/ig) + + list.forEach(item => { + _config.data.unshift({ + datatype: item.split(/\s+/)[1], + field: item.split(/\s+/)[0], + label: item.split(/\s+/)[0], + }) + }) + } else { + notification.warning({ + top: 92, + message: '瑙f瀽閿欒', + duration: 5 + }) + _config = '' + } + } + + if (!_config) return + + this.props.getPasteValue(_config, () => { + this.setState({visible: false, value: ''}) + }) + } + + changeVal = (e) => { + this.setState({value: e.target.value}) + } + + pasteSubmit = () => { + this.evalContent(this.state.value) + } + + enterPress = (e) => { + e.stopPropagation() + + this.evalContent(this.state.value) + } + + render() { + const { children } = this.props + const { visible, value } = this.state + + return ( + <> + {children ? <span onClick={this.trigger}>{children}</span> : <SnippetsOutlined title="绮樿创" onClick={this.trigger} />} + <Modal + title="绮樿创" + visible={visible} + width={600} + maskClosable={false} + onOk={this.pasteSubmit} + onCancel={() => {this.setState({visible: false})}} + destroyOnClose + > + <TextArea placeholder="璇疯緭鍏ラ厤缃俊鎭�" autoFocus autoSize={{ minRows: 8, maxRows: 8 }} value={value} onChange={this.changeVal} onPressEnter={this.enterPress}/> + </Modal> + </> + ) + } +} + +export default PaseComponent \ No newline at end of file diff --git a/src/components/pasteboard/index.scss b/src/components/pasteboard/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/components/pasteboard/index.scss diff --git a/src/menu/components/chart/antv-X6/index.jsx b/src/menu/components/chart/antv-X6/index.jsx index da3bba7..2cf20cf 100644 --- a/src/menu/components/chart/antv-X6/index.jsx +++ b/src/menu/components/chart/antv-X6/index.jsx @@ -533,17 +533,16 @@ }) // graph.on('cell:click', ({ e, x, y, cell, view }) => { - // console.log(cell) - // console.log(view) + // }) graph.on('node:click', ({ e, x, y, node, view }) => { - console.log(node) + }) graph.on('edge:click', ({ e, x, y, edge, view }) => { - console.log(edge) + }) graph.on('blank:click', ({ e, x, y }) => { - console.log(13) + }) const r1 = graph.createNode({ diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index ca3792b..b1d19ea 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -12,6 +12,7 @@ const { TextArea } = Input const { Paragraph } = Typography const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) +const MKTable = asyncComponent(() => import('@/components/normalform/modalform/mkTable')) const acTyOptions = { pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'position', 'tipTitle', 'hidden'], prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'position', 'tipTitle', 'hidden'], @@ -92,6 +93,8 @@ let hasclass = true this.props.formlist.forEach(item => { + if (!item.key) return + this.record[item.key] = item.initVal if (item.key === 'class') { @@ -520,6 +523,10 @@ } } + if (shows.includes('syncComponent') && this.record.syncComponent[0] === 'multiComponent') { + shows.push('syncComponents') + } + if (this.record.show === 'icon') { reRequired.icon = true } else { @@ -858,7 +865,14 @@ { required: item.required, message: '璇烽�夋嫨' + item.label + '!' } ] - content = <Cascader options={item.options || []} expandTrigger="hover" placeholder=""/> + content = <Cascader onChange={(value) => {this.optionChange(item.key, value)}} options={item.options || []} expandTrigger="hover" placeholder=""/> + } else if (item.type === 'table') { + span = 24 + className = 'textarea' + rules = [ + { required: item.required, message: '璇锋坊鍔�' + item.label + '!' } + ] + content = (<MKTable tip={''} columns={item.columns || []} actions={[]}/>) } else if (item.type === 'icon') { rules = [ { required: item.required, message: '璇烽�夋嫨' + item.label + '!' } @@ -1041,7 +1055,7 @@ } }) } - + resolve(values) } else { reject(err) diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index 8ab35f0..9d6f7b7 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -749,7 +749,7 @@ initVal: card.syncComponent || [], tooltip: '鎵ц鎴愬姛鍚庯紙鎴栧脊绐楁爣绛惧叧闂椂锛夛紝闇�瑕佸悓姝ュ埛鏂扮殑缁勪欢銆傛敞锛氶�夋嫨褰撳墠缁勪欢鐨勪笂绾х粍浠舵棤鏁堬紝鍒锋柊涓婄骇缁勪欢璇烽�夋嫨鎴愬姛鍚庘�滃埛鏂颁笂绾х粍浠� - 琛屸�濄��', required: false, - options: modules + options: modules.length ? [...modules, {value: 'multiComponent', label: '澶氱粍浠�'}] : [] }, { type: 'radio', @@ -1168,6 +1168,27 @@ value: 'progressbar', text: '杩涘害鏉�' }] + }, + { + type: 'table', + key: 'syncComponents', + label: '缁勪欢鍒楄〃', + initVal: card.syncComponents || [], + required: true, + actions: [], + columns: [ + { + title: '缁勪欢', + dataIndex: 'syncComId', + inputType: 'cascader', + editable: true, + required: true, + extends: [{key: 'label', value: 'label'}], + width: '70%', + render: (text, record) => record.label, + options: modules + } + ] } ] @@ -1704,7 +1725,7 @@ initVal: card.syncComponent || [], tooltip: '鎵ц鎴愬姛鍚庯紙鎴栧脊绐楁爣绛惧叧闂椂锛夛紝闇�瑕佸悓姝ュ埛鏂扮殑缁勪欢銆傛敞锛氶�夋嫨褰撳墠缁勪欢鐨勪笂绾х粍浠舵棤鏁堬紝鍒锋柊涓婄骇缁勪欢璇烽�夋嫨鎴愬姛鍚庘�滃埛鏂颁笂绾х粍浠� - 琛屸�濄��', required: false, - options: modules + options: modules.length ? [...modules, {value: 'multiComponent', label: '澶氱粍浠�'}] : [] }, { type: 'radio', @@ -1931,6 +1952,27 @@ value: 'progressbar', text: '杩涘害鏉�' }] + }, + { + type: 'table', + key: 'syncComponents', + label: '缁勪欢鍒楄〃', + initVal: card.syncComponents || [], + required: true, + actions: [], + columns: [ + { + title: '缁勪欢', + dataIndex: 'syncComId', + inputType: 'cascader', + editable: true, + required: true, + extends: [{key: 'label', value: 'label'}], + width: '70%', + render: (text, record) => record.label, + options: modules + } + ] } ] diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index 1239d4f..ddd14c0 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -64,6 +64,7 @@ inputType: 'input', editable: true, unique: true, + strict: true, copy: true, rules: [{ pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, diff --git a/src/menu/stylecontroller/index.jsx b/src/menu/stylecontroller/index.jsx index e06a198..6acd6cc 100644 --- a/src/menu/stylecontroller/index.jsx +++ b/src/menu/stylecontroller/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Collapse, Form, Col, InputNumber, Input, Select, Radio, Drawer, Button } from 'antd' +import { Collapse, Form, Col, InputNumber, Input, Select, Radio, Drawer, Button, message } from 'antd' import { ColumnHeightOutlined, FontSizeOutlined, @@ -29,7 +29,7 @@ ArrowLeftOutlined, ArrowRightOutlined, SwapOutlined, - EnterOutlined, + EnterOutlined } from '@ant-design/icons' import MKEmitter from '@/utils/events.js' @@ -42,6 +42,7 @@ const { Panel } = Collapse const { Option } = Select const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) +const PasteBoard = asyncComponent(() => import('@/components/pasteboard')) const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent')) class MobController extends Component { @@ -453,6 +454,77 @@ this.updateStyle({[type]: val}) } + copy = () => { + const { card, options } = this.state + + let msg = { copyType: 'style' } + + msg.data = card + msg.options = options + + try { + msg = window.btoa(window.encodeURIComponent(JSON.stringify(msg))) + } catch (e) { + console.warn('Stringify Failure') + msg = '' + } + + if (msg) { + let oInput = document.createElement('input') + oInput.value = msg + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + message.success('澶嶅埗鎴愬姛銆�') + } + } + + paste = (res, callback) => { + const { options } = this.state + + if (res.copyType !== 'style') { + message.warning('閰嶇疆淇℃伅鏍煎紡閿欒锛�', 5) + return + } else if (JSON.stringify(res.options) !== JSON.stringify(options)) { + message.warning('鏍峰紡閫夐」涓嶄竴鑷达紝涓嶅彲绮樿创锛�', 5) + return + } + + let style = res.data || {} + + let backgroundImage = '' + if (style.backgroundImage && /^url/ig.test(style.backgroundImage)) { + backgroundImage = style.backgroundImage.replace(/^url\(/ig, '').replace(/\)$/ig, '') + } + + let borposition = 'outer' + + if (!style.borderWidth) { + if (style.borderLeftWidth) { + borposition = 'left' + } else if (style.borderRightWidth) { + borposition = 'right' + } else if (style.borderTopWidth) { + borposition = 'top' + } else if (style.borderBottomWidth) { + borposition = 'bottom' + } + } + + this.setState({ + card: style, + borposition, + backgroundImage + }) + + this.callback && this.callback(style) + + callback() + + message.success('绮樿创鎴愬姛銆�') + } + render () { const { card, options, backgroundImage, borposition, fonts, type } = this.state const formItemLayout = { @@ -561,7 +633,7 @@ label={<FontColorsOutlined title="瀛椾綋棰滆壊"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <ColorSketch value={card.color || 'rgba(0, 0, 0, 0.85)'} onChange={this.changeFontColor} /> + <ColorSketch value={card.color || ''} onChange={this.changeFontColor} /> </Form.Item> <Form.Item colon={false} @@ -771,11 +843,11 @@ label={<BgColorsOutlined title="杈规棰滆壊"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - {borposition === 'outer' ? <ColorSketch value={card.borderColor || 'transparent'} onChange={this.changeBorderColor} /> : null} - {borposition === 'left' ? <ColorSketch value={card.borderLeftColor || 'transparent'} onChange={this.changeBorderColor} /> : null} - {borposition === 'right' ? <ColorSketch value={card.borderRightColor || 'transparent'} onChange={this.changeBorderColor} /> : null} - {borposition === 'top' ? <ColorSketch value={card.borderTopColor || 'transparent'} onChange={this.changeBorderColor} /> : null} - {borposition === 'bottom' ? <ColorSketch value={card.borderBottomColor || 'transparent'} onChange={this.changeBorderColor} /> : null} + {borposition === 'outer' ? <ColorSketch value={card.borderColor || ''} onChange={this.changeBorderColor} /> : null} + {borposition === 'left' ? <ColorSketch value={card.borderLeftColor || ''} onChange={this.changeBorderColor} /> : null} + {borposition === 'right' ? <ColorSketch value={card.borderRightColor || ''} onChange={this.changeBorderColor} /> : null} + {borposition === 'top' ? <ColorSketch value={card.borderTopColor || ''} onChange={this.changeBorderColor} /> : null} + {borposition === 'bottom' ? <ColorSketch value={card.borderBottomColor || ''} onChange={this.changeBorderColor} /> : null} </Form.Item> <Form.Item colon={false} @@ -802,7 +874,7 @@ label={<BgColorsOutlined title="闃村奖棰滆壊"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <ColorSketch value={card.shadowColor || 'transparent'} onChange={this.changeShadowColor} /> + <ColorSketch value={card.shadowColor || ''} onChange={this.changeShadowColor} /> </Form.Item> <Form.Item colon={false} @@ -972,8 +1044,12 @@ </Panel> : null} </Collapse> : null} </Form> - <div style={{textAlign: 'right'}}> - <Button style={{margin: '30px 10px 30px 0px'}} onClick={this.onCloseDrawer}>鍏抽棴</Button> + <div style={{textAlign: 'right', lineHeight: '60px', marginBottom: '30px'}}> + <div style={{float: 'left'}}> + <Button onClick={() => this.copy()} className="mk-border-green" style={{marginRight: '10px'}}>澶嶅埗</Button> + <PasteBoard getPasteValue={this.paste}><Button style={{borderColor: 'rgb(64, 169, 255)', color: 'rgb(64, 169, 255)'}}>绮樿创</Button></PasteBoard> + </div> + <Button style={{marginRight: '10px'}} onClick={this.onCloseDrawer}>鍏抽棴</Button> </div> </div> </Drawer> diff --git a/src/mob/colorsketch/index.jsx b/src/mob/colorsketch/index.jsx index 65c7df6..63abecf 100644 --- a/src/mob/colorsketch/index.jsx +++ b/src/mob/colorsketch/index.jsx @@ -140,7 +140,7 @@ <div className="color-sketch-block-inner" style={ {background: color} }></div> </div> </Popover> - <div className="color-sketch-value">{color}{allowClear && color ? <CloseCircleFilled onClick={this.clear}/> : null}</div> + <div className="color-sketch-value">{color || <span style={{color: '#ff4d4f'}}>鏃�</span>}{allowClear && color ? <CloseCircleFilled onClick={this.clear}/> : null}</div> </div> ) } diff --git a/src/tabviews/basetable/index.jsx b/src/tabviews/basetable/index.jsx index c479441..59932b9 100644 --- a/src/tabviews/basetable/index.jsx +++ b/src/tabviews/basetable/index.jsx @@ -348,10 +348,29 @@ cell.$MenuID = this.props.MenuID cell.$view = 'popview' - if (cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } } } @@ -414,10 +433,29 @@ cell.$view = 'popview' cell.$toolbtn = true - if (cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } } } diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 42725b3..0eef227 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -473,9 +473,7 @@ item.search = Utils.initSearchVal(item.search) } - let mutil = false if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢 - mutil = true item.setting.supModule = item.supNodes[0].componentId } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') { let pid = item.setting.supModule.pop() @@ -500,13 +498,6 @@ cell = this.resetButton(item, cell, popview) cell.$toolbtn = true - - if (!mutil && cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -553,13 +544,6 @@ if (cell.hidden === 'true') return false cell = this.resetButton(item, cell, popview) - - if (cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -618,13 +602,6 @@ cell = this.resetButton(item, cell, popview) - if (!mutil && cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } - if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) } @@ -642,13 +619,6 @@ if (cell.hidden === 'true') return false cell = this.resetButton(item, cell, popview) - - if (!mutil && cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -673,13 +643,6 @@ if (cell.hidden === 'true') return false cell = this.resetButton(item, cell, popview) - - if (cell.syncComponentId && cell.syncComponentId === item.wrap.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -805,6 +768,32 @@ } } + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } + } + } + return cell } diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx index aba165f..92c41c2 100644 --- a/src/tabviews/custom/popview/index.jsx +++ b/src/tabviews/custom/popview/index.jsx @@ -302,9 +302,7 @@ item.search = Utils.initSearchVal(item.search) } - let mutil = false if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢 - mutil = true item.setting.supModule = item.supNodes[0].componentId } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') { let pid = item.setting.supModule.pop() @@ -322,13 +320,6 @@ cell = this.resetButton(item, cell, Tab) cell.$toolbtn = true - - if (!mutil && cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } return true }) @@ -371,13 +362,6 @@ if (cell.hidden === 'true' || cell.OpenType === 'popview') return false cell = this.resetButton(item, cell, Tab) - - if (cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } } else { cell = this.resetElement(cell) } @@ -430,13 +414,6 @@ if (cell.hidden === 'true' || cell.OpenType === 'popview') return false cell = this.resetButton(item, cell, Tab) - - if (!mutil && cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } } else { cell = this.resetElement(cell) } @@ -451,13 +428,6 @@ if (cell.hidden === 'true' || cell.OpenType === 'popview') return false cell = this.resetButton(item, cell, Tab) - - if (!mutil && cell.syncComponentId && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } } else { cell = this.resetElement(cell) } @@ -478,13 +448,6 @@ if (cell.hidden === 'true' || cell.OpenType === 'popview') return false cell = this.resetButton(item, cell, Tab) - - if (cell.syncComponentId && cell.syncComponentId === item.wrap.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } } else { cell = this.resetElement(cell) } @@ -598,6 +561,32 @@ } } + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } + } + } + return cell } diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 8856f16..2abe56f 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -199,8 +199,18 @@ MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines) } - btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) - + if (btn.syncComponentId) { + if (btn.syncComponentId === 'multiComponent') { + btn.syncComponentIds.forEach((id, i) => { + setTimeout(() => { + MKEmitter.emit('reloadData', id) + }, 20 * i) + }) + } else { + MKEmitter.emit('reloadData', btn.syncComponentId) + } + } + if (btn.switchTab && btn.switchTab.length > 0) { let id = btn.switchTab[btn.switchTab.length - 1] let node = document.getElementById('tab' + id) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index 2d08e57..78fc739 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -1118,7 +1118,17 @@ MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', []) } - btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) + if (btn.syncComponentId) { + if (btn.syncComponentId === 'multiComponent') { + btn.syncComponentIds.forEach((id, i) => { + setTimeout(() => { + MKEmitter.emit('reloadData', id) + }, 20 * i) + }) + } else { + MKEmitter.emit('reloadData', btn.syncComponentId) + } + } if (btn.switchTab && btn.switchTab.length > 0) { let id = btn.switchTab[btn.switchTab.length - 1] diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 4a56408..07a4c6c 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -2050,7 +2050,17 @@ MKEmitter.emit('refreshDebugTable') } - btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) + if (btn.syncComponentId) { + if (btn.syncComponentId === 'multiComponent') { + btn.syncComponentIds.forEach((id, i) => { + setTimeout(() => { + MKEmitter.emit('reloadData', id) + }, 20 * i) + }) + } else { + MKEmitter.emit('reloadData', btn.syncComponentId) + } + } if (tabId) { MKEmitter.emit('reloadMenuView', tabId, 'table') diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx index 247d5bb..f61eadf 100644 --- a/src/tabviews/zshare/actionList/popupbutton/index.jsx +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -222,7 +222,17 @@ MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.popClose, btn) } - btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) + if (btn.syncComponentId) { + if (btn.syncComponentId === 'multiComponent') { + btn.syncComponentIds.forEach((id, i) => { + setTimeout(() => { + MKEmitter.emit('reloadData', id) + }, 20 * i) + }) + } else { + MKEmitter.emit('reloadData', btn.syncComponentId) + } + } } getPop = () => { diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx index 028c456..ad29e43 100644 --- a/src/templates/zshare/editTable/index.jsx +++ b/src/templates/zshare/editTable/index.jsx @@ -3,17 +3,17 @@ import { is, fromJS } from 'immutable' import { DndProvider, DragSource, DropTarget } from 'react-dnd' import { Table, Input, InputNumber, Popconfirm, Form, Select, Radio, Cascader, notification, message, Modal, Typography } from 'antd' -import { CopyOutlined, EditOutlined, DeleteOutlined, SnippetsOutlined, SwapOutlined } from '@ant-design/icons' +import { CopyOutlined, EditOutlined, DeleteOutlined, SwapOutlined } from '@ant-design/icons' import Utils from '@/utils/utils.js' import ColorSketch from '@/mob/colorsketch' -import PasteForm from '@/templates/zshare/pasteform' import asyncComponent from '@/utils/asyncComponent' import CusSwitch from './cusSwitch' import MKEmitter from '@/utils/events.js' import './index.scss' const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) +const PasteBoard = asyncComponent(() => import('@/components/pasteboard')) const EditableContext = React.createContext() const { confirm } = Modal let dragingIndex = -1 @@ -172,7 +172,6 @@ state = { data: [], editingKey: '', - visible: false, editLineId: '', columns: [] } @@ -196,7 +195,7 @@ 鎿嶄綔 <span className="copy-control"> {actions.includes('copy') ? <CopyOutlined title="澶嶅埗" onClick={() => this.copy()} /> : null} - {actions.includes('copy') ? <SnippetsOutlined title="绮樿创" onClick={this.paste} /> : null} + {actions.includes('copy') ? <PasteBoard getPasteValue={this.pasteSubmit}/> : null} {actions.includes('clear') ? <DeleteOutlined title="娓呯┖" onClick={this.clear} /> : null} </span> </div>), @@ -352,66 +351,74 @@ } } - paste = () => { - this.setState({visible: true}) - } - - pasteSubmit = () => { + pasteSubmit = (res, callback) => { const { type } = this.props const { columns } = this.state let data = fromJS(this.state.data).toJS() - this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType === 'columns' && type === 'datasourcefield') { - res.type = 'array' - res.data = [] - res.columns.forEach(col => { - if (!col.field) return - if (col.type === 'number') { - let datatype = 'Int' - if (col.decimal) { - datatype = `Decimal(18,${col.decimal})` - } - - res.data.push({ - $index: res.data.length + 1, - datatype: datatype, - field: col.field, - decimal: col.decimal, - label: col.label, - type: 'number', - uuid: Utils.getuuid() - }) - } else { - let datatype = 'Nvarchar(50)' - let fieldlength = 50 - if (col.fieldlength && [10, 20, 50, 100, 256, 512, 1024, 2048].includes(col.fieldlength)) { - fieldlength = col.fieldlength - datatype = `Nvarchar(${fieldlength})` - } - - res.data.push({ - $index: res.data.length + 1, - datatype: datatype, - field: col.field, - fieldlength: fieldlength, - label: col.label, - type: 'text', - uuid: Utils.getuuid() - }) + if (res.copyType === 'columns' && type === 'datasourcefield') { + res.type = 'array' + res.data = [] + res.columns.forEach(col => { + if (!col.field) return + if (col.type === 'number') { + let datatype = 'Int' + if (col.decimal) { + datatype = `Decimal(18,${col.decimal})` } - }) - } else if (res.key !== type) { - message.warning('閰嶇疆淇℃伅鏍煎紡閿欒锛�') - return - } - if (res.type === 'line') { - let unique = true - res.data.uuid = Utils.getuuid() - columns.forEach(col => { - if (col.unique !== true || !unique) return + res.data.push({ + $index: res.data.length + 1, + datatype: datatype, + field: col.field, + decimal: col.decimal, + label: col.label, + type: 'number', + uuid: Utils.getuuid() + }) + } else { + let datatype = 'Nvarchar(50)' + let fieldlength = 50 + if (col.fieldlength && [10, 20, 50, 100, 256, 512, 1024, 2048].includes(col.fieldlength)) { + fieldlength = col.fieldlength + datatype = `Nvarchar(${fieldlength})` + } + res.data.push({ + $index: res.data.length + 1, + datatype: datatype, + field: col.field, + fieldlength: fieldlength, + label: col.label, + type: 'text', + uuid: Utils.getuuid() + }) + } + }) + } else if (res.key !== type) { + message.warning('閰嶇疆淇℃伅鏍煎紡閿欒锛�') + return + } + + if (res.type === 'line') { + let unique = true + res.data.uuid = Utils.getuuid() + columns.forEach(col => { + if (col.unique !== true || !unique) return + + if (col.strict) { + let key = res.data[col.dataIndex].toLowerCase() + let _index = data.findIndex(item => key === item[col.dataIndex].toLowerCase()) + + if (_index > -1) { + notification.warning({ + top: 92, + message: col.title + '涓嶅彲閲嶅锛�', + duration: 5 + }) + unique = false + } + } else { let _index = data.findIndex(item => res.data[col.dataIndex] === item[col.dataIndex]) if (_index > -1) { @@ -422,38 +429,49 @@ }) unique = false } - }) + } + }) - if (!unique) return + if (!unique) return - data.unshift(res.data) - this.setState({ data, editingKey: '', editLineId: res.data.uuid || '', visible: false }, () => { - this.props.onChange(data) - }) - } else if (res.type === 'array') { - res.data.forEach(cell => { - let unique = true - cell.uuid = Utils.getuuid() - columns.forEach(col => { - if (col.unique !== true || !unique) return + data.unshift(res.data) + this.setState({ data, editingKey: '', editLineId: res.data.uuid || '' }, () => { + this.props.onChange(data) + }) + } else if (res.type === 'array') { + res.data.forEach(cell => { + let unique = true + cell.uuid = Utils.getuuid() + columns.forEach(col => { + if (col.unique !== true || !unique) return + + if (col.strict) { + let _index = data.findIndex(item => cell[col.dataIndex].toLowerCase() === item[col.dataIndex].toLowerCase()) + + if (_index > -1) { + unique = false + } + } else { let _index = data.findIndex(item => cell[col.dataIndex] === item[col.dataIndex]) if (_index > -1) { unique = false } - }) - - if (!unique) return - - data.push(cell) + } }) - this.setState({ data, editingKey: '', visible: false }, () => { - this.props.onChange(data) - }) - } - message.success('绮樿创鎴愬姛銆�') - }) + if (!unique) return + + data.push(cell) + }) + + this.setState({ data, editingKey: '' }, () => { + this.props.onChange(data) + }) + } + + callback() + message.success('绮樿创鎴愬姛銆�') } handleStatus = (record) => { @@ -673,18 +691,6 @@ })} /> </DndProvider> - {/* 淇℃伅绮樿创 */} - <Modal - title="绮樿创" - visible={this.state.visible} - width={600} - maskClosable={false} - onOk={this.pasteSubmit} - onCancel={() => {this.setState({visible: false})}} - destroyOnClose - > - <PasteForm wrappedComponentRef={(inst) => this.pasteFormRef = inst} inputSubmit={this.pasteSubmit}/> - </Modal> </div> </EditableContext.Provider> ) diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index 2fde239..6cb5386 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -19,6 +19,8 @@ } else if (item.type === 'tabs') { if (item.subtype === 'tabletabs') { item.subtabs.forEach(tab => { + if (tab.components[0].uuid === selfId) return + modules.push({ value: tab.components[0].uuid, label: tab.label, @@ -655,7 +657,12 @@ if (btn.anchors && btn.anchors.length > 0) { btn.anchors = btn.anchors.map(m => md5(commonId + m)) } - if (btn.syncComponent && btn.syncComponent.length > 0) { + if (btn.syncComponent && btn.syncComponent[0] === 'multiComponent' && btn.syncComponents) { + btn.syncComponents = btn.syncComponents.map(m => { + m.syncComId = m.syncComId.map(n => md5(commonId + n)) + return m + }) + } else if (btn.syncComponent && btn.syncComponent.length > 0) { btn.syncComponent = btn.syncComponent.map(m => md5(commonId + m)) } } -- Gitblit v1.8.0