| | |
| | | import demo3 from '@/assets/img/demo3.jpg' |
| | | import demo4 from '@/assets/img/demo4.jpg' |
| | | import demo5 from '@/assets/img/demo5.jpg' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncIconComponent from '@/utils/asyncIconComponent' |
| | | |
| | |
| | | const Video = asyncComponent(() => import('@/components/video')) |
| | | const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent')) |
| | | |
| | | const Card = ({ id, fields, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, updateMarks }) => { |
| | | const Card = ({ id, parent, fields, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, updateMarks }) => { |
| | | const originalIndex = findCard(id).index |
| | | const [{ isDragging }, drag] = useDrag({ |
| | | item: { type: 'action', id, originalIndex }, |
| | |
| | | } |
| | | } |
| | | |
| | | const clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'cardcell') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', card, parent, 'cardcell') |
| | | } |
| | | } |
| | | |
| | | return ( |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | |
| | | </div> |
| | | } trigger="hover"> |
| | | <div ref={node => drag(drop(node))} className={'ant-col card-cell ant-col-' + card.width}> |
| | | <div style={_style}> |
| | | <div style={_style} onClick={clickComponent} id={card.uuid}> |
| | | {getContent()} |
| | | </div> |
| | | </div> |
| | |
| | | import Action from './action' |
| | | import './index.scss' |
| | | |
| | | const Container = ({list, fields, handleList, handleMenu, deleteMenu, profileAction, handleStyle, updateMarks, dropButton, handleSubConfig }) => { |
| | | const Container = ({list, parent, fields, handleList, handleMenu, deleteMenu, profileAction, handleStyle, updateMarks, dropButton, handleSubConfig }) => { |
| | | const [cards, setCards] = useState(list) |
| | | const moveCard = (id, atIndex) => { |
| | | const { card, index } = findCard(id) |
| | |
| | | |
| | | const doubleClickCard = id => { |
| | | const { card } = findCard(id) |
| | | if (card.OpenType === 'pop') { |
| | | handleSubConfig(card) |
| | | } |
| | | handleSubConfig(card) |
| | | } |
| | | |
| | | const delCard = id => { |
| | |
| | | id={card.uuid} |
| | | key={card.uuid} |
| | | card={card} |
| | | parent={parent} |
| | | moveCard={moveCard} |
| | | editCard={editCard} |
| | | changeStyle={changeStyle} |
| | |
| | | id={card.uuid} |
| | | key={card.uuid} |
| | | card={card} |
| | | parent={parent} |
| | | fields={fields} |
| | | moveCard={moveCard} |
| | | copyCard={copyCard} |
| | |
| | | MKEmitter.addListener('cardAddElement', this.cardAddElement) |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | MKEmitter.addListener('submitModal', this.handleSave) |
| | | MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | MKEmitter.removeListener('cardAddElement', this.cardAddElement) |
| | | MKEmitter.removeListener('submitStyle', this.getStyle) |
| | | MKEmitter.removeListener('submitModal', this.handleSave) |
| | | MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | updateComponentStyle = (parentId, keys, style) => { |
| | | const { cardCell } = this.props |
| | | |
| | | if (!cardCell || cardCell.uuid !== parentId) return |
| | | |
| | | const { elements } = this.state |
| | | |
| | | let _elements = elements.map(item => { |
| | | if (keys.includes(item.uuid)) { |
| | | return this.resetCardStyle(item, {...item.style, ...style}) |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | elements: _elements |
| | | }, () => { |
| | | this.props.updateElement(_elements) |
| | | }) |
| | | } |
| | | |
| | | cardAddElement = (ids, element) => { |
| | |
| | | |
| | | if (comIds.length !== 3 || comIds[0] !== cards.uuid || comIds[1] !== cardCell.uuid) return |
| | | |
| | | let _card = this.resetCardStyle(card, style) |
| | | |
| | | let _elements = elements.map(cell => { |
| | | if (cell.uuid === _card.uuid) return _card |
| | | return cell |
| | | }) |
| | | |
| | | this.setState({ |
| | | elements: _elements |
| | | }, () => { |
| | | this.props.updateElement(_elements) |
| | | }) |
| | | } |
| | | |
| | | resetCardStyle = (card, style) => { |
| | | let _card = fromJS(card).toJS() |
| | | |
| | | if (_card.eleType === 'text' || _card.eleType === 'number') { |
| | |
| | | _card.style = style |
| | | } |
| | | |
| | | let _elements = elements.map(cell => { |
| | | if (cell.uuid === _card.uuid) return _card |
| | | return cell |
| | | }) |
| | | |
| | | this.setState({ |
| | | elements: _elements |
| | | }, () => { |
| | | this.props.updateElement(_elements) |
| | | }) |
| | | return _card |
| | | } |
| | | |
| | | /** |
| | |
| | | const { cards } = this.props |
| | | let btn = fromJS(item).toJS() |
| | | |
| | | if (btn.eleType !== 'button') return |
| | | if (btn.eleType !== 'button' || (sessionStorage.getItem('style-control') && sessionStorage.getItem('style-control') !== 'false')) return |
| | | |
| | | if (btn.OpenType === 'pop') { |
| | | if (!btn.modal) { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { cards } = this.props |
| | | const { cards, cardCell } = this.props |
| | | const { elements, visible, actvisible, profVisible, card, dict } = this.state |
| | | |
| | | return ( |
| | | <div className="model-menu-card-cell-list"> |
| | | <DragElement |
| | | list={elements} |
| | | parent={{...cardCell, components: elements}} |
| | | fields={cards.columns} |
| | | updateMarks={this.updateMarks} |
| | | handleList={this.handleList} |
| | |
| | | }) |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if ((sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'propcard') && this.props.cards.subtype === 'propcard') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card, this.props.cards, 'propcard') |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { cards, offset } = this.props |
| | | const { card, elements, side, settingVisible, dict } = this.state |
| | |
| | | |
| | | return ( |
| | | <Col span={card.setting.width || 6} offset={offset || 0}> |
| | | <div className="card-item" style={_style}> |
| | | <div className="card-item" style={_style} onClick={this.clickComponent} id={card.uuid}> |
| | | <CardCellComponent cards={cards} cardCell={card} side={side} elements={elements} updateElement={this.updateCard}/> |
| | | <div className="card-control"> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | |
| | | <Icon className="plus" title="左移" type="arrow-left" onClick={() => this.props.move(card, 'left')} /> |
| | | <Icon className="close" title="右移" type="arrow-right" onClick={() => this.props.move(card, 'right')} /> |
| | | </div> |
| | | } trigger="hover" getPopupContainer={() => document.getElementById(card.uuid)}> |
| | | <Icon type="swap" id={card.uuid}/> |
| | | } trigger="hover" getPopupContainer={() => document.getElementById(card.uuid + 'swap')}> |
| | | <Icon type="swap" id={card.uuid + 'swap'}/> |
| | | </Popover> : null} |
| | | {cards.subtype === 'propcard' ? <Icon className="close" title="删除卡片" type="delete" onClick={() => this.props.deleteElement(card)} /> : null} |
| | | {card.setting.type === 'multi' ? <Switch size="small" onClick={this.changeSide} defaultChecked /> : null} |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card) |
| | | } |
| | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | MKEmitter.addListener('logButton', this.logButton) |
| | | MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | MKEmitter.removeListener('submitStyle', this.getStyle) |
| | | MKEmitter.removeListener('logButton', this.logButton) |
| | | MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | updateComponentStyle = (parentId, keys, style) => { |
| | | const { card } = this.state |
| | | |
| | | if (card.uuid !== parentId) return |
| | | |
| | | 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}) |
| | | }) |
| | | } |
| | | |
| | | logButton = (id, item) => { |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card) |
| | | } |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card) |
| | | } |
| | |
| | | |
| | | componentDidMount () { |
| | | this.viewrender() |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('tabsChange', this.handleTabsChange) |
| | | MKEmitter.removeListener('submitStyle', this.getStyle) |
| | | MKEmitter.removeListener('tabsChange', this.handleTabsChange) |
| | | } |
| | | |
| | | handleTabsChange = (parentId) => { |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card) |
| | | } |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card) |
| | | } |
| | |
| | | MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | updateComponentStyle = (item) => { |
| | | updateComponentStyle = (parentId, keys, style) => { |
| | | const { group } = this.state |
| | | |
| | | if (group.uuid !== item.uuid) return |
| | | if (group.uuid !== parentId) return |
| | | |
| | | let components = group.components.map(item => { |
| | | if (keys.includes(item.uuid)) { |
| | | item.style = {...item.style, ...style} |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | group: {...group, components: []} |
| | | }, () => { |
| | | this.setState({ |
| | | group: {...group, components: item.components} |
| | | }) |
| | | this.updateComponent({...group, components: components}) |
| | | }) |
| | | } |
| | | |
| | |
| | | updateComponent = (component) => { |
| | | const { group } = this.state |
| | | |
| | | if (!is(fromJS(group.setting), fromJS(component.setting))) { |
| | | // 注册事件-标签变化,通知标签内元素 |
| | | if (!is(fromJS(group.setting), fromJS(component.setting)) || !is(fromJS(group.style), fromJS(component.style))) { |
| | | // 注册事件-标签变化,通知组内元素 |
| | | MKEmitter.emit('tabsChange', group.uuid) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.group) |
| | | } |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card) |
| | | } |
| | |
| | | * @description 按钮双击触发子配置 |
| | | */ |
| | | btnDoubleClick = (element) => { |
| | | if (sessionStorage.getItem('style-control') && sessionStorage.getItem('style-control') !== 'false') return |
| | | |
| | | if (element.OpenType === 'pop' || element.OpenType === 'popview') { |
| | | this.props.setSubConfig(element) |
| | | } else { |
| | |
| | | <DndProvider> |
| | | <Table |
| | | rowKey="uuid" |
| | | size={config.wrap.size || 'middle'} |
| | | rowClassName="editable-row" |
| | | bordered={config.wrap.bordered !== 'false'} |
| | | components={components} |
| | |
| | | position: relative; |
| | | .ant-table-body { |
| | | overflow-x: auto; |
| | | padding-bottom: 20px; |
| | | tr { |
| | | td { |
| | | background: #ffffff; |
| | |
| | | color: purple; |
| | | } |
| | | } |
| | | .ant-table-small > .ant-table-content > .ant-table-body { |
| | | margin: 0; |
| | | } |
| | | } |
| | | .normal-table-columns.false { |
| | | .ant-pagination { |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.card) |
| | | } |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="表格大小"> |
| | | {getFieldDecorator('size', { |
| | | initialValue: wrap.size || 'middle' |
| | | })( |
| | | <Radio.Group style={{whiteSpace: 'nowrap'}}> |
| | | <Radio key="default" value="default"> 大 </Radio> |
| | | <Radio key="middle" value="middle"> 中 </Radio> |
| | | <Radio key="small" value="small"> 小 </Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12} style={{height: '64px'}}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="默认值 #e8e8e8。"> |
| | | <Icon type="question-circle" /> |
| | |
| | | MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | updateComponentStyle = (item) => { |
| | | const { group } = this.state |
| | | updateComponentStyle = (parentId, keys, style) => { |
| | | const { tabs } = this.state |
| | | |
| | | if (group.uuid !== item.uuid) return |
| | | if (tabs.subtabs.findIndex(tab => tab.uuid === parentId) === -1) return |
| | | |
| | | this.setState({ |
| | | group: {...group, components: []} |
| | | }, () => { |
| | | this.setState({ |
| | | group: {...group, components: item.components} |
| | | }) |
| | | let _tabs = fromJS(tabs).toJS() |
| | | let _tabs_ = fromJS(tabs).toJS() |
| | | |
| | | let components = [] |
| | | _tabs.subtabs.forEach(tab => { |
| | | if (tab.uuid === parentId) { |
| | | components = tab.components.map(item => { |
| | | if (keys.includes(item.uuid)) { |
| | | item.style = {...item.style, ...style} |
| | | } |
| | | return item |
| | | }) |
| | | tab.components = [] |
| | | } |
| | | }) |
| | | |
| | | _tabs_.subtabs = _tabs_.subtabs.map(tab => { |
| | | if (tab.uuid === parentId) { |
| | | tab.components = components |
| | | } |
| | | return tab |
| | | }) |
| | | |
| | | this.setState({tabs: _tabs}, () => { |
| | | this.updateComponent(_tabs_) |
| | | }) |
| | | } |
| | | |
| | |
| | | updateComponent = (component) => { |
| | | const { tabs } = this.state |
| | | |
| | | if (!is(fromJS(tabs.setting), fromJS(component.setting))) { |
| | | if (!is(fromJS(tabs.setting), fromJS(component.setting)) || !is(fromJS(tabs.style), fromJS(component.style))) { |
| | | // 注册事件-标签变化,通知标签内元素 |
| | | MKEmitter.emit('tabsChange', tabs.uuid) |
| | | } |
| | |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true') { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | | MKEmitter.emit('clickComponent', this.state.tabs) |
| | | } |
| | |
| | | |
| | | render() { |
| | | const { tabs, dict, labelvisible, editab } = this.state |
| | | |
| | | return ( |
| | | <div className="menu-tabs-edit-box" style={tabs.style} onClick={this.clickComponent} id={tabs.uuid}> |
| | | <DraggableTabs tabPosition={tabs.setting.position} type={tabs.setting.tabStyle} tabsMove={this.moveSwitch}> |
| | |
| | | return cell |
| | | }) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = item.components.forEach(cell => { |
| | | cell = this.resetconfig(cell, item, true) |
| | | return cell |
| | | }) |
| | | } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) { |
| | | item.subcards.forEach(card => { |
| | | card.uuid = Utils.getuuid() |
| | |
| | | state = { |
| | | label: '调整', |
| | | parent: null, |
| | | type: '', |
| | | components: [] |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | submitCombineStyle = (style) => { |
| | | const { menu } = this.props |
| | | const { components, parent } = this.state |
| | | |
| | | let _parent = null |
| | | let getParents = (box) => { |
| | | box.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | if (tab.uuid === parent.uuid) { |
| | | _parent = tab |
| | | } else { |
| | | getParents(tab) |
| | | } |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | if (item.uuid === parent.uuid) { |
| | | _parent = item |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (menu.uuid === parent.uuid) { |
| | | _parent = menu |
| | | } else { |
| | | getParents(menu) |
| | | } |
| | | |
| | | let keys = components.map(item => item.uuid) |
| | | |
| | | _parent.components = _parent.components.map(item => { |
| | | if (keys.includes(item.uuid)) { |
| | | item.style = {...item.style, ...style} |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | MKEmitter.emit('submitComponentStyle', _parent) |
| | | |
| | | MKEmitter.emit('submitComponentStyle', parent.uuid, keys, style) |
| | | |
| | | setTimeout(() => { |
| | | keys.forEach(key => { |
| | |
| | | }, 100) |
| | | } |
| | | |
| | | clickComponent = (card) => { |
| | | clickComponent = (card, _p, _type) => { |
| | | const { menu } = this.props |
| | | const { parent } = this.state |
| | | const { parent, type } = this.state |
| | | let components = fromJS(this.state.components).toJS() |
| | | |
| | | if (!parent) { |
| | | let _parent = null |
| | | let getParents = (box) => { |
| | | box.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | if (tab.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | _parent = tab |
| | | } else { |
| | | getParents(tab) |
| | | } |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | if (item.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | _parent = item |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (menu.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | _parent = menu |
| | | if (_type === 'propcard') { |
| | | _parent = _p |
| | | MKEmitter.emit('changeCombineStyle', ['margin', 'padding', 'border', 'background', 'shadow']) |
| | | } else if (_type === 'cardcell') { |
| | | _parent = _p |
| | | MKEmitter.emit('changeCombineStyle', ['margin', 'padding', 'border', 'background', 'font']) |
| | | } else { |
| | | getParents(menu) |
| | | let getParents = (box) => { |
| | | box.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | if (tab.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | _parent = tab |
| | | } else { |
| | | getParents(tab) |
| | | } |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | if (item.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | _parent = item |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (menu.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | _parent = menu |
| | | } else { |
| | | getParents(menu) |
| | | } |
| | | |
| | | MKEmitter.emit('changeCombineStyle', ['margin', 'padding', 'border', 'background']) |
| | | } |
| | | |
| | | document.getElementById(card.uuid).classList.add('selected-control-element') |
| | | MKEmitter.emit('changeCombineStyle', ['margin', 'padding', 'border', 'background']) |
| | | |
| | | sessionStorage.setItem('style-control', (_type ? _type : 'component')) |
| | | |
| | | this.setState({ |
| | | type: _type ? _type : 'component', |
| | | parent: _parent, |
| | | components: [card] |
| | | }) |
| | |
| | | if (components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | components = components.filter(cell => cell.uuid !== card.uuid) |
| | | document.getElementById(card.uuid).classList.remove('selected-control-element') |
| | | } else if (parent.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | } else if (type !== 'propcard' && parent.components.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | components.push(card) |
| | | document.getElementById(card.uuid).classList.add('selected-control-element') |
| | | } else if (type === 'propcard' && parent.subcards.findIndex(cell => cell.uuid === card.uuid) > -1) { |
| | | components.push(card) |
| | | document.getElementById(card.uuid).classList.add('selected-control-element') |
| | | } |
| | | |
| | | if (components.length === 0) { |
| | | MKEmitter.emit('closeCombineStyle') |
| | | sessionStorage.setItem('style-control', 'true') |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | } |
| | | |
| | | triggerStyleChange = () => { |
| | | const { label } = this.state |
| | | const { label, components } = this.state |
| | | |
| | | if (label === '调整') { |
| | | document.body.className = 'style-control' |
| | |
| | | document.body.className = '' |
| | | sessionStorage.setItem('style-control', 'false') |
| | | |
| | | let eles = document.getElementsByClassName('selected-control-element') |
| | | for (let i = 0; i < eles.length; i++) { |
| | | eles[i].classList.remove('selected-control-element') |
| | | } |
| | | components.forEach(item => { |
| | | document.getElementById(item.uuid).classList.remove('selected-control-element') |
| | | }) |
| | | |
| | | MKEmitter.emit('closeCombineStyle') |
| | | |
| | |
| | | } |
| | | |
| | | .selected-control-element { |
| | | box-shadow: 0px 0px 6px orange; |
| | | box-shadow: 0px 0px 4px orange!important; |
| | | } |
| | | .selected-control-element:hover { |
| | | box-shadow: 0px 0px 4px orange!important; |
| | | } |
| | | .normal-table-columns { |
| | | .col-control { |
| | | display: none; |
| | | } |
| | | } |
| | | } |
| | |
| | | closable={false} |
| | | className="menu-style-drawer" |
| | | visible={this.state.visible} |
| | | destroyOnClose |
| | | > |
| | | <div className="menu-combine-style-controller"> |
| | | <Form {...formItemLayout}> |
| | |
| | | |
| | | return uuids |
| | | } |
| | | |
| | | /** |
| | | * @description 生成32位uuid string + 时间 |
| | | * @return {String} uuid |
| | | */ |
| | | static getuuid () { |
| | | let uuid = [] |
| | | let timestamp = new Date().getTime() |
| | | let _options = '0123456789abcdefghigklmnopqrstuv' |
| | | for (let i = 0; i < 19; i++) { |
| | | uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) |
| | | } |
| | | uuid = timestamp + uuid.join('') |
| | | return uuid |
| | | } |
| | | |
| | | /** |
| | | * @description 重置菜单配置 |
| | | * @return {String} components 配置信息 |
| | | */ |
| | | static resetConfig = (components) => { |
| | | return components.map(item => { |
| | | item.uuid = this.getuuid() |
| | | |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.uuid = this.getuuid() |
| | | tab.parentId = item.uuid |
| | | |
| | | tab.components = tab.components.map(cell => { |
| | | cell.tabId = tab.uuid |
| | | cell.parentId = item.uuid |
| | | return cell |
| | | }) |
| | | tab.components = this.resetConfig(tab.components) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | item.components = item.components.map(cell => { |
| | | cell.parentId = item.uuid |
| | | return cell |
| | | }) |
| | | item.components = this.resetConfig(item.components) |
| | | } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) { |
| | | item.subcards.forEach(card => { |
| | | card.uuid = this.getuuid() |
| | | if (card.elements) { |
| | | card.elements = card.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | if (card.backElements) { |
| | | card.backElements = card.backElements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | }) |
| | | } else if (item.type === 'table' && item.subtype === 'normaltable' && item.cols) { |
| | | let loopCol = (col) => { |
| | | col.subcols = col.subcols.map(c => { |
| | | c.uuid = this.getuuid() |
| | | |
| | | if (c.type === 'colspan' && c.subcols) { |
| | | c = loopCol(c) |
| | | } else if (c.type === 'custom' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (c.type === 'action' && c.elements) { |
| | | c.elements = c.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return c |
| | | }) |
| | | |
| | | return col |
| | | } |
| | | |
| | | item.cols = item.cols.map(col => { |
| | | col.uuid = this.getuuid() |
| | | |
| | | if (col.type === 'colspan' && col.subcols) { |
| | | col = loopCol(col) |
| | | } else if (col.type === 'custom' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } else if (col.type === 'action' && col.elements) { |
| | | col.elements = col.elements.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | |
| | | if (item.btnlog) { |
| | | item.btnlog = [] |
| | | } |
| | | |
| | | if (item.action) { |
| | | item.action = item.action.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | if (item.search) { |
| | | item.search = item.search.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | if (item.columns) { |
| | | item.columns = item.columns.map(cell => { |
| | | cell.uuid = this.getuuid() |
| | | return cell |
| | | }) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | } |
| | |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <Table |
| | | size="middle" |
| | | components={components} |
| | | size={setting.size || 'middle'} |
| | | bordered={setting.bordered !== 'false'} |
| | | rowSelection={rowSelection} |
| | | columns={this.state.columns} |
| | |
| | | import MenuForm from './menuform' |
| | | import TransferForm from '@/templates/zshare/basetransferform' |
| | | import Utils from '@/utils/utils.js' |
| | | import MenuUtils from '@/menu/utils/menuUtils.js' |
| | | import DragElement from '../menuelement' |
| | | import asyncLoadComponent from '@/utils/asyncLoadComponent' |
| | | import './index.scss' |
| | |
| | | OpenType: 'newtab' |
| | | } |
| | | |
| | | if (sysMenu.OriginMenuId && sysMenu.Template === 'CustomPage') { |
| | | PageParam.originMenuId = sysMenu.OriginMenuId |
| | | } else if (sysMenu.Template === 'NewPage') { |
| | | if (sysMenu.Template === 'NewPage') { |
| | | PageParam.OpenType = 'NewPage' |
| | | PageParam.url = res.url |
| | | } |
| | |
| | | confirmLoading: true |
| | | }) |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | sysTemplates: sysTemplates, |
| | | confirmLoading: false, |
| | | handleMVisible: false, |
| | | sysMenu: '', |
| | | tabview: '' |
| | | }) |
| | | if (sysMenu.Template === 'CustomPage' && sysMenu.OriginMenuId) { |
| | | this.copyMenu(param, sysMenu.OriginMenuId) |
| | | } else { |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | sysTemplates: sysTemplates, |
| | | confirmLoading: false, |
| | | handleMVisible: false, |
| | | sysMenu: '', |
| | | tabview: '' |
| | | }) |
| | | |
| | | this.props.reload() |
| | | } else { |
| | | this.setState({ |
| | | confirmLoading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.props.reload() |
| | | } else { |
| | | this.setState({ |
| | | confirmLoading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | copyMenu = (param, MenuId) => { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: MenuId |
| | | }).then(result => { |
| | | if (result.status) { |
| | | let config = null |
| | | |
| | | try { |
| | | config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = null |
| | | } |
| | | }) |
| | | |
| | | if (config) { |
| | | config.uuid = param.MenuID |
| | | config.MenuID = param.MenuID |
| | | config.parentId = param.ParentID |
| | | config.MenuName = param.MenuName |
| | | config.MenuNo = param.MenuNo |
| | | config.easyCode = '' |
| | | config.components = MenuUtils.resetConfig(config.components) |
| | | |
| | | param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(config))) |
| | | } |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | confirmLoading: false, |
| | | handleMVisible: false, |
| | | sysMenu: '', |
| | | tabview: '' |
| | | }) |
| | | |
| | | this.props.reload() |
| | | } else { |
| | | this.setState({ |
| | | confirmLoading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | confirmLoading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | |
| | | type: 'radio', |
| | | key: 'setAll', |
| | | label: Formdict['header.form.setAll'], |
| | | initVal: card.setAll || 'false', |
| | | initVal: card.setAll || 'true', |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['model.true'] |
| | |
| | | MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) |
| | | } |
| | | |
| | | updateComponentStyle = (item) => { |
| | | updateComponentStyle = (parentId, keys, style) => { |
| | | const { config } = this.state |
| | | |
| | | if (config.uuid !== item.uuid) return |
| | | if (config.uuid !== parentId) return |
| | | |
| | | let components = config.components.map(item => { |
| | | if (keys.includes(item.uuid)) { |
| | | item.style = {...item.style, ...style} |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | config: {...config, components: []} |
| | | }, () => { |
| | | this.setState({ |
| | | config: {...config, components: item.components} |
| | | config: {...config, components: components} |
| | | }) |
| | | }) |
| | | } |