From 8a6ce370f1aa1c061b76fa3e9d2d4d1df53ca4c5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 五月 2024 16:38:09 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/card/balcony/index.jsx | 376 ++++++++++++++++++++++++++++------------------------ 1 files changed, 202 insertions(+), 174 deletions(-) diff --git a/src/menu/components/card/balcony/index.jsx b/src/menu/components/card/balcony/index.jsx index acb1fd6..516c514 100644 --- a/src/menu/components/card/balcony/index.jsx +++ b/src/menu/components/card/balcony/index.jsx @@ -1,27 +1,23 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Popover, Modal } from 'antd' +import { Popover, Checkbox, message } from 'antd' +import { PlusOutlined, PlusSquareOutlined, EditOutlined, FontColorsOutlined, DeleteOutlined, SettingOutlined, ToolOutlined, ClockCircleOutlined, ColumnHeightOutlined } from '@ant-design/icons' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' -import { resetStyle } from '@/utils/utils-custom.js' +import { resetStyle, getTables, checkComponent } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import Utils from '@/utils/utils.js' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' +import getWrapForm from './options' import './index.scss' const SettingComponent = asyncIconComponent(() => import('@/menu/datasource')) -const WrapComponent = asyncIconComponent(() => import('./wrapsetting')) +const NormalForm = asyncIconComponent(() => import('@/components/normalform')) const CardCellComponent = asyncComponent(() => import('../cardcellcomponent')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) -const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) -const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) +const PasteComponent = asyncIconComponent(() => import('@/components/paste')) const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) -const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) - -const { confirm } = Modal class BalconyEditComponent extends Component { static propTpyes = { @@ -31,7 +27,6 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, card: null, back: false } @@ -40,58 +35,61 @@ const { card } = this.props if (card.isNew) { - // let ismob = sessionStorage.getItem('appType') === 'mob' let _card = { uuid: card.uuid, type: card.type, - floor: card.floor, - tabId: card.tabId || '', - parentId: card.parentId || '', format: 'object', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 pageable: false, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� - dataName: card.dataName || '', width: card.width || 24, name: card.name, subtype: card.subtype, setting: { interType: 'system' }, - wrap: { name: card.name, width: card.width || 24, linkType: 'static', position: 'relative', datatype: 'static' }, - style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' }, + wrap: { name: card.name, width: card.width || 24, linkType: 'static', datatype: 'static' }, + style: { marginLeft: '0px', marginRight: '0px', marginTop: '0px', marginBottom: '0px', position: 'unset' }, columns: [], scripts: [], elements: [], } - if (card.config) { - let config = fromJS(card.config).toJS() + this.updateComponent(_card) + } else { + let _card = fromJS(card).toJS() - _card.wrap = config.wrap - _card.wrap.name = card.name - _card.style = config.style - - _card.elements = _card.elements.map(elem => { - elem.uuid = Utils.getuuid() - return elem - }) + if (!_card.style.position) { // 鍏煎 + if (_card.wrap.position === 'fixed' || _card.wrap.position === 'absolute') { + _card.style.position = _card.wrap.position + _card.style.zIndex = _card.wrap.position === 'fixed' ? 3 : 2 + _card.style.left = _card.wrap.left || '' + _card.style.right = _card.wrap.right || '' + _card.style.top = _card.wrap.top || '' + _card.style.bottom = _card.wrap.bottom || '' + _card.style.transform = _card.wrap.transform || '' + _card.style.width = _card.wrap.realwidth || '' + } else if (_card.wrap.left || _card.wrap.right || _card.wrap.top || _card.wrap.bottom) { + _card.style.position = 'relative' + _card.style.zIndex = 1 + _card.style.left = _card.wrap.left || '' + _card.style.right = _card.wrap.right || '' + _card.style.top = _card.wrap.top || '' + _card.style.bottom = _card.wrap.bottom || '' + } else { + _card.style.position = 'unset' + } } + this.setState({ card: _card - }) - this.props.updateConfig(_card) - } else { - this.setState({ - card: fromJS(card).toJS() }) } } - componentDidMount () { - MKEmitter.addListener('submitStyle', this.getStyle) - MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) - } - shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('mkUpdateInter', this.mkUpdateInter) } /** @@ -101,169 +99,176 @@ this.setState = () => { return } - MKEmitter.removeListener('submitStyle', this.getStyle) - MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) + MKEmitter.removeListener('mkUpdateInter', this.mkUpdateInter) } - updateComponentStyle = (parentId, keys, style) => { + mkUpdateInter = (inter, split) => { const { card } = this.state + + if (card.wrap.datatype === 'public' && card.wrap.publicId === inter.uuid) { + let _card = {...card, columns: fromJS(inter.columns).toJS()} - if (card.uuid !== parentId) return + split.delay = split.delay + 10 - let subcards = card.subcards.map(item => { - if (keys.includes(item.uuid)) { - item.style = {...item.style, ...style} - } - return item - }) - - this.setState({card: {...card, subcards: []}}, () => { - this.updateComponent({...card, subcards: subcards}) - }) + setTimeout(() => { + this.updateComponent(_card) + }, split.delay) + } } /** * @description 鍗$墖琛屽灞備俊鎭洿鏂帮紙鏁版嵁婧愶紝鏍峰紡绛夛級 */ - updateComponent = (component) => { + updateComponent = (card) => { + card.width = card.wrap.width + card.name = card.wrap.name + + if (window.GLOB.styling && card.errors) { // 鏍峰紡淇敼鏃朵笉鍋氱瓫鏌� + this.setState({ + card: card + }) + + this.props.updateConfig(card) + return + } + + card.$c_ds = card.wrap.datatype === 'dynamic' + card.$c_ac = false + card.$c_sc = false + card.$c_el = true + + card.errors = checkComponent(card) + + if (card.errors.length === 0) { + card.$tables = getTables(card) + } + this.setState({ - card: component + card: card }) - - component.width = component.wrap.width - component.name = component.wrap.name - - this.props.updateConfig(component) - } - - /** - * @description 鍗曚釜鍗$墖淇℃伅鏇存柊 - */ - updateCard = (cell) => { - let card = fromJS(this.state.card).toJS() - - card.subcards = card.subcards.map(item => { - if (item.uuid === cell.uuid) return cell - return item - }) - - this.setState({card}) this.props.updateConfig(card) } - /** - * @description 鍗曚釜鍗$墖淇℃伅鏇存柊 - */ - deleteCard = (cell) => { - let card = fromJS(this.state.card).toJS() - let _this = this + updateCard = (elements) => { + const { card } = this.state - confirm({ - content: '纭畾鍒犻櫎鍗$墖鍚楋紵', - onOk() { - card.subcards = card.subcards.filter(item => item.uuid !== cell.uuid) - - let uuids = [] - cell.elements && cell.elements.forEach(c => { - if (c.eleType === 'button') { - uuids.push(c.uuid) - } - }) - cell.backElements && cell.backElements.forEach(c => { - if (c.eleType === 'button') { - uuids.push(c.uuid) - } - }) - MKEmitter.emit('delButtons', uuids) + let _card = {...card, elements: elements} - _this.setState({card}) - _this.props.updateConfig(card) - }, - onCancel() {} - }) + this.updateComponent(_card) } changeStyle = () => { const { card } = this.state - MKEmitter.emit('changeStyle', [card.uuid], ['height', 'background', 'border', 'padding', 'margin'], card.style) + MKEmitter.emit('changeStyle', ['width', 'height', 'background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight', 'position', 'transform'], card.style, this.getStyle) } - getStyle = (comIds, style) => { + getStyle = (style) => { + let _card = {...this.state.card, style} + + this.updateComponent(_card) + } + + addElement = () => { const { card } = this.state - if (comIds.length !== 1 || comIds[0] !== card.uuid) return - - let _card = {...card, style} - - this.setState({ - card: _card - }) + let newcard = {} + newcard.uuid = Utils.getuuid() + newcard.focus = true - this.props.updateConfig(_card) - } + newcard.eleType = 'text' + newcard.datatype = 'dynamic' + newcard.height = 1 - addCard = () => { - let card = fromJS(this.state.card).toJS() - - let newcard = { - uuid: Utils.getuuid(), - setting: { width: 6, type: 'simple'}, - style: { - borderWidth: '1px', borderColor: '#e8e8e8', - paddingTop: '15px', paddingBottom: '15px', paddingLeft: '15px', paddingRight: '15px', - marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' - }, - backStyle: {}, - elements: [], - backElements: [] + if (card.wrap.datatype === 'static') { + newcard.datatype = 'static' } - if (card.subcards.length > 0) { - newcard = fromJS(card.subcards.slice(-1)[0]).toJS() - newcard.uuid = Utils.getuuid() - newcard.elements = newcard.elements.map(elem => { - elem.uuid = Utils.getuuid() - return elem - }) - newcard.backElements = newcard.backElements.map(elem => { - elem.uuid = Utils.getuuid() - return elem - }) - } - - card.subcards.push(newcard) - - this.setState({card}) - this.props.updateConfig(card) + // 娉ㄥ唽浜嬩欢-娣诲姞鍏冪礌 + MKEmitter.emit('cardAddElement', card.uuid, newcard) } - move = (item, direction) => { - let card = fromJS(this.state.card).toJS() + addButton = () => { + const { card } = this.state - let dragIndex = card.subcards.findIndex(c => c.uuid === item.uuid) - let hoverIndex = null + let newcard = {eleType: 'button', label: 'button', verify: null, show: 'link', sqlType: '', Ot: 'requiredSgl', OpenType: 'prompt', icon: '', class: 'primary', intertype: 'system', execSuccess: 'grid', execError: 'never', popClose: 'never'} + newcard.uuid = Utils.getuuid() + newcard.focus = true - if (direction === 'left') { - hoverIndex = dragIndex - 1 + // 娉ㄥ唽浜嬩欢-娣诲姞鍏冪礌 + MKEmitter.emit('cardAddElement', card.uuid, newcard) + } + + pasteComponent = (res, resolve) => { + const { card } = this.state + + let type = res.copyType + delete res.copyType + + res.uuid = Utils.getuuid() + res.focus = true + + if (type === 'customCardElement') { + MKEmitter.emit('cardAddElement', card.uuid, res) } else { - hoverIndex = dragIndex + 1 + res.eleType = 'button' + res.width = res.width || 12 + MKEmitter.emit('cardAddElement', card.uuid, res) } - - if (hoverIndex === -1 || hoverIndex === card.subcards.length) return - - card.subcards.splice(hoverIndex, 0, ...card.subcards.splice(dragIndex, 1)) - - this.setState({card}) - this.props.updateConfig(card) + resolve({status: true}) } - clickComponent = (e) => { - if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { - e.stopPropagation() - MKEmitter.emit('clickComponent', this.state.card) + getWrapForms = () => { + const { card } = this.state + + let buttons = [] + card.elements && card.elements.forEach(item => { + if (item.eleType === 'button') { + buttons.push({ + value: item.uuid, + label: item.label + }) + } + }) + + return getWrapForm(card.wrap, buttons, card.columns) + } + + updateWrap = (res) => { + delete res.quick + + res.linkType = res.linkType || 'static' + + let _card = {...this.state.card, wrap: res} + + if (res.datatype === 'public') { + let interfaces = window.GLOB.customMenu.interfaces || [] + + let d = interfaces.filter(m => m.uuid === res.publicId && m.status === 'true')[0] + + if (d) { + _card.columns = fromJS(d.columns).toJS() + + _card.setting = { interType: 'system' } + _card.scripts = [] + } } + + if (_card.wrap.position === 'fixed') { + if (_card.wrap.top && _card.wrap.bottom && _card.wrap.top.indexOf('vh') > -1 && _card.wrap.bottom.indexOf('vh') > -1) { + if (parseFloat(_card.wrap.top) + parseFloat(_card.wrap.bottom) >= 100) { + message.warning('鍏冪礌璺濅笂璺濅笅涔嬪拰瓒呭嚭100%锛屽彲鑳藉鑷村厓绱犳棤娉曟樉绀恒��') + } + } + if (_card.wrap.left && _card.wrap.right && _card.wrap.left.indexOf('vw') > -1 && _card.wrap.right.indexOf('vw') > -1) { + if (parseFloat(_card.wrap.left) + parseFloat(_card.wrap.right) >= 100) { + message.warning('鍏冪礌璺濆乏璺濆彸涔嬪拰瓒呭嚭100%锛屽彲鑳藉鑷村厓绱犳棤娉曟樉绀恒��') + } + } + } + + this.updateComponent(_card) } render() { @@ -272,26 +277,49 @@ let _style = resetStyle(card.style) return ( - <div className="menu-balcony-edit-box" style={_style} onClick={this.clickComponent} id={card.uuid}> - <NormalHeader defaultshow="hidden" config={card} updateComponent={this.updateComponent}/> + <div className="menu-balcony-edit-box" style={_style} id={card.uuid}> + {card.style.height ? <ColumnHeightOutlined className="fixed-height" title="瀹氶珮" /> : null} <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - <Icon className="plus" title="娣诲姞鍏冪礌" onClick={this.addElement} type="plus" /> - <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> - <WrapComponent config={card} updateConfig={this.updateComponent} /> + <PlusOutlined className="plus" title="娣诲姞鍏冪礌" onClick={this.addElement} /> + <PlusSquareOutlined className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} /> + <NormalForm title="娴姩鍗¤缃�" width={900} update={this.updateWrap} getForms={this.getWrapForms}> + <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/> + </NormalForm> <CopyComponent type="balcony" card={card}/> - <PasteComponent config={card} options={['cardcell']} updateConfig={this.updateComponent} /> - <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> - <ClockComponent config={card} updateConfig={this.updateComponent}/> - <UserComponent config={card}/> - <Icon className="close" title="鍒犻櫎缁勪欢" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> - {card.wrap.datatype !== 'static' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null} - {card.wrap.datatype === 'static' ? <Icon style={{color: '#eeeeee', cursor: 'not-allowed'}} type="setting"/> : null} + <PasteComponent options={['action', 'customCardElement']} updateConfig={this.pasteComponent} /> + <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} /> + {card.wrap.datatype === 'dynamic' ? <ClockComponent config={card} updateConfig={this.updateComponent}/> : <ClockCircleOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/>} + <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> + {card.wrap.datatype === 'dynamic' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : <SettingOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/>} </div> } trigger="hover"> - <Icon type="tool" /> + <ToolOutlined /> </Popover> + {card.wrap.checkAll === 'show' ? <div className="check-all"><Checkbox>鍏ㄩ��</Checkbox></div> : null} <CardCellComponent cards={card} cardCell={card} elements={card.elements} updateElement={this.updateCard}/> + <div className="component-name"> + <div className="center"> + <div className="title" onDoubleClick={() => { + let oInput = document.createElement('input') + oInput.value = 'anchor' + card.uuid + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + message.success('澶嶅埗鎴愬姛銆�') + }}>{card.name}</div> + <div className="content"> + {card.errors && card.errors.map((err, index) => { + if (err.level === 0) { + return <span key={index} className="error">{err.detail}</span> + } else { + return <span key={index} className="waring">{err.detail}锛�</span> + } + })} + </div> + </div> + </div> </div> ) } -- Gitblit v1.8.0