From 09e0de52a398dd08a0dc3f4b43e4589d211e9c27 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 30 十二月 2021 12:44:45 +0800 Subject: [PATCH] 2021-12-30 --- src/mob/searchconfig/index.jsx | 15 src/tabviews/formtab/index.jsx | 2 src/templates/subtableconfig/source.jsx | 3 src/menu/components/card/table-card/index.jsx | 1 src/tabviews/zshare/topSearch/index.jsx | 36 + src/templates/formtabconfig/index.jsx | 1 src/menu/components/share/searchcomponent/index.jsx | 14 src/menu/components/form/normal-form/index.jsx | 1 src/menu/components/chart/chart-custom/index.jsx | 1 src/menu/components/share/searchcomponent/dragsearch/card.jsx | 14 src/templates/formtabconfig/dragelement/index.jsx | 1 src/templates/sharecomponent/fieldscomponent/index.jsx | 2 src/menu/components/chart/antv-bar/index.jsx | 1 src/menu/components/chart/antv-scatter/index.jsx | 1 src/tabviews/zshare/mutilform/mkSelect/index.jsx | 12 src/templates/formtabconfig/source.jsx | 3 src/locales/en-US/main.js | 1 src/tabviews/commontable/index.jsx | 2 src/templates/calendarconfig/source.jsx | 3 src/mob/colorsketch/index.jsx | 4 src/locales/zh-CN/main.js | 1 src/templates/zshare/formconfig.jsx | 109 ++-- src/menu/components/form/tab-form/index.jsx | 1 src/templates/comtableconfig/source.jsx | 3 src/menu/components/search/main-search/dragsearch/card.jsx | 14 src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx | 1 src/menu/components/card/data-card/index.jsx | 1 src/menu/components/chart/antv-pie/index.jsx | 1 src/menu/components/search/main-search/index.jsx | 14 src/mob/components/formdragelement/card.jsx | 2 /dev/null | 97 ---- src/templates/modalconfig/source.jsx | 3 src/mob/colorsketch/index.scss | 12 src/tabviews/zshare/topSearch/advanceform/index.jsx | 4 src/templates/sharecomponent/searchcomponent/searchform/index.jsx | 881 +++++++++++++++++++--------------------- 35 files changed, 552 insertions(+), 710 deletions(-) diff --git a/src/locales/en-US/main.js b/src/locales/en-US/main.js index 6e51b13..2a9103e 100644 --- a/src/locales/en-US/main.js +++ b/src/locales/en-US/main.js @@ -6,7 +6,6 @@ 'main.submit': 'Submit', 'main.return': 'Return', 'main.close': 'Close', - 'main.all': 'All', 'main.cancel': 'Cancel', 'main.logout': 'Logout', 'main.doc': '鏂囨。涓績', diff --git a/src/locales/zh-CN/main.js b/src/locales/zh-CN/main.js index ad30e7c..db616d0 100644 --- a/src/locales/zh-CN/main.js +++ b/src/locales/zh-CN/main.js @@ -6,7 +6,6 @@ 'main.submit': '鎻愪氦', 'main.return': '杩斿洖', 'main.close': '鍏抽棴', - 'main.all': '鍏ㄩ儴', 'main.cancel': '鍙栨秷', 'main.logout': '閫�鍑�', 'main.doc': '鏂囨。涓績', diff --git a/src/menu/components/card/data-card/index.jsx b/src/menu/components/card/data-card/index.jsx index c544ede..738e3c1 100644 --- a/src/menu/components/card/data-card/index.jsx +++ b/src/menu/components/card/data-card/index.jsx @@ -298,7 +298,6 @@ newcard.type = 'select' newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' newcard.match = '=' } diff --git a/src/menu/components/card/table-card/index.jsx b/src/menu/components/card/table-card/index.jsx index 1b396b1..6470b65 100644 --- a/src/menu/components/card/table-card/index.jsx +++ b/src/menu/components/card/table-card/index.jsx @@ -310,7 +310,6 @@ newcard.type = 'select' newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' newcard.match = '=' } diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx index d5600ef..57ab6f4 100644 --- a/src/menu/components/chart/antv-bar/index.jsx +++ b/src/menu/components/chart/antv-bar/index.jsx @@ -1244,7 +1244,6 @@ newcard.type = 'select' newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' newcard.match = '=' diff --git a/src/menu/components/chart/antv-pie/index.jsx b/src/menu/components/chart/antv-pie/index.jsx index a308338..14f1db8 100644 --- a/src/menu/components/chart/antv-pie/index.jsx +++ b/src/menu/components/chart/antv-pie/index.jsx @@ -635,7 +635,6 @@ newcard.type = 'select' newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' newcard.match = '=' diff --git a/src/menu/components/chart/antv-scatter/index.jsx b/src/menu/components/chart/antv-scatter/index.jsx index 47a58d9..2cca38a 100644 --- a/src/menu/components/chart/antv-scatter/index.jsx +++ b/src/menu/components/chart/antv-scatter/index.jsx @@ -283,7 +283,6 @@ newcard.type = 'select' newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' newcard.match = '=' diff --git a/src/menu/components/chart/chart-custom/index.jsx b/src/menu/components/chart/chart-custom/index.jsx index 0142b95..929d17c 100644 --- a/src/menu/components/chart/chart-custom/index.jsx +++ b/src/menu/components/chart/chart-custom/index.jsx @@ -213,7 +213,6 @@ newcard.type = 'select' newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' newcard.match = '=' diff --git a/src/menu/components/form/normal-form/index.jsx b/src/menu/components/form/normal-form/index.jsx index 1ef602d..7a970bb 100644 --- a/src/menu/components/form/normal-form/index.jsx +++ b/src/menu/components/form/normal-form/index.jsx @@ -398,7 +398,6 @@ initval: '', type: 'text', resourceType: '0', - setAll: 'false', span: span, labelwidth: 33.3, options: [], diff --git a/src/menu/components/form/tab-form/index.jsx b/src/menu/components/form/tab-form/index.jsx index 7fa4b18..27ca911 100644 --- a/src/menu/components/form/tab-form/index.jsx +++ b/src/menu/components/form/tab-form/index.jsx @@ -390,7 +390,6 @@ initval: '', type: 'text', resourceType: '0', - setAll: 'false', span: span, labelwidth: 33.3, options: [], diff --git a/src/menu/components/search/main-search/dragsearch/card.jsx b/src/menu/components/search/main-search/dragsearch/card.jsx index d1bba4c..3ab0c51 100644 --- a/src/menu/components/search/main-search/dragsearch/card.jsx +++ b/src/menu/components/search/main-search/dragsearch/card.jsx @@ -37,15 +37,11 @@ let _defaultValue = '' // 涓嬫媺鎼滅储銆佹椂闂磋寖鍥寸被鍨嬶紝鍒濆鍊奸渶瑕侀澶勭悊 if (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 = 'All' + let _option = card.options.filter(option => option.Value === card.initval)[0] + if (_option) { + _defaultValue = _option.Text || '' + } else { + _defaultValue = '' } } else if (card.type === 'daterange') { _defaultValue = [null, null] diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx index 786763b..618db11 100644 --- a/src/menu/components/search/main-search/index.jsx +++ b/src/menu/components/search/main-search/index.jsx @@ -169,12 +169,14 @@ let linkableFields = [] card.search.forEach(item => { - if (item.uuid !== cell.uuid && (item.type === 'select' || item.type === 'link')) { - linkableFields.push({ - value: item.field, - text: item.label - }) - } + if (item.uuid === card.uuid) return + if (!['select', 'link', 'checkcard'].includes(item.type)) return + if (item.type === 'checkcard' && item.multiple === 'true') return + + linkableFields.push({ + value: item.field, + text: item.label + }) }) this.setState({ diff --git a/src/menu/components/share/searchcomponent/dragsearch/card.jsx b/src/menu/components/share/searchcomponent/dragsearch/card.jsx index a118ebc..19b27ed 100644 --- a/src/menu/components/share/searchcomponent/dragsearch/card.jsx +++ b/src/menu/components/share/searchcomponent/dragsearch/card.jsx @@ -36,15 +36,11 @@ let _defaultValue = '' // 涓嬫媺鎼滅储銆佹椂闂磋寖鍥寸被鍨嬶紝鍒濆鍊奸渶瑕侀澶勭悊 if (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 = '鍏ㄩ儴' + let _option = card.options.filter(option => option.Value === card.initval)[0] + if (_option) { + _defaultValue = _option.Text || '' + } else { + _defaultValue = '' } } else if (card.type === 'daterange') { _defaultValue = [null, null] diff --git a/src/menu/components/share/searchcomponent/index.jsx b/src/menu/components/share/searchcomponent/index.jsx index 5aa9876..5c18abf 100644 --- a/src/menu/components/share/searchcomponent/index.jsx +++ b/src/menu/components/share/searchcomponent/index.jsx @@ -102,12 +102,14 @@ let linkableFields = [] searchlist.forEach(item => { - if (item.uuid !== card.uuid && (item.type === 'select' || item.type === 'link')) { - linkableFields.push({ - value: item.field, - text: item.label - }) - } + if (item.uuid === card.uuid) return + if (!['select', 'link', 'checkcard'].includes(item.type)) return + if (item.type === 'checkcard' && item.multiple === 'true') return + + linkableFields.push({ + value: item.field, + text: item.label + }) }) this.setState({ diff --git a/src/mob/colorsketch/index.jsx b/src/mob/colorsketch/index.jsx index e53ece9..c7ea1a8 100644 --- a/src/mob/colorsketch/index.jsx +++ b/src/mob/colorsketch/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import { SketchPicker } from 'react-color' import { Popover } from 'antd' -import { CloseOutlined } from '@ant-design/icons' +import { CloseCircleFilled } from '@ant-design/icons' import './index.scss' @@ -90,7 +90,7 @@ <div className="color-sketch-block-inner" style={ {background: color} }></div> </div> </Popover> - <div className="color-sketch-value">{color}{allowClear && color ? <CloseOutlined onClick={this.clear}/> : null}</div> + <div className="color-sketch-value">{color}{allowClear && color ? <CloseCircleFilled onClick={this.clear}/> : null}</div> </div> ) } diff --git a/src/mob/colorsketch/index.scss b/src/mob/colorsketch/index.scss index ce226de..9aa1fc3 100644 --- a/src/mob/colorsketch/index.scss +++ b/src/mob/colorsketch/index.scss @@ -29,21 +29,25 @@ white-space: nowrap; overflow: visible; - .anticon-close { + .anticon-close-circle { position: relative; right: -10px; - font-size: 10px; + font-size: 12px; padding: 3px; - background: #eeeeee; border-radius: 50%; cursor: pointer; opacity: 0; transition: opacity 0.3s; + background: #fff; + color: #bcbcbc; + } + .anticon-close-circle:hover { + color: #959595; } } } .color-sketch-block:hover { - .anticon-close { + .anticon-close-circle { opacity: 1; } } diff --git a/src/mob/components/formdragelement/card.jsx b/src/mob/components/formdragelement/card.jsx index 73cf503..4bfe3dd 100644 --- a/src/mob/components/formdragelement/card.jsx +++ b/src/mob/components/formdragelement/card.jsx @@ -55,8 +55,6 @@ } else { selectval = '' } - } else if (card.setAll === 'true') { - selectval = card.emptyText || '绌�' } } diff --git a/src/mob/searchconfig/index.jsx b/src/mob/searchconfig/index.jsx index e8f380a..127b319 100644 --- a/src/mob/searchconfig/index.jsx +++ b/src/mob/searchconfig/index.jsx @@ -144,12 +144,25 @@ * @description 琛ㄥ崟缂栬緫 */ handleForm = (_card) => { + const { group } = this.state let card = fromJS(_card).toJS() + let linkableFields = [] + + group.fields.forEach(item => { + if (item.uuid === card.uuid) return + if (!['select', 'link', 'checkcard'].includes(item.type)) return + if (item.type === 'checkcard' && item.multiple === 'true') return + + linkableFields.push({ + value: item.field, + text: item.label + }) + }) this.setState({ visible: true, card: card, - formlist: getSearchForm(card, []) + formlist: getSearchForm(card, linkableFields) }) } diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 9469b12..831a435 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -956,7 +956,7 @@ reloadview = () => { this.setState({ loadingview: true, viewlost: false, config: {}, setting: null, data: null, total: 0, loading: false, pageIndex: 1, shortcuts: null, - pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false + pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false, searchlist: null }, () => { this.loadconfig() }) diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx index de39406..b16b3c7 100644 --- a/src/tabviews/formtab/index.jsx +++ b/src/tabviews/formtab/index.jsx @@ -185,7 +185,7 @@ item.options.unshift({ key: Utils.getuuid(), Value: '', - Text: this.state.dict['main.all'] + Text: '鍏ㄩ儴' }) } diff --git a/src/tabviews/zshare/mutilform/checkCard/index.jsx b/src/tabviews/zshare/mutilform/checkCard/index.jsx deleted file mode 100644 index b7b30ed..0000000 --- a/src/tabviews/zshare/mutilform/checkCard/index.jsx +++ /dev/null @@ -1,133 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Col, Row } from 'antd' - -import MKEmitter from '@/utils/events.js' -import './index.scss' - -class CheckCard extends Component { - static propTpyes = { - card: PropTypes.bool, // 鍗$墖淇℃伅 - onChange: PropTypes.func // 鏁版嵁鍒囨崲 - } - - state = { - selectKeys: null - } - - UNSAFE_componentWillMount() { - const { card } = this.props - - if (card.multiple === 'true') { - this.setState({ - selectKeys: card.initval ? card.initval.split(',') : [] - }) - } else { - this.setState({ - selectKeys: card.initval - }) - } - } - - changeCard = (item) => { - const { card } = this.props - const { selectKeys } = this.state - - if (card.readonly || item.$disabled) return - - if (card.multiple === 'true') { - let keys = [] - if (selectKeys.includes(item.$value)) { - keys = selectKeys.filter(key => key !== item.$value) - } else { - keys = [...selectKeys, item.$value] - } - - this.setState({ - selectKeys: keys - }, () => { - this.props.onChange && this.props.onChange(keys.join(',')) - }) - } else if (selectKeys !== item.$value) { - card.linkFields && card.linkFields.forEach((m, i) => { - setTimeout(() => { - MKEmitter.emit('mkSP', m.uuid, item.$value, 0) - }, (i + 1) * 10) - }) - - this.setState({ - selectKeys: item.$value - }, () => { - this.props.onChange && this.props.onChange(item.$value) - }) - } - } - - getCards = () => { - const { display, width, options, fields, ratio, multiple, backgroundColor, borderColor } = this.props.card - const { selectKeys } = this.state - - let paddingTop = '100%' - if (ratio === '4:3') { - paddingTop = '75%' - } else if (ratio === '3:2') { - paddingTop = '66.7%' - } else if (ratio === '16:9') { - paddingTop = '56.25%' - } - - let style = borderColor ? {borderColor} : {} - let _style = backgroundColor ? {backgroundColor} : null - - if (!options || options.length === 0) { - return null - } else if (display !== 'picture') { - if (!fields || fields.length === 0) { - return null - } - - return options.map(item => { - let _active = false - if (multiple === 'true' && selectKeys.includes(item.$value)) { - _active = true - } else if (multiple !== 'true' && selectKeys === item.$value) { - _active = true - } - - return <Col span={width} key={item.key}> - <div className={'card-cell' + (_active ? ' active' : '') + (_style ? ' bg-control' : '')} style={style} onClick={() => this.changeCard(item)}> - <div className="bg-mask" style={_style}></div> - {fields.map(col => { - return <span key={col.key} style={{color: col.color, fontSize: col.fontSize + 'px', height: col.fontSize * 1.5 + 'px', textAlign: col.align}}>{item[col.field]}</span> - })} - </div> - </Col> - }) - } else { - return options.map(item => { - let _active = false - if (multiple === 'true' && selectKeys.includes(item.$value)) { - _active = true - } else if (multiple !== 'true' && selectKeys === item.$value) { - _active = true - } - - return <Col span={width} key={item.key}> - <div className={'card-pic-cell ' + (_active ? 'active' : '')} onClick={() => this.changeCard(item)} style={{...style, paddingTop, backgroundImage: `url(${item.$url})`}}> - </div> - </Col> - }) - } - } - - render() { - const { card } = this.props - return ( - <div className={'check-card-search-box' + (card.readonly ? ' readonly' : '')}> - <Row gutter={12}>{this.getCards()}</Row> - </div> - ) - } -} - -export default CheckCard \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/checkCard/index.scss b/src/tabviews/zshare/mutilform/checkCard/index.scss deleted file mode 100644 index ce51901..0000000 --- a/src/tabviews/zshare/mutilform/checkCard/index.scss +++ /dev/null @@ -1,97 +0,0 @@ -.check-card-search-box { - margin-top: 10px; - margin-bottom: -10px; - .card-cell { - position: relative; - border: 1px solid #bcbcbc; - border-radius: 4px; - padding: 6px; - margin-bottom: 12px; - line-height: 1.5; - cursor: pointer; - transition: all 0.3s; - span { - display: block; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - position: relative; - z-index: 1; - } - .bg-mask { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - opacity: 0.3; - border-radius: 4px; - background-color: transparent; - transition: opacity 0.3s; - } - } - .card-cell:not(.bg-control).active { - border-color: #1890ff; - background: #1890ff; - span { - color: #ffffff!important; - } - } - .card-cell.bg-control.active { - .bg-mask { - opacity: 1; - } - } - .card-pic-cell { - position: relative; - border: 1px solid #bcbcbc; - border-radius: 4px; - background-size: cover; - background-position: center; - margin-bottom: 12px; - line-height: 1.5; - cursor: pointer; - transition: all 0.3s; - } - .card-pic-cell.active { - border-color: #1890ff; - box-shadow: 0px 0px 4px #1890ff; - } - - .card-cell:not(.bg-control).active::after { - content: ' '; - position: absolute; - display: table; - border: 2px solid #ffffff; - border-top: 0; - border-left: 0; - bottom: 0; - right: 12px; - width: 6px; - height: 12px; - transform: rotate(45deg) scale(1) translate(-50%, -50%); - } -} -.check-card-search-box:not(.readonly) { - .card-cell:not(.bg-control):hover { - border-color: #1890ff; - background: #1890ff; - span { - color: #ffffff!important; - } - } - .card-cell.bg-control:not(.active):hover { - .bg-mask { - opacity: 0.7; - } - } - .card-pic-cell:hover { - border-color: #1890ff; - box-shadow: 0px 0px 4px #1890ff; - } -} -.check-card-search-box.readonly { - .card-cell, .card-pic-cell { - cursor: not-allowed; - } -} \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/mkSelect/index.jsx b/src/tabviews/zshare/mutilform/mkSelect/index.jsx index 86ff5c5..54c46f4 100644 --- a/src/tabviews/zshare/mutilform/mkSelect/index.jsx +++ b/src/tabviews/zshare/mutilform/mkSelect/index.jsx @@ -19,11 +19,7 @@ } } else if (value) { let option = null - if (config.setAll === 'true') { - option= config.oriOptions[1] - } else { - option= config.oriOptions[0] - } + option= config.oriOptions[0] if (typeof(value) === 'string' && option && typeof(option.value) === 'number') { value = +value if (isNaN(value)) { @@ -67,11 +63,7 @@ }) } else { let option = null - if (config.setAll === 'true') { - option= nextProps.config.oriOptions[1] - } else { - option= nextProps.config.oriOptions[0] - } + option= nextProps.config.oriOptions[0] if (option && typeof(option.value) === 'number') { let val = +value if (!isNaN(val)) { diff --git a/src/tabviews/zshare/topSearch/advanceform/index.jsx b/src/tabviews/zshare/topSearch/advanceform/index.jsx index d5c4c88..8680e75 100644 --- a/src/tabviews/zshare/topSearch/advanceform/index.jsx +++ b/src/tabviews/zshare/topSearch/advanceform/index.jsx @@ -6,7 +6,7 @@ import asyncComponent from '@/utils/asyncComponent' import './index.scss' -const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard')) +const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheckCard')) const MKSelect = asyncComponent(() => import('../mkSelect')) const MKDatePicker = asyncComponent(() => import('../mkDatePicker')) @@ -47,7 +47,7 @@ } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { content = (<MKDatePicker config={item}/>) } else if (item.type === 'checkcard') { - content = <MKCheckCard card={item}/> + content = <MKCheckCard config={item}/> } if (content) { diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 8cbca63..8f02a8b 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -16,7 +16,7 @@ import './index.scss' const MutilForm = asyncSpinComponent(() => import('./advanceform')) -const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/checkCard')) +const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheckCard')) const MKSelect = asyncComponent(() => import('./mkSelect')) const DateGroup = asyncComponent(() => import('./dategroup')) const MKDatePicker = asyncComponent(() => import('./mkDatePicker')) @@ -95,7 +95,8 @@ } _searchlist.forEach(item => { - if (item.type === 'link') { + // if (item.type === 'link') { + if (item.linkField) { linkFields[item.linkField] = linkFields[item.linkField] || [] linkFields[item.linkField].push({field: item.field, uuid: item.uuid}) } @@ -131,7 +132,8 @@ item.options.unshift({ key: Utils.getuuid(), Value: '', - Text: this.state.dict['main.all'] + Text: '鍏ㄩ儴', + ParentID: '' }) } @@ -165,11 +167,11 @@ let _list = _searchlist.map(item => { if (item.hidden) return item - if (linkFields[item.field]) { + if (linkFields[item.field] && (item.type === 'select' || item.type === 'link' || (item.type === 'checkcard' && item.multiple !== 'true'))) { item.linkFields = linkFields[item.field] } - if (item.type === 'link') { + if (item.linkField) { let supItem = fieldMap.get(item.linkField) if (!supItem) { @@ -388,7 +390,7 @@ _item = {..._item, ...cell} } - if (item.type === 'link') { + if (item.linkField) { _item.ParentID = cell[item.linkField] } @@ -398,13 +400,13 @@ item.oriOptions = [...item.oriOptions, ...options] } - if (item.type === 'link') { + if (item.linkField) { if (item.supInitVal) { item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal || option.Value === '') } else { item.options = item.oriOptions } - } else if (item.type === 'select' || item.type === 'multiselect' || item.type === 'checkcard') { + } else if (item.oriOptions) { item.options = item.oriOptions } @@ -426,7 +428,9 @@ this.handleSubmit() }, 1000) } else { - this.handleSubmit() + setTimeout(() => { + this.handleSubmit() + }, 10) } } @@ -435,6 +439,16 @@ this.record[item.field] = type this.handleSubmit() + } + + cardChange = (val, item) => { + this.record[item.field] = val + + if (!item.linkFields) { + setTimeout(() => { + this.handleSubmit() + }, 10) + } } getFields() { @@ -469,7 +483,7 @@ content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} /> } else if (item.type === 'checkcard') { className = 'checkcard' - content = <MKCheckCard card={item} onChange={this.handleSubmit} /> + content = <MKCheckCard config={item} onChange={(val) => this.cardChange(val, item)} /> } if (content) { @@ -520,7 +534,7 @@ this.setState({}, () => { this.props.form.validateFields((err, values) => { if (err) return - + let { searches, error } = this.getFieldsValues(values) if (error) { diff --git a/src/templates/calendarconfig/source.jsx b/src/templates/calendarconfig/source.jsx index 1fdbb8e..fb3bceb 100644 --- a/src/templates/calendarconfig/source.jsx +++ b/src/templates/calendarconfig/source.jsx @@ -44,7 +44,6 @@ initval: '', type: 'text', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'like', @@ -56,7 +55,6 @@ initval: '', type: 'select', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'equal', @@ -68,7 +66,6 @@ initval: '', type: 'date', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'greater', diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index 07b053a..781963e 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -36,7 +36,6 @@ initval: '', type: 'text', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'like', @@ -48,7 +47,6 @@ initval: '', type: 'select', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'equal', @@ -60,7 +58,6 @@ initval: '', type: 'date', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'greater', diff --git a/src/templates/formtabconfig/dragelement/index.jsx b/src/templates/formtabconfig/dragelement/index.jsx index 148baba..4816521 100644 --- a/src/templates/formtabconfig/dragelement/index.jsx +++ b/src/templates/formtabconfig/dragelement/index.jsx @@ -115,7 +115,6 @@ newcard.type = item.subType newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' newcard.match = _match } else if (item.type === 'action') { diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 1a7f71f..297b37b 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -1324,7 +1324,6 @@ initval: '', type: item.type, resourceType: '0', - setAll: 'false', options: [], orderType: 'asc' } diff --git a/src/templates/formtabconfig/source.jsx b/src/templates/formtabconfig/source.jsx index 94de283..e5ddf6c 100644 --- a/src/templates/formtabconfig/source.jsx +++ b/src/templates/formtabconfig/source.jsx @@ -29,7 +29,6 @@ initval: '', type: 'text', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc' }, { @@ -40,7 +39,6 @@ initval: '', type: 'select', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc' }, { @@ -51,7 +49,6 @@ initval: '', type: 'date', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc' } diff --git a/src/templates/modalconfig/source.jsx b/src/templates/modalconfig/source.jsx index 230eeb8..0f50944 100644 --- a/src/templates/modalconfig/source.jsx +++ b/src/templates/modalconfig/source.jsx @@ -26,7 +26,6 @@ initval: '', type: 'text', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', decimal: 0, @@ -44,7 +43,6 @@ initval: '', type: 'select', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', decimal: 0, @@ -62,7 +60,6 @@ initval: '', type: 'date', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', decimal: 0, diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx index d69e4c5..26c4cf0 100644 --- a/src/templates/sharecomponent/fieldscomponent/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/index.jsx @@ -126,7 +126,6 @@ initval: initval, type: item.type, resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: _match, @@ -189,7 +188,6 @@ initval: item.type === 'number' ? 0 : '', type: item.type, resourceType: '0', - setAll: 'false', span: span, labelwidth: 33.3, options: [], diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx index 9cb45c3..504ef5f 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx @@ -89,7 +89,6 @@ newcard.type = item.subType newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' let _match = 'like' diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index cc1c227..955dfb7 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -5,16 +5,15 @@ import { QuestionCircleOutlined } from '@ant-design/icons' import { dateOptions, matchReg, formRule } from '@/utils/option.js' -import EditTable from '../searcheditable' import Utils from '@/utils/utils.js' import CodeMirror from '@/templates/zshare/codemirror' import asyncComponent from '@/utils/asyncComponent' -import MkIcon from '@/components/mk-icon' import './index.scss' const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) const FieldsTable = asyncComponent(() => import('@/templates/zshare/modalform/fieldtable')) const DataTable = asyncComponent(() => import('@/templates/zshare/modalform/datatable')) +const EditTable = asyncComponent(() => import('@/templates/zshare/modalform/modaleditable')) const groupOptions = [ { @@ -125,75 +124,37 @@ textTooltip: '瀛楁鍚嶅彲浠ヤ娇鐢ㄩ�楀彿鍒嗛殧锛岃繘琛岀患鍚堟悳绱�', } - /** - * @description 琛ㄥ崟棰勫鐞� - * 1銆佹牴鎹〃鍗曠被鍨嬶紝鏄剧ず琛ㄥ崟鍙紪杈戦」 - * 2銆佷笅鎷夐�夋嫨锛屾牴鎹暟鎹簮绫诲瀷鏄剧ず鐩稿叧閰嶇疆 - */ + record = {} + UNSAFE_componentWillMount () { - const { formlist, dict } = this.props - - let type = '' - let _items = [] - let resourceType = '' - let display = '' - let cFields = [] - let multiple = 'false' - - formlist.forEach(cell => { - if (cell.key === 'type') { - type = cell.initVal - } else if (cell.key === 'items') { - _items = cell.initVal - } else if (cell.key === 'display') { - display = cell.initVal - } else if (cell.key === 'resourceType') { - resourceType = cell.initVal - } else if (cell.key === 'fields') { - cFields = cell.initVal - } else if (cell.key === 'multiple') { - multiple = cell.initVal - } + this.props.formlist.forEach(item => { + this.record[item.key] = item.initVal }) - let _options = this.getOptions(type, resourceType, display) - + let { shows, reOptions, reTypes, reTooltip, reLabel, reRequired } = this.getMutilOptions() + this.setState({ - display, - cFields, - openType: type, - items: _items, - resourceType, - formlist: formlist.map(form => { - // 琛ㄥ崟涓哄垵濮嬪�煎瓧娈碉紝涓旀暟鎹被鍨嬪睘浜庢椂闂寸被鍨嬫椂锛岃缃垵濮嬪�间负涓嬫媺閫夋嫨锛屽苟閲嶇疆閫夋嫨椤� - if (form.key === 'initval' && dateOptions.hasOwnProperty(type)) { - form.options = dateOptions[type] - form.type = 'select' - } else if (form.key === 'initval' && type === 'group') { - form.options = groupOptions.filter(op => _items.includes(op.value)) - form.type = 'cascader' - } else if (form.key === 'match') { // 琛ㄥ崟涓哄尮閰嶅瓧娈垫椂锛屾牴鎹笉鍚岀殑绫诲瀷锛屾樉绀哄搴旂殑鍖归厤瑙勫垯 - if (type === 'text') { - form.options = matchReg.text - } else if (type === 'multiselect' || (type === 'checkcard' && multiple === 'true')) { - form.options = matchReg.multiselect - } else if (type === 'select' || type === 'link' || type === 'checkcard') { - form.options = matchReg.select - } else if (type === 'date') { - form.options = matchReg.date - } else if (type === 'datemonth') { - form.options = matchReg.datemonth - } else if (type === 'dateweek' || type === 'daterange' || type === 'range') { - form.options = matchReg.daterange - } - } else if (form.key === 'field' && (type === 'text' || type === 'select')) { - form.tooltip = this.state.textTooltip - } else if (form.key === 'field' && type === 'group') { - form.tooltip = '鏌ヨ鏁版嵁鏃讹紙鑷畾涔夎剼鏈垨缁熻鏁版嵁婧愶級锛岀被鍨嬪瓧娈靛皢鐢ㄤ綔鏇挎崲鑴氭湰涓殑 @瀛楁@ 锛岀被鍨嬪瓧娈靛搴斿�间负 {"鏃�": "day", "鍛�": "week", "鏈�": "month", "瀛�": "quarter", "骞�": "year", "鑷畾涔�": "customized"}銆�' - form.label = dict['model.form.type'] + dict['model.form.field'] + formlist: this.props.formlist.map(item => { + item.hidden = !shows.includes(item.key) + item.initVal = this.record[item.key] + + if (reOptions[item.key]) { + item.options = reOptions[item.key] } - form.hidden = !_options.includes(form.key) - return form + if (reTypes[item.key]) { + item.type = reTypes[item.key] + } + if (reTooltip[item.key] !== undefined) { + item.tooltip = reTooltip[item.key] + } + if (reLabel[item.key] !== undefined) { + item.label = reLabel[item.key] + } + if (reRequired[item.key] !== undefined) { + item.required = reRequired[item.key] + } + + return item }) }) } @@ -211,182 +172,211 @@ } } - getOptions = (type, resourceType, display) => { - let _options = fromJS(searchTypeOptions[type]).toJS() // 閫夐」鍒楄〃 - - if (['multiselect', 'select', 'link'].includes(type) && resourceType === '0') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓鸿嚜瀹氫箟璧勬簮 - _options.push('options') - } else if (['multiselect', 'select', 'link'].includes(type) && resourceType === '1') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓哄悗鍙版暟鎹簮涓幏鍙� - _options.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database') + getMutilOptions = () => { + let type = this.record.type + let shows = fromJS(searchTypeOptions[type]).toJS() + let reOptions = {} + let reTypes = {} + let reTooltip = {} + let reRequired = {} + let reLabel = {} + + if (['multiselect', 'select', 'link'].includes(type)) { + reRequired.linkField = true + if (this.record.resourceType === '0') { // 鑷畾涔夎祫婧� + shows.push('options') + } else if (this.record.resourceType === '1') { // 鏁版嵁婧� + shows.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database') + } } else if (type === 'checkcard') { - if (display === 'picture') { - if (resourceType === '0') { // 鑷畾涔夎祫婧� - _options.push('options', 'picratio') - } else if (resourceType === '1') { // 鏁版嵁婧� - _options.push('dataSource', 'cardValField', 'urlField', 'orderBy', 'orderType', 'database', 'picratio') + if (this.record.display === 'picture') { + if (this.record.resourceType === '0') { // 鑷畾涔夎祫婧� + shows.push('options', 'picratio') + } else if (this.record.resourceType === '1') { // 鏁版嵁婧� + shows.push('dataSource', 'cardValField', 'urlField', 'orderBy', 'orderType', 'database', 'picratio') } } else { - if (resourceType === '0') { // 鑷畾涔夎祫婧� - _options.push('options', 'fields', 'backgroundColor') - } else if (resourceType === '1') { // 鏁版嵁婧� - _options.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database', 'backgroundColor') + if (this.record.resourceType === '0') { // 鑷畾涔夎祫婧� + shows.push('options', 'fields', 'backgroundColor') + } else if (this.record.resourceType === '1') { // 鏁版嵁婧� + shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database', 'backgroundColor') } + } + if (this.record.multiple === 'false') { + shows.push('linkField') + } + reRequired.linkField = false + } + + if (dateOptions.hasOwnProperty(type)) { // 鏍规嵁鎼滅储鏉′欢绫诲瀷锛岄�夋嫨鍒濆鍊肩殑绫诲瀷鍙婃暟鎹� + reOptions.initval = dateOptions[type] + reTypes.initval = 'select' + } else if (type === 'group') { + reOptions.initval = groupOptions.filter(op => this.record.items.includes(op.value)) + reTypes.initval = 'cascader' + } else { + reTypes.initval = 'text' + } + + if (type === 'text') { + reOptions.match = matchReg.text + } else if (type === 'multiselect') { + reOptions.match = matchReg.multiselect + } else if (type === 'select' || type === 'link') { + reOptions.match = matchReg.select + } else if (type === 'date') { + reOptions.match = matchReg.date + } else if (type === 'datemonth') { + reOptions.match = matchReg.datemonth + } else if (type === 'dateweek' || type === 'daterange' || type === 'range') { + reOptions.match = matchReg.daterange + } else if (type === 'checkcard') { + if (this.record.multiple === 'false') { + reOptions.match = matchReg.select + } else if (this.record.multiple === 'true') { + reOptions.match = matchReg.multiselect } } - return _options + reTooltip.field = '' + reLabel.field = '瀛楁' + + if (type === 'text' || type === 'select') { + reTooltip.field = '瀛楁鍚嶅彲浠ヤ娇鐢ㄩ�楀彿鍒嗛殧锛岃繘琛岀患鍚堟悳绱€��' + } else if (type === 'group') { + reTooltip.field = '鏌ヨ鏁版嵁鏃讹紙鑷畾涔夎剼鏈垨缁熻鏁版嵁婧愶級锛岀被鍨嬪瓧娈靛皢鐢ㄤ綔鏇挎崲鑴氭湰涓殑 @瀛楁@ 锛岀被鍨嬪瓧娈靛搴斿�间负锛氭棩 -> day锛涘懆 -> week锛涙湀 -> month锛涘 -> quarter锛涘勾 -> year锛涜嚜瀹氫箟 -> customized' + reLabel.field = '绫诲瀷瀛楁' + } + + return { + shows, + reOptions, + reTypes, + reTooltip, + reRequired, + reLabel + } } - /** - * @description 鎼滅储鏉′欢绫诲瀷鍒囨崲 - */ - openTypeChange = (key, value) => { - const { dict } = this.props - const { resourceType, items, display } = this.state + optionChange = (key, value) => { + this.record[key] = value + let _fieldval = {} if (key === 'type') { - let _options = this.getOptions(value, resourceType, display) - let matchs = [] + this.record.initval = '' + _fieldval.initval = '' - this.setState({ - openType: value, - formlist: this.state.formlist.map(form => { - form.hidden = !_options.includes(form.key) // 闅愯棌琛ㄥ崟 + if (value === 'text' || value === 'multiselect') { + this.record.match = 'like' + _fieldval.match = 'like' + } else if (value === 'select' || value === 'link' || value === 'checkcard') { + this.record.match = '=' + _fieldval.match = '=' + } else if (value === 'date') { + this.record.match = '>=' + _fieldval.match = '>=' + } else if (value === 'datemonth' || value === 'dateweek' || value === 'daterange' || value === 'range') { + this.record.match = 'between' + _fieldval.match = 'between' + } - if (form.key === 'initval') { - if (dateOptions.hasOwnProperty(value)) { // 鏍规嵁鎼滅储鏉′欢绫诲瀷锛岄�夋嫨鍒濆鍊肩殑绫诲瀷鍙婃暟鎹� - form.options = dateOptions[value] - form.type = 'select' - } else if (value === 'group') { - form.options = groupOptions.filter(op => items.includes(op.value)) - form.type = 'cascader' - } else { - form.type = 'text' - } - } else if (form.key === 'match') { // 鎼滅储鏉′欢绫诲瀷鍒囨崲鏃讹紝鍖归厤瑙勫垯绫诲瀷瀵瑰簲鍒囨崲 - if (value === 'text') { - form.options = matchReg.text - } else if (value === 'multiselect') { - form.options = matchReg.multiselect - } else if (value === 'select' || value === 'link' || value === 'checkcard') { - form.options = matchReg.select - } else if (value === 'date') { - form.options = matchReg.date - } else if (value === 'datemonth') { - form.options = matchReg.datemonth - } else if (value === 'dateweek' || value === 'daterange' || value === 'range') { - form.options = matchReg.daterange - } - matchs = form.options - } else if (form.key === 'field') { - form.tooltip = '' - form.label = dict['model.form.field'] - if (value === 'text' || value === 'select') { - form.tooltip = this.state.textTooltip - } else if (value === 'group') { - form.tooltip = '鏌ヨ鏁版嵁鏃讹紙鑷畾涔夎剼鏈垨缁熻鏁版嵁婧愶級锛岀被鍨嬪瓧娈靛皢鐢ㄤ綔鏇挎崲鑴氭湰涓殑 @瀛楁@ 锛岀被鍨嬪瓧娈靛搴斿�间负 {"鏃�": "day", "鍛�": "week", "鏈�": "month", "瀛�": "quarter", "骞�": "year", "鑷畾涔�": "customized"}銆�' - form.label = dict['model.form.type'] + dict['model.form.field'] - } + if (value === 'checkcard') { + this.record.multiple = 'false' + _fieldval.multiple = 'false' + } + + if (this.record.options.length > 0) { + if (value === 'checkcard') { + this.record.options = this.record.options.map(cell => { + cell.$value = cell.Value || '' + delete cell.Value + return cell + }) + + if (this.record.options[0].Text) { + let key = Utils.getuuid() + + this.record.fields = [{ + $index: 1, + align: 'left', + color: 'rgba(0, 0, 0, 0.85)', + field: 'Text', + fontSize: 14, + key: key, + uuid: key + }] } - - return form - }) - }, () => { - if (this.props.form.getFieldValue('initval') !== undefined) { - this.props.form.setFieldsValue({initval: ''}) + } else if (['multiselect', 'select', 'link'].includes(value)) { + if (!this.record.options[0].Text && this.record.fields.length > 0) { + let field = this.record.fields[0].field + + this.record.options = this.record.options.map(cell => { + cell.Value = cell.Value || cell.$value || '' + cell.Text = cell[field] || '' + + return cell + }) + } else { + this.record.options = this.record.options.map(cell => { + cell.Value = cell.Value || cell.$value || '' + + return cell + }) + } } - if (this.props.form.getFieldValue('match') !== undefined) { - this.props.form.setFieldsValue({match: matchs[0].value}) - } - if (this.props.form.getFieldValue('multiple') !== undefined) { - this.props.form.setFieldsValue({multiple: 'false'}) - } - }) - } - } - - /** - * @description 鏁版嵁婧愮被鍨嬪垏鎹� - */ - onChange = (e, key) => { - const { openType, display, resourceType } = this.state - let value = e.target.value - - if (key === 'resourceType') { - let _options = this.getOptions(openType, value, display) - - this.setState({ - resourceType: value, - formlist: this.state.formlist.map(form => { - form.hidden = !_options.includes(form.key) - return form - }) - }) - } else if (key === 'display') { - let _options = this.getOptions(openType, resourceType, value) - - this.setState({ - display: value, - formlist: this.state.formlist.map(form => { - form.hidden = !_options.includes(form.key) - return form - }) - }) + } } else if (key === 'multiple') { - let matchs = [] - this.setState({ - formlist: this.state.formlist.map(form => { - if (form.key === 'match') { - if (value === 'true') { - form.options = matchReg.multiselect - } else { - form.options = matchReg.select - } - matchs = form.options - } - - return form - }) - }, () => { - if (this.props.form.getFieldValue('match') !== undefined) { - this.props.form.setFieldsValue({match: matchs[0].value}) - } - }) + if (value === 'false') { + this.record.match = '=' + _fieldval.match = '=' + } else if (value === 'true') { + this.record.match = 'like' + _fieldval.match = 'like' + } + } else if (key === 'items') { + let _initval = this.props.form.getFieldValue('initval') + if (_initval && !value.includes(_initval[0])) { + this.record.initval = '' + _fieldval.initval = '' + } } - } - changeField = (data) => { + let { shows, reOptions, reTypes, reLabel, reTooltip, reRequired } = this.getMutilOptions() + this.setState({ - cFields: data, - formlist: this.state.formlist.map(form => { - if (form.key === 'fields') { - form.initVal = data + formlist: this.state.formlist.map(item => { + item.hidden = !shows.includes(item.key) + item.initVal = this.record[item.key] + + if (reOptions[item.key]) { + item.options = reOptions[item.key] } - return form + if (reTypes[item.key]) { + item.type = reTypes[item.key] + } + if (reTooltip[item.key] !== undefined) { + item.tooltip = reTooltip[item.key] + } + if (reLabel[item.key] !== undefined) { + item.label = reLabel[item.key] + } + if (reRequired[item.key] !== undefined) { + item.required = reRequired[item.key] + } + + return item }) + }, () => { + this.props.form.setFieldsValue(_fieldval) }) } - checkChange = (values, key) => { - const { openType, formlist } = this.state + changeField = (data) => { + this.record.fields = data || [] + } - if (key === 'items') { - this.setState({ - items: values, - formlist: formlist.map(form => { - if (form.key === 'initval' && openType === 'group') { - form.options = groupOptions.filter(op => values.includes(op.value)) - } - - return form - }) - }) - - let _initval = this.props.form.getFieldValue('initval') - if (_initval && !values.includes(_initval[0])) { - this.props.form.setFieldsValue({initval: ''}) - } - } + changeOptions = (data) => { + this.record.options = data || [] } handleSubmit = (e) => { @@ -398,243 +388,147 @@ } getFields() { - const { openType } = this.state const { getFieldDecorator } = this.props.form + const { dict } = this.props + const { formlist } = this.state const fields = [] - this.state.formlist.forEach((item, index) => { + + formlist.forEach((item, index) => { if (item.hidden || item.forbid) return + let span = 12 + let rules = [] + let className = '' + let content = null + let initVal = item.initVal || '' + if (item.type === 'text') { // 鏂囨湰鎼滅储 - let rules = [] + let type = this.record.type + rules = [ + { required: item.required, message: dict['form.required.input'] + item.label + '!' } + ] if (item.key === 'field' || item.key === 'datefield') { - rules = [{ - pattern: (openType === 'text' || openType === 'select') ? formRule.field.multipattern : formRule.field.pattern, + rules.push({ + pattern: (type === 'text' || type === 'select') ? formRule.field.multipattern : formRule.field.pattern, message: formRule.field.message }, { max: formRule.field.max, message: formRule.field.maxMessage - }] + }) } else { - rules = [{ + rules.push({ 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.required, - message: this.props.dict['form.required.input'] + item.label + '!' - }, - ...rules - ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) + + content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> } else if (item.type === 'number') { - 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: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(item.max ? - <InputNumber min={item.min} max={item.max} precision={0} onPressEnter={this.handleSubmit}/> : - <InputNumber onPressEnter={this.handleSubmit}/> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value) => {this.openTypeChange(item.key, value)}} - getPopupContainer={() => document.getElementById('commontable-search-form-box')} - > - {item.options.map(option => - <Select.Option id={option.value} title={option.text} key={option.value} value={option.value}> - {item.key === 'icon' && <MkIcon type={option.text} />} {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: this.props.dict['form.required.select'] + 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 className="text-area" label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<CodeMirror />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'options') { - if (openType !== 'checkcard') { - fields.push( - <Col span={24} key={index}> - <Form.Item label={item.label} className="text-area"> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<EditTable dict={this.props.dict} type={this.state.openType} data={item.initVal}/>)} - </Form.Item> - </Col> - ) + rules = [ + { required: item.required, message: dict['form.required.input'] + item.label + '!' } + ] + initVal = item.initVal + + if (item.max) { + content = <InputNumber min={item.min} max={item.max} precision={0} onPressEnter={this.handleSubmit}/> } else { - fields.push( - <Col span={24} key={index}> - <Form.Item label={item.label} className="text-area"> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<DataTable dict={this.props.dict} type={this.state.display} fields={this.state.cFields}/>)} - </Form.Item> - </Col> - ) + content = <InputNumber onPressEnter={this.handleSubmit}/> + } + } else if (item.type === 'select') { // 涓嬫媺鎼滅储 + rules = [ + { required: item.required, message: dict['form.required.select'] + item.label + '!' } + ] + + content = <Select + showSearch + allowClear={item.allowClear === true} + filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} + onChange={(value) => {this.optionChange(item.key, value)}} + getPopupContainer={() => document.getElementById('commontable-search-form-box')} + > + {item.options.map((option, i) => + <Select.Option key={`${i}`} value={option.value}> + {option.text || option.label} + </Select.Option> + )} + </Select> + } else if (item.type === 'radio') { + rules = [ + { required: item.required, message: dict['form.required.select'] + item.label + '!' } + ] + + content = <Radio.Group onChange={(e) => {this.optionChange(item.key, e.target.value)}}> + {item.options.map(option => { + return ( + <Radio key={option.value} value={option.value}>{option.text}</Radio> + ) + })} + </Radio.Group> + } else if (item.type === 'textarea') { + rules = [ + { required: item.required, message: dict['form.required.input'] + item.label + '!' } + ] + span = 24 + className = 'text-area' + + content = <CodeMirror /> + } else if (item.type === 'options') { + span = 24 + className = 'text-area' + + let type = this.record.type + + if (type !== 'checkcard') { + content = <EditTable type={type} transfield={{}} linkSubFields={[]} onChange={this.changeOptions}/> + } else { + if (this.record.linkField) { + type = 'link' + } + content = <DataTable dict={dict} type={type} display={this.record.display} linkSubFields={[]} transfield={{}} fields={this.record.fields || []} onChange={this.changeOptions}/> } } else if (item.type === 'fields') { - fields.push( - <Col span={24} key={index}> - <Form.Item label={item.label} className="text-area"> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<FieldsTable dict={this.props.dict} onChange={this.changeField}/>)} - </Form.Item> - </Col> - ) + span = 24 + className = 'text-area' + + content = <FieldsTable dict={dict} onChange={this.changeField}/> } else if (item.type === 'checkbox') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Checkbox.Group style={{width: '105%'}} options={item.options} onChange={(values) => this.checkChange(values, item.key)}/> - )} - </Form.Item> - </Col> - ) + rules = [ + { required: item.required, message: dict['form.required.select'] + item.label + '!' } + ] + + content = <Checkbox.Group style={{width: '105%'}} options={item.options} onChange={(values) => this.optionChange(item.key, values)}/> } else if (item.type === 'multiselect') { // 澶氶�� - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || [] - })( - <Select - showSearch - mode="multiple" - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) + content = <Select + showSearch + mode="multiple" + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + > + {item.options.map((option, i) => + <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> + )} + </Select> } else if (item.type === 'cascader') { // 澶氶�� - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })( - <Cascader options={item.options} placeholder="" /> - )} - </Form.Item> - </Col> - ) + content = <Cascader options={item.options} placeholder="" /> } else if (item.type === 'color') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label} className="color-form-item"> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<ColorSketch allowClear={true}/>)} - </Form.Item> - </Col> - ) + className = 'color-form-item' + content = <ColorSketch allowClear={true}/> } + + fields.push( + <Col span={span} key={index}> + <Form.Item className={className} label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <QuestionCircleOutlined className="mk-form-tip" /> + {item.label} + </Tooltip> : item.label + }> + {getFieldDecorator(item.key, { + initialValue: initVal, + rules: rules + })(content)} + </Form.Item> + </Col> + ) }) return fields @@ -645,23 +539,92 @@ return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { - let isvalid = true values.uuid = this.props.card.uuid // 涓嬫媺鑿滃崟鎴栬仈鍔ㄨ彍鍗� - if (['multiselect', 'select', 'link', 'checkcard'].includes(values.type) && values.resourceType === '0') { - values.options = values.options || [] - values.dataSource = '' - let emptys = [] - if (['multiselect', 'select'].includes(values.type)) { - emptys = values.options.filter(op => !(op.Value && op.Text)) - } else if (values.type === 'link') { - emptys = values.options.filter(op => !(op.Value && op.Text && op.ParentID)) + if (['multiselect', 'select', 'link'].includes(values.type)) { + if (values.resourceType === '0') { + values.options = values.options || [] + values.dataSource = '' + + if (values.options.filter(op => op.Text === '').length > 0) { + notification.warning({ + top: 92, + message: '鎻愮ず鏂囨湰锛圱ext锛変笉鍙负绌猴紒', + duration: 5 + }) + return + } else if (values.options.filter(op => op.Value === '').length > 1) { + notification.warning({ + top: 92, + message: 'Value涓虹┖鏈�澶氬彧鍙坊鍔犱竴琛岋紙鍦ㄥ叧鑱旇彍鍗曚腑锛孷alue涓虹┖鏃朵笉鍖哄垎ParentID锛夛紒', + duration: 5 + }) + return + } else if (values.type === 'link') { + let arr = values.options.map(m => m.ParentID + m.Value) + let _arr = Array.from(new Set(arr)) + if (arr.length > _arr.length) { + notification.warning({ + top: 92, + message: '鍚屼竴ParentID涓紝Value鍊间笉鍙噸澶嶏紒', + duration: 5 + }) + return + } + } else { + let arr = values.options.map(m => m.Value) + let _arr = Array.from(new Set(arr)) + if (arr.length > _arr.length) { + notification.warning({ + top: 92, + message: 'Value鍊间笉鍙噸澶嶏紒', + duration: 5 + }) + return + } + } + } else { + values.options = [] } - if (emptys.length > 0) { - isvalid = false + } else if (values.type === 'checkcard') { + if (values.resourceType === '0') { + values.options = values.options || [] + values.options = values.options.map(m => { + m.ParentID = m.ParentID || '' + return m + }) + + let type = values.type + if (values.linkField) { + type = 'link' + } + + if (type === 'link') { + let arr = values.options.map(m => m.ParentID + m.$value) + let _arr = Array.from(new Set(arr)) + if (arr.length > _arr.length) { + notification.warning({ + top: 92, + message: '鍚屼竴ParentID涓紝Value鍊间笉鍙噸澶嶏紒', + duration: 5 + }) + return + } + } else { + let arr = values.options.map(m => m.$value) + let _arr = Array.from(new Set(arr)) + if (arr.length > _arr.length) { + notification.warning({ + top: 92, + message: 'Value鍊间笉鍙噸澶嶏紒', + duration: 5 + }) + return + } + } + } else { + values.options = [] } - } else if (['multiselect', 'select', 'link', 'checkcard'].includes(values.type) && values.resourceType === '1') { - values.options = [] } if (values.type === 'range') { @@ -705,32 +668,24 @@ } } - if (isvalid) { - ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => { - if (values[item]) { - values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '') - } - }) - - let error = Utils.verifySql(values.dataSource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - return + ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => { + if (values[item]) { + values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '') } + }) - resolve(values) - } else { + let error = Utils.verifySql(values.dataSource) + + if (error) { notification.warning({ top: 92, - message: '涓嬫媺閫夐」璁剧疆閿欒锛�', + message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, duration: 5 }) + return } + + resolve(values) } else { reject(err) } diff --git a/src/templates/subtableconfig/source.jsx b/src/templates/subtableconfig/source.jsx index e29bb3f..478a464 100644 --- a/src/templates/subtableconfig/source.jsx +++ b/src/templates/subtableconfig/source.jsx @@ -35,7 +35,6 @@ initval: '', type: 'text', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'like', @@ -47,7 +46,6 @@ initval: '', type: 'select', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'equal', @@ -59,7 +57,6 @@ initval: '', type: 'date', resourceType: '0', - setAll: 'false', options: [], orderType: 'asc', match: 'greater', diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 3eabad5..0498a8c 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -364,23 +364,30 @@ } } + let options = card.options || [] + if (['select', 'link'].includes(card.type) && card.setAll === 'true') { // 鍏煎 + options.unshift({ + key: 'empty', + Value: '', + Text: '鍏ㄩ儴', + ParentID: '' + }) + } + return [ { type: 'text', key: 'label', label: Formdict['model.name'], initVal: card.label || '', - required: true, - readonly: false + required: true }, { type: 'text', key: 'field', label: Formdict['model.form.field'], initVal: card.field || '', - tooltipClass: 'middle', - required: true, - readonly: false + required: true }, { type: 'select', @@ -395,8 +402,7 @@ key: 'datefield', label: '鏃堕棿瀛楁', initVal: card.datefield || '', - required: true, - readonly: false + required: true }, { type: 'text', @@ -420,19 +426,19 @@ text: Formdict['header.form.datasource'] }] }, - { - type: 'radio', - key: 'setAll', - label: '璁剧疆鍏ㄩ儴', - initVal: card.setAll || 'true', - options: [{ - value: 'true', - text: Formdict['model.true'] - }, { - value: 'false', - text: Formdict['model.false'] - }] - }, + // { + // type: 'radio', + // key: 'setAll', + // label: '璁剧疆鍏ㄩ儴', + // initVal: card.setAll || 'true', + // options: [{ + // value: 'true', + // text: Formdict['model.true'] + // }, { + // value: 'false', + // text: Formdict['model.false'] + // }] + // }, { type: 'radio', key: 'display', @@ -463,16 +469,14 @@ key: 'cardValField', label: '鍊悸峰瓧娈�', initVal: card.cardValField || 'Value', - required: true, - readonly: false + required: true }, { type: 'text', key: 'urlField', label: '鍦板潃瀛楁', initVal: card.urlField || '', - required: true, - readonly: false + required: true }, { type: 'radio', @@ -499,24 +503,21 @@ key: 'fields', label: '瀛楁闆�', initVal: card.fields || [], - required: true, - readonly: false + required: true }, { type: 'textarea', key: 'dataSource', label: Formdict['header.form.datasource'], initVal: card.dataSource || '', - required: true, - readonly: false + required: true }, { type: 'options', key: 'options', label: '閫夐」', - initVal: card.options || [], - required: true, - readonly: false + initVal: options, + required: true }, { type: 'checkbox', @@ -524,7 +525,6 @@ label: '閫夐」', initVal: card.items || ['day', 'week', 'month', 'quarter', 'year', 'customized'], required: true, - readonly: false, options: [{ value: 'day', label: '鏃�' @@ -546,12 +546,26 @@ }] }, { + type: 'radio', + key: 'multiple', + label: '閫夋嫨褰㈠紡', + initVal: card.multiple || 'false', + required: true, + options: [{ + value: 'false', + text: '鍗曢��' + }, { + value: 'true', + text: '澶氶��' + }] + }, + { type: 'select', key: 'linkField', label: '鍏宠仈瀛楁', initVal: card.linkField || '', required: true, - readonly: false, + allowClear: true, options: linkableFields }, { @@ -559,24 +573,21 @@ key: 'valueField', label: '鍊悸峰瓧娈�', initVal: card.valueField || '', - required: true, - readonly: false + required: true }, { type: 'text', key: 'valueText', label: '鏂囨湰路瀛楁', initVal: card.valueText || '', - required: true, - readonly: false + required: true }, { type: 'text', key: 'orderBy', label: '鎺掑簭路瀛楁', initVal: card.orderBy || '', - required: false, - readonly: false + required: false }, { type: 'select', @@ -637,20 +648,6 @@ initVal: card.ratio || 6, forbid: appType === 'mob', required: false - }, - { - type: 'radio', - key: 'multiple', - label: '鍙閫�', - initVal: card.multiple || 'false', - required: true, - options: [{ - value: 'true', - text: '鏄�' - }, { - value: 'false', - text: '鍚�' - }] }, { type: 'radio', @@ -2554,11 +2551,11 @@ initVal: card.multiple || 'false', required: true, options: [{ - value: 'true', - text: '澶氶��' - }, { value: 'false', text: '鍗曢��' + }, { + value: 'true', + text: '澶氶��' }] }, { -- Gitblit v1.8.0