| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Row, Col, Input, Select, Radio, Tooltip, InputNumber, Cascader, Popover, message } from 'antd' |
| | | import { Form, Row, Col, Input, Select, Radio, Tooltip, InputNumber, Cascader, Popover, message, AutoComplete } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import { formRule } from '@/utils/option.js' |
| | |
| | | formlist: formlist.map(item => { |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'field' || item.key === 'linkurl' || item.key === 'bgImage' || item.key === 'posterField') { |
| | | if ((item.key === 'field' || item.key === 'linkurl' || item.key === 'bgImage' || item.key === 'posterField') && item.type === 'select') { |
| | | item.options = [] |
| | | |
| | | if (side === 'sub') { |
| | |
| | | item.required = card.eleType !== 'qrcode' |
| | | } |
| | | if (item.key === 'linkurl') { |
| | | item.type = card.link === 'dynamic' ? 'select' : 'textarea' |
| | | item.type = card.link === 'dynamic' ? item.defType : 'textarea' |
| | | } |
| | | |
| | | return item |
| | |
| | | item.initVal = this.record[item.key] |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'field') { |
| | | if (item.key === 'field' && item.type === 'select') { |
| | | item.options = [] |
| | | |
| | | if (side === 'sub') { |
| | |
| | | item.hidden = !_options.includes(item.key) |
| | | |
| | | if (item.key === 'linkurl') { |
| | | item.type = value === 'dynamic' ? 'select' : 'textarea' |
| | | item.type = value === 'dynamic' ? item.defType : 'textarea' |
| | | } |
| | | return item |
| | | }) |
| | |
| | | if (item.hidden || item.forbid) return |
| | | |
| | | if (item.type === 'text') { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: item.readonly ? false : !!item.required, |
| | | message: '请输入' + item.label + '!' |
| | | }, |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | if (item.options && item.options.length > 0) { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: !!item.required, |
| | | message: '请输入' + item.label + '!' |
| | | }, |
| | | { |
| | | pattern: formRule.field.pattern, |
| | | message: formRule.field.message |
| | | }, |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | })( |
| | | <AutoComplete |
| | | dataSource={item.options.map((cell, i) => <AutoComplete.Option value={cell.value} key={i}> |
| | | {cell.value} |
| | | </AutoComplete.Option>)} |
| | | filterOption={(input, option) => option.props.children.indexOf(input) > -1} |
| | | > |
| | | <Input autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | </AutoComplete> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } else { |
| | | fields.push( |
| | | <Col span={12} key={index}> |
| | | <Form.Item label={item.tooltip ? |
| | | <Tooltip placement="topLeft" title={item.tooltip}> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | {item.label} |
| | | </Tooltip> : item.label |
| | | }> |
| | | {getFieldDecorator(item.key, { |
| | | initialValue: item.initVal || '', |
| | | rules: [ |
| | | { |
| | | required: item.readonly ? false : !!item.required, |
| | | message: '请输入' + item.label + '!' |
| | | }, |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} |
| | | </Form.Item> |
| | | </Col> |
| | | ) |
| | | } |
| | | } else if (item.type === 'textarea') { |
| | | fields.push( |
| | | <Col span={24} className="textarea" key={index}> |
| | |
| | | .ant-form-explain, .ant-form-extra { |
| | | font-size: 13px; |
| | | } |
| | | .ant-select-search__field__mirror { |
| | | max-width: 100%; |
| | | overflow: hidden; |
| | | } |
| | | } |
| | | .formula-fields { |
| | | z-index: 1200!important; |
| | |
| | | appMenus.push({value: 'goback', text: '返回(上一页)'}) |
| | | } |
| | | |
| | | let fields = [] |
| | | if (cards.subtype === 'propcard' && cards.wrap.datatype === 'static') { |
| | | if (cards.wrap.supModule && cards.wrap.supModule.length) { |
| | | let cell = MenuUtils.getComponent(cards.wrap.supModule[cards.wrap.supModule.length - 1]) |
| | | if (cell && cell.columns) { |
| | | fields = cell.columns.map(col => ({ value: col.field })) |
| | | } |
| | | } else { |
| | | fields = cards.columns.map(col => ({ value: col.field })) |
| | | } |
| | | } |
| | | |
| | | let forms = [ |
| | | { |
| | | type: 'select', |
| | |
| | | ] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select', |
| | | key: 'field', |
| | | label: '字段', |
| | | initVal: card.field || '', |
| | | required: true, |
| | | options: [] |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'icon', |
| | |
| | | required: true |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select', |
| | | key: 'posterField', |
| | | label: '预览地址', |
| | | initVal: card.posterField || '', |
| | | required: true |
| | | required: true, |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select', |
| | | key: 'bgImage', |
| | | label: '动态背景', |
| | | initVal: card.bgImage || '', |
| | | tooltip: '绑定数据源字段,可根据返回值改变背景图。', |
| | | required: false, |
| | | allowClear: true, |
| | | options: [], |
| | | options: fields, |
| | | forbid: isHeader |
| | | }, |
| | | { |
| | |
| | | forbid: ['pc', 'mob'].includes(appType) |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select', |
| | | defType: cards.subtype === 'propcard' && cards.wrap.datatype === 'static' ? 'text' : 'select', |
| | | key: 'linkurl', |
| | | label: '链接地址', |
| | | initVal: card.linkurl || '', |
| | | tooltip: ['pc', 'mob'].includes(appType) ? '当链接类型为“其他”,且链接地址以@menuid@开头时,其后内容将被视为菜单ID。' : '', |
| | | required: true, |
| | | options: [] |
| | | options: fields |
| | | }, |
| | | { |
| | | type: 'radio', |
| | |
| | | |
| | | class CardCellComponent extends Component { |
| | | static propTpyes = { |
| | | cards: PropTypes.object, // 菜单配置信息 |
| | | cards: PropTypes.object, |
| | | cardCell: PropTypes.object, |
| | | side: PropTypes.string, |
| | | elements: PropTypes.array, // 元素集 |
| | | updateElement: PropTypes.func // 菜单配置更新 |
| | | timestamp: PropTypes.any, |
| | | elements: PropTypes.array, |
| | | updateElement: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (this.props.side !== nextProps.side && nextProps.side) { |
| | | if (this.props.timestamp !== nextProps.timestamp && nextProps.timestamp) { |
| | | this.setState({ |
| | | elements: fromJS(nextProps.elements).toJS() |
| | | }) |
| | |
| | | formlist: null, // 设置表单信息 |
| | | elements: null, // 编辑组 |
| | | side: 'front', |
| | | timestamp: '', |
| | | appType: sessionStorage.getItem('appType'), |
| | | visible: false |
| | | } |
| | |
| | | const { card } = this.props |
| | | |
| | | this.setState({ |
| | | timestamp: new Date().getTime() + '', |
| | | card: fromJS(card).toJS(), |
| | | elements: fromJS(card.elements).toJS(), |
| | | }) |
| | |
| | | _elements = fromJS(card.backElements).toJS() |
| | | } |
| | | |
| | | this.setState({side: _side, elements: _elements}) |
| | | this.setState({side: _side, elements: _elements, timestamp: new Date().getTime() + ''}) |
| | | } |
| | | |
| | | addElement = () => { |
| | |
| | | okText: '确定', |
| | | cancelText: '取消', |
| | | onOk() { |
| | | that.setState({ card: _card, side: '', elements: fromJS(_card.elements).toJS() }, () => { |
| | | that.setState({ side: 'front' }) |
| | | }) |
| | | that.setState({ card: _card, side: 'front', timestamp: new Date().getTime() + '', elements: fromJS(_card.elements).toJS() }) |
| | | that.props.updateElement(_card) |
| | | }, |
| | | onCancel() {} |
| | |
| | | if (side === 'back' && res.type === 'simple') { |
| | | this.setState({ |
| | | side: 'front', |
| | | timestamp: new Date().getTime() + '', |
| | | elements: fromJS(_card.elements).toJS() |
| | | }) |
| | | } |
| | |
| | | this.props.updateElement(_card) |
| | | } |
| | | |
| | | updateFields = (elements, resolve, type) => { |
| | | const { card, side } = this.state |
| | | |
| | | let items = elements |
| | | |
| | | if (type === 'form') { |
| | | items = [] |
| | | |
| | | elements.forEach(item => { |
| | | let cell = { |
| | | uuid: Utils.getuuid(), |
| | | eleType: 'text', |
| | | height: 1, |
| | | innerHeight: 21, |
| | | prefix: item.label ? item.label + ': ' : '', |
| | | datatype: item.field ? 'dynamic' : 'static', |
| | | field: item.field || '', |
| | | width: item.span || 12, |
| | | value: '', |
| | | style: {marginBottom: '15px'} |
| | | } |
| | | |
| | | if (item.type === 'number') { |
| | | cell.eleType = 'number' |
| | | cell.decimal = typeof(item.decimal) === 'number' ? item.decimal : '' |
| | | } |
| | | |
| | | items.push(cell) |
| | | }) |
| | | } |
| | | |
| | | if (items.length === 0) { |
| | | resolve({status: false, message: '元素不可为空!'}) |
| | | return |
| | | } |
| | | |
| | | let _card = { ...card } |
| | | let _card2 = { ...card } |
| | | let pass = false |
| | | |
| | | if (side === 'back') { |
| | | if (!_card.backElements || _card.backElements.length === 0) { |
| | | _card.backElements = items |
| | | pass = true |
| | | } else { |
| | | _card.backElements = items |
| | | _card2.backElements = [...card.backElements, ...items] |
| | | } |
| | | } else { |
| | | if (!_card.elements || _card.elements.length === 0) { |
| | | _card.elements = items |
| | | pass = true |
| | | } else { |
| | | _card.elements = items |
| | | _card2.elements = [...card.elements, ...items] |
| | | } |
| | | } |
| | | |
| | | if (pass) { |
| | | this.setState({ |
| | | card: _card, |
| | | timestamp: new Date().getTime() + '', |
| | | elements: side === 'back' ? fromJS(_card.backElements).toJS() : fromJS(_card.elements).toJS() |
| | | }) |
| | | |
| | | this.props.updateElement(_card) |
| | | } else { |
| | | const that = this |
| | | const _modal = confirm({ |
| | | title: '卡片中已存在元素,请选择要进行的操作。', |
| | | className: 'mk-confirm-modal', |
| | | content: <div className="footer"> |
| | | <Button key="cancel" onClick={() => _modal.destroy()}>取消</Button> |
| | | <Button key="replace" className="mk-border-purple" onClick={() => { |
| | | that.setState({ |
| | | card: _card, |
| | | timestamp: new Date().getTime() + '', |
| | | elements: side === 'back' ? fromJS(_card.backElements).toJS() : fromJS(_card.elements).toJS() |
| | | }) |
| | | |
| | | that.props.updateElement(_card) |
| | | _modal.destroy() |
| | | }}>替换</Button> |
| | | <Button key="confirm" className="mk-border-green" onClick={() => { |
| | | that.setState({ |
| | | card: _card2, |
| | | timestamp: new Date().getTime() + '', |
| | | elements: side === 'back' ? fromJS(_card2.backElements).toJS() : fromJS(_card2.elements).toJS() |
| | | }) |
| | | |
| | | that.props.updateElement(_card2) |
| | | _modal.destroy() |
| | | }}>添加</Button> |
| | | </div> |
| | | }) |
| | | } |
| | | |
| | | resolve({status: true}) |
| | | } |
| | | |
| | | paste = (element, resolve) => { |
| | | const { card } = this.state |
| | | |
| | | if (['simpleform', 'forms', 'formgroup', 'cardcell'].includes(element.copyType)) { |
| | | if (element.copyType === 'simpleform') { |
| | | this.updateFields(element.subcards[0].fields, resolve, 'form') |
| | | } else if (element.copyType === 'forms') { |
| | | this.updateFields(element.fields, resolve, 'form') |
| | | } else if (element.copyType === 'formgroup') { |
| | | this.updateFields(element.fields, resolve, 'form') |
| | | } else { |
| | | this.updateFields(element.elements, resolve) |
| | | } |
| | | return |
| | | } |
| | | |
| | | let _uuid = Utils.getuuid() |
| | | |
| | |
| | | |
| | | render() { |
| | | const { cards } = this.props |
| | | const { card, elements, side, visible } = this.state |
| | | const { card, elements, side, visible, timestamp } = this.state |
| | | |
| | | let _style = {...card.style} |
| | | |
| | |
| | | <Col span={card.setting.width || 6} style={_style_}> |
| | | <div className={'card-item ' + (card.setting.btnControl || '') + checkAll + tablerole} style={_style} onDoubleClick={(e) => {e.stopPropagation(); this.doubleClickCard()}} id={card.uuid}> |
| | | <span className="circle-select"></span> |
| | | <CardCellComponent cards={cards} cardCell={card} side={side} elements={elements} updateElement={this.updateCard}/> |
| | | <CardCellComponent cards={cards} cardCell={card} side={side} timestamp={timestamp} elements={elements} updateElement={this.updateCard}/> |
| | | <div className="card-control" onDoubleClick={(e) => e.stopPropagation()}> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | |
| | | <EditOutlined className="edit" title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="cardcell" card={card}/> |
| | | <PasteController options={['action', 'customCardElement']} updateConfig={this.paste} /> |
| | | <PasteController options={['action', 'customCardElement', 'simpleform', 'forms', 'formgroup', 'cardcell']} updateConfig={this.paste} /> |
| | | <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle} /> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | |
| | | display: inline; |
| | | } |
| | | } |
| | | |
| | | .mk-confirm-modal { |
| | | .ant-modal-confirm-btns { |
| | | display: none; |
| | | } |
| | | .footer { |
| | | margin-top: 24px; |
| | | text-align: right; |
| | | .ant-btn { |
| | | margin-left: 8px; |
| | | } |
| | | } |
| | | } |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Popover } from 'antd' |
| | | import { Popover, Modal, Button } from 'antd' |
| | | import { PlusOutlined, PlusSquareOutlined, EditOutlined, ArrowLeftOutlined, ArrowRightOutlined, SwapOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | const NormalForm = asyncIconComponent(() => import('@/components/normalform')) |
| | | const NodesWrap = asyncComponent(() => import('./node-wrap')) |
| | |
| | | state = { |
| | | card: null, // 卡片信息 |
| | | formlist: null, // 设置表单信息 |
| | | appType: sessionStorage.getItem('appType') |
| | | appType: sessionStorage.getItem('appType'), |
| | | timestamp: '' |
| | | } |
| | | |
| | | /** |
| | |
| | | const { card } = this.props |
| | | |
| | | this.setState({ |
| | | card: fromJS(card).toJS() |
| | | card: fromJS(card).toJS(), |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | } |
| | | |
| | |
| | | this.props.updateElement(_card) |
| | | } |
| | | |
| | | updateFields = (elements, resolve, type) => { |
| | | const { card } = this.state |
| | | |
| | | let items = elements |
| | | |
| | | if (type === 'form') { |
| | | items = [] |
| | | |
| | | elements.forEach(item => { |
| | | let cell = { |
| | | uuid: Utils.getuuid(), |
| | | eleType: 'text', |
| | | height: 1, |
| | | innerHeight: 21, |
| | | prefix: item.label ? item.label + ': ' : '', |
| | | datatype: item.field ? 'dynamic' : 'static', |
| | | field: item.field || '', |
| | | width: item.span || 12, |
| | | value: '', |
| | | style: {marginBottom: '15px'} |
| | | } |
| | | |
| | | if (item.type === 'number') { |
| | | cell.eleType = 'number' |
| | | cell.decimal = typeof(item.decimal) === 'number' ? item.decimal : '' |
| | | } |
| | | |
| | | items.push(cell) |
| | | }) |
| | | } |
| | | |
| | | if (items.length === 0) { |
| | | resolve({status: false, message: '元素不可为空!'}) |
| | | return |
| | | } |
| | | |
| | | let _card = { ...card, elements: items } |
| | | let _card2 = { ...card, elements: [...card.elements, ...items] } |
| | | |
| | | if (card.elements.length === 0) { |
| | | this.setState({ |
| | | card: _card, |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | |
| | | this.props.updateElement(_card) |
| | | } else { |
| | | const that = this |
| | | const _modal = confirm({ |
| | | title: '卡片中已存在元素,请选择要进行的操作。', |
| | | className: 'mk-confirm-modal', |
| | | content: <div className="footer"> |
| | | <Button key="cancel" onClick={() => _modal.destroy()}>取消</Button> |
| | | <Button key="replace" className="mk-border-purple" onClick={() => { |
| | | that.setState({ |
| | | card: _card, |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | |
| | | that.props.updateElement(_card) |
| | | _modal.destroy() |
| | | }}>替换</Button> |
| | | <Button key="confirm" className="mk-border-green" onClick={() => { |
| | | that.setState({ |
| | | card: _card2, |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | |
| | | that.props.updateElement(_card2) |
| | | _modal.destroy() |
| | | }}>添加</Button> |
| | | </div> |
| | | }) |
| | | } |
| | | |
| | | resolve({status: true}) |
| | | } |
| | | |
| | | paste = (element, resolve) => { |
| | | const { card } = this.state |
| | | |
| | | if (['simpleform', 'forms', 'formgroup', 'cardcell'].includes(element.copyType)) { |
| | | if (element.copyType === 'simpleform') { |
| | | this.updateFields(element.subcards[0].fields, resolve, 'form') |
| | | } else if (element.copyType === 'forms') { |
| | | this.updateFields(element.fields, resolve, 'form') |
| | | } else if (element.copyType === 'formgroup') { |
| | | this.updateFields(element.fields, resolve, 'form') |
| | | } else { |
| | | this.updateFields(element.elements, resolve) |
| | | } |
| | | return |
| | | } |
| | | |
| | | let _uuid = Utils.getuuid() |
| | | |
| | |
| | | |
| | | render() { |
| | | const { cards } = this.props |
| | | const { card } = this.state |
| | | const { card, timestamp } = this.state |
| | | |
| | | let _style = {...card.style} |
| | | |
| | |
| | | |
| | | return ( |
| | | <div className="card-item" style={_style}> |
| | | <CardCellComponent cards={cards} cardCell={card} elements={card.elements} updateElement={this.updateCard}/> |
| | | <CardCellComponent cards={cards} cardCell={card} timestamp={timestamp} elements={card.elements} updateElement={this.updateCard}/> |
| | | <div className="card-control"> |
| | | <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | |
| | | <EditOutlined style={{color: '#1890ff'}} title="编辑"/> |
| | | </NormalForm> : <NodesWrap card={card} updateMenus={this.updateNodes}/>} |
| | | {cards.type !== 'timeline' ? <CopyComponent type="cardcell" card={card}/> : null} |
| | | <PasteController options={['action', 'customCardElement']} updateConfig={this.paste} /> |
| | | <PasteController options={['action', 'customCardElement', 'simpleform', 'forms', 'formgroup', 'cardcell']} updateConfig={this.paste} /> |
| | | <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/> |
| | | {control ? <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ |
| | | <div className="mk-popover-control"> |
| | |
| | | cursor: pointer; |
| | | background: rgba(255, 255, 255, 0.55); |
| | | } |
| | | } |
| | | |
| | | .mk-confirm-modal { |
| | | .ant-modal-confirm-btns { |
| | | display: none; |
| | | } |
| | | .footer { |
| | | margin-top: 24px; |
| | | text-align: right; |
| | | .ant-btn { |
| | | margin-left: 8px; |
| | | } |
| | | } |
| | | } |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Popover, Col } from 'antd' |
| | | import { Popover, Col, Modal, Button } from 'antd' |
| | | import { UpOutlined, PlusOutlined, PlusSquareOutlined, EditOutlined, ToolOutlined, FontColorsOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | const NormalForm = asyncIconComponent(() => import('@/components/normalform')) |
| | | const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent')) |
| | |
| | | card: null, // 卡片信息,包括正反面 |
| | | appType: sessionStorage.getItem('appType'), |
| | | visible: false, |
| | | timestamp: '', |
| | | side: '' |
| | | } |
| | | |
| | |
| | | const { card } = this.props |
| | | |
| | | this.setState({ |
| | | card: fromJS(card).toJS() |
| | | card: fromJS(card).toJS(), |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | } |
| | | |
| | |
| | | this.props.updateElement(_card) |
| | | } |
| | | |
| | | updateFields = (elements, resolve, position, type) => { |
| | | const { card } = this.state |
| | | |
| | | let items = elements |
| | | |
| | | if (type === 'form') { |
| | | items = [] |
| | | |
| | | elements.forEach(item => { |
| | | let cell = { |
| | | uuid: Utils.getuuid(), |
| | | eleType: 'text', |
| | | height: 1, |
| | | innerHeight: 21, |
| | | prefix: item.label ? item.label + ': ' : '', |
| | | datatype: item.field ? 'dynamic' : 'static', |
| | | field: item.field || '', |
| | | width: item.span || 12, |
| | | value: '', |
| | | style: {marginBottom: '15px'} |
| | | } |
| | | |
| | | if (item.type === 'number') { |
| | | cell.eleType = 'number' |
| | | cell.decimal = typeof(item.decimal) === 'number' ? item.decimal : '' |
| | | } |
| | | |
| | | items.push(cell) |
| | | }) |
| | | } |
| | | |
| | | if (items.length === 0) { |
| | | resolve({status: false, message: '元素不可为空!'}) |
| | | return |
| | | } |
| | | |
| | | let _card = { ...card } |
| | | let _card2 = { ...card } |
| | | let pass = false |
| | | |
| | | if (position === 'sub') { |
| | | if (_card.backElements.length === 0) { |
| | | _card.backElements = items |
| | | pass = true |
| | | } else { |
| | | _card.backElements = items |
| | | _card2.backElements = [...card.backElements, ...items] |
| | | } |
| | | } else { |
| | | if (_card.elements.length === 0) { |
| | | _card.elements = items |
| | | pass = true |
| | | } else { |
| | | _card.elements = items |
| | | _card2.elements = [...card.elements, ...items] |
| | | } |
| | | } |
| | | |
| | | if (pass) { |
| | | this.setState({ |
| | | card: _card, |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | |
| | | this.props.updateElement(_card) |
| | | } else { |
| | | const that = this |
| | | const _modal = confirm({ |
| | | title: '卡片中已存在元素,请选择要进行的操作。', |
| | | className: 'mk-confirm-modal', |
| | | content: <div className="footer"> |
| | | <Button key="cancel" onClick={() => _modal.destroy()}>取消</Button> |
| | | <Button key="replace" className="mk-border-purple" onClick={() => { |
| | | that.setState({ |
| | | card: _card, |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | |
| | | that.props.updateElement(_card) |
| | | _modal.destroy() |
| | | }}>替换</Button> |
| | | <Button key="confirm" className="mk-border-green" onClick={() => { |
| | | that.setState({ |
| | | card: _card2, |
| | | timestamp: new Date().getTime() + '' |
| | | }) |
| | | |
| | | that.props.updateElement(_card2) |
| | | _modal.destroy() |
| | | }}>添加</Button> |
| | | </div> |
| | | }) |
| | | } |
| | | |
| | | resolve({status: true}) |
| | | } |
| | | |
| | | paste = (element, resolve, type) => { |
| | | const { card } = this.state |
| | | |
| | | if (['simpleform', 'forms', 'formgroup', 'cardcell'].includes(element.copyType)) { |
| | | if (element.copyType === 'simpleform') { |
| | | this.updateFields(element.subcards[0].fields, resolve, type, 'form') |
| | | } else if (element.copyType === 'forms') { |
| | | this.updateFields(element.fields, resolve, type, 'form') |
| | | } else if (element.copyType === 'formgroup') { |
| | | this.updateFields(element.fields, resolve, type, 'form') |
| | | } else { |
| | | this.updateFields(element.elements, resolve, type) |
| | | } |
| | | return |
| | | } |
| | | |
| | | let _uuid = Utils.getuuid() |
| | | |
| | |
| | | |
| | | render() { |
| | | const { cards } = this.props |
| | | const { card } = this.state |
| | | const { card, timestamp } = this.state |
| | | |
| | | let _style = {...card.style} |
| | | let _backStyle = {...card.backStyle} |
| | |
| | | <EditOutlined className="edit" title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="cardcell" card={{...card, backElements: []}}/> |
| | | <PasteController options={['action', 'customCardElement']} updateConfig={(element, resolve) => this.paste(element, resolve, 'main')} /> |
| | | <PasteController options={['action', 'customCardElement', 'simpleform', 'forms', 'formgroup', 'cardcell']} updateConfig={(element, resolve) => this.paste(element, resolve, 'main')} /> |
| | | <FontColorsOutlined className="style" title="调整样式" onClick={() => this.changeStyle()} /> |
| | | </div> |
| | | } trigger="hover"> |
| | | <ToolOutlined /> |
| | | </Popover> |
| | | </div> |
| | | <CardCellComponent cards={cards} cardCell={card} side="main" elements={card.elements} updateElement={(elements, btn) => this.updateCard(elements, btn)}/> |
| | | <CardCellComponent cards={cards} cardCell={card} side="main" timestamp={timestamp} elements={card.elements} updateElement={(elements, btn) => this.updateCard(elements, btn)}/> |
| | | </div> |
| | | <Col span={card.backSetting.width || 24}> |
| | | <div className={'card-item ' + (card.backSetting.btnControl || '')} style={_backStyle} onDoubleClick={(e) => {e.stopPropagation(); this.doubleClickCard('sub')}} id={card.uuid}> |
| | |
| | | <EditOutlined className="edit" title="编辑"/> |
| | | </NormalForm> |
| | | <CopyComponent type="cardcell" card={{...card, elements: card.backElements, backElements: []}}/> |
| | | <PasteController options={['action', 'customCardElement']} updateConfig={(element, resolve) => this.paste(element, resolve, 'sub')} /> |
| | | <PasteController options={['action', 'customCardElement', 'simpleform', 'forms', 'formgroup', 'cardcell']} updateConfig={(element, resolve) => this.paste(element, resolve, 'sub')} /> |
| | | <FontColorsOutlined className="style" title="调整样式" onClick={() => this.changeStyle('sub')} /> |
| | | </div> |
| | | } trigger="hover"> |
| | | <ToolOutlined /> |
| | | </Popover> |
| | | </div> |
| | | <CardCellComponent cards={cards} cardCell={card} side="sub" elements={card.backElements} updateElement={(elements, btn) => this.updateCard(elements, btn, 'sub')}/> |
| | | <CardCellComponent cards={cards} cardCell={card} side="sub" timestamp={timestamp} elements={card.backElements} updateElement={(elements, btn) => this.updateCard(elements, btn, 'sub')}/> |
| | | </div> |
| | | </Col> |
| | | </div> |
| | |
| | | display: inline-block; |
| | | } |
| | | } |
| | | |
| | | .mk-confirm-modal { |
| | | .ant-modal-confirm-btns { |
| | | display: none; |
| | | } |
| | | .footer { |
| | | margin-top: 24px; |
| | | text-align: right; |
| | | .ant-btn { |
| | | margin-left: 8px; |
| | | } |
| | | } |
| | | } |
| | |
| | | } else if (this.record.type === 'close' || this.record.type === 'reset') { |
| | | shows = ['typeName', 'label'] |
| | | } else { |
| | | shows = ['typeName', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'output', 'reload', 'preButton', 'formCache'] // 选项列表 |
| | | shows = ['typeName', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'output', 'reload', 'preButton'] // 选项列表 |
| | | |
| | | if (this.record.execSuccess === 'never') { |
| | | shows.push('resetForms') |
| | |
| | | value: 'true', |
| | | text: '刷新' |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'formCache', |
| | | // label: '表单缓存', |
| | | // initVal: card.formCache || 'false', |
| | | // tooltip: '主要用于数据修改后,更新相关表单的选项,清空缓存后表单再次打开时数据会重新加载。', |
| | | // required: false, |
| | | // options: [{ |
| | | // value: 'false', |
| | | // text: '不清空' |
| | | // }, { |
| | | // value: 'clear', |
| | | // text: '清空' |
| | | // }] |
| | | // }, |
| | | } |
| | | ] |
| | | } |
| | |
| | | const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) |
| | | const MKTable = asyncComponent(() => import('@/components/normalform/modalform/mkTable')) |
| | | const acTyOptions = { |
| | | pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'hover', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'position', 'tipTitle', 'hoverTitle', 'hidden', 'preButton', 'formCache'], |
| | | prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'hover', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'position', 'tipTitle', 'hoverTitle', 'hidden', 'preButton', 'formCache'], |
| | | exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'hover', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'hoverTitle', 'hidden', 'preButton', 'formCache'], |
| | | pop: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'hover', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'position', 'hoverTitle', 'hidden', 'preButton'], |
| | | prompt: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'hover', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'position', 'tipTitle', 'hoverTitle', 'hidden', 'preButton'], |
| | | exec: ['label', 'OpenType', 'intertype', 'Ot', 'show', 'hover', 'swipe', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'anchors', 'width', 'openmenu', 'refreshTab', 'hoverTitle', 'hidden', 'preButton'], |
| | | excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'hover', 'icon', 'class', 'color', 'sheet', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'width', 'hidden'], |
| | | excelOut: ['label', 'Ot', 'OpenType', 'intertype', 'show', 'hover', 'icon', 'class', 'color', 'execSuccess', 'execError', 'syncComponent', 'switchTab', 'pagination', 'search', 'width', 'hidden'], |
| | | popview: ['label', 'Ot', 'OpenType', 'show', 'hover', 'icon', 'class', 'color', 'popClose', 'width', 'display', 'ratio', 'syncComponent', 'clickouter', 'maskStyle', 'closeButton', 'hidden'], |
| | |
| | | key: 'tipTitle', |
| | | label: '确认提示', |
| | | initVal: card.tipTitle || '', |
| | | tooltip: '注:弹窗(表单)在显示为是否框时有效。', |
| | | tooltip: '提示框的确认提示信息。', |
| | | required: false |
| | | }, |
| | | { |
| | |
| | | initVal: card.reason || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'formCache', |
| | | label: '表单缓存', |
| | | initVal: card.formCache || 'false', |
| | | tooltip: '主要用于数据修改后,更新相关表单的选项,清空缓存后表单再次打开时数据会重新加载。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'false', |
| | | text: '不清空' |
| | | }, { |
| | | value: 'clear', |
| | | text: '清空' |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'formCache', |
| | | // label: '表单缓存', |
| | | // initVal: card.formCache || 'false', |
| | | // tooltip: '主要用于数据修改后,更新相关表单的选项,清空缓存后表单再次打开时数据会重新加载。', |
| | | // required: false, |
| | | // options: [{ |
| | | // value: 'false', |
| | | // text: '不清空' |
| | | // }, { |
| | | // value: 'clear', |
| | | // text: '清空' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | key: 'hidden', |
| | |
| | | key: 'tipTitle', |
| | | label: '确认提示', |
| | | initVal: card.tipTitle || '', |
| | | tooltip: '注:弹窗(表单)在显示为是否框时有效。', |
| | | tooltip: '提示框的确认提示信息。', |
| | | required: false |
| | | }, |
| | | { |
| | |
| | | initVal: card.reason || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'formCache', |
| | | label: '表单缓存', |
| | | initVal: card.formCache || 'false', |
| | | tooltip: '主要用于数据修改后,更新相关表单的选项,清空缓存后表单再次打开时数据会重新加载。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'false', |
| | | text: '不清空' |
| | | }, { |
| | | value: 'clear', |
| | | text: '清空' |
| | | }] |
| | | }, |
| | | // { |
| | | // type: 'radio', |
| | | // key: 'formCache', |
| | | // label: '表单缓存', |
| | | // initVal: card.formCache || 'false', |
| | | // tooltip: '主要用于数据修改后,更新相关表单的选项,清空缓存后表单再次打开时数据会重新加载。', |
| | | // required: false, |
| | | // options: [{ |
| | | // value: 'false', |
| | | // text: '不清空' |
| | | // }, { |
| | | // value: 'clear', |
| | | // text: '清空' |
| | | // }] |
| | | // }, |
| | | { |
| | | type: 'radio', |
| | | key: 'hidden', |
| | |
| | | |
| | | _data.$$BID = BID || '' |
| | | _data.$$BData = BData || '' |
| | | |
| | | if (_config.wrap.datatype === 'static' && BData) { |
| | | Object.keys(BData).forEach(key => { |
| | | if (/\$/.test(key)) return |
| | | _data[key] = BData[key] |
| | | }) |
| | | } |
| | | |
| | | if (_config.setting.primaryKey) { |
| | | _data.$$uuid = _data[_config.setting.primaryKey] || '' |
| | | } |
| | |
| | | } |
| | | |
| | | if (config.wrap.datatype === 'static') { |
| | | let _data = {$$BID: BID || '', $$BData: BData, $$empty: true, $$time: new Date().getTime()} |
| | | if (BData) { |
| | | Object.keys(BData).forEach(key => { |
| | | if (/\$/.test(key)) return |
| | | _data[key] = BData[key] |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | data: {$$BID: BID || '', $$BData: BData, $$empty: true, $$time: new Date().getTime()}, |
| | | data: _data, |
| | | }) |
| | | |
| | | if (!btn) { |
| | |
| | | tabId = btn.refreshTab[btn.refreshTab.length - 1] |
| | | } |
| | | |
| | | if (btn.formCache === 'clear') { // 清除表单缓存 |
| | | window.GLOB.CacheMap = new Map() |
| | | } |
| | | // if (btn.formCache === 'clear') { // 清除表单缓存 |
| | | // window.GLOB.CacheMap = new Map() |
| | | // } |
| | | |
| | | if (tabId && btn.$MenuID === tabId) { // 刷新当前菜单时,停止其他操作 |
| | | MKEmitter.emit('reloadMenuView', tabId, 'table') |
| | |
| | | } |
| | | |
| | | modelconfirm = () => { |
| | | const { btn, BID } = this.props |
| | | const { BID } = this.props |
| | | const { btnconfig, selines } = this.state |
| | | let _this = this |
| | | |
| | |
| | | this.execSubmit(selines, () => {}, result) |
| | | } else { |
| | | confirm({ |
| | | title: btn.tipTitle || '确定要执行吗?', |
| | | title: btnconfig.setting.tipTitle || '确定要执行吗?', |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | _this.execSubmit(selines, resolve, result) |
| | |
| | | let _data = null |
| | | let primaryId = '' |
| | | |
| | | if (btn.Ot === 'requiredSgl' && setting.primaryKey) { |
| | | if (btn.Ot === 'requiredSgl') { |
| | | _data = data[0] |
| | | primaryId = _data.$$uuid || _data[setting.primaryKey] || '' |
| | | primaryId = _data.$$uuid || '' |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | item.readin = item.readin !== 'false' && item.readin !== 'top' |
| | | item.readonly = check || item.readonly === 'true' |
| | | item.writein = item.writein !== 'false' |
| | | item.defHidden = item.hidden === 'true' |
| | | item.hidden = item.hidden === 'true' |
| | | item.fieldlength = item.fieldlength || 50 |
| | | |
| | |
| | | |
| | | let _hidden = false |
| | | |
| | | if (supItem.hidden) { |
| | | if (supItem.hidden && !supItem.defHidden) { |
| | | _hidden = true |
| | | } else { |
| | | let box = [...item.values] |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {appType !== 'mob' ? <Col span={12}> |
| | | <Form.Item label="表单类型"> |
| | | {appType !== 'mob' && (display === 'drawer' || display === 'modal') ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="选择查看时表单均为只读,仅用于数据展示。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 表单类型 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('formType', { |
| | | initialValue: config.setting.formType || 'edit' |
| | | })( |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {display === 'prompt' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="提示框的确认提示信息。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 确认提示 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('tipTitle', { |
| | | initialValue: config.setting.tipTitle || '' |
| | | })( |
| | | <Input autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {!this.props.isSubTab && !appType && this.state.viewType !== 'popview' && display === 'modal' ? <Col span={12}> |
| | | <Form.Item label="挂载对象"> |
| | | {getFieldDecorator('container', { |
| | |
| | | |
| | | const { TextArea } = Input |
| | | const actionTypeOptions = { |
| | | pop: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'tipTitle', 'hidden'], |
| | | pop: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'hidden'], |
| | | prompt: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'tipTitle', 'hidden'], |
| | | exec: ['label', 'position', 'OpenType', 'intertype', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'openmenu', 'output', 'hidden'], |
| | | excelIn: ['label', 'Ot', 'OpenType', 'intertype', 'icon', 'class', 'sheet', 'execSuccess', 'execError', 'hidden'], |
| | |
| | | key: 'tipTitle', |
| | | label: '确认提示', |
| | | initVal: card.tipTitle || '', |
| | | tooltip: '注:弹窗(表单)在显示为是否框时有效。', |
| | | tooltip: '提示框的确认提示信息。', |
| | | required: false |
| | | }, |
| | | { |
| | |
| | | <Form {...formItemLayout} className="config-paste-form"> |
| | | <Row gutter={24}> |
| | | <Col span={24}> |
| | | <Form.Item label="配置信息" className="textarea"> |
| | | <Form.Item label="" className="textarea"> |
| | | {getFieldDecorator('config', { |
| | | initialValue: '', |
| | | rules: [ |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取指定组件 |
| | | * @return {String} 组件id |
| | | */ |
| | | static getComponent (Id) { |
| | | let interfaces = window.GLOB.customMenu.interfaces |
| | | let components = window.GLOB.customMenu.components |
| | | let cell = null |
| | | |
| | | let mapComponents = (components = []) => { |
| | | components.forEach(item => { |
| | | if (item.uuid === Id) { |
| | | cell = item |
| | | }else if (item.type === 'tabs') { |
| | | item.subtabs.forEach(f_tab => { |
| | | mapComponents(f_tab.components) |
| | | }) |
| | | } else if (item.type === 'group') { |
| | | mapComponents(item.components) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | mapComponents(components) |
| | | |
| | | if (!cell && interfaces) { |
| | | interfaces.forEach(m => { |
| | | if (m.uuid === Id && m.status === 'true') { |
| | | cell = m |
| | | } |
| | | }) |
| | | } |
| | | |
| | | return cell |
| | | } |
| | | |
| | | /** |
| | | * @description 获取上级模块 |
| | | * @return {String} selfId 当前组件id |
| | | */ |