From e5fc2d92b1036aabf9ffc2c9706ed401bd9735c8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 09 九月 2021 18:14:29 +0800 Subject: [PATCH] 2021-09-09 --- src/menu/components/card/cardcellcomponent/index.jsx | 376 +++++++++++++++++++++++++++-------------------------- 1 files changed, 189 insertions(+), 187 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index fcb32ec..58f38e9 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -1,7 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import {connect} from 'react-redux' import { Modal, Button } from 'antd' import zhCN from '@/locales/zh-CN/model.js' @@ -11,7 +10,7 @@ import { getActionForm } from '@/menu/components/share/actioncomponent/formconfig' import MKEmitter from '@/utils/events.js' -import MenuUtils from '@/menu/utils/menuUtils.js' +import MenuUtils from '@/utils/utils-custom.js' import ElementForm from './elementform' import DragElement from './dragaction' import './index.scss' @@ -35,6 +34,7 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + appType: sessionStorage.getItem('appType'), card: null, // 缂栬緫涓厓绱� formlist: null, // 琛ㄥ崟淇℃伅 elements: null, // 鎸夐挳缁� @@ -48,16 +48,25 @@ */ UNSAFE_componentWillMount () { const { elements } = this.props + let _elements = fromJS(elements).toJS() this.setState({ - elements: fromJS(elements).toJS() + elements: _elements.map(item => { + if (item.btnstyle) { // 鍏煎 + item.style = item.style || {} + item.style = {...item.style, ...item.btnstyle} + delete item.btnstyle + } + + return item + }) }) } componentDidMount () { - MKEmitter.addListener('cardAddElement', this.cardAddElement) MKEmitter.addListener('submitStyle', this.getStyle) MKEmitter.addListener('submitModal', this.handleSave) + MKEmitter.addListener('cardAddElement', this.cardAddElement) MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) } @@ -84,9 +93,9 @@ this.setState = () => { return } - MKEmitter.removeListener('cardAddElement', this.cardAddElement) MKEmitter.removeListener('submitStyle', this.getStyle) MKEmitter.removeListener('submitModal', this.handleSave) + MKEmitter.removeListener('cardAddElement', this.cardAddElement) MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) } @@ -127,12 +136,10 @@ const { cards, cardCell } = this.props let _style = element.style ? fromJS(element.style).toJS() : {} - let options = ['font', 'border', 'padding', 'margin', 'backgroundColor'] + let options = ['font', 'border', 'padding', 'margin', 'background'] if (element.eleType === 'button') { - if (element.btnstyle) { - _style = {..._style, ...element.btnstyle} - } + options.push('width', 'float') } else if (element.eleType === 'picture') { options = ['border', 'margin'] } else if (element.eleType === 'slider') { @@ -152,7 +159,13 @@ const { cards, cardCell } = this.props const { card, elements } = this.state - if (comIds.length !== 3 || comIds[0] !== cards.uuid || comIds[1] !== cardCell.uuid) return + if (comIds.length !== 3 || comIds[0] !== cards.uuid || comIds[1] !== cardCell.uuid || !card) return + + if (card.eleType === 'button') { + if ((style.paddingLeft || style.paddingRight) && !style.width) { + style.width = 'auto' + } + } let _card = this.resetCardStyle(card, style) @@ -171,12 +184,12 @@ resetCardStyle = (card, style) => { let _card = fromJS(card).toJS() - if (_card.eleType === 'text' || _card.eleType === 'number') { + if (['text', 'number', 'formula'].includes(_card.eleType)) { _card.style = style let fontSize = 14 let lineHeight = 1.5 - let line = _card.height || 1 + let line = _card.height || null if (_card.style.fontSize) { fontSize = parseInt(_card.style.fontSize) @@ -185,7 +198,20 @@ lineHeight = parseFloat(_card.style.lineHeight) } - _card.innerHeight = fontSize * lineHeight * line + if (line) { + _card.innerHeight = fontSize * lineHeight * line + } + } else if (_card.eleType === 'sequence') { + _card.style = style + + let fontSize = 14 + let lineHeight = 1.5 + + if (_card.style.fontSize) { + fontSize = parseInt(_card.style.fontSize) + } + + _card.innerHeight = fontSize * lineHeight } else if (_card.eleType === 'barcode') { _card.style = style @@ -197,47 +223,7 @@ _card.innerHeight = _card.barHeight + (_card.displayValue === 'true' ? fontSize + 2 : 0) } else if (_card.eleType === 'button') { // 鎷嗗垎style - let _style = fromJS(style).toJS() - _card.style = {} - - if (_style.marginTop) { - _card.style.marginTop = _style.marginTop - delete _style.marginTop - } - if (_style.marginBottom) { - _card.style.marginBottom = _style.marginBottom - delete _style.marginBottom - } - if (_style.marginLeft) { - _card.style.marginLeft = _style.marginLeft - delete _style.marginLeft - } - if (_style.marginRight) { - _card.style.marginRight = _style.marginRight - delete _style.marginRight - } - if (_style.paddingTop) { - _card.style.paddingTop = _style.paddingTop - delete _style.paddingTop - } - if (_style.paddingBottom) { - _card.style.paddingBottom = _style.paddingBottom - delete _style.paddingBottom - } - if (_style.paddingLeft) { - _card.style.paddingLeft = _style.paddingLeft - delete _style.paddingLeft - } - if (_style.paddingRight) { - _card.style.paddingRight = _style.paddingRight - delete _style.paddingRight - } - if (_style.textAlign) { - _card.style.textAlign = _style.textAlign - delete _style.textAlign - } - - _card.btnstyle = _style + _card.style = style } else { _card.style = style } @@ -258,7 +244,7 @@ * @description 鍏冪礌缂栬緫锛岃幏鍙栧厓绱犺〃鍗曚俊鎭� */ handleElement = (card) => { - const { cards } = this.props + const { cards, cardCell } = this.props if (card.eleType === 'button') { this.handleAction(card) @@ -266,7 +252,7 @@ this.setState({ visible: true, card: card, - formlist: getCardCellForm(card, cards.type) + formlist: getCardCellForm(card, cards.type, cards.subtype, cardCell) }) } } @@ -275,13 +261,13 @@ * @description 鎸夐挳缂栬緫锛岃幏鍙栨寜閽〃鍗曚俊鎭� */ handleAction = (card) => { - const { menu, cards } = this.props + const { cards } = this.props let usefulFields = sessionStorage.getItem('permFuncField') if (usefulFields) { try { usefulFields = JSON.parse(usefulFields) - } catch { + } catch (e) { usefulFields = [] } } else { @@ -297,19 +283,19 @@ if (menulist) { try { menulist = JSON.parse(menulist) - } catch { + } catch (e) { menulist = [] } } else { menulist = [] } - let modules = MenuUtils.getSubModules(menu.components, cards.uuid) + let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, cards.uuid) this.setState({ actvisible: true, card: card, - formlist: getActionForm(card, functip, cards.setting, usefulFields, 'card', menulist, modules) + formlist: getActionForm(card, functip, cards, usefulFields, 'card', menulist, modules) }) } @@ -317,11 +303,15 @@ * @description 鍙栨秷淇濆瓨锛屽鏋滃厓绱犱负鏂版坊鍏冪礌锛屽垯浠庡簭鍒椾腑鍒犻櫎 */ editModalCancel = () => { - const { card, elements } = this.state + const { card, elements, appType } = this.state let _elements = null if (card.focus) { _elements = elements.filter(item => item.uuid !== card.uuid) + + if (card.OpenType === 'popview' && appType !== 'mob') { // 寮圭獥鏍囩鎸夐挳锛屼粠澶嶅埗鍒楄〃涓垹闄� + MKEmitter.emit('delButtons', [card.uuid]) + } } else { _elements = elements } @@ -331,6 +321,8 @@ elements: _elements, visible: false, actvisible: false + }, () => { + this.props.updateElement(_elements) }) } @@ -348,10 +340,10 @@ if (res.eleType === 'splitline' && cell.eleType !== 'splitline') { res.style.paddingTop = '5px' res.style.paddingBottom = '5px' - } else if (res.eleType === 'text' || res.eleType === 'number') { + } else if (['text', 'number', 'formula'].includes(res.eleType)) { let fontSize = 14 let lineHeight = 1.5 - let line = res.height || 1 + let line = res.height || null if (res.style && res.style.fontSize) { fontSize = parseInt(res.style.fontSize) @@ -359,7 +351,10 @@ if (res.style && res.style.lineHeight) { lineHeight = parseFloat(res.style.lineHeight) } - res.innerHeight = fontSize * lineHeight * line + + if (line) { + res.innerHeight = fontSize * lineHeight * line + } if (res.eleType === 'text' && res.link && !res.style.color) { res.style.color = '#2440B3' @@ -400,18 +395,18 @@ if (cell.uuid === res.uuid) { res = {...cell, ...res} delete res.focus - let btnstyle = {} + let style = {} - if (res.class !== cell.class || res.show !== cell.show || !res.btnstyle) { + if (res.class !== cell.class || res.show !== cell.show || !res.style) { if (res.show === 'link' || res.show === 'icon') { - btnstyle.color = color[res.class] - btnstyle.backgroundColor = 'transparent' + style.color = color[res.class] + style.backgroundColor = 'transparent' } else { - btnstyle.color = '#ffffff' - btnstyle.backgroundColor = color[res.class] + style.color = '#ffffff' + style.backgroundColor = color[res.class] } } - res.btnstyle = {...res.btnstyle, ...btnstyle} + res.style = {...res.style, ...style} return res } @@ -432,17 +427,14 @@ */ deleteElement = (card) => { const { cards, cardCell, side } = this.props - const { dict, elements } = this.state + const { dict, elements, appType } = this.state let _this = this confirm({ content: dict['model.confirm'] + dict['model.delete'] + '鍏冪礌鍚楋紵', onOk() { let _elements = elements.filter(item => item.uuid !== card.uuid) - - if (card.eleType === 'button') { - MKEmitter.emit('delButtons', [card.uuid]) - } + if (card.OpenType === 'popview' || card.verify || card.modal) { card.$parentId = cardCell.uuid card.$side = side || '' @@ -455,6 +447,11 @@ }, () => { _this.props.updateElement(_elements) }) + + if (card.eleType !== 'button') return + if (appType === 'mob' || (appType === 'pc' && card.OpenType !== 'popview')) return + + MKEmitter.emit('delButtons', [card.uuid]) }, onCancel() {} }) @@ -496,23 +493,38 @@ handleSubConfig = (item) => { const { cards } = this.props + const { appType } = this.state let btn = fromJS(item).toJS() - if (btn.eleType !== 'button' || (sessionStorage.getItem('style-control') && sessionStorage.getItem('style-control') !== 'false')) return + if ((sessionStorage.getItem('style-control') && sessionStorage.getItem('style-control') === 'true')) return - if (btn.OpenType === 'pop') { - if (!btn.modal) { - btn.modal = { - setting: { title: btn.label, width: 60, cols: '2', container: 'view', focus: '', finish: 'close', clickouter: 'unclose', display: 'modal' }, - tables: [], - groups: [], - fields: [] + if (btn.eleType === 'button') { + if (btn.OpenType === 'pop') { + if (!btn.modal) { + btn.modal = { + setting: { title: btn.label, width: appType === 'mob' ? 100 : 60, cols: '2', container: 'view', focus: '', finish: 'close', clickouter: 'unclose', display: 'modal' }, + tables: [], + groups: [], + fields: [] + } } + + MKEmitter.emit('changeModal', cards, btn) + } else if (btn.OpenType === 'popview') { + MKEmitter.emit('changePopview', cards, btn) + } else if (btn.OpenType === 'innerpage' && btn.pageTemplate === 'page') { + MKEmitter.emit('changeEditMenu', {MenuID: btn.uuid, copyMenuId: btn.copyMenuId}) + } else if (btn.OpenType === 'innerpage' && btn.pageTemplate === 'linkpage') { + MKEmitter.emit('changeEditMenu', {MenuID: btn.linkmenu}) + } else { + this.handleElement(item) } - - MKEmitter.emit('changeModal', cards, btn) - } else if (btn.OpenType === 'popview') { - MKEmitter.emit('changePopview', cards, btn) + } else { + if (btn.link === 'page') { + MKEmitter.emit('changeEditMenu', {MenuID: btn.uuid, copyMenuId: btn.copyMenuId}) + } else if (btn.link === 'linkpage') { + MKEmitter.emit('changeEditMenu', {MenuID: btn.linkmenu}) + } } } @@ -569,12 +581,11 @@ btn.eleType = 'button' let _elements = [...this.state.elements, btn] - let _action = cards.action.filter(item => item.uuid !== id) this.setState({ elements: _elements }, () => { - this.props.updateElement(_elements, _action) + this.props.updateElement(_elements, btn) }) } @@ -597,108 +608,99 @@ handleSubConfig={this.handleSubConfig} deleteMenu={this.deleteElement} /> - {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} - <Modal - title={'缂栬緫鍏冪礌'} - visible={visible} - width={800} - maskClosable={false} - onCancel={this.editModalCancel} - onOk={this.handleSubmit} - destroyOnClose - > - <ElementForm - dict={dict} - card={card} - formlist={this.state.formlist} - inputSubmit={this.handleSubmit} - config={cards} - wrappedComponentRef={(inst) => this.elementFormRef = inst} - /> - </Modal> - {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} - <Modal - title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} - visible={actvisible} - width={800} - maskClosable={false} - onCancel={this.editModalCancel} - footer={[ - <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>, - <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>{dict['model.confirm']}</Button> - ]} - destroyOnClose - > - <ActionForm - dict={dict} - type="card" - card={card} - formlist={this.state.formlist} - inputSubmit={this.handleActionSubmit} - setting={cards.setting} - wrappedComponentRef={(inst) => this.actionFormRef = inst} - /> - </Modal> - {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} - <Modal - wrapClassName="model-table-action-verify-modal" - title={'楠岃瘉淇℃伅'} - visible={profVisible} - width={'75vw'} - maskClosable={false} - style={{minWidth: '900px', maxWidth: '1200px'}} - okText={dict['model.submit']} - onOk={this.verifySubmit} - onCancel={() => { this.setState({ profVisible: false }) }} - destroyOnClose - > - {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ? - <VerifyCard - card={card} + <div onDoubleClick={(e) => e.stopPropagation()}> + {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} + <Modal + title={'缂栬緫鍏冪礌'} + visible={visible} + width={800} + maskClosable={false} + onCancel={this.editModalCancel} + onOk={this.handleSubmit} + destroyOnClose + > + <ElementForm dict={dict} + card={card} + formlist={this.state.formlist} + inputSubmit={this.handleSubmit} config={cards} - columns={cards.columns} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - {card && card.execMode ? - <VerifyPrint - card={card} + wrappedComponentRef={(inst) => this.elementFormRef = inst} + /> + </Modal> + {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} + <Modal + title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} + visible={actvisible} + width={800} + maskClosable={false} + onCancel={this.editModalCancel} + footer={[ + <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>, + <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>{dict['model.confirm']}</Button> + ]} + destroyOnClose + > + <ActionForm dict={dict} - columns={cards.columns} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - {card && card.OpenType === 'excelIn' ? - <VerifyExcelIn + type={cards.type === 'balcony' ? '' : 'card'} card={card} - dict={dict} - columns={cards.columns} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - {card && card.OpenType === 'excelOut' ? - <VerifyExcelOut - card={card} - dict={dict} - config={cards} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> : null - } - </Modal> + formlist={this.state.formlist} + inputSubmit={this.handleActionSubmit} + setting={cards.setting} + wrappedComponentRef={(inst) => this.actionFormRef = inst} + /> + </Modal> + {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} + <Modal + wrapClassName="model-table-action-verify-modal" + title={'楠岃瘉淇℃伅'} + visible={profVisible} + width={'75vw'} + maskClosable={false} + okText={dict['model.submit']} + onOk={this.verifySubmit} + onCancel={() => { this.setState({ profVisible: false }) }} + destroyOnClose + > + {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ? + <VerifyCard + card={card} + dict={dict} + config={cards} + columns={cards.columns} + wrappedComponentRef={(inst) => this.verifyRef = inst} + /> : null + } + {card && card.execMode ? + <VerifyPrint + card={card} + dict={dict} + columns={cards.columns} + wrappedComponentRef={(inst) => this.verifyRef = inst} + /> : null + } + {card && card.OpenType === 'excelIn' ? + <VerifyExcelIn + card={card} + dict={dict} + columns={cards.columns} + wrappedComponentRef={(inst) => this.verifyRef = inst} + /> : null + } + {card && card.OpenType === 'excelOut' ? + <VerifyExcelOut + card={card} + dict={dict} + config={cards} + wrappedComponentRef={(inst) => this.verifyRef = inst} + /> : null + } + </Modal> + </div> </div> ) } } -const mapStateToProps = (state) => { - return { - menu: state.customMenu - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(CardCellComponent) \ No newline at end of file +export default CardCellComponent \ No newline at end of file -- Gitblit v1.8.0