From f54dcd2506479be5edb05bc0742ffb78fd34d61a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 11 七月 2023 18:06:56 +0800 Subject: [PATCH] 2023-07-11 --- /dev/null | 0 1 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/templates/formtabconfig/actionform/index.jsx b/src/templates/formtabconfig/actionform/index.jsx deleted file mode 100644 index d275498..0000000 --- a/src/templates/formtabconfig/actionform/index.jsx +++ /dev/null @@ -1,442 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Radio, notification, Tooltip, InputNumber } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' - -import { btnIcons, btnClasses, formRule } from '@/utils/option.js' -import MkIcon from '@/components/mk-icon' -import './index.scss' - -const { TextArea } = Input - -class MainSearch extends Component { - static propTpyes = { - formlist: PropTypes.any, // 琛ㄥ崟淇℃伅 - card: PropTypes.any, // 鎸夐挳淇℃伅 - tabs: PropTypes.array, // 鎵�鏈夋爣绛鹃〉 - inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 - } - - state = { - formlist: null, // 琛ㄥ崟淇℃伅 - openType: null, // 鎵撳紑鏂瑰紡 - interType: null, // 鎺ュ彛绫诲瀷锛氬唴閮ㄣ�佸閮� - insertUpdateOptions: [{ - value: 'insert', - text: '娣诲姞' - }, { - value: 'update', - text: '淇敼' - }, { - value: 'insertOrUpdate', - text: '娣诲姞鎴栦慨鏀�' - }], - returnoptions: [{ // 杩斿洖鍚�-涓嶅埛鏂般�佸埛鏂伴〉闈€�佸埛鏂拌〃鏍� - value: 'never', - text: '涓嶅埛鏂�' - }, { - value: 'grid', - text: '鍒锋柊' - }], - currentoptions: [{ // 涓嶈繑鍥炴椂-涓嶅埛鏂般�佸埛鏂� - value: 'never', - text: '涓嶅埛鏂�' - }, { - value: 'refresh', - text: '鍒锋柊' - }], - interTypeOptions: [{ - value: 'system', - text: '绯荤粺' - }, { - value: 'inner', - text: '鍐呴儴' - }, { - value: 'outer', - text: '澶栭儴' - }, { - value: 'custom', - text: '鑷畾涔�' - }] - } - - - UNSAFE_componentWillMount () { - const { card } = this.props - let _intertype = '' - - this.props.formlist.forEach(form => { - if (form.key === 'intertype') { - _intertype = form.initVal - if (card.btnType !== 'confirm') { - form.options = this.state.interTypeOptions.filter(op => op.value !== 'system') - } else { - form.options = this.state.interTypeOptions - } - } - }) - - let _options = this.getOptions(card.btnType, _intertype) - - let formlist = this.props.formlist.map(item => { - if (item.key === 'class') { - item.options = btnClasses - } else if (item.key === 'icon') { - item.options = btnIcons - } else if (item.key === 'resetPageIndex') { - item.tooltip = '椤甸潰鍏抽棴锛屼笖鎵ц鍒锋柊鏃剁敓鏁�' - } else if (item.key === 'sqlType') { - item.options = this.state.insertUpdateOptions - } else if (item.key === 'OpenType') { - item.options = [ - { - value: 'prompt', - text: '鎻愮ず妗�' - }, { - value: 'exec', - text: '鐩存帴鎵ц' - } - ] - if (card.btnType === 'cancel') { - item.readonly = true - } - } else if (item.key === 'execSuccess' && card.btnType === 'cancel') { - item.label = '鍏抽棴鍚�' - item.options[1].text = '鍒锋柊' - } else if (item.key === 'execSuccess' || item.key === 'execError') { - item.options[1].text = '鍒锋柊' - } else if (item.key === 'innerFunc' && card.btnType !== 'confirm' && _intertype === 'inner') { - item.required = true - } - - item.hidden = !_options.includes(item.key) - return item - }) - formlist.push({ - type: 'radio', - key: 'afterExecSuccess', - label: '鎴愬姛鍚�', - initVal: card.afterExecSuccess || 'close', - required: true, - options: [{ - value: 'close', - text: '鍏抽棴' - }, { - value: 'notclose', - text: '涓嶅叧闂�' - }] - }, - { - type: 'radio', - key: 'afterExecError', - label: '澶辫触鍚�', - initVal: card.afterExecError || 'notclose', - required: true, - options: [{ - value: 'close', - text: '鍏抽棴' - }, { - value: 'notclose', - text: '涓嶅叧闂�' - }] - },) - - this.setState({formlist}) - } - - componentDidMount () { - const { card } = this.props - - if (card.focus) { - try { - let _form = document.getElementById('label') - _form.select() - } catch (e) { - console.warn('琛ㄥ崟focus澶辫触锛�') - } - } - } - - getOptions = (btnType, intertype) => { - let _options = [] - - if (btnType === 'cancel') { - _options = ['label', 'OpenType', 'icon', 'class', 'execSuccess', 'resetPageIndex'] - } else if (btnType === 'confirm') { - if (intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] - } else if (intertype === 'system') { - _options = ['label', 'OpenType', 'intertype', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] - } - } else { - if (intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'sysInterface', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError', 'afterExecSuccess', 'afterExecError', 'resetPageIndex'] - } - } - - return _options - } - - onChange = (e, key) => { - const { card } = this.props - - let value = e.target.value - - if (key === 'intertype') { - let _options = this.getOptions(card.btnType, value) - - this.setState({ - interType: value, - formlist: this.state.formlist.map(item => { - item.hidden = !_options.includes(item.key) - - if (item.key === 'interface') { - item.readonly = false - } else if (item.key === 'sysInterface') { - item.initVal = 'false' - } else if (item.key === 'innerFunc' && value === 'inner') { - item.required = true - } else if (item.key === 'innerFunc' && value === 'outer') { - item.required = false - } - - return item - }) - }) - } else if (key === 'sysInterface') { - if (value === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - } - this.setState({ - formlist: this.state.formlist.map(item => { - if (item.key === 'interface' && value === 'true') { - item.readonly = true - } else if (item.key === 'interface') { - item.readonly = false - } - - return item - }) - }) - } - } - - handleSubmit = (e) => { - e.preventDefault() - - if (this.props.inputSubmit) { - this.props.inputSubmit() - } - } - - getFields() { - const { getFieldDecorator } = this.props.form - const fields = [] - - this.state.formlist.forEach((item, index) => { - if (item.hidden) return - - if (item.type === 'text') { - let _rules = [] - if (item.key === 'innerFunc') { - let str = '^(' + item.fields.join('|') + ')' - let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') - _rules = [{ - pattern: _patten, - message: formRule.func.innerMessage - }, { - max: formRule.func.max, - message: formRule.func.maxMessage - }] - } else if (item.key === 'outerFunc' || item.key === 'callbackFunc') { - _rules = [{ - pattern: formRule.func.pattern, - message: formRule.func.message - }, { - max: formRule.func.max, - message: formRule.func.maxMessage - }] - } else { - _rules = [{ - max: formRule.input.max, - message: formRule.input.message - }] - } - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} 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 + '!' - }, - ..._rules - ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<InputNumber min={1} max={10000} precision={0} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: '璇烽�夋嫨' + item.label + '!' - } - ] - })( - <Select - getPopupContainer={() => document.getElementById('winter')} - disabled={!!item.readonly} - > - {item.options.map((option, index) => - <Select.Option id={`${index}`} title={option.text} key={`${index}`} value={option.value}> - {item.key === 'icon' && option.value && <MkIcon type={option.value} />} {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - 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.required, - message: '璇烽�夋嫨' + item.label + '!' - } - ] - })( - <Radio.Group onChange={(e) => {this.onChange(e, item.key)}}> - { - item.options.map(option => { - return ( - <Radio key={option.value} value={option.value}>{option.text}</Radio> - ) - }) - } - </Radio.Group> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'textarea') { - fields.push( - <Col span={24} key={index}> - <Form.Item label={item.label} className="textarea"> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: item.readonly ? false : !!item.required, - message: '璇疯緭鍏�' + item.label + '!' - } - ] - })(<TextArea rows={4} readOnly={item.readonly}/>)} - </Form.Item> - </Col> - ) - } - }) - return fields - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.props.card.uuid - values.verify = this.props.card.verify || null - values.btnType = this.props.card.btnType || 'tabFormBtn' - - - if (values.innerFunc === '' && values.sql === '') { - notification.warning({ - top: 92, - message: '浣跨敤绯荤粺鍑芥暟鏃讹紝璇峰~鍐欒〃鍚嶏紝浣跨敤鑷畾涔夊嚱鏁版椂锛屽彲蹇界暐銆�', - duration: 5 - }) - } else if (values.innerFunc === '' && values.sql !== '' && values.sqlType === '') { - notification.warning({ - top: 92, - message: '浣跨敤绯荤粺鍑芥暟鏃讹紝璇烽�夋嫨鎿嶄綔绫诲瀷锛屼娇鐢ㄨ嚜瀹氫箟鍑芥暟鏃讹紝鍙拷鐣ャ��', - duration: 5 - }) - } else { - resolve(values) - } - } else { - reject(err) - } - }) - }) - } - - render() { - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 7 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 17 } - } - } - return ( - <Form {...formItemLayout} className="formtab-action-list-form" id="winter"> - <Row gutter={24}>{this.getFields()}</Row> - </Form> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/templates/formtabconfig/actionform/index.scss b/src/templates/formtabconfig/actionform/index.scss deleted file mode 100644 index 969304f..0000000 --- a/src/templates/formtabconfig/actionform/index.scss +++ /dev/null @@ -1,33 +0,0 @@ -.formtab-action-list-form { - min-height: 190px; - .superconfig { - color: #1890ff; - cursor: pointer; - } - .textarea { - .ant-col-sm-7 { - width: 14%; - } - .ant-col-sm-17 { - width: 86%; - } - } - .with-button { - .ant-form-item-control-wrapper { - padding-right: 63px; - } - .ant-btn { - position: absolute; - right: 12px; - top: 4.5px; - } - } - .ant-input:read-only { - background: #fafafa; - resize: none; - } - .ant-input:read-only:hover, .ant-input:read-only:focus { - border-color: #d9d9d9; - box-shadow: none; - } -} \ No newline at end of file diff --git a/src/templates/formtabconfig/dragelement/card.jsx b/src/templates/formtabconfig/dragelement/card.jsx deleted file mode 100644 index feab70f..0000000 --- a/src/templates/formtabconfig/dragelement/card.jsx +++ /dev/null @@ -1,161 +0,0 @@ -import React from 'react' -import { useDrag, useDrop } from 'react-dnd' -import { Button, Select, DatePicker, Input, InputNumber, Popover } from 'antd' -import { EditOutlined, CopyOutlined, ProfileOutlined, CloseOutlined, UploadOutlined, TableOutlined } from '@ant-design/icons' -import moment from 'moment' -import ItemTypes from './itemtypes' -import './index.scss' - -const { MonthPicker } = DatePicker -const { TextArea } = Input - -const Card = ({ id, type, cols, card, moveCard, findCard, editCard, delCard, profileCard, copyCard }) => { - const originalIndex = findCard(id).index - const [{ isDragging }, drag] = useDrag({ - item: { type: ItemTypes[type], id, originalIndex }, - collect: monitor => ({ - isDragging: monitor.isDragging(), - }), - }) - const [, drop] = useDrop({ - accept: ItemTypes[type], - canDrop: () => true, - drop: (item) => { - const { id: draggedId, originalIndex } = item - - if (originalIndex === undefined) { - item.dropTargetId = id - } else if (draggedId && draggedId !== id) { - const { index: overIndex } = findCard(id) - moveCard(draggedId, overIndex) - } - } - }) - const opacity = isDragging ? 0.5 : 1 - - const edit = () => { - editCard(id) - } - - const del = () => { - delCard(id) - } - - const copy = () => { - copyCard(id) - } - - const profile = () => { - profileCard(id) - } - - let _defaultValue = '' // 涓嬫媺鎼滅储銆佹椂闂磋寖鍥寸被鍨嬶紝鍒濆鍊奸渶瑕侀澶勭悊 - - if (type === 'search' && (card.type === 'multiselect' || card.type === 'select' || card.type === 'link')) { - if (card.initval) { - let _option = card.options.filter(option => option.Value === card.initval)[0] - if (_option) { - _defaultValue = _option.Text || '' - } else { - _defaultValue = '' - } - } else if (card.setAll === 'true') { - _defaultValue = card.emptyText || '绌�' - } - } else if (type === 'search' && card.type === 'daterange') { - _defaultValue = [null, null] - if (card.initval === 'week') { - _defaultValue = [moment().startOf('week'), moment().endOf('week')] - } else if (card.initval === 'month') { - _defaultValue = [moment().startOf('month'), moment().endOf('month')] - } else if (card.initval) { - try { - let _initval = JSON.parse(card.initval) - _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch (e) { - _defaultValue = [null, null] - } - } - } - - let labelCol = 'ant-col-sm-8' - let wrapCol = 'ant-col-sm-16' - if (card.type === 'textarea') { - if (cols === '2') { - labelCol = 'textarea-line ant-col-sm-4' - wrapCol = 'textarea-line ant-col-sm-20' - } else if (cols === '3') { - labelCol = 'textarea-line ant-col-cuslabel' - wrapCol = 'textarea-line ant-col-cuswrap' - } else if (cols === '4') { - labelCol = 'textarea-line ant-col-sm-2' - wrapCol = 'textarea-line ant-col-sm-22' - } - } - - return ( - <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ - <div className="mk-popover-control"> - <EditOutlined className="edit" title="缂栬緫" onClick={edit} /> - {type === 'search' ? <CopyOutlined className="edit copy" title="澶嶅埗" onClick={copy} /> : null} - {type === 'action' && card.btnType !== 'cancel' ? - <ProfileOutlined className="edit profile" title="鏍¢獙瑙勫垯" onClick={profile} /> : null - } - {type === 'search' || (type === 'action' && card.btnType !== 'confirm' && card.btnType !== 'cancel') ? <CloseOutlined className="edit close" title="鍒犻櫎" onClick={del} /> : null} - </div> - } trigger="hover"> - <div className="page-card" style={{ opacity: opacity}}> - <div ref={node => drag(drop(node))}> - {type === 'search' ? - <div className="ant-row ant-form-item"> - <div className={'ant-col ant-form-item-label ant-col-xs-24 ' + labelCol}> - <label title={card.label}>{card.label}</label> - </div> - <div className={'ant-col ant-form-item-control-wrapper ant-col-xs-24 ' + wrapCol}> - {card.type === 'text' ? - <Input style={{marginTop: '4px'}} value={card.initval} /> : null - } - {card.type === 'number' ? - <InputNumber value={card.initval} precision={card.decimal} /> : null - } - {(card.type === 'multiselect' || card.type === 'select' || card.type === 'link') ? - <Select value={_defaultValue}></Select> : null - } - {card.type === 'date' ? - <DatePicker value={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null - } - {card.type === 'datemonth' ? - <MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null - } - {card.type === 'datetime' ? - <DatePicker showTime value={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null - } - {card.type === 'textarea' ? - <TextArea value={card.initval} autoSize={{ minRows: 2, maxRows: 6 }} /> : null - } - {card.type === 'funcvar' && - <Input style={{marginTop: '4px'}} value={card.linkfield} /> - } - {card.type === 'fileupload' ? - <Button> - <UploadOutlined /> 鐐瑰嚮涓婁紶 - </Button> : null - } - </div> - </div> : null - } - {type === 'action' ? - <Button - className={'mk-btn mk-' + card.class} - icon={card.icon} - key={card.uuid} - > - {card.label}{card.position === 'grid' && <TableOutlined />} - </Button> : null - } - </div> - </div> - </Popover> - ) -} -export default Card diff --git a/src/templates/formtabconfig/dragelement/index.jsx b/src/templates/formtabconfig/dragelement/index.jsx deleted file mode 100644 index 3621397..0000000 --- a/src/templates/formtabconfig/dragelement/index.jsx +++ /dev/null @@ -1,199 +0,0 @@ -import React, { useState } from 'react' -import { useDrop } from 'react-dnd' -import update from 'immutability-helper' -import { is, fromJS } from 'immutable' -import { Col } from 'antd' -import Utils from '@/utils/utils.js' -import Card from './card' -import ItemTypes from './itemtypes' -import './index.scss' - -const Container = ({list, type, groupId, setting, handleList, handleMenu, deleteMenu, profileMenu }) => { - const [cards, setCards] = useState(list) - const moveCard = (id, atIndex) => { - const { card, index } = findCard(id) - - if (!card) return - - const _cards = update(cards, { $splice: [[index, 1], [atIndex, 0, card]] }) - if (type === 'action') { - handleList(type, _cards) - } else { - handleList(type, _cards, null, groupId) - } - } - - if (!is(fromJS(cards), fromJS(list))) { - setCards(list) - } - - const findCard = id => { - const card = cards.filter(c => `${c.uuid}` === id)[0] - return { - card, - index: cards.indexOf(card), - } - } - - const editCard = id => { - const { card } = findCard(id) - handleMenu(card) - } - - const copyCard = id => { - const { card } = findCard(id) - - let _card = JSON.parse(JSON.stringify(card)) - - _card.originUuid = _card.uuid - _card.uuid = Utils.getuuid() - _card.iscopy = true - _card.focus = true - - // 澶嶅埗鍒板壀鍒囨澘 - let oInput = document.createElement('input') - let val = JSON.parse(JSON.stringify(_card)) - val.copyType = 'form' - val.uuid = Utils.getuuid() - - delete val.originUuid - delete val.iscopy - - delete val.$srcId - - let srcid = localStorage.getItem(window.location.href.split('#')[0] + 'srcId') - if (srcid) { - val.$srcId = srcid - } - - oInput.value = window.btoa(window.encodeURIComponent(JSON.stringify(val))) - document.body.appendChild(oInput) - oInput.select() - document.execCommand('Copy') - oInput.className = 'oInput' - oInput.style.display = 'none' - document.body.removeChild(oInput) - - handleMenu(_card) - } - - const profileCard = id => { - const { card } = findCard(id) - profileMenu(card) - } - - const delCard = id => { - const { card } = findCard(id) - deleteMenu({card: card, type: type}) - } - - const [, drop] = useDrop({ - accept: ItemTypes[type], - drop(item) { - if (item.hasOwnProperty('originalIndex') && groupId) { - const { card } = findCard(item.id) - - if (!card) { - handleList(type, cards, null, groupId, item.id) - } - } - - if (item.hasOwnProperty('originalIndex')) { - return - } - - let newcard = {} - newcard.uuid = Utils.getuuid() - newcard.focus = true - - if (item.type === 'search') { - let _match = 'like' - if (item.subType === 'select' || item.subType === 'link') { - _match = '=' - } else if (item.subType === 'date' || item.subType === 'datemonth') { - _match = '>=' - } else if (item.subType === 'dateweek' || item.subType === 'daterange') { - _match = 'between' - } - - newcard.label = 'label' - newcard.field = '' - newcard.initval = '' - newcard.type = item.subType - newcard.resourceType = '0' - newcard.options = [] - newcard.orderType = 'asc' - newcard.match = _match - } else if (item.type === 'action') { - newcard.label = 'button' - newcard.Ot = 'requiredSgl' - newcard.OpenType = item.subType - newcard.tabType = 'SubTable' - newcard.linkTab = '' - newcard.class = 'default' - newcard.intertype = 'inner' - newcard.position = 'toolbar' - newcard.execSuccess = 'grid' - newcard.execError = 'never' - newcard.popClose = 'never' - newcard.verify = null - } - - let targetId = '' - - if (item.dropTargetId) { - targetId = item.dropTargetId - delete item.dropTargetId - } else if (cards.length > 0) { - targetId = cards.slice(-1)[0].uuid - } - - const { index: overIndex } = findCard(`${targetId}`) - const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) - - handleList(type, _cards, newcard, groupId) - } - }) - - let _width = (setting && setting.width) || 100 - - return ( - <div ref={drop} className="ant-row" style={type === 'search' ? {margin: '0 auto', width: _width + '%'} : {}}> - {type === 'action' && cards.map(card => ( - <Card - key={card.uuid} - id={card.uuid} - type={type} - card={card} - moveCard={moveCard} - editCard={editCard} - delCard={delCard} - profileCard={profileCard} - findCard={findCard} - /> - ))} - {type === 'search' && cards.map(card => ( - <Col key={card.uuid} span={card.type !== 'textarea' ? 24 / setting.cols : 24}> - <Card - id={card.uuid} - key={card.uuid} - type={type} - card={card} - cols={setting.cols} - moveCard={moveCard} - editCard={editCard} - delCard={delCard} - copyCard={copyCard} - findCard={findCard} - /> - </Col> - ))} - {cards.length === 0 && - <div className="common-drawarea-placeholder"> - {type === 'action' ? '璇锋坊鍔犳寜閽�' : '璇锋坊鍔犺〃鍗�'} - </div> - } - </div> - ) -} -export default Container diff --git a/src/templates/formtabconfig/dragelement/index.scss b/src/templates/formtabconfig/dragelement/index.scss deleted file mode 100644 index 38776f9..0000000 --- a/src/templates/formtabconfig/dragelement/index.scss +++ /dev/null @@ -1,15 +0,0 @@ -.common-source-item { - display: block; - box-shadow: 0px 0px 2px #bcbcbc; - padding: 0.4rem 0.7rem; - background-color: white; - margin: 0px 0px 10px; - cursor: move; - border-radius: 4px; -} -.common-drawarea-placeholder { - width: 100%; - line-height: 65px; - text-align: center; - color: #bcbcbc; -} \ No newline at end of file diff --git a/src/templates/formtabconfig/dragelement/itemtypes.js b/src/templates/formtabconfig/dragelement/itemtypes.js deleted file mode 100644 index 9ea1f2c..0000000 --- a/src/templates/formtabconfig/dragelement/itemtypes.js +++ /dev/null @@ -1,8 +0,0 @@ -export default { - CARD: 'card', - form: 'form', - search: 'search', - action: 'action', - columns: 'columns', - tab: 'tab' -} diff --git a/src/templates/formtabconfig/dragelement/source.jsx b/src/templates/formtabconfig/dragelement/source.jsx deleted file mode 100644 index ab22158..0000000 --- a/src/templates/formtabconfig/dragelement/source.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react' -import { useDrag } from 'react-dnd' -import './index.scss' - -const SourceElement = ({content}) => { - const [, drag] = useDrag({ item: content }) - return ( - <div ref={drag} className="common-source-item"> - {content.label} - </div> - ) -} -export default SourceElement \ No newline at end of file diff --git a/src/templates/formtabconfig/groupform/index.jsx b/src/templates/formtabconfig/groupform/index.jsx deleted file mode 100644 index ed21eb8..0000000 --- a/src/templates/formtabconfig/groupform/index.jsx +++ /dev/null @@ -1,129 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, InputNumber } from 'antd' -import { formRule } from '@/utils/option.js' -import TransferForm from '../transferform' -// import Utils from '@/utils/utils.js' -// import './index.scss' - -class GroupForm extends Component { - static propTpyes = { - group: PropTypes.object, // 褰撳墠鍒嗙粍 - groups: PropTypes.array, // 鎵�鏈夊垎缁� - inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 - } - - state = { - source: null, - selectds: null, - default: null - } - - UNSAFE_componentWillMount () { - const { groups, group } = this.props - let defaultgroup = groups.filter(item => item.isDefault)[0] - let _source = defaultgroup.sublist.filter(item => !item.origin) - let _selectds = group.sublist.map(item => item.uuid ) - - _source = [..._source, ...group.sublist] - - this.setState({ - source: _source, - selectds: _selectds, - }) - } - - handleConfirm = () => { - const { groups, group } = this.props - let defaultgroup = groups.filter(item => item.isDefault)[0] - - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = group.uuid - - if (group.isDefault) { - values.isDefault = true - values.sublist = group.sublist - - resolve(values) - } else { - let targetKeys = this.refs['fields-transfer'].state.targetKeys - let defaultlist = this.state.source.filter(item => !targetKeys.includes(item.uuid)) - - values.sublist = targetKeys.map(item => { - return this.state.source.filter(cell => cell.uuid === item)[0] - }) - - resolve({ - default: {...defaultgroup, sublist: defaultlist}, - target: values - }) - } - } else { - reject(err) - } - }) - }) - } - - handleSubmit = (e) => { - e.preventDefault() - - if (this.props.inputSubmit) { - this.props.inputSubmit() - } - } - - render() { - const { group, groups } = this.props - const { getFieldDecorator } = this.props.form - - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - return ( - <Form {...formItemLayout}> - <Row gutter={24}> - <Col span={12}> - <Form.Item label="鍒嗙粍鍚嶇О"> - {getFieldDecorator('label', { - initialValue: group.label, - rules: [ - { - required: true, - message: '璇疯緭鍏ュ垎缁勫悕绉�!' - }, - { - max: formRule.input.max, - message: formRule.input.message - } - ] - })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - <Col span={12}> - <Form.Item label="鎺掑簭"> - {getFieldDecorator('sort', { - initialValue: group.hasOwnProperty('sort') ? group.sort : groups.length - })(<InputNumber min={0} max={100} precision={0} />)} - </Form.Item> - </Col> - {!group.isDefault ? <Col span={24}> - <TransferForm fields={this.state.source} ref="fields-transfer" selected={this.state.selectds}/> - </Col> : null} - </Row> - </Form> - ) - } -} - -export default Form.create()(GroupForm) \ No newline at end of file diff --git a/src/templates/formtabconfig/groupform/index.scss b/src/templates/formtabconfig/groupform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/templates/formtabconfig/groupform/index.scss +++ /dev/null diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx deleted file mode 100644 index 2a172db..0000000 --- a/src/templates/formtabconfig/index.jsx +++ /dev/null @@ -1,1777 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { DndProvider } from 'react-dnd' -import HTML5Backend from 'react-dnd-html5-backend' -import moment from 'moment' -import { Button, Card, Modal, Collapse, notification, Spin, Switch, Tooltip } from 'antd' -import { QuestionCircleOutlined, RedoOutlined, SettingOutlined, PlusOutlined, DeleteOutlined, EditOutlined, SnippetsOutlined } from '@ant-design/icons' - -import Api from '@/api' -import Utils, { FuncUtils } from '@/utils/utils.js' -import { getModalForm, getActionForm } from '@/templates/zshare/formconfig' -import { queryTableSql } from '@/utils/option.js' - -import TabsComponent from '@/templates/sharecomponent/tabscomponent' - -import PasteForm from '@/templates/zshare/pasteform' -import ActionForm from './actionform' -import SettingForm from './settingform' -import DragElement from './dragelement' -import GroupForm from './groupform' - -import MenuForm from '@/templates/zshare/menuform' -import SourceElement from '@/templates/zshare/dragsource' -import asyncComponent from '@/utils/asyncComponent' -import Source from './source' -import './index.scss' - -const { Panel } = Collapse -const { confirm } = Modal - -const UpdateTable = asyncComponent(() => import('./updatetable')) -const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) -const CreateFunc = asyncComponent(() => import('@/templates/zshare/createfunc')) -const VerifyCard = asyncComponent(() => import('@/templates/zshare/verifycard')) - -class ComTableConfig extends Component { - static propTpyes = { - menu: PropTypes.any, - btnTab: PropTypes.object, - config: PropTypes.any, - handleView: PropTypes.func - } - - state = { - config: null, // 椤甸潰閰嶇疆 - modaltype: '', // 妯℃�佹绫诲瀷锛屾帶鍒舵ā鎬佹鏄剧ず - tableColumns: [], // 琛ㄦ牸鏄剧ず鍒� - fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� - menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 - formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 - card: null, // 缂栬緫鍏冪礌 - menuloading: false, // 鑿滃崟淇濆瓨涓� - menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 - loading: false, // 鍔犺浇涓紝椤甸潰spin - settingVisible: false, // 鍏ㄥ眬閰嶇疆妯℃�佹 - closeVisible: false, // 鍏抽棴妯℃�佹 - tables: [], // 鍙敤琛ㄥ悕 - originMenu: null, // 鍘熷鑿滃崟 - delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 - tabviews: [], // 鎵�鏈夋爣绛鹃〉 - profileVisible: false, // 楠岃瘉淇℃伅妯℃�佹 - editgroup: null, // 褰撳墠缂栬緫缁� - groupVisible: false, // 缂栬緫缁勬ā鎬佹 - activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 - pasteVisible: false, // 绮樿创妯℃�佹 - sqlVerifing: false, // sql楠岃瘉 - openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� - } - - /** - * @description 鏁版嵁棰勫鐞� - * 1銆佽缃〉闈㈤厤缃俊鎭紝鏂板缓鎴栨棤閰嶇疆淇℃伅鏃讹紙鍒囨崲妯℃澘鍚庢棤閰嶇疆淇℃伅锛夛紝浣跨敤妯℃澘榛樿閰嶇疆 - * 2銆佽缃搷浣滅被鍨嬨�佸師濮嬭彍鍗曚俊鎭紙姣忔淇濆瓨鍚庨噸缃級銆佸凡浣跨敤琛ㄥ強鍩烘湰淇℃伅琛ㄥ崟 - */ - UNSAFE_componentWillMount () { - const { menu, btnTab, config } = this.props - - let _config = '' - let columns = [] - - if (!config) { - _config = JSON.parse(JSON.stringify(Source.baseConfig)) - _config.isAdd = true - if (menu && menu.LongParam && menu.LongParam.setting) { - _config.setting.tableName = menu.LongParam.setting.tableName - _config.setting.primaryKey = menu.LongParam.setting.primaryKey - _config.setting.dataresource = menu.LongParam.setting.dataresource - _config.setting.interType = menu.LongParam.setting.interType - _config.setting.interface = menu.LongParam.setting.interface - _config.setting.outerFunc = menu.LongParam.setting.outerFunc - _config.setting.innerFunc = menu.LongParam.setting.innerFunc - _config.setting.sysInterface = menu.LongParam.setting.sysInterface - } - } else { - _config = config - - if (menu && menu.LongParam && menu.LongParam.setting) { - _config.setting.primaryKey = menu.LongParam.setting.primaryKey - } - } - - if (!_config.tabgroups) { - _config.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } else if (typeof(_config.tabgroups[0]) === 'string') { - let _tabgroups = [] - _config.tabgroups.forEach(groupId => { - let _group = { - uuid: groupId, - sublist: fromJS(_config[groupId]).toJS() - } - - delete _config[groupId] - - _tabgroups.push(_group) - }) - - _config.tabgroups = _tabgroups - } - - if (menu && menu.LongParam && menu.LongParam.columns) { - columns = menu.LongParam.columns - } - - // 閰嶇疆榛樿鍊硷紝鍏煎 - _config.Template = 'FormTab' - _config.action = _config.action.map(item => { - if (item.intertype === 'inner' && !item.innerFunc) { - item.intertype = 'system' - } - return item - }) - - _config.btnId = btnTab.uuid - _config.btnName = btnTab.label - - this.setState({ - config: _config, - activeKey: btnTab.activeKey || '0', - openEdition: btnTab.open_edition || '', - columns: columns, - originMenu: JSON.parse(JSON.stringify(_config)), - menuformlist: [ - { - type: 'text', - key: 'menuName', - label: '鑿滃崟鍚嶇О', - initVal: menu.MenuName, - readonly: true - }, - { - type: 'text', - key: 'actionName', - label: '鎸夐挳鍚嶇О', - initVal: btnTab.label, - readonly: true - } - ] - }) - } - - /** - * @description 鍔犺浇瀹屾垚鍚� - * 1銆佽幏鍙栫郴缁熷彲浣跨敤琛� - * 2銆佹牴鎹厤缃俊鎭腑宸蹭娇鐢ㄨ〃鑾峰彇鐩稿叧瀛楁淇℃伅 - * 3銆佽幏鍙栨墍鏈夋爣绛鹃〉淇℃伅 - */ - componentDidMount () { - let param = { - func: 'sPC_Get_SelectedList', - LText: queryTableSql, - obj_name: 'data', - arr_field: 'TbName,Remark' - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉 - - Api.getSystemConfig(param).then(res => { - if (res.status) { - this.setState({ - tables: res.data - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - - Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { - if (res.status) { - this.setState({ - tabviews: res.UserTemp.map(temp => { - return { - uuid: temp.MenuID, - value: temp.MenuID, - text: temp.MenuName, - type: temp.Template, - MenuNo: temp.MenuNo - } - }) - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - } - - /** - * @description 鍔犺浇鎴栧埛鏂版爣绛句俊鎭� - */ - reloadTab = () => { - this.setState({ - loading: true, - tabviews: [] - }) - Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { - if (res.status) { - this.setState({ - loading: false, - tabviews: res.UserTemp.map(temp => { - return { - uuid: temp.MenuID, - value: temp.MenuID, - text: temp.MenuName, - type: temp.Template, - MenuNo: temp.MenuNo - } - }) - }) - notification.success({ - top: 92, - message: '鍒锋柊鎴愬姛銆�', - duration: 2 - }) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - - // 椤甸潰杩斿洖 - handleViewBack = () => { - const { menu } = this.props - let _tabview = menu ? menu.LongParam.Template : '' - let param = { - editMenu: menu, - editTab: null, - tabConfig: null, - editSubTab: null, - subTabConfig: null, - btnTab: null, - btnTabConfig: null, - editAction: null, - subConfig: null, - tabview: _tabview - } - - this.props.handleView(param) - } - - handleList = (type, list, card, groupId, elementId) => { - const { config } = this.state - - if (type === 'action') { - if (list.length > config.action.length) { - - this.handleAction(card) - } - - this.setState({config: {...config, action: list}}) - } else if (type === 'search') { - let _groups = null - - if (card) { - // 鍏冪礌娣诲姞 - if (config.groups.length === 1) { - _groups = config.groups.map(group => { - let _list = list.filter(item => !item.origin) - return {...group, sublist: _list} - }) - } else { - _groups = config.groups.map(group => { - if (group.uuid === groupId) { - return {...group, sublist: list} - } else { - return group - } - }) - } - this.handleSearch(card) - } else if (elementId) { - // 淇敼宸叉湁鍏冪礌鐨勫垎缁� - let element = null - _groups = config.groups.map(group => { - group.sublist = group.sublist.filter(item => { - if (item.uuid === elementId) { - element = item - return false - } else { - return true - } - }) - return group - }) - - _groups = _groups.map(group => { - if (group.uuid === groupId) { - group.sublist.push(element) - } - return group - }) - } else { - // 鍏冪礌绉诲姩 - _groups = config.groups.map(group => { - if (group.uuid === groupId) { - return {...group, sublist: list} - } else { - return group - } - }) - } - - this.setState({ - config: {...config, groups: _groups} - }) - } - } - - handleSearch = (card) => { - const { menu } = this.props - const { config } = this.state - let _inputfields = [] - let _tabfields = [] - let _linkableFields = [] - let _linksupFields = [] - let _formfields = [] - - // 璁剧疆涓嬫媺鑿滃崟鍙叧鑱斿瓧娈� - config.groups.forEach(group => { - _formfields = [..._formfields, ...group.sublist] - }) - - let uniq = new Map() - uniq.set(card.field, true) - - _formfields.forEach(item => { - if (['text', 'number', 'textarea', 'color'].includes(item.type) && card.field !== item.field) { - _inputfields.push({ - field: item.field, - label: item.label - }) - } - if (card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { - _tabfields.push({ - field: item.field, - label: item.label - }) - } - - if (item.type !== 'select' && item.type !== 'link') return - if (item.field && !uniq.has(item.field)) { - uniq.set(item.field, true) - - _linkableFields.push({ - field: item.field, - label: item.label + '-琛ㄥ崟' - }) - _linksupFields.push({ - field: item.field, - label: item.label - }) - } - }) - - if (card.linkSubField && card.linkSubField.length > 0) { - let fields = _inputfields.map(item => item.field) - card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) - } - - if (menu.LongParam) { - menu.LongParam.columns.forEach(col => { - if (col.field && !uniq.has(col.field)) { - uniq.set(col.field, true) - - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) - } - - this.setState({ - modaltype: 'search', - card: card, - formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields).map(item => { - if (item.key === 'type') { - item.options = item.options.filter(option => !['switch', 'checkbox', 'radio', 'checkcard', 'hint'].includes(option.value)) - } - return item - }) - }) - } - - handleAction = (card) => { - let usefulFields = sessionStorage.getItem('permFuncField') - if (usefulFields) { - try { - usefulFields = JSON.parse(usefulFields) - } catch (e) { - usefulFields = [] - } - } else { - usefulFields = [] - } - - this.setState({ - modaltype: 'actionEdit', - card: card, - formlist: getActionForm(card, this.state.config, usefulFields) - }) - } - - - /** - * @description 鎼滅储銆佹寜閽�佹樉绀哄垪淇敼鍚庢彁浜や繚瀛� - * 1銆佹悳绱㈡潯浠朵繚瀛橈紝褰撶被鍨嬩负涓嬫媺妗嗕笖瀛樺湪鏁版嵁婧愭椂锛屽皢鏌ヨ鏉′欢鎷兼帴涓簊ql锛屽苟鐢╞ase64杞爜 - * 2銆佹寜閽寘鎷甯哥紪杈戝拰澶嶅埗锛屽鍒舵椂,鎸夐挳鍒楁湯灏炬坊鍔� - * 3銆佹坊鍔犳垨缂栬緫鍒楋紝淇濆瓨鏃讹紝濡傛寜閽綅缃缃负琛ㄦ牸锛屽垯淇敼鎿嶄綔鍒楁樉绀虹姸鎬� - */ - handleSubmit = () => { - const { config, modaltype, card } = this.state - - if (modaltype === 'search') { - this.modalFormRef.handleConfirm().then(res => { - let _config = JSON.parse(JSON.stringify(config)) - - if (_config.setting.primaryKey && _config.setting.primaryKey.toLowerCase() === res.field.toLowerCase()) { - notification.warning({ - top: 92, - message: '琛ㄥ崟涓瓧娈靛悕涓嶅彲涓庝富閿噸澶嶏紒', - duration: 5 - }) - return - } - - let _groups = null - let fieldrepet = false // 瀛楁閲嶅 - - if (card.iscopy) { - _groups = _config.groups.map(group => { - let _index = null - group.sublist.forEach((item, index) => { - if (item.uuid === card.originUuid) { - _index = index - } - - if (item.uuid !== res.uuid && item.field === res.field) { - fieldrepet = true - } - }) - - if (_index !== null) { - group.sublist.splice(_index + 1, 0, res) - } - - if (group.isDefault) { - group.sublist = group.sublist.filter(item => !item.origin) - } - return group - }) - } else { - _groups = _config.groups.map(group => { - group.sublist = group.sublist.map(item => { - if (item.uuid !== res.uuid && item.field === res.field) { - fieldrepet = true - } - - if (item.uuid === res.uuid) { - return res - } else { - return item - } - }) - if (group.isDefault) { - group.sublist = group.sublist.filter(item => !item.origin) - } - return group - }) - } - - if (fieldrepet) { - notification.warning({ - top: 92, - message: '瀛楁宸插瓨鍦紒', - duration: 5 - }) - return - } - - if ((res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && res.resourceType === '1' && /\s/.test(res.dataSource)) { - this.setState({ - sqlVerifing: true - }) - - let param = { - func: 's_debug_sql', - exec_type: 'y', - LText: `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) - ${res.dataSource}` - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) - param.LText = param.LText.replace(/\n/g, ' ') - - param.LText = Utils.formatOptions(param.LText) - param.secretkey = Utils.encrypt('', param.timestamp) - - if (window.GLOB.mainSystemApi && res.database === 'sso') { - param.rduri = window.GLOB.mainSystemApi - } - - Api.genericInterface(param).then(result => { - if (result.status) { - this.setState({ - sqlVerifing: false, - config: {..._config, groups: _groups}, - modaltype: '' - }) - } else { - this.setState({sqlVerifing: false}) - - Modal.error({ - title: result.message - }) - } - }) - } else { - this.setState({ - config: {..._config, groups: _groups}, - modaltype: '' - }) - } - }) - } else if (modaltype === 'actionEdit') { - this.actionFormRef.handleConfirm().then(res => { - let _action = config.action.map(item => { - if (item.uuid === res.uuid) { - return res - } else { - return item - } - }) - - this.setState({ - config: {...config, action: _action}, - modaltype: '' - }) - }) - } - } - - editModalCancel = () => { - const { config, card, modaltype } = this.state - - if (card.focus) { - let _config = null - if (modaltype === 'search') { - let _groups = config.groups.map(group => { - group.sublist = group.sublist.filter(item => item.uuid !== card.uuid) - return group - }) - _config = {...config, groups: _groups} - } else if (modaltype === 'actionEdit') { - let _action = config.action.filter(item => item.uuid !== card.uuid) - _config = {...config, action: _action} - } else { - _config = config - } - - this.setState({ - card: null, - config: _config, - modaltype: '' - }) - } else { - this.setState({ - card: null, - modaltype: '' - }) - } - } - - /** - * @description 鍒涘缓鎸夐挳瀛樺偍杩囩▼ - */ - creatFunc = () => { - const { menu } = this.props - let _config = JSON.parse(JSON.stringify(this.state.config)) - - this.actionFormRef.handleConfirm().then(res => { - let btn = res // 鎸夐挳淇℃伅 - let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql - - // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 - if (!btn.innerFunc) { - notification.warning({ - top: 92, - message: '璇峰~鍐欏唴閮ㄥ嚱鏁帮紒', - duration: 5 - }) - return - } - - let fields = [] - _config.groups.forEach(group => { - fields = [...fields, ...group.sublist] - }) - - let _param = { - funcName: btn.innerFunc, - name: _config.setting.tableName || '', - fields: fields, - menuNo: menu.MenuNo - } - - newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(FuncUtils.dropfunc(_param.funcName)) - - this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText) - }) - } - - /** - * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼ - */ - tableCreatFunc = () => { - const { menu } = this.props - const { config } = this.state - - this.settingRef.handleConfirm().then(setting => { - - if (!(setting.interType === 'inner') || !setting.innerFunc) { - notification.warning({ - top: 92, - message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', - duration: 5 - }) - return - } - - if (/[^\s]+\s+[^\s]+/ig.test(setting.dataresource) && config.setting.dataresource !== setting.dataresource) { - let param = { - func: 's_DataSrc_Save', - LText: setting.dataresource, - MenuID: menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.genericInterface(param) - } - - let _config = {...config, setting: setting} - let newLText = Utils.formatOptions(FuncUtils.getTableFunc(setting.innerFunc, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = Utils.formatOptions(FuncUtils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - - this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText) - }) - } - - deleteElement = (element) => { - let _this = this - confirm({ - content: `纭畾鍒犻櫎<<${element.card.label}>>鍚楋紵`, - onOk() { - let _config = JSON.parse(JSON.stringify(_this.state.config)) - let _delActions = _this.state.delActions - - if (element.type === 'search') { - _config.groups = _config.groups.map(group => { - group.sublist = group.sublist.filter(item => item.uuid !== element.card.uuid) - return group - }) - } else { - _config[element.type] = _config[element.type].filter(item => { - if (item.uuid === element.card.uuid) { - return false - } else { - return true - } - }) - _delActions.push(element.card.uuid) - } - - _this.setState({ - config: _config, - delActions: _delActions - }) - }, - onCancel() {} - }) - } - - /** - * @description 楠岃瘉淇℃伅閰嶇疆 - */ - profileAction = (element) => { - this.setState({ - profileVisible: true, - card: element - }) - } - - /** - * @description 楠岃瘉淇℃伅淇濆瓨 - */ - verifySubmit = () => { - const { card } = this.state - let config = JSON.parse(JSON.stringify(this.state.config)) - - this.verifyRef.handleConfirm().then(res => { - config.action = config.action.map(item => { - if (item.uuid === card.uuid) { - item.verify = res - } - - return item - }) - - this.setState({ - profileVisible: false, - config: config, - card: '' - }) - }) - } - - /** - * @description 鑿滃崟淇濆瓨 - */ - submitConfig = () => { - const { menu, btnTab } = this.props - const { delActions, openEdition } = this.state - - let config = JSON.parse(JSON.stringify(this.state.config)) - - this.menuformRef.handleConfirm().then(res => { - if (config.isAdd) { - if (config.groups[0] && config.groups[0].sublist[0] && config.groups[0].sublist[0].origin) { - config.groups[0].sublist = config.groups[0].sublist.filter(item => !item.origin) - } - config.tabgroups[0].sublist = config.tabgroups[0].sublist.filter(item => !item.origin) - } - - let btnNames = config.action.map(item => item.label) - btnNames = Array.from(new Set(btnNames)) - if (btnNames.length < config.action.length) { - notification.warning({ - top: 92, - message: '鎸夐挳鍚嶇О涓嶅彲鐩稿悓锛�', - duration: 5 - }) - return - } - - let _LongParam = '' - let _config = {...config} - - // 鏁版嵁鏉ユ簮涓烘煡璇笖鏈缃富閿椂锛屽惎鐢ㄤ负false - if (_config.setting.datatype === 'query' && !_config.setting.primaryKey) { - _config.enabled = false - } else if (_config.setting.datatype === 'query' && _config.setting.interType === 'inner' && !_config.setting.innerFunc && !_config.setting.dataresource) { - _config.enabled = false - } - - // 鏍囩涓嶅悎娉曟椂锛屽惎鐢ㄧ姸鎬佷负false - if (_config.tabgroups.length > 1) { - _config.tabgroups.forEach(group => { - if (group.sublist.length === 0) { - _config.enabled = false - } - }) - } - - // 瀛樺湪澶氫綑鐨勭┖琛ㄥ崟缁� - let _ismutil = _config.groups.length > 1 - let _primary = _config.setting.primaryKey ? _config.setting.primaryKey.toLowerCase() : '' - - _config.groups.forEach(group => { - if (_ismutil && group.sublist.length === 0) { - _config.enabled = false - } - let arr = group.sublist.filter(item => item.field && item.field.toLowerCase() === _primary) - - if (arr.length > 0) { - _config.enabled = false - } - }) - - _config.funcs = [] // 椤甸潰鍙婂瓙椤甸潰瀛樺偍杩囩▼闆� - - if (_config.setting.datatype === 'query') { - _config.funcs.push({ - type: 'view', - subtype: 'view', - uuid: btnTab.uuid, - intertype: _config.setting.interType || 'inner', - interface: _config.setting.interface || '', - tableName: _config.setting.tableName || '', - innerFunc: _config.setting.innerFunc || '', - outerFunc: _config.setting.outerFunc || '' - }) - } - - _config.action.forEach(item => { - if (item.btnType !== 'cancel') { - _config.funcs.push({ - type: 'button', - subtype: 'btn', - uuid: item.uuid, - label: item.label, - tableName: item.sql || '', - intertype: item.intertype, - interface: item.interface || '', - innerFunc: item.innerFunc || '', - outerFunc: item.outerFunc || '', - callbackFunc: item.callbackFunc || '' - }) - } - }) - - _config.tabgroups.forEach(group => { - group.sublist.forEach(tab => { - _config.funcs.push({ - type: 'tab', - subtype: 'tab', - uuid: tab.uuid, - label: tab.label, - linkTab: tab.linkTab - }) - }) - }) - - if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� - this.setState({ - menucloseloading: true - }) - } else { - this.setState({ - menuloading: true - }) - } - - new Promise(resolve => { - let deffers = [] - _config.funcs.forEach(item => { - if (item.type === 'tab') { - let deffer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: item.linkTab - }).then(result => { - if (result.status && result.LongParam) { - let _LongParam = '' - - if (result.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam) { - item.menuNo = _LongParam.tabNo - item.subfuncs = _LongParam.funcs || [] - } - } - resolve() - }) - }) - - deffers.push(deffer) - } - }) - - if (deffers.length === 0) { - resolve() - } else { - Promise.all(deffers).then(() => { - resolve() - }) - } - }).then(() => { - - // 鍒犻櫎娣诲姞鏍囪瘑 - delete _config.isAdd - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 5 - }) - - this.setState({ - menucloseloading: false, - menuloading: false - }) - return - } - - let _sort = 0 // 鎸夐挳鍙婃爣绛炬帓搴� - - let btnParam = { // 娣诲姞鑿滃崟鎸夐挳 - func: 'sPC_Button_AddUpt', - Type: 60, // 娣诲姞鎸夐挳琛ㄥ崟椤典笅鐨勬寜閽� - ParentID: btnTab.uuid, - MenuNo: menu.MenuNo, - Template: menu.PageParam.Template || '', - PageParam: '', - LongParam: '', - LText: config.action.map((item, index) => { - _sort++ - return `select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort` - }) - } - - btnParam.LText = btnParam.LText.join(' union all ') - btnParam.LText = Utils.formatOptions(btnParam.LText) - btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) - - // let tabParam = { // 娣诲姞鑿滃崟tab椤� - // func: 'sPC_sMenusTab_AddUpt', - // MenuID: btnTab.uuid - // } - - // let _LText = [] - - // config.tabgroups.forEach(group => { - // group.sublist.forEach(item => { - // _sort++ - // _LText.push(`select '${btnTab.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) - // }) - // }) - - // _LText = _LText.join(' union all ') - - // tabParam.LText = Utils.formatOptions(_LText) - - // tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - // tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) - - let param = { - func: 'sPC_ButtonParam_AddUpt', - ParentID: menu.MenuID, - MenuID: btnTab.uuid, - MenuNo: menu.MenuNo, - Template: 'FormTab', - MenuName: btnTab.label, - PageParam: JSON.stringify({Template: 'FormTab'}), - LongParam: _LongParam - } - - if (openEdition) { - param.open_edition = openEdition - } - - // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣� - // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆 - new Promise(resolve => { - if (delActions.length > 0) { - let deffers = delActions.map(item => { - let _param = { - func: 'sPC_MainMenu_Del', - MenuID: item - } - return new Promise(resolve => { - Api.getSystemConfig(_param).then(response => { - resolve(response) - }) - }) - }) - Promise.all(deffers).then(result => { - let error = null - result.forEach(response => { - if (!response.status) { - error = response - } - }) - - if (error) { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) - resolve(false) - } else { - this.setState({ - delActions: [] - }) - resolve(true) - } - }) - } else if (delActions.length === 0) { - resolve(true) - } - }).then(resp => { - if (resp === false) return - - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - openEdition: response.open_edition || '', - config: _config, - originMenu: _config - }) - - this.submitAction(btnParam) - } else { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 5 - }) - } - }) - }) - }) - }, () => { - notification.warning({ - top: 92, - message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', - duration: 5 - }) - }) - } - - /** - * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽� - */ - submitAction = (btnParam) => { - new Promise(resolve => { - if (btnParam.LText) { - Api.getSystemConfig(btnParam).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - resolve(false) - } else { - resolve(true) - } - }) - } else { - resolve(true) - } - }).then(response => { - this.setState({ - menuloading: false, - menucloseloading: false - }) - - if (response) { - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 2 - }) - if (this.state.closeVisible) { - this.handleViewBack() - } - } - }) - } - - cancelConfig = () => { - const { config, originMenu } = this.state - - let _this = this - - if (config.isAdd) { - confirm({ - content: '鎸夐挳閰嶇疆灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', - onOk() { - _this.handleViewBack() - }, - onCancel() {} - }) - } else { - let _config = {...config} - - if (!is(fromJS(_config), fromJS(originMenu))) { - this.setState({ - closeVisible: true - }) - } else { - this.handleViewBack() - } - } - } - - changeSetting = () => { - this.setState({ - settingVisible: true - }) - } - - settingSave = () => { - const { menu } = this.props - const {config} = this.state - - this.settingRef.handleConfirm().then(res => { - if ( - res.interType === 'inner' && - !res.innerFunc && - /[^\s]+\s+[^\s]+/ig.test(res.dataresource) && - config.setting.dataresource !== res.dataresource - ) { - let param = { - func: 's_DataSrc_Save', - LText: res.dataresource, - MenuID: menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.genericInterface(param) - } - - if (res.interType === 'inner' && !res.innerFunc && res.dataresource && /\s/.test(res.dataresource)) { - this.setState({ - sqlVerifing: true - }) - - let param = { - func: 's_debug_sql', - exec_type: 'y', - LText: res.dataresource - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) - param.LText = param.LText.replace(/\n/g, ' ') - - param.LText = Utils.formatOptions(param.LText) - param.secretkey = Utils.encrypt('', param.timestamp) - - Api.genericInterface(param).then(result => { - if (result.status) { - this.setState({ - sqlVerifing: false, - config: {...config, setting: res}, - settingVisible: false - }) - } else { - this.setState({sqlVerifing: false}) - - Modal.error({ - title: result.message - }) - } - }) - } else { - this.setState({ - config: {...config, setting: res}, - settingVisible: false - }) - } - }) - } - - /** - * @description 璁剧疆鍙厤缃爣绛� - */ - setSubConfig = (btn) => { - const {menu, btnTab} = this.props - const { config, originMenu, activeKey, openEdition } = this.state - - if (config.isAdd) { - notification.warning({ - top: 92, - message: '鑿滃崟灏氭湭淇濆瓨锛岃淇濆瓨鑿滃崟閰嶇疆锛�', - duration: 5 - }) - } else { - this.menuformRef.handleConfirm().then(res => { - let _config = {...config} - - if (!is(fromJS(originMenu), fromJS(_config))) { - notification.warning({ - top: 92, - message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 5 - }) - } else { - this.setState({ - loading: true - }) - - btnTab.activeKey = activeKey // 淇濆瓨褰撳墠鎵撳紑椤电 - btnTab.open_edition = openEdition // 鏇存柊鐗堟湰鍙� - - let param = { - editMenu: menu, - editTab: btn, - tabConfig: null, - editSubTab: null, - subTabConfig: null, - btnTab: btnTab, - btnTabConfig: _config, - editAction: null, - subConfig: '', - tabview: btn.type - } - - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: btn.linkTab - }).then(res => { - if (res.status) { - this.setState({ - loading: false - }) - let _LongParam = '' - if (res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { - param.subConfig = _LongParam - } - - if (param.editTab) { - param.editTab.open_edition = res.open_edition || '' - } - - this.props.handleView(param) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - }, () => { - notification.warning({ - top: 92, - message: '鑿滃崟鍩烘湰淇℃伅宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 5 - }) - }) - } - } - - onEnabledChange = () => { - const { config } = this.state - - let tabinvalid = true - if (config.tabgroups.length > 1) { - config.tabgroups.forEach(group => { - if (group.sublist.length === 0) { - tabinvalid = false - } - }) - } - let forminvalid = true - if (config.groups.length > 1) { - config.groups.forEach(group => { - if (group.sublist.length === 0) { - forminvalid = false - } - }) - } - - let _primary = config.setting.primaryKey ? config.setting.primaryKey.toLowerCase() : '' - let primaryrepeat = false - - config.groups.forEach(group => { - let arr = group.sublist.filter(item => item.field && item.field.toLowerCase() === _primary) - - if (arr.length > 0) { - primaryrepeat = true - } - }) - - if (config.setting.datatype === 'query' && config.setting.interType === 'inner' && !config.setting.innerFunc && !config.setting.dataresource) { - notification.warning({ - top: 92, - message: '灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�', - duration: 5 - }) - } else if (config.setting.datatype === 'query' && !config.setting.primaryKey) { - notification.warning({ - top: 92, - message: '灏氭湭璁剧疆涓婚敭锛屼笉鍙惎鐢紒', - duration: 5 - }) - } else if (!tabinvalid) { - notification.warning({ - top: 92, - message: '瀛樺湪澶氫綑鏍囩缁勶紝涓嶅彲鍚敤锛�', - duration: 5 - }) - } else if (!forminvalid) { - notification.warning({ - top: 92, - message: '瀛樺湪澶氫綑绌鸿〃鍗曠粍锛屼笉鍙惎鐢紒', - duration: 5 - }) - } else if (primaryrepeat) { - notification.warning({ - top: 92, - message: '琛ㄥ崟瀛楁涓庝富閿噸澶嶏紝涓嶅彲鍚敤锛�', - duration: 5 - }) - } else { - this.setState({ - config: {...config, enabled: !config.enabled} - }) - } - } - - - - handleGroup = (group) => { - let editgroup = { - label: '', - sort: 0, - uuid: Utils.getuuid(), - sublist: [] - } - - if (group) { - editgroup = group - } - - this.setState({ - groupVisible: true, - editgroup: editgroup - }) - } - - closeGroup = (group) => { - const { config } = this.state - let _this = this - - confirm({ - content: `纭畾鍒犻櫎鍒嗙粍<<${group.label}>>鍚楋紵`, - onOk() { - let groups = config.groups.filter(item => !(item.uuid === group.uuid)) - groups = groups.map(item => { - if (item.isDefault) { - item.sublist = [...item.sublist, ...group.sublist] - } - - return item - }) - - _this.setState({ - config: {...config, groups: groups}, - }) - }, - onCancel() {} - }) - } - - handleGroupSave = () => { - const { editgroup, config } = this.state - let groups = config.groups.filter(item => !item.isDefault && item.uuid !== editgroup.uuid) - - this.groupRef.handleConfirm().then(res => { - if (editgroup.isDefault) { - groups.push(res) - } else { - groups.push(res.default, res.target) - } - - groups = groups.sort((a, b) => { - return a.sort - b.sort - }) - - this.setState({ - config: {...config, groups: groups}, - editgroup: '', - groupVisible: false, - }) - }) - } - - - pasteSubmit = () => { - let _config = JSON.parse(JSON.stringify(this.state.config)) - - this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType === 'form') { - _config.groups.forEach(group => { - if (group.isDefault) { - group.sublist.push(res) - } - }) - - if (res.type === 'linkMain') { - notification.warning({ - top: 92, - message: '涓嶆敮鎸佹琛ㄥ崟绫诲瀷锛�', - duration: 5 - }) - return - } - - this.setState({ - config: _config, - pasteVisible: null - }, () => { - this.handleSearch(res) - }) - } else { - notification.warning({ - top: 92, - message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', - duration: 5 - }) - } - }) - } - - /** - * @description 鏇存柊鏍囩閰嶇疆淇℃伅 - */ - updatetabs = (config, delcards) => { - const { delActions } = this.state - - this.setState({ - config: config, - delActions: delcards ? [...delActions, ...delcards.map(item => item.uuid)] : delActions - }) - } - - render () { - const { config, modaltype, activeKey } = this.state - let _length = config.groups.length - - let configTabs = [] - config.tabgroups.forEach(group => { - configTabs.push(...group.sublist) - }) - - return ( - <div className="form-tab-board"> - <DndProvider backend={HTML5Backend}> - {/* 宸ュ叿鏍� */} - <div className="tools"> - <Collapse accordion defaultActiveKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> - {/* 鍩烘湰淇℃伅 */} - <Panel forceRender={true} header="鍩烘湰淇℃伅" key="0" id="common-basedata"> - {/* 鑿滃崟淇℃伅 */} - <MenuForm - formlist={this.state.menuformlist} - wrappedComponentRef={(inst) => this.menuformRef = inst} - /> - </Panel> - {/* 鎼滅储鏉′欢娣诲姞 */} - <Panel header="琛ㄥ崟" key="1"> - <div className="search-element"> - {Source.searchItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} - </div> - </Panel> - {/* 鎸夐挳娣诲姞 */} - <Panel header="鎸夐挳" key="2"> - <div className="search-element"> - {Source.actionItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} - </div> - </Panel> - {/* 娣诲姞鏍囩 */} - <Panel header="鏍囩椤�" key="4"> - <div className="search-element"> - {Source.tabItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} - </div> - {configTabs.length > 0 ? - <p className="config-btn-title"> - <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫爣绛鹃厤缃俊鎭��"> - <QuestionCircleOutlined className="mk-form-tip" /> - </Tooltip> - 鏍囩閰嶇疆 - </p> : null - } - {configTabs.map((item, index) => { - return ( - <div key={index}> - <Button - className="config-button" - icon={item.icon} - style={{marginBottom: '10px'}} - onClick={() => this.setSubConfig(item, 'tab')} - >{item.label}</Button> - </div> - ) - })} - </Panel> - </Collapse> - </div> - <div className="setting"> - <Card title={ - <div> - 椤甸潰閰嶇疆 - <RedoOutlined style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={this.reloadTab} /> - </div> - } bordered={false} extra={ - <div> - <UpdateTable config={config} menu={this.props.menu}/> - <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> - <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>淇濆瓨</Button> - <Button onClick={this.cancelConfig}>杩斿洖</Button> - </div> - } style={{ width: '100%' }}> - <SettingOutlined onClick={this.changeSetting} /> - <Collapse - activeKey={config.groups.map(group => group.uuid)} - expandIconPosition={'right'} - > - {config.groups.map((group, index) => ( - <Panel showArrow={false} header={group.label} key={group.uuid} extra={( - <span> - {index === _length - 1 ? <PlusOutlined - onClick={() => { this.handleGroup()}} - /> : null} - {_length > 1 && index !== _length - 1 ? <DeleteOutlined - onClick={() => { this.closeGroup(group) }} - /> : null} - <EditOutlined onClick={() => { this.handleGroup(group) }}/> - </span> - )}> - {group.isDefault ? <SnippetsOutlined title="绮樿创" onClick={() => {this.setState({pasteVisible: true})}} /> : null} - <DragElement - type="search" - groupId={group.uuid} - list={group.sublist} - handleList={this.handleList} - setting={config.setting} - handleMenu={this.handleSearch} - deleteMenu={this.deleteElement} - /> - </Panel> - ))} - </Collapse> - <div className="action-list"> - <DragElement - type="action" - list={this.state.config.action} - handleList={this.handleList} - handleMenu={this.handleAction} - deleteMenu={this.deleteElement} - profileMenu={this.profileAction} - /> - </div> - {/* 鏍囩缁� */} - <TabsComponent - config={config} - tabs={this.state.tabviews} - setSubConfig={(item) => this.setSubConfig(item, 'tab')} - updatetabs={this.updatetabs} - /> - </Card> - </div> - </DndProvider> - {/* 缂栬緫琛ㄥ崟 */} - <Modal - title={this.state.card && this.state.card.iscopy ? '琛ㄥ崟-澶嶅埗' : '琛ㄥ崟-缂栬緫'} - visible={modaltype === 'search'} - width={950} - maskClosable={false} - onOk={this.handleSubmit} - confirmLoading={this.state.sqlVerifing} - onCancel={this.editModalCancel} - destroyOnClose - > - <ModalForm - card={this.state.card} - formlist={this.state.formlist} - inputSubmit={this.handleSubmit} - wrappedComponentRef={(inst) => this.modalFormRef = inst} - /> - </Modal> - {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} - <Modal - title="鎸夐挳缂栬緫" - visible={modaltype === 'actionEdit'} - width={920} - maskClosable={false} - onCancel={this.editModalCancel} - footer={[ - this.state.card && this.state.card.btnType !== 'cancel' ? - <CreateFunc key="create" ref="btnCreatFunc" trigger={this.creatFunc}/> : null, - <Button key="cancel" onClick={this.editModalCancel}>鍙栨秷</Button>, - <Button key="confirm" type="primary" onClick={this.handleSubmit}>纭畾</Button> - ]} - destroyOnClose - > - <ActionForm - card={this.state.card} - tabs={this.state.tabviews} - formlist={this.state.formlist} - inputSubmit={this.handleSubmit} - wrappedComponentRef={(inst) => this.actionFormRef = inst} - /> - </Modal> - {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} - <Modal - wrapClassName="mk-pop-modal" - visible={this.state.profileVisible} - width={'90vw'} - maskClosable={false} - okText="鎻愪氦" - onOk={this.verifySubmit} - onCancel={() => { - if (this.verifyRef.handleCancel) { - this.verifyRef.handleCancel().then(() => { - this.setState({ profileVisible: false }) - }) - } else { - this.setState({ profileVisible: false }) - } - }} - destroyOnClose - > - <VerifyCard - card={this.state.card} - btnTab={this.props.btnTab} - config={this.state.config} - columns={this.state.columns} - wrappedComponentRef={(inst) => this.verifyRef = inst} - /> - </Modal> - {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} - <Modal - title="缂栬緫" - visible={this.state.settingVisible} - width={700} - maskClosable={false} - onCancel={() => { // 鍙栨秷淇敼 - this.setState({ - settingVisible: false - }) - }} - footer={[ - <CreateFunc key="create" ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, - <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>鍙栨秷</Button>, - <Button key="confirm" type="primary" loading={this.state.sqlVerifing} onClick={this.settingSave}>纭畾</Button> - ]} - destroyOnClose - > - <SettingForm - menu={this.props.menu} - config={this.state.config} - inputSubmit={this.settingSave} - wrappedComponentRef={(inst) => this.settingRef = inst} - /> - </Modal> - <Modal - bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}} - closable={false} - maskClosable={false} - visible={this.state.closeVisible} - onCancel={() => { this.setState({closeVisible: false}) }} - footer={[ - <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>淇濆瓨</Button>, - <Button key="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>涓嶄繚瀛�</Button>, - <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>鍙栨秷</Button> - ]} - destroyOnClose - > - 閰嶇疆宸蹭慨鏀癸紝鏄惁淇濆瓨閰嶇疆淇℃伅锛� - </Modal> - <Modal - title="鍒嗙粍绠$悊" - visible={this.state.groupVisible} - width={700} - maskClosable={false} - onOk={this.handleGroupSave} - onCancel={() => { this.setState({ groupVisible: false }) }} - destroyOnClose - > - <GroupForm - groups={config.groups} - group={this.state.editgroup} - inputSubmit={this.handleGroupSave} - wrappedComponentRef={(inst) => this.groupRef = inst} - /> - </Modal> - {/* 鎸夐挳閰嶇疆淇℃伅绮樿创澶嶅埗 */} - <Modal - title="绮樿创" - visible={this.state.pasteVisible} - width={600} - maskClosable={false} - onOk={this.pasteSubmit} - onCancel={() => {this.setState({pasteVisible: null})}} - destroyOnClose - > - <PasteForm - wrappedComponentRef={(inst) => this.pasteFormRef = inst} - inputSubmit={this.pasteSubmit} - /> - </Modal> - {this.state.loading && <Spin size="large" />} - </div> - ) - } -} - -export default ComTableConfig diff --git a/src/templates/formtabconfig/index.scss b/src/templates/formtabconfig/index.scss deleted file mode 100644 index cb73f81..0000000 --- a/src/templates/formtabconfig/index.scss +++ /dev/null @@ -1,394 +0,0 @@ -.form-tab-board { - position: fixed; - z-index: 1070; - padding-top: 48px; - top: 0px; - left: 0px; - right: 0px; - bottom: 0px; - background: rgba(0, 0, 0, 0.35); - display: flex; - .tools { - flex: 1; - background: #ffffff; - border-right: 1px solid #d9d9d9; - height: 100%; - overflow-y: auto; - padding-bottom: 30px; - .ant-collapse-borderless { - background-color: #ffffff; - } - .ant-collapse-item { - position: relative; - border: 0; - } - .ant-input-search { - margin-top: 10px; - } - .ant-collapse-item.ant-collapse-item-active { - border-bottom: 1px solid #d9d9d9; - } - .ant-collapse .ant-collapse-header { - padding: 11px 16px 10px 40px; - border-bottom: 1px solid #d9d9d9; - background: #1890ff; - color: #ffffff; - } - .ant-collapse-content-box { - .ant-form-item { - margin-bottom: 10px; - .ant-form-item-label { - text-align: left; - height: 25px; - line-height: 25px; - } - } - } - .search-element { - padding-top: 10px; - li { - padding: 0px 16px 10px; - div { - cursor: move; - } - } - } - .config-btn-title { - margin-top: 20px; - margin-bottom: 10px; - color: #1890ff; - border-bottom: 1px solid #e8e8e8; - } - .config-button { - min-width: 65px; - } - } - .tools::-webkit-scrollbar { - width: 4px; - } - .tools::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.08); - background: rgba(0, 0, 0, 0.08); - } - .tools::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - .setting { - position: relative; - width: calc(100vw - 235px); - height: 100%; - background: #ffffff; - .ant-switch.big { - min-width: 60px; - height: 28px; - line-height: 28px; - margin-top: -2px; - .ant-switch-inner { - font-size: 14px; - } - } - .ant-switch.big::after { - width: 24px; - height: 24px; - } - .ant-card-head { - min-height: 44px; - } - .ant-card-head-title { - padding: 5px 0; - color: #1890ff; - } - .ant-card-extra { - padding: 5px 0; - button { - margin-left: 20px; - } - } - .ant-card-body { - position: relative; - padding: 0 0 40px; - - > .anticon-setting { - position: absolute; - font-size: 18px; - right: 7px; - top: 10px; - padding: 10px; - z-index: 1; - } - - >.ant-collapse { - border-radius: 0; - border: 0; - margin-top: 45px; - .ant-collapse-header { - cursor: default; - border-radius: 0; - background: #1890ff; - color: #ffffff; - padding-left: 30px; - padding-right: 20px; - .anticon { - font-size: 16px; - } - .ant-collapse-extra { - .anticon-edit { - position: absolute; - left: 5px; - top: 2px; - } - } - } - .ant-collapse-item:last-child { - border-radius: 0; - .ant-collapse-content { - border-radius: 0; - } - } - .ant-collapse-content-box { - position: relative; - padding: 16px 30px; - > .ant-row { - min-height: 90px; - padding-bottom: 30px; - .page-card { - position: relative; - background: #ffffff; - border-radius: 2px; - padding-top: 15px; - .ant-form-item { - cursor: move; - display: flex; - margin-bottom: 0px; - .ant-form-item-label { - overflow: visible; - label { - width: 100%; - cursor: move; - overflow: hidden; - display: inline-block; - text-overflow: ellipsis; - white-space: nowrap; - } - } - .ant-form-item-label.ant-col-cuslabel { - width: 11%; - } - .ant-form-item-control-wrapper.ant-col-cuswrap { - width: 89%; - } - .ant-form-item-control-wrapper { - position: relative; - .ant-input-number { - margin-top: 4px; - } - .ant-select { - width: 100%; - margin-top: 4px; - } - .ant-calendar-picker { - margin-top: 4px; - } - .ant-btn { - margin-top: 4px; - } - .data-range .ant-calendar-picker-input { - padding: 4px 20px 4px 5px; - font-size: 13px; - } - } - .ant-form-item-control-wrapper::after { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - opacity: 0; - z-index: 1; - } - } - } - .ant-calendar-picker { - min-width: 100px!important; - width: 100%; - } - } - .anticon-snippets { - position: absolute; - font-size: 14px; - right: 10px; - top: 0px; - padding: 10px; - z-index: 1; - } - } - } - - .action-list { - position: relative; - padding: 0px 20px 15px; - min-height: 82px; - text-align: center; - > .ant-row { - min-height: 67px; - } - .page-card { - display: inline-block; - padding: 0px; - margin: 15px 10px 0 0; - position: relative; - div { - cursor: move; - } - - button { - cursor: move; - min-width: 70px; - margin-right: 10px; - height: 35px; - font-size: 15px; - padding: 5px 20px; - .anticon-table { - font-size: 10px; - position: absolute; - right: 1px; - bottom: 0px; - } - } - } - } - .tab-list { - position: relative; - padding: 30px 20px 0px; - .ant-switch { - position: absolute; - right: 20px; - top: 20px; - } - > .ant-row { - min-height: 47px; - .page-card { - position: relative; - padding: 0px; - > div { - padding: 12px 0px 0px; - cursor: move; - } - } - .ant-tabs-tab { - cursor: default; - } - .ant-tabs-bar { - min-height: 55px; - } - .ant-tabs-content { - .ant-tabs-tabpane img { - width: 100%; - } - } - } - > .anticon-plus { - position: absolute; - font-size: 18px; - right: 25px; - top: 50px; - z-index: 1; - color: #26C281; - cursor: pointer; - } - > .anticon-delete { - position: absolute; - font-size: 19px; - right: 25px; - top: 50px; - z-index: 1; - color: #ff4d4f; - cursor: pointer; - } - > .anticon-arrow-up { - position: absolute; - right: 55px; - font-size: 19px; - z-index: 1; - top: 50px; - color: #1890ff; - cursor: pointer; - } - > .anticon-arrow-down { - position: absolute; - right: 55px; - font-size: 19px; - z-index: 1; - top: 50px; - color: purple; - cursor: pointer; - } - > .anticon-arrow-down + .anticon-arrow-up { - right: 85px; - } - .ant-tabs-nav-container-scrolling { - margin-right: 50px; - } - } - } - } - .setting { - overflow-y: scroll; - } - .setting::-webkit-scrollbar { - width: 7px; - } - .setting::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - display: none; - } - .setting::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - .setting:hover::-webkit-scrollbar-thumb { - display: block; - } - .ant-spin { - position: absolute; - margin-left: calc(50vw - 22px); - margin-top: 30vh; - } -} - -.common-table-fields-modal { - .ant-modal { - top: 50px; - padding-bottom: 5px; - .ant-modal-body { - max-height: calc(100vh - 190px); - overflow-y: auto; - .ant-empty { - margin: 15vh 8px; - } - } - .ant-modal-body::-webkit-scrollbar { - width: 7px; - } - .ant-modal-body::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - .ant-modal-body::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - } -} diff --git a/src/templates/formtabconfig/settingform/index.jsx b/src/templates/formtabconfig/settingform/index.jsx deleted file mode 100644 index 7330244..0000000 --- a/src/templates/formtabconfig/settingform/index.jsx +++ /dev/null @@ -1,361 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio, Select, Tooltip, notification, InputNumber } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' - -import { formRule } from '@/utils/option.js' -import Utils from '@/utils/utils.js' -import './index.scss' - -const { TextArea } = Input - -class SettingForm extends Component { - static propTpyes = { - menu: PropTypes.object, - config: PropTypes.object, - inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 - } - - state = { - interType: (this.props.config.setting && this.props.config.setting.interType) || 'inner', - columns: null, - usefulFields: [], - interReadonly: false, - } - - UNSAFE_componentWillMount() { - const { config } = this.props - - let _columns = [] - let _setting = config.setting - - try { - config.groups.forEach(group => { - let list = group.sublist.filter(item => item.field) - _columns = [..._columns, ...list] - }) - - let _colMap = new Map() - _columns = _columns.filter(item => { - if (_colMap.has(item.field)) { - return false - } else { - _colMap.set(item.field, true) - return true - } - }) - } catch (e) { - notification.warning({ - top: 92, - message: '鑿滃崟淇℃伅閿欒锛�', - duration: 5 - }) - } - - let usefulFields = sessionStorage.getItem('permFuncField') - if (usefulFields) { - try { - usefulFields = JSON.parse(usefulFields) - } catch (e) { - usefulFields = [] - } - } else { - usefulFields = [] - } - - this.setState({ - columns: _columns, - setting: _setting, - interType: _setting.interType || 'inner', - interReadonly: _setting.sysInterface === 'true', - datatype: _setting.datatype || 'maintable', - usefulFields - }) - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - return - } - - resolve(values) - } else { - reject(err) - } - }) - }) - } - - onSysChange = (e) => { - if (e.target.value === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - this.setState({ - interReadonly: true - }) - } else { - this.setState({ - interReadonly: false - }) - } - } - - onChange = (e) => { - this.setState({ - interType: e.target.value - }, () => { - if (e.target.value === 'inner') return - - let _type = this.props.form.getFieldValue('sysInterface') - if (_type === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - this.setState({ - interReadonly: true - }) - } else { - this.setState({ - interReadonly: false - }) - } - }) - } - - sourceChange = (e) => { - const { interType } = this.state - - this.setState({ - datatype: e.target.value - }, () => { - if (interType === 'inner') return - - let _type = this.props.form.getFieldValue('sysInterface') - if (_type === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - this.setState({ - interReadonly: true - }) - } else { - this.setState({ - interReadonly: false - }) - } - }) - } - - handleSubmit = (e) => { - e.preventDefault() - - if (this.props.inputSubmit) { - this.props.inputSubmit() - } - } - - render() { - const { menu } = this.props - const { getFieldDecorator } = this.props.form - const { interType, setting, datatype, usefulFields } = this.state - - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - let str = '^(' + usefulFields.join('|') + ')' - let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') - - return ( - <Form {...formItemLayout} className="ant-advanced-search-form commontable-setting-form" id="commontable-setting-form"> - <Row gutter={24}> - <Col span={12}> - <Form.Item label="琛ㄥ悕"> - {getFieldDecorator('tableName', { - initialValue: setting.tableName, - rules: [ - { - required: true, - message: '璇疯緭鍏ヨ〃鍚�!' - }, - { - max: 50, - message: '琛ㄥ悕鏈�闀夸负50涓瓧绗�!' - } - ] - })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - <Col span={12}> - <Form.Item label="鍒楁暟"> - {getFieldDecorator('cols', { - initialValue: setting.cols || '2' - })( - <Select> - <Select.Option value="1">1鍒�</Select.Option> - <Select.Option value="2">2鍒�</Select.Option> - <Select.Option value="3">3鍒�</Select.Option> - <Select.Option value="4">4鍒�</Select.Option> - </Select> - )} - </Form.Item> - </Col> - <Col span={12}> - <Form.Item label="鏁版嵁鏉ユ簮"> - {getFieldDecorator('datatype', { - initialValue: setting.datatype || 'query' - })( - <Radio.Group onChange={this.sourceChange}> - <Radio value="maintable">涓昏〃</Radio> - <Radio value="query">鏌ヨ</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - <Col span={12}> - <Form.Item label="涓婚敭"> - {getFieldDecorator('primaryKey', { - initialValue: setting.primaryKey - })(<Input placeholder="" autoComplete="off" disabled/>)} - </Form.Item> - </Col> - {datatype === 'query' ? <Col span={12}> - <Form.Item label="鎺ュ彛绫诲瀷"> - {getFieldDecorator('interType', { - initialValue: interType - })( - <Radio.Group onChange={this.onChange}> - <Radio value="inner">鍐呴儴</Radio> - <Radio value="outer">澶栭儴</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> : null} - {datatype === 'query' && interType === 'outer' ? <Col span={12}> - <Form.Item label={ - <Tooltip placement="topLeft" title="鍗曠偣鐧诲綍绯荤粺"> - <QuestionCircleOutlined className="mk-form-tip" /> - 绯荤粺鎺ュ彛 - </Tooltip> - }> - {getFieldDecorator('sysInterface', { - initialValue: setting.sysInterface || 'false' - })( - <Radio.Group onChange={this.onSysChange}> - <Radio value="true">鏄�</Radio> - <Radio value="false">鍚�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> : null} - {datatype === 'query' && interType === 'outer' ? <Col span={12}> - <Form.Item label="鎺ュ彛鍦板潃"> - {getFieldDecorator('interface', { - initialValue: setting.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (setting.interface || ''), - rules: [ - { - required: true, - message: '璇疯緭鍏ユ帴鍙e湴鍧�!' - }, - { - max: formRule.input.max, - message: formRule.input.message - } - ] - })(<Input placeholder="" autoComplete="off" disabled={this.state.interReadonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> : null} - {datatype === 'query' && interType !== 'outer' ? <Col span={12}> - <Form.Item label={ - <Tooltip placement="topLeft" overlayClassName="middle" title={`鍙嚜瀹氫箟鏁版嵁澶勭悊鍑芥暟锛屽嚱鏁板悕绉伴渶浠�${usefulFields.join(', ')}绛夊瓧绗﹀紑濮嬶紱鏈缃椂浼氳皟鐢ㄧ郴缁熷嚱鏁帮紝浣跨敤绯荤粺鍑芥暟闇�瀹屽杽鏁版嵁婧愩�俙}> - <QuestionCircleOutlined className="mk-form-tip" /> - 鍐呴儴鍑芥暟 - </Tooltip> - }> - {getFieldDecorator('innerFunc', { - initialValue: setting.innerFunc || '', - rules: [ - { - pattern: _patten, - message: formRule.func.innerMessage - }, { - max: formRule.func.max, - message: formRule.func.maxMessage - } - ] - })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> : null} - {datatype === 'query' && interType !== 'outer' ? <Col span={24}> - <Form.Item help={'鏁版嵁ID锛�' + menu.MenuID} label={ - <Tooltip placement="topLeft" title="浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愶紝鑷畾涔夊嚱鏁版椂锛屽彲蹇界暐銆�"> - <QuestionCircleOutlined className="mk-form-tip" /> - 鏁版嵁婧� - </Tooltip> - } className="textarea"> - {getFieldDecorator('dataresource', { - initialValue: setting.dataresource - })(<TextArea rows={4} />)} - </Form.Item> - </Col> : null} - {datatype === 'query' && interType === 'outer' ? <Col span={12}> - <Form.Item label="澶栭儴鍑芥暟"> - {getFieldDecorator('outerFunc', { - initialValue: setting.outerFunc || '', - rules: [ - { - pattern: formRule.func.pattern, - message: formRule.func.message - }, { - max: formRule.func.max, - message: formRule.func.maxMessage - } - ] - })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> : null} - <Col span={12}> - <Form.Item label="瀹藉害"> - {getFieldDecorator('width', { - initialValue: setting.width || 100 - })(<InputNumber min={10} max={100} precision={0} />)} - </Form.Item> - </Col> - <Col span={12}> - <Form.Item label="鍒濆鍖�"> - {getFieldDecorator('onload', { - initialValue: setting.onload || 'true' - })( - <Select> - <Select.Option value="true">鍔犺浇鏁版嵁</Select.Option> - <Select.Option value="false">涓嶅姞杞芥暟鎹�</Select.Option> - </Select> - )} - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(SettingForm) \ No newline at end of file diff --git a/src/templates/formtabconfig/settingform/index.scss b/src/templates/formtabconfig/settingform/index.scss deleted file mode 100644 index bf9fa12..0000000 --- a/src/templates/formtabconfig/settingform/index.scss +++ /dev/null @@ -1,10 +0,0 @@ -.ant-advanced-search-form.commontable-setting-form { - .textarea { - .ant-form-item-label { - width: 16.3%; - } - .ant-form-item-control-wrapper { - width: 83.33333333%; - } - } -} \ No newline at end of file diff --git a/src/templates/formtabconfig/source.jsx b/src/templates/formtabconfig/source.jsx deleted file mode 100644 index 57eeafd..0000000 --- a/src/templates/formtabconfig/source.jsx +++ /dev/null @@ -1,184 +0,0 @@ -import Utils from '@/utils/utils.js' - -class CommonTableBaseData { - baseConfig = { - Template: 'FormTab', - enabled: false, - setting: { - datatype: 'query', - cols: '2', - width: 90 - }, - tables: [], - groups: [ - { - isDefault: true, - uuid: Utils.getuuid(), - label: 'label', - sort: 101, - sublist: [ - { - origin: true, - uuid: Utils.getuuid(), - label: 'label', - field: '', - initval: '', - type: 'text', - resourceType: '0', - options: [], - orderType: 'asc' - }, { - origin: true, - uuid: Utils.getuuid(), - label: 'label', - field: '', - initval: '', - type: 'select', - resourceType: '0', - options: [], - orderType: 'asc' - }, { - origin: true, - uuid: Utils.getuuid(), - label: 'label', - field: '', - initval: '', - type: 'date', - resourceType: '0', - options: [], - orderType: 'asc' - } - ] - } - ], - action: [ - { - btnType: 'confirm', - uuid: Utils.getuuid(), - label: '纭畾', - intertype: 'system', - innerFunc: '', - interface: '', - outerFunc: '', - sql: '', - sqlType: '', - callbackFunc: '', - Ot: 'notRequired', - execSuccess: 'grid', - execError: 'never', - OpenType: 'exec', - icon: '', - class: 'border-primary', - verify: null - }, { - btnType: 'cancel', - uuid: Utils.getuuid(), - label: '鍏抽棴', - execSuccess: 'grid', - execError: 'never', - OpenType: 'exec', - pageTemplate: '', - url: '', - icon: '', - class: 'border-danger' - } - ], - tabgroups: [{ - uuid: 'tabs', - sublist: [ - { - origin: true, // 鏄惁涓虹ず渚� - uuid: Utils.getuuid(), - label: 'tab1', - type: 'SubTable', - linkTab: '', - supMenu: '' - }, - { - origin: true, - uuid: Utils.getuuid(), - label: 'tab2', - type: 'SubTable', - linkTab: '', - supMenu: '' - } - ] - }] - } - - searchItems = [ - { - type: 'search', - label: '鏂囨湰', - subType: 'text', - url: '' - }, - { - type: 'search', - label: '鏁板瓧', - subType: 'number', - url: '' - }, - { - type: 'search', - label: '涓嬫媺閫夋嫨', - subType: 'select', - url: '' - }, - { - type: 'search', - label: '鏂囦欢涓婁紶', - subType: 'fileupload', - url: '' - }, - { - type: 'search', - label: '鏃堕棿锛堝ぉ锛�', - subType: 'date', - url: '' - }, - { - type: 'search', - label: '鏃堕棿锛堟湀锛�', - subType: 'datemonth', - url: '' - }, - { - type: 'search', - label: '鏃堕棿锛堢锛�', - subType: 'datetime', - url: '' - }, - { - type: 'search', - label: '澶氳鏂囨湰', - subType: 'textarea', - url: '' - } - ] - - actionItems = [ - { - type: 'action', - label: '鎻愮ず妗�', - subType: 'prompt', - url: '' - }, - { - type: 'action', - label: '鐩存帴鎵ц', - subType: 'exec', - url: '' - } - ] - - tabItems = [ - { - type: 'tabs', - label: '瀛愯〃', - subType: 'SubTable', - } - ] -} - -export default new CommonTableBaseData() diff --git a/src/templates/formtabconfig/transferform/index.jsx b/src/templates/formtabconfig/transferform/index.jsx deleted file mode 100644 index 3ff7f65..0000000 --- a/src/templates/formtabconfig/transferform/index.jsx +++ /dev/null @@ -1,72 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Transfer } from 'antd' -import './index.scss' - -class TransferForm extends Component { - static propTypes = { - fields: PropTypes.array, - selected: PropTypes.array - } - - state = { - data: [], - targetKeys: [], - selectedKeys: [] - } - - handleChange = (nextTargetKeys, direction, moveKeys) => { - this.setState({ targetKeys: nextTargetKeys }) - } - - handleSelectChange = (sourceSelectedKeys, targetSelectedKeys) => { - this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys] }) - } - - UNSAFE_componentWillMount() { - let datas = new Map() - this.props.fields.forEach(item => { - if (!item.origin) { - datas.set(item.uuid, item) - } - }) - - let selecteds = [] - - this.props.selected.forEach(item => { - if (datas.has(item)) { - selecteds.push(item) - } - }) - - this.setState({ - data: [...datas.values()].map(item => { - return { - key: item.uuid, - title: item.label, - description: '' - } - }), - targetKeys: selecteds - }) - } - - render() { - const { data, targetKeys, selectedKeys } = this.state - - return ( - <div className="modal-fields-transfer"> - <Transfer - dataSource={data} - targetKeys={targetKeys} - selectedKeys={selectedKeys} - onChange={this.handleChange} - onSelectChange={this.handleSelectChange} - render={item => item.title} - /> - </div> - ) - } -} - -export default TransferForm diff --git a/src/templates/formtabconfig/transferform/index.scss b/src/templates/formtabconfig/transferform/index.scss deleted file mode 100644 index fcb7ff4..0000000 --- a/src/templates/formtabconfig/transferform/index.scss +++ /dev/null @@ -1,6 +0,0 @@ -.modal-fields-transfer { - padding-left: 18px; - .ant-transfer-list { - width: 296px; - } -} \ No newline at end of file diff --git a/src/templates/formtabconfig/updatetable/index.jsx b/src/templates/formtabconfig/updatetable/index.jsx deleted file mode 100644 index 5245a83..0000000 --- a/src/templates/formtabconfig/updatetable/index.jsx +++ /dev/null @@ -1,1274 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Modal, Button, notification } from 'antd' -import { ArrowUpOutlined } from '@ant-design/icons' -import moment from 'moment' -import md5 from 'md5' - -import { colorTransform } from '@/utils/option.js' -import { getTables } from '@/utils/utils-custom.js' -import Api from '@/api' -import Utils from '@/utils/utils.js' -// import './index.scss' - -const { confirm } = Modal - -class UpdateTable extends Component { - static propTpyes = { - config: PropTypes.object - } - - state = {} - delButtons = [] - baseMsg = {} - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) - } - - trigger = () => { - const { config } = this.props - const _this = this - - if (!config.enabled) { - notification.warning({ - top: 92, - message: '鏈惎鐢ㄨ彍鍗曚笉鍙崌绾э紒', - duration: 5 - }) - return - } - - confirm({ - title: '纭畾鍗囩骇褰撳墠鑿滃崟鍚楋紵', - content: '', - onOk() { - return new Promise(resolve => { - _this.execUpdate(resolve) - }) - }, - onCancel() {} - }) - } - - execUpdate = (_resolve) => { - const { menu } = this.props - const config = fromJS(this.props.config).toJS() - this.delButtons = [] - this.baseMsg = { - fstMenuId: config.fstMenuId, - parentId: config.ParentId, - MenuName: config.MenuName, - MenuNo: config.MenuNo, - } - - let MenuID = md5(menu.MenuID + config.btnId) - - let _config = { - version: 1.0, - uuid: MenuID, - MenuID: MenuID, - fstMenuId: menu.fstMenuId, - parentId: menu.ParentId, - Template: 'CustomPage', - easyCode: '', - enabled: false, - MenuName: menu.MenuName + '-' + config.btnName, - MenuNo: menu.MenuNo + '_' + MenuID.substr(-4), - OpenType: 'newtab', - tables: config.tables || [], - urlFields: [], - hidden: 'true', - Remark: '', - components: [], - viewType: 'menu', - style: { backgroundColor: '#ffffff', paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'}, - } - - let formActions = [] - let popActions = [] - let errors = [] - - let mainF = { - uuid: Utils.getuuid(), - type: 'form', - format: 'object', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 - pageable: false, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� - switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� - width: 24, - name: '涓昏〃鍗�', - subtype: 'simpleform', - setting: { interType: 'system' }, - wrap: { name: '涓昏〃鍗�', width: 24, datatype: 'static' }, - style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' }, - headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, - columns: [], - scripts: [], - subcards: [] - } - - let card = { - uuid: Utils.getuuid(), - setting: {title: '', align: 'left_right', enable: 'true'}, - style: {}, - fields: [], - subButton: {label: '纭畾', type: 'submit', reload: 'false', sql: '', Ot: 'notRequired', enable: 'true', style: {backgroundColor: 'rgba(255, 255, 255, 1)', color: 'rgba(24, 144, 255, 1)', paddingLeft: '20px', paddingRight: '20px', paddingTop: '5px', paddingBottom: '5px', borderColor: 'rgba(24, 144, 255, 1)', borderWidth: '1px'}}, - closeButton: {label: '鍏抽棴', type: 'close', enable: 'true', style: { color: 'rgba(245, 34, 45, 1)', paddingTop: '5px', paddingRight: '20px', marginLeft: '20px', backgroundColor: '#ffffff', borderColor: 'rgba(245, 34, 45, 1)', paddingLeft: '20px', borderWidth: '1px', paddingBottom: '5px'}}, - } - - let btn = config.action[0] - - card.subButton.intertype = btn.intertype - card.subButton.innerFunc = btn.innerFunc || '' - card.subButton.execSuccess = btn.execSuccess || 'never' - card.subButton.execError = btn.execError || 'never' - - if (btn.intertype === 'outer') { - card.subButton.procMode = btn.innerFunc ? 'inner' : 'none' - card.subButton.sysInterface = btn.sysInterface || 'false' - card.subButton.interface = btn.interface || '' - card.subButton.outerFunc = btn.outerFunc || '' - card.subButton.callbackFunc = btn.callbackFunc || '' - card.subButton.callbackType = btn.callbackFunc ? 'func' : 'none' - } else if (btn.intertype === 'system') { - card.subButton.sqlType = btn.sqlType || '' - card.subButton.sql = btn.sql || '' - card.subButton.verify = btn.verify || null - } - - if (config.setting.datatype === 'query') { - mainF.wrap.datatype = 'dynamic' - mainF.setting = { - interType: config.setting.interType || 'system', - innerFunc: config.setting.innerFunc || '', - outerFunc: config.setting.outerFunc || '', - interface: config.setting.interface || '', - dataresource: config.setting.dataresource || '', - sysInterface: config.setting.sysInterface || 'false', - order: '', - primaryKey: config.setting.primaryKey || '', - tableName: menu.LongParam.setting.tableName || '', - supModule: ['empty'], - sync: 'false', - onload: 'true' - } - - if (mainF.setting.interType === 'inner' && !mainF.setting.innerFunc) { - mainF.setting.interType = 'system' - } - - card.subButton.Ot = 'requiredSgl' - } - - config.groups.forEach(group => { - if (!group.isDefault) { - card.fields.push({ - uuid: Utils.getuuid(), - label: group.label, - span: 24, - type: 'split' - }) - } - - group.sublist.forEach(item => { - item.labelwidth = 33.3 - item.span = 12 - - if (item.type === 'textarea' && config.setting.cols === '2') { - item.labelwidth = 16.2 - item.span = 24 - } - - card.fields.push(item) - }) - }) - - card.fields.forEach(item => { - if (item.field) { - if (item.type === 'number') { - mainF.columns.push({ - datatype: `decimal(18,${item.decimal === 0 ? 0 : (item.decimal || 2)})`, - field: item.field, - decimal: item.decimal || 0, - label: item.label, - type: 'number', - uuid: Utils.getuuid() - }) - } else { - mainF.columns.push({ - datatype: `Nvarchar(${item.fieldlength || 50})`, - field: item.field, - fieldlength: 50, - label: item.label, - type: 'text', - uuid: Utils.getuuid() - }) - } - } - }) - - mainF.subcards.push(card) - - let oldtabs = { - mainTable: mainF.uuid - } - - _config.components.push(mainF) - - let _tbs = [] - if (config.tabgroups && config.tabgroups.length > 0) { - config.tabgroups.forEach((m, i) => { - if (!m.sublist || m.sublist.length === 0) return - - let tabs = { - uuid: Utils.getuuid(), - type: 'tabs', - subtype: 'tabs', - name: '鏍囩缁�' + (i + 1), - width: 24, - setting: {name: '鏍囩缁�' + (i + 1), width: 24, position: 'top'}, - style: {}, - subtabs: m.sublist.map(n => { - let tab = { uuid: Utils.getuuid(), label: n.label, icon: n.icon, permission: 'false', components: [ - { - uuid: Utils.getuuid(), - linkTab: n.linkTab, - name: n.label, - useMSearch: 'false', - supModule: n.supMenu || '', - equalTab: n.equalTab && n.equalTab.length > 0 ? n.equalTab[0] : '' - } - ]} - this.delButtons.push(n.linkTab) - oldtabs[n.uuid] = tab.components[0].uuid - - _tbs.push(tab.components[0]) - - return tab - }) - } - - _config.components.push(tabs) - }) - } - - if (_tbs.length > 0) { - let defers = _tbs.map((item, i) => { - return new Promise((resolve) => { - setTimeout(() => { - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: item.linkTab - }).then(res => { - if (res.status) { - let _LongParam = '' - if (res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam) { - _LongParam.uuid = item.linkTab - resolve(_LongParam) - } else { - resolve({uuid: item.linkTab, $empty: true}) - } - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - resolve({uuid: item.linkTab, $empty: true}) - } - }) - }, i * 50) - }) - }) - Promise.all(defers).then(res => { - let menus = {} - res.forEach(item => { - if (item && !item.$empty) { - menus[item.uuid] = item - } - }) - - _config.components = _config.components.map(item => { - if (item.type === 'tabs') { - item.subtabs = item.subtabs.map(tab => { - tab.components[0] = this.getTable(menus[tab.components[0].linkTab], tab.components[0], errors, formActions, popActions, oldtabs) - - return tab - }) - } - return item - }) - - this.setPopView(_resolve, _config, formActions, popActions, errors) - }) - } else { - this.setPopView(_resolve, _config, formActions, popActions, errors) - } - } - - setPopView = (_resolve, _config, formActions, popActions, errors) => { - if (popActions.length > 0) { - let defers = popActions.map((item, i) => { - return new Promise((resolve) => { - setTimeout(() => { - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: item.linkTab - }).then(res => { - if (res.status) { - let _LongParam = '' - if (res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam) { - _LongParam.uuid = item.uuid - resolve(_LongParam) - } else { - resolve({uuid: item.uuid, $empty: true}) - } - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - resolve({uuid: item.uuid, $empty: true}) - } - }) - }, i * 50) - }) - }) - Promise.all(defers).then(res => { - let menus = {} - res.forEach(item => { - if (item && !item.$empty) { - menus[item.uuid] = item - } - }) - - _config.components.forEach(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - tab.components[0].action.forEach(btn => { - if (btn.OpenType === 'popview') { - if (menus[btn.uuid]) { - let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} - - btn.config = { - uuid: btn.uuid, - MenuID: btn.uuid, - ParentId: tab.components[0].uuid, - MenuName: btn.label, - tables: _config.tables || [], - Template: 'CustomPage', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], - viewType: 'popview', - style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } - } - - btn.config.enabled = this.setEnabled(btn.config) - } else { - errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - tab.components[0].cols.forEach(col => { - if (col.type !== 'custom') return - col.elements.forEach(btn => { - if (btn.eleType !== 'button') return - if (btn.OpenType === 'popview') { - if (menus[btn.uuid]) { - let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} - - btn.config = { - uuid: btn.uuid, - MenuID: btn.uuid, - ParentId: tab.components[0].uuid, - MenuName: btn.label, - tables: _config.tables || [], - Template: 'CustomPage', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], - viewType: 'popview', - style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } - } - - btn.config.enabled = this.setEnabled(btn.config) - } else { - errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - }) - }) - } else if (item.type !== 'form') { - item.action.forEach(btn => { - if (btn.OpenType === 'popview') { - if (menus[btn.uuid]) { - let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} - - btn.config = { - uuid: btn.uuid, - MenuID: btn.uuid, - ParentId: item.uuid, - MenuName: btn.label, - tables: _config.tables || [], - Template: 'CustomPage', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], - viewType: 'popview', - style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } - } - - btn.config.enabled = this.setEnabled(btn.config) - } else { - errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - item.cols.forEach(col => { - if (col.type !== 'custom') return - col.elements.forEach(btn => { - if (btn.eleType !== 'button') return - if (btn.OpenType === 'popview') { - if (menus[btn.uuid]) { - let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} - - btn.config = { - uuid: btn.uuid, - MenuID: btn.uuid, - ParentId: item.uuid, - MenuName: btn.label, - tables: _config.tables || [], - Template: 'CustomPage', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], - viewType: 'popview', - style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } - } - - btn.config.enabled = this.setEnabled(btn.config) - } else { - errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - }) - } - }) - - this.setPopForm(_resolve, _config, formActions, errors) - }) - } else { - this.setPopForm(_resolve, _config, formActions, errors) - } - } - - setEnabled = (config) => { - let enabled = true - config.components.forEach(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - if (tab.components[0].errors.length > 0) { - enabled = false - } - }) - } else { - if (item.errors.length > 0) { - enabled = false - } - } - }) - - return enabled - } - - setPopForm = (_resolve, _config, formActions, errors) => { - if (formActions.length > 0) { - let defers = formActions.map((item, i) => { - return new Promise((resolve) => { - setTimeout(() => { - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: item.origin - }).then(res => { - if (res.status) { - let _LongParam = '' - if (res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam) { - _LongParam.uuid = item.uuid - resolve(_LongParam) - } else { - resolve({uuid: item.uuid, $empty: true}) - } - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - resolve({uuid: item.uuid, $empty: true}) - } - }) - }, i * 50) - }) - }) - Promise.all(defers).then(res => { - let menus = {} - res.forEach(item => { - if (item && !item.$empty) { - menus[item.uuid] = item - } - }) - - _config.components.forEach(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - tab.components[0].action.forEach(btn => { - if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { - this.setTbForm(btn.config.components[0], menus, errors, tab.components[0].name + '-' + btn.label) - } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { - if (menus[btn.uuid]) { - btn.modal = { - setting: menus[btn.uuid].setting, - tables: [], - groups: [], - fields: menus[btn.uuid].fields || [] - } - } else { - errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - tab.components[0].cols.forEach(col => { - if (col.type !== 'custom') return - col.elements.forEach(btn => { - if (btn.eleType !== 'button') return - if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { - this.setTbForm(btn.config.components[0], menus, errors, tab.components[0].name + '-' + btn.label) - } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { - if (menus[btn.uuid]) { - btn.modal = { - setting: menus[btn.uuid].setting, - tables: [], - groups: [], - fields: menus[btn.uuid].fields || [] - } - } else { - errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - }) - }) - } else if (item.type !== 'form') { - item.action.forEach(btn => { - if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { - this.setTbForm(btn.config.components[0], menus, errors, item.name + '-' + btn.label) - } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { - if (menus[btn.uuid]) { - btn.modal = { - setting: menus[btn.uuid].setting, - tables: [], - groups: [], - fields: menus[btn.uuid].fields || [] - } - } else { - errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - - item.cols.forEach(col => { - if (col.type !== 'custom') return - col.elements.forEach(btn => { - if (btn.eleType !== 'button') return - if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { - this.setTbForm(btn.config.components[0], menus, errors, item.name + '-' + btn.label) - } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { - if (menus[btn.uuid]) { - btn.modal = { - setting: menus[btn.uuid].setting, - tables: [], - groups: [], - fields: menus[btn.uuid].fields || [] - } - } else { - errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - }) - } - }) - - this.saveConfig(_resolve, _config, errors) - }) - } else { - this.saveConfig(_resolve, _config, errors) - } - } - - setTbForm = (item, menus, errors, name) => { - item.action.forEach(btn => { - if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { - if (menus[btn.uuid]) { - btn.modal = { - setting: menus[btn.uuid].setting, - tables: [], - groups: [], - fields: menus[btn.uuid].fields || [] - } - } else { - errors.push(name + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - item.cols.forEach(col => { - if (col.type !== 'custom') return - col.elements.forEach(btn => { - if (btn.eleType !== 'button') return - if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { - if (menus[btn.uuid]) { - btn.modal = { - setting: menus[btn.uuid].setting, - tables: [], - groups: [], - fields: menus[btn.uuid].fields || [] - } - } else { - errors.push(name + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') - } - } - }) - }) - } - - saveConfig = (_resolve, _config, errors) => { - let err = errors.join('锛�') - let _this = this - - if (err) { - _resolve() - confirm({ - title: err + '锛岀‘瀹氬崌绾у綋鍓嶈彍鍗曞悧锛�', - content: '', - onOk() { - return new Promise(resolve => { - _this.saveNewMenu(resolve, _config) - }) - }, - onCancel() {} - }) - } else { - this.saveNewMenu(_resolve, _config) - } - } - - saveNewMenu = (_resolve, _config) => { - _config.components.forEach(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - tab.components[0].action.forEach(btn => { - if (btn.OpenType === 'popview' && btn.config) { - btn.config.$tables = getTables(btn.config.components[0]) - } - }) - tab.components[0].cols.forEach(col => { - if (col.type !== 'custom') return - col.elements.forEach(btn => { - if (btn.eleType !== 'button') return - if (btn.OpenType === 'popview' && btn.config) { - btn.config.$tables = getTables(btn.config.components[0]) - } - }) - }) - - tab.components[0].$tables = getTables(tab.components[0]) - }) - } else { - item.$tables = getTables(item) - } - }) - - this.submitConfig(_resolve, _config) - } - - checkBtns = (card) => { - card.action.forEach(cell => { - if (cell.hidden === 'true') return - if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { - if (!cell.modal || cell.modal.fields.length === 0) { - card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`}) - } - } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) { - card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣}) - } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) { - card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣}) - } - }) - - card.cols.forEach(col => { - if (col.type !== 'custom') return - - col.elements.forEach(cell => { - if (cell.hidden === 'true' || cell.eleType !== 'button') return - if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { - if (!cell.modal || cell.modal.fields.length === 0) { - card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`}) - } - } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) { - card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣}) - } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) { - card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣}) - } - }) - }) - } - - submitConfig = (_resolve, config) => { - let tbs = [] - config.components.forEach(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - if (tab.components[0].$tables) { - tbs.push(...tab.components[0].$tables) - } - - this.checkBtns(tab.components[0]) - }) - } else { - if (item.$tables) { - tbs.push(...item.$tables) - } - } - }) - - let arr = [] - tbs = tbs.filter(tb => { - let _tb = tb.toLowerCase() - - if (arr.includes(_tb)) return false - arr.push(_tb) - - return true - }) - tbs.sort() - if (tbs.length && sessionStorage.getItem('mk_tb_names')) { - let names = sessionStorage.getItem('mk_tb_names') - tbs = tbs.filter(tb => names.indexOf(',' + tb.toLowerCase() + ',') > -1) - } - tbs = tbs.map(tb => `'${tb}'`).join(';') - - let key = md5(config.uuid + tbs.toLowerCase()) - - let urlparam = { - FstId: config.fstMenuId, - ParentId: config.parentId, - MenuID: config.uuid, - MenuName: config.MenuName, - MenuNo: config.MenuNo, - EasyCode: config.easyCode, - type: 'admin', - OpenType: config.OpenType, - PageParam: {Template: 'CustomPage', OpenType: 'newtab', hidden: config.hidden}, - MenuType: 'custom' - } - let url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) - config.tbkey = key - - let param = { - func: 'sPC_TrdMenu_AddUpt', - FstID: config.fstMenuId || '', - SndID: config.parentId, - ParentID: config.parentId, - MenuID: config.uuid, - MenuNo: config.MenuNo || '', - EasyCode: config.easyCode || '', - Template: 'CustomPage', - MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType, hidden: config.hidden}), - open_edition: '', - debug_md5: key, - debug_url: url, - debug_list: window.btoa(tbs), - LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))) - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - let save = false - - new Promise(resolve => { - Api.getSystemConfig(param).then(res => { - resolve(res) - }) - }).then(res => { // 鍒犻櫎鍘熻彍鍗� - if (!res || !res.status) return res - - save = true - - return res - // if (this.delButtons.length === 0) return res - - // return Api.getSystemConfig({ - // func: 'sPC_MainMenu_Del', - // up_type: 'Y', - // MenuID: this.delButtons.join(',') - // }) - }).then(res => { - if (!res) return - - _resolve() - - if (res.status) { - delete urlparam.type - - let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) - - window.open(window.location.href.split('#')[0] + `#/menudesign/${_param}`) - } else { - Modal.warning({ - title: res.message, - okText: '鐭ラ亾浜�', - onOk: () => { - if (save) { - delete urlparam.type - - let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) - window.open(window.location.href.split('#')[0] + `#/menudesign/${_param}`) - } else { - window.location.reload() - } - } - }) - } - }) - } - - getTable = (config, newCon, errors, formActions, popActions, oldtabs) => { - let _card = { - uuid: newCon.uuid, - type: 'table', - name: newCon.name, - format: 'array', - pageable: true, - switchable: true, - search: [], - action: [], - subtype: 'normaltable', - setting: { useMSearch: 'false', sync: 'false', onload: 'true' }, - wrap: {}, - style: {}, - headerStyle: {}, - columns: [], - cols: [], - scripts: [] - } - - if (!config) { - errors.push(newCon.name + '閰嶇疆淇℃伅涓㈠け') - return _card - } - - if (oldtabs && newCon.supModule && oldtabs[newCon.supModule]) { - _card.setting.supModule = [oldtabs[newCon.supModule]] - } else { - _card.setting.supModule = ['empty'] - } - - _card.search = config.search.map(item => { - item.uuid = Utils.getuuid() - return item - }) - - let _cols = {} - let _colspan = [] - let lineMarks = [] - config.columns.forEach(col => { - if (col.type === 'colspan') { - _colspan.push(...col.subfield.split(', ')) - } - if (!col.field) return - - let _col = fromJS(col).toJS() - - if (_col.marks) { - _col.marks = [] - col.marks.forEach(m => { - if (m.signType === 'card') return - - let field = [] - field.push(m.field) - field.push(m.contrastType) - - if (m.contrastField) { - field.push(m.contrastField) - } - let color = '#1890ff' - if (m.color && m.color[1]) { - color = colorTransform[m.color[1]] - } - let signType = ['font'] - if (m.signType === 'background') { - signType = ['background'] - } else if (m.signType === 'icon') { - if (m.position === 'back') { - signType = ['iconback'] - } else { - signType = ['iconfront'] - } - signType.push(m.iconType) - signType.push(m.icon) - } - - if (m.signType === 'line') { - lineMarks.push({ - $index: lineMarks.length + 1, - uuid: Utils.getuuid(), - field: field, - color: color, - contrastValue: m.contrastValue || '', - match: m.match, - signType: ['background'] - }) - } else { - _col.marks.push({ - $index: _col.marks.length + 1, - uuid: Utils.getuuid(), - field: field, - color: color, - contrastValue: m.contrastValue || '', - match: m.match, - signType: signType - }) - } - }) - } - - _cols[col.field] = _col - }) - - config.columns.forEach(col => { - if (col.type === 'index') { - _card.cols.push(fromJS(col).toJS()) - } else if (col.field && _cols[col.field]) { - let _col = fromJS(_cols[col.field]).toJS() - - if (_colspan.includes(col.field)) { - _col.Hide = 'true' - } - - _card.cols.push(_col) - } - - if (col.type === 'colspan') { - let ucol = { - Align: col.Align, - Hide: col.Hide, - label: col.label, - marks: [], - isSub: false, - uuid: col.uuid, - blacklist: [] - } - if (col.unfold === 'true') { - ucol.type = 'colspan' - ucol.subcols = [] - - col.subfield.split(', ').forEach(sub => { - if (_cols[sub]) { - let _col = fromJS(_cols[sub]).toJS() - _col.Hide = 'false' - _col.isSub = true - _col.uuid = Utils.getuuid() - - ucol.subcols.push(_col) - } - }) - - if (ucol.subcols.length > 0) { - _card.cols.push(ucol) - } - } else { - ucol.Width = 120 - ucol.type = 'custom' - ucol.elements = [] - ucol.style = {paddingTop: '12px', paddingLeft: '8px', paddingBottom: '12px', paddingRight: '8px'} - - col.subfield.split(', ').forEach(sub => { - if (_cols[sub]) { - let _col = { - copyable: 'false', - datatype: 'dynamic', - eleType: _cols[sub].type !== 'number' ? 'text' : 'number', - field: sub, - height: '', - innerHeight: 'auto', - marks: _cols[sub].marks || null, - noValue: 'show', - prefix: _cols[sub].prefix || '', - postfix: _cols[sub].postfix || '', - style: {}, - width: 24, - uuid: Utils.getuuid() - } - - ucol.elements.push(_col) - } - }) - - if (ucol.elements.length > 0) { - _card.cols.push(ucol) - } - } - } - }) - - _card.lineMarks = lineMarks - _card.columns = [] - _card.absFields = [] - _card.cols.forEach(col => { - if (!col.field) return - if (['text', 'picture', 'video', 'textarea'].includes(col.type)) { - _card.columns.push({ - datatype: `Nvarchar(${col.fieldlength || 50})`, - field: col.field, - fieldlength: col.fieldlength || 50, - label: col.label, - type: 'text', - uuid: col.uuid - }) - } else if (col.type === 'link') { - _card.columns.push({ - datatype: `Nvarchar(${col.fieldlength || 50})`, - field: col.field, - fieldlength: col.fieldlength || 50, - label: col.label, - type: 'text', - uuid: col.uuid - }) - if (col.nameField) { - _card.columns.push({ - datatype: `Nvarchar(${col.fieldlength || 50})`, - field: col.nameField, - fieldlength: col.fieldlength || 50, - label: col.label + '(鍚嶇О)', - type: 'text', - uuid: col.uuid + 'name' - }) - } - } else if (col.type === 'number') { - _card.columns.push({ - datatype: `Decimal(18,${col.decimal || 0})`, - field: col.field, - decimal: col.decimal || 0, - label: col.label, - type: 'number', - uuid: col.uuid - }) - - if (col.format === 'abs') { - _card.absFields.push(col.field) - } - } - }) - - if (_card.absFields.length) { - _card.absFields = Array.from(new Set(_card.absFields)) - } else { - _card.absFields = null - } - - let colbtns = [] - let colors = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#E7E7EF', default: 'rgba(0, 0, 0, 0.65)' } - - let uuids = {} - config.action.forEach(btn => { - let _c = btn.class ? btn.class.replace('border-', '') : '' - let color = colors[_c] || '#1890ff' - let _btn = fromJS(btn).toJS() - - delete _btn.position - delete _btn.linkTab - - if (_btn.intertype === 'inner' && !_btn.innerFunc) { - _btn.intertype = 'system' - } - if ((_btn.intertype === 'outer' || _btn.intertype === 'custom') && !_btn.procMode) { // 鍏煎澶栭儴鍑芥暟鐩翠紶绫诲瀷 - _btn.procMode = !_btn.innerFunc ? 'none' : 'inner' - } - if (_btn.funcType === 'print' && _btn.execMode) { - _btn.OpenType = 'funcbutton' - } else if (_btn.OpenType === 'blank') { - _btn.OpenType = 'tab' - } - - this.delButtons.push(btn.uuid) - - _btn.show = 'button' - - if (_btn.execSuccess === 'equaltab') { - _btn.execSuccess = 'grid' - _btn.syncComponent = [] - - if (newCon.equalTab && oldtabs && oldtabs[newCon.equalTab]) { - _btn.syncComponent.push(oldtabs[newCon.equalTab]) - } - } else if (_btn.execSuccess === 'maingrid') { - _btn.execSuccess = 'mainline' - } - - if (_btn.execError === 'equaltab') { - _btn.execError = 'grid' - } else if (_btn.execError === 'maingrid') { - _btn.execError = 'mainline' - } - - if (_btn.popClose === 'equaltab') { - _btn.popClose = 'grid' - _btn.syncComponent = [] - - if (newCon.equalTab && oldtabs && oldtabs[newCon.equalTab]) { - _btn.syncComponent.push(oldtabs[newCon.equalTab]) - } - } else if (_btn.popClose === 'maingrid') { - _btn.popClose = 'mainline' - } - - if (_btn.OpenType === 'pop' || (_btn.OpenType === 'funcbutton' && _btn.funcType === 'print' && _btn.execMode === 'pop')) { - - formActions.push({origin: btn.uuid, uuid: _btn.uuid, name: newCon.name, label: btn.label}) - } else if (_btn.OpenType === 'popview') { - if (!popActions) return - - popActions.push({origin: btn.uuid, linkTab: btn.linkTab || '', uuid: _btn.uuid, name: newCon.name, label: btn.label}) - } else if (_btn.OpenType === 'tab') { - if (btn.tabTemplate === 'FormTab') { - errors.push(newCon.name + '涓寜閽��' + btn.label + '銆嬩笉鍦ㄦ敮鎸�') - return - } else if (!btn.linkmenu || btn.linkmenu.length !== 3) { - - errors.push(newCon.name + '涓寜閽��' + btn.label + '銆嬩笉鍦ㄦ敮鎸�') - return - } - } - - uuids[btn.uuid] = true - - if (_btn.tabType === 'CommonTable' || _btn.tabType === 'SubTable') { - _btn.tabType = 'BaseTable' - } - - if (btn.position === 'grid') { - _btn.eleType = 'button' - _btn.width = 24 - _btn.style = {color: color, backgroundColor: 'transparent', borderColor: 'transparent'} - colbtns.push(_btn) - } else { - if (btn.class === 'default') { - _btn.style = {color: 'rgba(0, 0, 0, 0.65)', backgroundColor: '#fff', borderColor: '#d9d9d9', marginRight: '15px'} - } else if (btn.class.indexOf('border') > -1) { - _btn.style = {color: color, backgroundColor: '#fff', borderColor: color, marginRight: '15px'} - } else { - _btn.style = {color: btn.class === 'gray' ? 'rgba(0, 0, 0, 0.65)' : '#fff', backgroundColor: color, borderColor: color, marginRight: '15px'} - } - _card.action.push(_btn) - } - }) - - if (colbtns.length > 0) { - _card.cols.push({ - Align: 'left', - label: '鎿嶄綔', - marks: [], - isSub: false, - uuid: Utils.getuuid(), - type: 'custom', - Width: 120, - elements: colbtns, - style: {paddingTop: '12px', paddingLeft: '8px', paddingBottom: '12px', paddingRight: '8px'} - }) - } - - let sets = ['tableName', 'interType', 'sysInterface', 'innerFunc', 'interface', 'proInterface', 'outerFunc', 'dataresource', ['queryType', 'query'], 'primaryKey', 'order', 'execute', ['laypage', 'true'], ['pageSize', 10], ['onload', 'true']] - let wraps = ['tableType', ['bordered', 'true'], 'actionfixed', ['size', 'middle'], ['selected', 'false'], ['tableMode', 'compatible'], ['mask', 'show'], ['borderColor', '#e8e8e8'], 'height', 'controlField', 'controlVal'] - - _card.scripts = config.setting.scripts || [] - - sets.forEach(n => { - if (n === 'interType') { - if (!['system', 'inner', 'outer'].includes(config.setting.interType)) { - _card.setting.interType = 'system' - } else if (config.setting.interType === 'inner' && !config.setting.innerFunc) { - _card.setting.interType = 'system' - } else { - _card.setting.interType = config.setting.interType - } - } else if (typeof(n) === 'string') { - _card.setting[n] = config.setting[n] || '' - } else { - _card.setting[n[0]] = config.setting[n[0]] || n[1] - } - }) - wraps.forEach(w => { - if (typeof(w) === 'string') { - _card.wrap[w] = config.setting[w] || '' - } else { - _card.wrap[w[0]] = config.setting[w[0]] || w[1] - } - }) - - _card.wrap.doubleClick = config.setting.doubleClick || '' - if (_card.wrap.doubleClick && !uuids[_card.wrap.doubleClick]) { - _card.wrap.doubleClick = '' - } - - _card.errors = [] - let columns = _card.columns.map(c => c.field) - if (_card.setting.interType === 'system' && _card.setting.execute !== 'false' && !_card.setting.dataresource) { - _card.errors.push({ level: 0, detail: '鏈缃暟鎹簮锛�'}) - } else if (_card.setting.interType === 'system' && _card.setting.execute === 'false' && _card.scripts.filter(script => script.status !== 'false').length === 0) { - _card.errors.push({ level: 0, detail: '鏁版嵁婧愪腑鏃犲彲鐢ㄨ剼鏈紒'}) - } else if (!_card.setting.primaryKey) { - _card.errors.push({ level: 0, detail: '鏈缃富閿紒'}) - } else if (!columns.includes(_card.setting.primaryKey)) { - _card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'}) - } else if (!_card.setting.supModule) { - _card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'}) - } - - return _card - } - - render() { - return ( - <Button className="mk-border-purple" onClick={this.trigger}><ArrowUpOutlined /> 鍗囩骇</Button> - ) - } -} - -export default UpdateTable \ No newline at end of file diff --git a/src/templates/formtabconfig/updatetable/index.scss b/src/templates/formtabconfig/updatetable/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/templates/formtabconfig/updatetable/index.scss +++ /dev/null -- Gitblit v1.8.0