From 106263ec10e60ce6c406e4fd5eb76d195772d0f0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 18 十二月 2020 18:07:05 +0800 Subject: [PATCH] 2020-12-18 --- src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 49 +-- src/tabviews/custom/components/chart/antv-bar-line/index.scss | 33 -- src/tabviews/zshare/topSearch/index.jsx | 123 ++++++--- src/tabviews/subtabtable/index.scss | 5 src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx | 66 ++-- src/tabviews/custom/components/chart/antv-pie/index.scss | 30 -- src/menu/components/share/searchcomponent/dragsearch/card.jsx | 18 src/templates/zshare/editcomponent/index.jsx | 33 -- src/tabviews/custom/components/share/normalheader/index.scss | 41 +++ src/tabviews/zshare/topSearch/index.scss | 11 src/tabviews/custom/components/card/data-card/index.scss | 2 src/menu/components/search/main-search/index.scss | 49 +-- src/tabviews/custom/components/share/normalheader/index.jsx | 57 ++++ src/tabviews/custom/components/table/normal-table/index.scss | 5 src/tabviews/custom/components/card/data-card/index.jsx | 18 + src/tabviews/custom/components/card/prop-card/index.scss | 2 src/tabviews/custom/components/card/table-card/index.jsx | 30 + src/tabviews/custom/components/card/cardcellList/index.jsx | 2 src/tabviews/custom/components/card/prop-card/index.jsx | 6 src/menu/components/share/searchcomponent/index.scss | 10 src/tabviews/subtable/index.scss | 5 src/tabviews/custom/components/share/tabtransfer/index.jsx | 2 src/tabviews/calendar/index.scss | 4 src/tabviews/custom/components/table/normal-table/index.jsx | 2 src/menu/components/search/main-search/dragsearch/card.jsx | 67 ++-- src/tabviews/custom/components/chart/antv-pie/index.jsx | 23 src/menu/components/search/main-search/index.jsx | 2 /dev/null | 3 src/tabviews/zshare/mutilform/index.jsx | 6 src/tabviews/commontable/index.scss | 4 src/tabviews/custom/index.jsx | 2 src/menu/components/card/data-card/wrapsetting/settingform/index.jsx | 2 src/templates/sharecomponent/searchcomponent/index.scss | 59 +--- src/views/login/index.jsx | 8 34 files changed, 424 insertions(+), 355 deletions(-) diff --git a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx index 2ae6842..f1690da 100644 --- a/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx +++ b/src/menu/components/card/data-card/wrapsetting/settingform/index.jsx @@ -183,7 +183,7 @@ </Col> : null} {config.subtype !== 'tablecard' ? <Col span={12}> <Form.Item label={ - <Tooltip placement="topLeft" title="榧犳爣鎮诞浜庡崱鐗囦笂鏂规椂锛屽崱鐗囨斁澶�1.1鍊嶃��"> + <Tooltip placement="topLeft" title="榧犳爣鎮诞浜庡崱鐗囦笂鏂规椂锛屽崱鐗囨斁澶�1.05鍊嶃��"> <Icon type="question-circle" /> 鍗$墖鏀惧ぇ </Tooltip> diff --git a/src/menu/components/search/main-search/dragsearch/card.jsx b/src/menu/components/search/main-search/dragsearch/card.jsx index 84a30c3..2b56c5b 100644 --- a/src/menu/components/search/main-search/dragsearch/card.jsx +++ b/src/menu/components/search/main-search/dragsearch/card.jsx @@ -1,6 +1,6 @@ import React from 'react' import { useDrag, useDrop } from 'react-dnd' -import { Icon, Select, DatePicker, Input, Popover } from 'antd' +import { Icon, Select, DatePicker, Input, Popover, Form } from 'antd' import moment from 'moment' import DateGroup from '../dategroup' @@ -22,6 +22,9 @@ drop: ({ id: draggedId }) => { if (!draggedId) return if (draggedId !== id) { + const { index: originIndex } = findCard(draggedId) + if (originIndex === -1) return + const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) } @@ -64,37 +67,37 @@ } trigger="hover"> <div className={'page-card ' + card.labelShow} style={{ opacity: opacity}}> <div ref={node => drag(drop(node))}> - <div className="ant-row ant-form-item"> - <div className="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"> - <label className={card.required === 'true' ? 'ant-form-item-required' : ''} title={card.label}>{card.label}</label> - </div> - <div className="ant-col ant-form-item-control-wrapper ant-col-xs-24 ant-col-sm-16"> - {card.type === 'text' ? - <Input style={{marginTop: '4px'}} placeholder={card.labelShow === 'false' ? card.label : ''} value={card.initval} /> : 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 === 'dateweek' ? - <WeekPicker value={card.initval ? moment().subtract(card.initval * 7, 'days') : null} /> : null - } - {card.type === 'datemonth' ? - <MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null - } - {card.type === 'daterange' ? - <RangePicker - className="data-range" - placeholder={['BeginTime', 'EndTime']} - renderExtraFooter={() => 'extra footer'} - value={_defaultValue} - /> : null - } - {card.type === 'group' ? <DateGroup card={card} /> : null } - </div> - </div> + <Form.Item + labelCol={{xs: { span: 24 }, sm: { span: 8 }}} + wrapperCol = {{xs: { span: 24 }, sm: { span: 16 }}} + label={card.labelShow !== 'false' ? card.label : ''} + required={card.required === 'true'} + > + {card.type === 'text' ? + <Input style={{marginTop: '4px'}} placeholder={card.labelShow === 'false' ? card.label : ''} value={card.initval} /> : 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 === 'dateweek' ? + <WeekPicker value={card.initval ? moment().subtract(card.initval * 7, 'days') : null} /> : null + } + {card.type === 'datemonth' ? + <MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null + } + {card.type === 'daterange' ? + <RangePicker + className="data-range" + placeholder={['BeginTime', 'EndTime']} + renderExtraFooter={() => 'extra footer'} + value={_defaultValue} + /> : null + } + {card.type === 'group' ? <DateGroup card={card} /> : null } + </Form.Item> </div> </div> </Popover> diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx index 53be372..87bbadc 100644 --- a/src/menu/components/search/main-search/index.jsx +++ b/src/menu/components/search/main-search/index.jsx @@ -52,7 +52,7 @@ width: 24, name: card.name, subtype: card.subtype, - wrap: { name: card.name, width: 24 }, + wrap: { name: card.name, width: 24, show: 'true', float: 'left' }, style: { marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' }, diff --git a/src/menu/components/search/main-search/index.scss b/src/menu/components/search/main-search/index.scss index 288990d..2342b30 100644 --- a/src/menu/components/search/main-search/index.scss +++ b/src/menu/components/search/main-search/index.scss @@ -27,23 +27,9 @@ border-radius: 2px; padding-bottom: 15px; .ant-form-item { - cursor: move; - display: flex; + position: relative; margin-bottom: 0px; - .ant-form-item-label { - height: 40px; - label { - width: 100%; - cursor: move; - overflow: hidden; - display: inline-block; - text-overflow: ellipsis; - white-space: nowrap; - } - } .ant-form-item-control-wrapper { - position: relative; - flex: 1 1; .ant-select { width: 100%; margin-top: 4px; @@ -56,26 +42,31 @@ font-size: 13px; } } - .ant-form-item-control-wrapper::after { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - opacity: 0; - z-index: 2; - } + } + .ant-form-item::after { + display: block; + content: ' '; + clear: both; + } + >div::after { + display: block; + content: ' '; + position: absolute; + cursor: move; + top: 0; + left: 0; + right: 0; + bottom: 0; + opacity: 0; + z-index: 2; } } .page-card.false { .ant-form-item-label { display: none; } - } - .page-card:hover { - .edit { - display: inline-block; + .ant-form-item-control-wrapper { + width: 100%; } } .ant-calendar-picker { diff --git a/src/menu/components/share/searchcomponent/dragsearch/card.jsx b/src/menu/components/share/searchcomponent/dragsearch/card.jsx index 6e023ff..6d7e365 100644 --- a/src/menu/components/share/searchcomponent/dragsearch/card.jsx +++ b/src/menu/components/share/searchcomponent/dragsearch/card.jsx @@ -1,6 +1,6 @@ import React from 'react' import { useDrag, useDrop } from 'react-dnd' -import { Icon, Select, DatePicker, Input, Popover } from 'antd' +import { Icon, Select, DatePicker, Input, Popover, Form } from 'antd' import moment from 'moment' import DateGroup from '../dategroup' @@ -19,8 +19,7 @@ const [, drop] = useDrop({ accept: 'search', canDrop: () => true, - drop: () => {}, - hover({ id: draggedId }) { + drop: ({ id: draggedId }) => { if (!draggedId || draggedId === id) return const { index: originIndex } = findCard(draggedId) @@ -29,7 +28,7 @@ const { index: overIndex } = findCard(id) moveCard(draggedId, overIndex) - }, + } }) const opacity = isDragging ? 0 : 1 @@ -66,9 +65,14 @@ <Icon className="close" title="delete" type="close" onClick={() => delCard(id)} /> </div> } trigger="hover"> - <div className="page-card" style={{ opacity: opacity}}> + <div className={'page-card ' + (card.labelShow || '')} style={{ opacity: opacity}}> <div ref={node => drag(drop(node))}> - <div className="ant-form-item"> + <Form.Item + labelCol={{xs: { span: 24 }, sm: { span: 8 }}} + wrapperCol = {{xs: { span: 24 }, sm: { span: 16 }}} + label={card.labelShow !== 'false' ? card.label : ''} + required={card.required === 'true'} + > {card.type === 'text' ? <Input placeholder={card.label} value={card.initval} /> : null } @@ -93,7 +97,7 @@ /> : null } {card.type === 'group' ? <DateGroup card={card} /> : null } - </div> + </Form.Item> </div> </div> </Popover> diff --git a/src/menu/components/share/searchcomponent/index.scss b/src/menu/components/share/searchcomponent/index.scss index 8751690..770b589 100644 --- a/src/menu/components/share/searchcomponent/index.scss +++ b/src/menu/components/share/searchcomponent/index.scss @@ -10,7 +10,6 @@ position: relative; border-radius: 2px; height: 45px; - padding-top: 8px; .ant-form-item { position: relative; cursor: move; @@ -37,6 +36,7 @@ } } .ant-form-item::after { + display: block; content: ' '; position: absolute; top: 0; @@ -47,6 +47,14 @@ z-index: 2; } } + .page-card.false { + .ant-form-item-label { + display: none; + } + .ant-form-item-control-wrapper { + width: 100%; + } + } .ant-calendar-picker { min-width: 100px!important; width: 100%; diff --git a/src/tabviews/calendar/index.scss b/src/tabviews/calendar/index.scss index b35d19b..34cab53 100644 --- a/src/tabviews/calendar/index.scss +++ b/src/tabviews/calendar/index.scss @@ -6,6 +6,10 @@ .box404 { padding-top: 30px; } + >.top-search { + padding: 0px 24px 5px; + border-bottom: 1px solid #efefef; + } .ant-modal-mask { position: absolute; diff --git a/src/tabviews/commontable/index.scss b/src/tabviews/commontable/index.scss index f76ce06..127ac7c 100644 --- a/src/tabviews/commontable/index.scss +++ b/src/tabviews/commontable/index.scss @@ -6,6 +6,10 @@ .box404 { padding-top: 30px; } + >.top-search { + padding: 0px 24px 5px; + border-bottom: 1px solid #efefef; + } .commontable-main-action { min-height: 25px; .button-list { diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 14b4bdb..9f8f546 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -284,7 +284,7 @@ val = '' + val } - if (card.format === 'percent') { + if (card.format === 'percent' && (!card.postfix || card.postfix.indexOf('%') === -1)) { val = val + '%' } else if (card.format === 'thdSeparator') { val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') diff --git a/src/tabviews/custom/components/card/data-card/index.jsx b/src/tabviews/custom/components/card/data-card/index.jsx index 348ed3f..dce1567 100644 --- a/src/tabviews/custom/components/card/data-card/index.jsx +++ b/src/tabviews/custom/components/card/data-card/index.jsx @@ -4,6 +4,7 @@ import { Spin, Empty, notification, Col, Pagination } from 'antd' import Api from '@/api' +import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import preImg from '@/assets/img/prev.png' import nextImg from '@/assets/img/next.png' @@ -13,6 +14,7 @@ const CardItem = asyncComponent(() => import('../cardItem')) const MainAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) +const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) class DataCard extends Component { static propTpyes = { @@ -27,6 +29,7 @@ BID: '', // 涓婄骇ID BData: '', // 涓婄骇琛屾暟鎹� config: null, // 鍥捐〃閰嶇疆淇℃伅 + search: null, // 鎼滅储鏉′欢 pageIndex: 1, // 椤电爜 activeKey: '', // 閫変腑鍗� selectKeys: [], // 澶氶�夋椂閫変腑鍗$墖 @@ -87,6 +90,7 @@ BID: BID || '', config: _config, card: _card, + search: Utils.initMainSearch(_config.search), arr_field: _config.columns.map(col => col.field).join(','), }, () => { if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { @@ -163,7 +167,7 @@ async loadData () { const { mainSearch, menuType } = this.props - const { config, arr_field, pageIndex, BID } = this.state + const { config, arr_field, pageIndex, search, BID } = this.state if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -178,7 +182,7 @@ return } - let searches = [] + let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 let keys = searches.map(item => item.key) mainSearch.forEach(item => { @@ -268,6 +272,15 @@ this.loadData() }) } + + refreshSearch = (list) => { + this.setState({ + search: list, + pageIndex: 1 + }, () => { + this.loadData() + }) + } changeCard = (index, item) => { const { config, selectKeys, selectedData, activeKey } = this.state @@ -337,6 +350,7 @@ <Spin /> </div> : null } + <NormalHeader config={config} BID={BID} menuType={this.props.menuType} refresh={this.refreshSearch} /> {config.action && config.action.length > 0 ? <MainAction BID={BID} diff --git a/src/tabviews/custom/components/card/data-card/index.scss b/src/tabviews/custom/components/card/data-card/index.scss index 72029b8..c93b704 100644 --- a/src/tabviews/custom/components/card/data-card/index.scss +++ b/src/tabviews/custom/components/card/data-card/index.scss @@ -33,7 +33,7 @@ >.ant-col:hover { >.card-item-box { z-index: 1; - transform: scale(1.1); + transform: scale(1.05); } } } diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index 757af64..9ee4b69 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -10,6 +10,7 @@ import './index.scss' const CardItem = asyncComponent(() => import('../cardItem')) +const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) class DataCard extends Component { static propTpyes = { @@ -36,6 +37,7 @@ let _data = {} let _sync = false + if (_config.setting && _config.wrap.datatype !== 'static') { _sync = _config.setting.sync === 'true' @@ -132,10 +134,9 @@ _data = nextProps.data[config.dataName] if (_data && Array.isArray(_data)) { _data = _data[0] - } else { - _data = {} } } + if (_data) { _data.$$BID = BID || '' } @@ -263,6 +264,7 @@ <Spin /> </div> : null } + <NormalHeader config={config}/> <div className={`card-row-list ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}> {config.subcards.map((item, index) => ( <Col className={activeKey === index ? 'active' : ''} key={index} span={item.setting.width || 6} offset={item.offset || 0} onClick={() => {this.changeCard(index, item)}}> diff --git a/src/tabviews/custom/components/card/prop-card/index.scss b/src/tabviews/custom/components/card/prop-card/index.scss index ba16fac..48206ff 100644 --- a/src/tabviews/custom/components/card/prop-card/index.scss +++ b/src/tabviews/custom/components/card/prop-card/index.scss @@ -34,7 +34,7 @@ >.ant-col:hover { >.card-item-box { z-index: 1; - transform: scale(1.1); + transform: scale(1.05); } } } diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index 140a11c..cb76eae 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -3,13 +3,15 @@ import { is, fromJS } from 'immutable' import { Spin, notification, Col, Empty, Pagination } from 'antd' -import asyncComponent from '@/utils/asyncComponent' import Api from '@/api' +import Utils from '@/utils/utils.js' +import asyncComponent from '@/utils/asyncComponent' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' import './index.scss' const CardCellComponent = asyncComponent(() => import('../cardcellList')) +const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) class TableCard extends Component { static propTpyes = { @@ -24,13 +26,12 @@ BID: '', // 涓婄骇ID config: null, // 鍥捐〃閰嶇疆淇℃伅 loading: false, // 鏁版嵁鍔犺浇鐘舵�� + search: null, // 鎼滅储鏉′欢 preIndex: 0, // 寮�濮嬬储寮� pageIndex: 1, // 椤电爜 total: 0, // 鎬绘暟 sync: false, // 鏄惁缁熶竴璇锋眰鏁版嵁 data: null, // 鏁版嵁 - title: '', // 鏍囬 - showHeader: false // 瀛樺湪鏍囬銆佹悳绱� } /** @@ -87,12 +88,11 @@ }) this.setState({ - showHeader: showHeader, - title: _config.wrap.title, sync: _sync, BID: BID || '', data: _data, config: _config, + search: Utils.initMainSearch(_config.search), arr_field: _config.columns.map(col => col.field).join(','), }, () => { if (_config.setting.sync !== 'true' && _config.setting.onload === 'true') { @@ -172,7 +172,7 @@ async loadData () { const { mainSearch, menuType } = this.props - const { config, arr_field, pageIndex, BID } = this.state + const { config, arr_field, pageIndex, search, BID } = this.state if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -183,7 +183,7 @@ return } - let searches = [] + let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 let keys = searches.map(item => item.key) mainSearch.forEach(item => { @@ -292,8 +292,17 @@ return line } + refreshSearch = (list) => { + this.setState({ + search: list, + pageIndex: 1 + }, () => { + this.loadData() + }) + } + render() { - const { config, loading, data, title, showHeader, pageIndex, preIndex, total } = this.state + const { config, loading, data, BID, pageIndex, preIndex, total } = this.state return ( <div className="custom-table-card-box" style={{...config.style, height: config.wrap.height}}> @@ -303,10 +312,7 @@ <Spin /> </div> : null } - {showHeader ? <div className="table-header" style={config.headerStyle}> - <span className="table-title">{title}</span> - {/* <searchLine /> */} - </div> : null} + <NormalHeader config={config} BID={BID} menuType={this.props.menuType} refresh={this.refreshSearch} /> {data && data.length > 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}> {data.map((item, index) => this.getLines(item, preIndex + index + 1))} </div> : null} diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx index f45ba50..92b1fd3 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx @@ -12,10 +12,10 @@ import Utils from '@/utils/utils.js' import UtilsDM from '@/utils/utils-datamanage.js' import { modifyTabview } from '@/store/action' -// import searchLine from '../../share/searchLine' import MKEmitter from '@/utils/events.js' import './index.scss' +const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton')) const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton')) @@ -35,7 +35,6 @@ loading: false, // 鏁版嵁鍔犺浇鐘舵�� chartId: Utils.getuuid(), // 鍥捐〃Id transfield: {}, // 瀛楁鍚嶇О缈昏瘧 - title: '', // 缁勪欢鏍囬 sync: false, // 鏄惁缁熶竴璇锋眰鏁版嵁 plot: null, // 鍥捐〃璁剧疆 data: null, // 鏁版嵁 @@ -45,7 +44,6 @@ chartData: [], // 鍥捐〃鏁版嵁 chartFields: [], // 缁熻鍥捐〃鐢熸垚瀛楁闆� selectFields: [], // 缁熻鍥捐〃閫夋嫨瀛楁 - showHeader: false // 瀛樺湪鏍囬銆佹悳绱€�佹垨缁熻鏁版嵁鏃舵樉绀� } UNSAFE_componentWillMount () { @@ -99,9 +97,7 @@ }) } - let showHeader = false - if (config.plot.title || _config.plot.datatype === 'statistics' || config.search.length > 0) { - showHeader = true + if (config.plot.title || config.search.length > 0) { _config.plot.height = _config.plot.height - 80 } else { _config.plot.height = _config.plot.height - 30 @@ -196,10 +192,8 @@ arr_field: _config.columns.map(col => col.field).join(','), plot: _config.plot, sync: _sync, - title: config.plot.title, search: Utils.initMainSearch(config.search), - transfield, - showHeader + transfield }, () => { if (config.setting.sync !== 'true' && config.setting.onload === 'true') { this.loadData() @@ -1265,8 +1259,14 @@ }) } + refreshSearch = (list) => { + this.setState({search: list}, () => { + this.loadData() + }) + } + render() { - const { showHeader, config, loading, title, plot, empty, chartFields, selectFields, BID } = this.state + const { config, loading, plot, empty, chartFields, selectFields, BID } = this.state return ( <div className="custom-line-chart-plot-box" style={config.style}> @@ -1276,23 +1276,9 @@ <Spin /> </div> : null } - {showHeader ? <div className="chart-header" style={config.headerStyle}> - <span className="chart-title">{title}</span> - {/* <searchLine /> */} - {plot.datatype === 'statistics' && chartFields.length > 0 ? <Select - mode="multiple" - showSearch - showArrow={true} - value={selectFields} - onChange={this.handleChange} - maxTagCount={0} - maxTagPlaceholder={(option) => <div className="type-label">{option.join('銆�')}</div>} - > - {chartFields.map((item, i) => <Select.Option key={i} value={item}>{item}</Select.Option>)} - </Select> : null} - </div> : null} + <NormalHeader config={config} BID={BID} menuType={this.props.menuType} refresh={this.refreshSearch} /> <div className="canvas-wrap"> - <div className={'chart-action ' + (plot.title ? 'with-title' : '')}> + <div className="chart-action"> {config.action.map(item => { if (item.OpenType === 'excelOut') { return ( @@ -1319,6 +1305,17 @@ ) } })} + {plot.datatype === 'statistics' && chartFields.length > 0 ? <Select + mode="multiple" + showSearch + showArrow={true} + value={selectFields} + onChange={this.handleChange} + maxTagCount={0} + maxTagPlaceholder={(option) => <div className="type-label">{option.join('銆�')}</div>} + > + {chartFields.map((item, i) => <Select.Option key={i} value={item}>{item}</Select.Option>)} + </Select> : null} </div> <div className={'canvas' + (empty ? ' empty' : '')} id={this.state.chartId}></div> </div> diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.scss b/src/tabviews/custom/components/chart/antv-bar-line/index.scss index 7d6a79a..24f4113 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.scss +++ b/src/tabviews/custom/components/chart/antv-bar-line/index.scss @@ -1,26 +1,11 @@ .custom-line-chart-plot-box { + position: relative; background: #ffffff; background-position: center center; background-repeat: no-repeat; background-size: cover; min-height: 100px; - > .chart-header { - height: 45px; - // border-bottom: 1px solid #e8e8e8; - overflow: hidden; - - .chart-title { - // font-size: 16px; - float: left; - line-height: 45px; - margin-left: 10px; - text-decoration: inherit; - font-weight: inherit; - font-style: inherit; - } - } - .canvas-wrap { margin: 0 0px; position: relative; @@ -29,9 +14,6 @@ top: 2px; right: 5px; z-index: 1; - } - .chart-action.with-title { - top: 35px; } } @@ -56,14 +38,10 @@ } .loading-mask { position: absolute; - left: 20px; + left: 0px; top: 0; - right: 20px; - bottom: 30px; - display: flex; - align-items: center; - justify-content: center; - text-align: justify; + right: 0px; + bottom: 0px; z-index: 1; .ant-spin-blur { @@ -73,9 +51,6 @@ opacity: 0.5; background: #ffffff; } - } - .chart-title + .loading-mask { - top: 40px; } > .ant-select { width: 150px; diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx index 14e691d..44bbdda 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.jsx +++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx @@ -6,14 +6,16 @@ import DataSet from '@antv/data-set' import { Spin, Empty, notification } from 'antd' -// import searchLine from '../../share/searchLine' import Api from '@/api' import Utils from '@/utils/utils.js' import { modifyTabview } from '@/store/action' import { chartColors } from '@/utils/option.js' +import asyncComponent from '@/utils/asyncComponent' import UtilsDM from '@/utils/utils-datamanage.js' import MKEmitter from '@/utils/events.js' import './index.scss' + +const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) class PieChart extends Component { static propTpyes = { @@ -35,7 +37,6 @@ plot: null, // 鍥捐〃璁剧疆 data: null, // 鏁版嵁 search: null, // 鎼滅储鏉′欢 - showHeader: false // 瀛樺湪鏍囬銆佹悳绱€�佹垨缁熻鏁版嵁鏃舵樉绀� } UNSAFE_componentWillMount () { @@ -53,9 +54,7 @@ _sync = false } - let showHeader = false if (config.plot.title || config.search.length > 0) { - showHeader = true _config.plot.height = _config.plot.height - 80 } else { _config.plot.height = _config.plot.height - 30 @@ -75,8 +74,7 @@ plot: _config.plot, sync: _sync, title: config.plot.title, - search: Utils.initMainSearch(config.search), - showHeader + search: Utils.initMainSearch(config.search) }, () => { if (config.setting.sync !== 'true' && config.setting.onload === 'true') { this.loadData() @@ -556,8 +554,14 @@ chart.render() } + refreshSearch = (list) => { + this.setState({search: list}, () => { + this.loadData() + }) + } + render() { - const { showHeader, config, loading, title, empty } = this.state + const { config, loading, empty, BID } = this.state return ( <div className="custom-pie-chart-plot-box" style={config.style}> @@ -567,10 +571,7 @@ <Spin /> </div> : null } - {showHeader ? <div className="chart-header" style={config.headerStyle}> - <span className="chart-title">{title}</span> - {/* <searchLine /> */} - </div> : null} + <NormalHeader config={config} BID={BID} menuType={this.props.menuType} refresh={this.refreshSearch} /> <div className="canvas-wrap"> <div className={'canvas' + (empty ? ' empty' : '')} id={this.state.chartId}></div> </div> diff --git a/src/tabviews/custom/components/chart/antv-pie/index.scss b/src/tabviews/custom/components/chart/antv-pie/index.scss index e6a1847..3839a61 100644 --- a/src/tabviews/custom/components/chart/antv-pie/index.scss +++ b/src/tabviews/custom/components/chart/antv-pie/index.scss @@ -1,25 +1,10 @@ .custom-pie-chart-plot-box { + position: relative; background: #ffffff; background-position: center center; background-repeat: no-repeat; background-size: cover; min-height: 100px; - - > .chart-header { - height: 45px; - // border-bottom: 1px solid #e8e8e8; - overflow: hidden; - - .chart-title { - // font-size: 16px; - float: left; - line-height: 45px; - margin-left: 10px; - text-decoration: inherit; - font-weight: inherit; - font-style: inherit; - } - } .canvas-wrap { margin: 0 0px; @@ -56,14 +41,10 @@ } .loading-mask { position: absolute; - left: 20px; + left: 0px; top: 0; - right: 20px; - bottom: 30px; - display: flex; - align-items: center; - justify-content: center; - text-align: justify; + right: 0px; + bottom: 0px; z-index: 1; .ant-spin-blur { @@ -73,9 +54,6 @@ opacity: 0.5; background: #ffffff; } - } - .chart-title + .loading-mask { - top: 40px; } > .ant-select { width: 150px; diff --git a/src/tabviews/custom/components/search/main-search/index.jsx b/src/tabviews/custom/components/search/main-search/index.jsx deleted file mode 100644 index 7a785e0..0000000 --- a/src/tabviews/custom/components/search/main-search/index.jsx +++ /dev/null @@ -1,794 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Button, Select, DatePicker, notification } from 'antd' -import moment from 'moment' - -import Api from '@/api' -import options from '@/store/options.js' -import DateGroup from '@/tabviews/zshare/dategroup' -import Utils from '@/utils/utils.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' -import './index.scss' - -const { MonthPicker, WeekPicker, RangePicker } = DatePicker - -class MainSearch extends Component { - static propTpyes = { - BID: PropTypes.any, // 鐖剁骇Id - config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 - menuType: PropTypes.any, // 鑿滃崟绫诲瀷 - refreshdata: PropTypes.func // 鍒锋柊鏁版嵁 - } - - state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - match: null, // 鎼滅储鏉′欢鍖归厤瑙勫垯 - style: null, // 鎼滅储鏉′欢绫诲瀷 - label: null, // 鎻愮ず鏂囧瓧 - required: null, // 鏄惁蹇呭~ - searchlist: null, // 鎼滅储椤� - groups: null, // 缁勫悎鎼滅储椤� - formId: Utils.getuuid() // 鎼滅储琛ㄥ崟Id - } - - UNSAFE_componentWillMount () { - let searchlist = fromJS(this.props.config.search).toJS() - let match = {} - let label = {} - let style = {} - let required = {} - let _list = [] - let fieldMap = new Map() - let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� - let localItems = [] // 鏈湴鏁版嵁 - let deForms = [] // 娴嬭瘯绯荤粺锛屽崟涓姹� - - searchlist.forEach(item => { - if (fieldMap.has(item.field)) { - item.field = item.field + '@tail@' - } - fieldMap.set(item.field, true) - - match[item.field] = item.match - label[item.field] = item.label - style[item.field] = item.type - required[item.field] = item.required === 'true' - - if (['select', 'link', 'multiselect'].includes(item.type)) { - if (item.setAll === 'true' && item.type !== 'multiselect') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.state.dict['main.all'] - }) - } - - // 鏁版嵁婧愭煡璇㈣鍙� - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _option.sql = _option.sql.replace(/\$@/ig, '/*') - _option.sql = _option.sql.replace(/@\$/ig, '*/') - } else { - _option.sql = _option.sql.replace(/@\$|\$@/ig, '') - } - - // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 - if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { - deForms.push({ - ...item, - arr_field: _option.field, - data_sql: Utils.formatOptions(_option.sql) - }) - } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 - // 澶栬仈鏁版嵁搴撴浛鎹� - if (window.GLOB.externalDatabase !== null) { - _option.sql = _option.sql.replace(/@db@/ig, `[${window.GLOB.externalDatabase}]..`) - } - if (item.database === 'sso') { - mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) - } else { - localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) - } - } - } - item.oriOptions = fromJS(item.options).toJS() - } - - _list.push(item) - }) - - let _groups = [] - _list = _list.map(item => { - if (item.type === 'link') { - let supItem = _list.filter(form => form.field === item.linkField)[0] - - if (!supItem) { - notification.warning({ - top: 92, - message: '鏈煡璇㈠埌鎼滅储鏉′欢銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', - duration: 5 - }) - item.supInitVal = '' - } else { - item.supInitVal = supItem.initval - item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval) - } - } else if (item.type === 'group' && item.Hide !== 'true') { - _groups.push(fromJS(item).toJS()) - } - - return item - }) - - this.setState({ - match: match, - label: label, - style: style, - required: required, - searchlist: _list, - groups: _groups - }, () => { - if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { - this.improveSimpleSearch(deForms) - } else { - this.improveSearch(mainItems, localItems) - } - }) - } - - // 鏌ヨ涓嬫媺鑿滃崟 - improveSearch = (mainItems, localItems) => { - const { menuType, BID } = this.props - let deffers = [] - - if (menuType !== 'HS' && window.GLOB.systemType !== 'production') { - localItems = [...localItems, ...mainItems] - mainItems = [] - } - - // 鏈湴璇锋眰 - let param = { - func: 'sPC_Get_SelectedList', - LText: localItems.join(' union all '), - obj_name: '', - arr_field: '', - table_type: 'Y' - } - - if (BID) { - param.BID = BID - } - - if (param.LText) { - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - deffers.push( - new Promise(resolve => { - Api.getSystemCacheConfig(param).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - resolve(res) - }) - }) - ) - } - - // 绯荤粺璇锋眰 - let mainparam = { - func: 'sPC_Get_SelectedList', - LText: mainItems.join(' union all '), - obj_name: '', - arr_field: '', - table_type: 'Y' - } - - if (BID) { - mainparam.BID = BID - } - - if (mainparam.LText) { - mainparam.LText = Utils.formatOptions(mainparam.LText) - mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp) - - if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp) - if (options.cloudServiceApi) { - mainparam.rduri = options.cloudServiceApi - mainparam.userid = sessionStorage.getItem('CloudUserID') || '' - mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } - } else if (window.GLOB.mainSystemApi) { - mainparam.rduri = window.GLOB.mainSystemApi - } - - deffers.push( - new Promise(resolve => { - Api.getSystemCacheConfig(mainparam).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - resolve(res) - }) - }) - ) - } - - Promise.all(deffers).then(response => { - let result = {...response[0], ...(response[1] || {})} - - delete result.ErrCode - delete result.ErrMesg - delete result.message - delete result.status - - let _searchlist = this.state.searchlist.map(item => { - if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { - let options = result[item.field].map(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[item.valueField], - Text: cell[item.valueText] - } - - if (item.type === 'link') { - _item.ParentID = cell[item.linkField] - } - - return _item - }) - - item.oriOptions = [...item.oriOptions, ...options] - } - return item - }) - - this.setState({ - searchlist: _searchlist.map(item => { - if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) - } else { - item.options = item.oriOptions - } - } else if (item.type === 'select' || item.type === 'multiselect') { - item.options = item.oriOptions - } - - return item - }) - }) - }) - } - - // 娴嬭瘯绯荤粺鍗曚釜璇锋眰涓嬫媺閫夐」 - improveSimpleSearch = (deForms) => { - if (deForms.length === 0) return - - let deffers = deForms.map(item => { - let param = { - func: 'sPC_Get_SelectedList', - LText: item.data_sql, - obj_name: item.field, - arr_field: item.arr_field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - return ( - new Promise(resolve => { - Api.getSystemCacheConfig(param).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - resolve(res) - }) - }) - ) - }) - - Promise.all(deffers).then(response => { - let result = {} - - response.forEach(res => { - result = {...result, ...res} - }) - - delete result.ErrCode - delete result.ErrMesg - delete result.message - delete result.status - - let _searchlist = this.state.searchlist.map(item => { - if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { - let options = result[item.field].map(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[item.valueField], - Text: cell[item.valueText] - } - - if (item.type === 'link') { - _item.ParentID = cell[item.linkField] - } - - return _item - }) - - item.oriOptions = [...item.oriOptions, ...options] - } - return item - }) - - this.setState({ - searchlist: _searchlist.map(item => { - if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) - } else { - item.options = item.oriOptions - } - } else if (item.type === 'select' || item.type === 'multiselect') { - item.options = item.oriOptions - } - - return item - }) - }) - }) - } - - resetform = (formlist, supfields, index, fieldsvalue) => { - index++ - let subfields = [] - - supfields.forEach(supfield => { - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === supfield.field) { - item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval) - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - }) - - if (subfields.length === 0 || index > 6) { - return formlist - } else { - return this.resetform(formlist, subfields, index, fieldsvalue) - } - } - - selectChange = (_field, value) => { - let formlist = fromJS(this.state.searchlist).toJS() - - let subfields = [] - let fieldsvalue = {} - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === _field.field) { - item.options = item.oriOptions.filter(option => option.ParentID === value) - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - - if (subfields.length === 0) { - this.searchChange() - return - } - - formlist = this.resetform(formlist, subfields, 0, fieldsvalue) - - if (Object.keys(fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - - this.setState({ - searchlist: formlist - }, () => { - this.searchChange() - }) - } - - getFields() { - const { getFieldDecorator } = this.props.form - const { config } = this.props - const fields = [] - - this.state.searchlist.forEach((item, index) => { - if (item.Hide === 'true') return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required === 'true', - message: this.state.dict['form.required.input'] + item.label + '!' - } - ] - })(<Input placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required === 'true', - message: this.state.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - onChange={(value) => {this.selectChange(item, value)}} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById(this.state.formId)} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 涓嬫媺澶氶�� - let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: item.required === 'true', - message: this.state.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - mode="multiple" - onChange={this.searchChange} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById(this.state.formId)} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval, 'days') : null, - rules: [ - { - required: item.required === 'true', - message: this.state.dict['form.required.select'] + item.label + '!' - } - ] - })( - <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datemonth') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval, 'month') : null, - rules: [ - { - required: item.required === 'true', - message: this.state.dict['form.required.select'] + item.label + '!' - } - ] - })( - <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'dateweek') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null, - rules: [ - { - required: item.required === 'true', - message: this.state.dict['form.required.select'] + item.label + '!' - } - ] - })( - <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'daterange') { - let _defaultValue = [null, null] - - if (item.initval) { - try { - let _initval = JSON.parse(item.initval) - _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch { - _defaultValue = [null, null] - } - } - - fields.push( - <Col className="daterange" span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> - {getFieldDecorator(item.field, - { - initialValue: _defaultValue, - rules: [ - { - required: item.required === 'true', - message: this.state.dict['form.required.select'] + item.label + '!' - } - ] - })( - <RangePicker - placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']} - renderExtraFooter={() => 'extra footer'} - onChange={this.searchChange} - getCalendarContainer={() => document.getElementById(this.state.formId)} - /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'group') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.labelShow !== 'false' ? item.label : ''} className={item.required === 'true' ? 'group-required' : ''}> - <DateGroup ref={item.uuid} position={index} card={item} onGroupChange={this.searchChange} /> - </Form.Item> - </Col> - ) - } - }) - - if (config.wrap.float !== 'right' && config.wrap.show !== 'false') { - fields.push( - <Col span={6} style={{ whiteSpace: 'nowrap' }} key="actions"> - <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}> - <Button type="primary" htmlType="submit"> - {this.state.dict['main.search']} - </Button> - <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> - {this.state.dict['main.reset']} - </Button> - </Form.Item> - </Col> - ) - } - - return fields - } - - addHideFieldValue = (values) => { - const { searchlist } = this.state - let hideValue = {} - searchlist.forEach(item => { - if (item.Hide === 'true') { - let value = '' - - if (item.type === 'multiselect') { // 涓嬫媺澶氶�� - value = item.initval ? item.initval.split(',').filter(Boolean) : [] - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - value = item.initval ? moment().subtract(item.initval, 'days') : '' - } else if (item.type === 'datemonth') { - value = item.initval ? moment().subtract(item.initval, 'month') : '' - } else if (item.type === 'dateweek') { - value = item.initval ? moment().subtract(item.initval * 7, 'days') : '' - } else if (item.type === 'daterange') { - if (item.initval) { - try { - let _initval = JSON.parse(item.initval) - value = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch { - value = '' - } - } - } else if (item.type !== 'group') { - value = item.initval - } - - hideValue[item.field] = value - } - }) - - return {...hideValue, ...values} - } - - handleSearch = (e) => { - // 鍥炶溅鎴栫偣鍑绘悳绱� - e.preventDefault() - this.props.form.validateFields((err, values) => { - if (!err) { - values = this.addHideFieldValue(values) - let searches = this.getFieldsValues(values) - this.props.refreshdata(searches) - } - }) - } - - searchChange = () => { - this.setState({}, () => { - this.props.form.validateFields((err, values) => { - if (!err) { - values = this.addHideFieldValue(values) - let searches = this.getFieldsValues(values) - this.props.refreshdata(searches) - } - }) - }) - } - - /** - * @description 鎼滅储鏉′欢閲嶇疆 - */ - handleReset = () => { - const { groups } = this.state - - if (groups.length > 0) { - groups.forEach(item => { - this.refs[item.uuid].reset() - }) - } - - let searchlist = this.state.searchlist.map(item => { - item.initval = item.oriInitval - return item - }) - - this.setState({searchlist}, () => { - this.props.form.resetFields() - this.props.form.validateFields((err, values) => { - if (!err) { - // 寮傛鑾峰彇鏇存柊鍚庣殑鏃堕棿缁� - this.setState({}, () => { - values = this.addHideFieldValue(values) - let searches = this.getFieldsValues(values) - this.props.refreshdata(searches) - }) - } - }) - }) - } - - getFieldsValues = (values) => { - const { groups } = this.state - // 鑾峰彇鎼滅储鏉′欢鍊� - let search = [] - Object.keys(values).forEach(key => { - let _value = '' - if (this.state.style[key] === 'daterange') { - if (values[key].length > 0 && values[key][0] && values[key][1]) { - _value = [moment(values[key][0]).format('YYYY-MM-DD'), moment(values[key][1]).format('YYYY-MM-DD')] - } - } else if (this.state.style[key] === 'dateweek') { - if (values[key]) { - _value = [moment(values[key]).startOf('week').format('YYYY-MM-DD'), moment(values[key]).endOf('week').format('YYYY-MM-DD')] - } - } else if (this.state.style[key] === 'date') { - if (values[key]) { - _value = moment(values[key]).format('YYYY-MM-DD') - } - } else if (this.state.style[key] === 'datemonth') { - if (values[key]) { - _value = moment(values[key]).format('YYYY-MM') - } - } else if (this.state.style[key] === 'multiselect') { - _value = values[key] || [] - - } else { - _value = (values[key] || values[key] === 0) ? values[key] : '' - - _value = _value.replace(/(^\s*|\s*$)/ig, '') - } - - search.push({ - type: this.state.style[key], - key: key.replace(/@tail@$/, ''), - value: _value, - label: this.state.label[key], - match: this.state.match[key], - required: this.state.required[key] - }) - }) - - if (groups.length > 0) { - groups.forEach(item => { - let items = this.refs[item.uuid].getSearchItems() - search.push(...items) - }) - } - - return search - } - - render() { - const { config } = this.props - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className={`custom-main-search ${config.wrap.float} ${config.wrap.show}`} style={config.style} id={this.state.formId} onSubmit={this.handleSearch}> - <Row gutter={24}>{this.getFields()}</Row> - </Form> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/tabviews/custom/components/search/main-search/index.scss b/src/tabviews/custom/components/search/main-search/index.scss deleted file mode 100644 index 8b7c1f4..0000000 --- a/src/tabviews/custom/components/search/main-search/index.scss +++ /dev/null @@ -1,46 +0,0 @@ -.custom-main-search { - background: #ffffff; - .ant-form-item { - display: flex; - margin-bottom: 0px; - min-height: 60px; - .ant-form-explain { - white-space: nowrap; - } - } - .ant-form-item-control-wrapper { - flex: 1; - width: calc(100% - 100px); - } - .ant-form-item-label { - text-overflow: ellipsis; - } - .daterange .ant-calendar-picker-input { - padding: 4px 20px 4px 5px; - font-size: 13px; - } - .ant-select-dropdown { - z-index: 10 !important; - } - .ant-calendar-picker-container { - z-index: 10 !important; - } - .group-required { - label::before { - display: inline-block; - margin-right: 4px; - color: #f5222d; - font-size: 14px; - font-family: SimSun, sans-serif; - line-height: 1; - content: '*'; - } - } -} -.custom-main-search.right { - >.ant-row { - >.ant-col { - float: right; - } - } -} \ No newline at end of file diff --git a/src/tabviews/custom/components/share/normalheader/index.jsx b/src/tabviews/custom/components/share/normalheader/index.jsx new file mode 100644 index 0000000..9643142 --- /dev/null +++ b/src/tabviews/custom/components/share/normalheader/index.jsx @@ -0,0 +1,57 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' + +import asyncComponent from '@/utils/asyncComponent' +import './index.scss' + +const SearchComponent = asyncComponent(() => import('@/tabviews/zshare/topSearch')) + +class NormalHeader extends Component { + static propTpyes = { + BID: PropTypes.any, // 涓婄骇涓婚敭鍊� + menuType: PropTypes.any, // 鑿滃崟绫诲瀷 + config: PropTypes.object, // 閰嶇疆淇℃伅 + refresh: PropTypes.func // 鏉′欢鍒锋柊 + } + + state = { + title: '', // 鏍囬 + show: false, // 鏄惁鏄剧ず鎼滅储 + } + + UNSAFE_componentWillMount () { + const { config } = this.props + + this.setState({ + title: config.plot ? config.plot.title : config.wrap.title, + show: !['normaltable', 'propcard'].includes(config.subtype) && config.search && config.search.length > 0 + }) + } + + shouldComponentUpdate (nextProps, nextState) { return false } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + render() { + const { config, menuType, BID } = this.props + const { title, show } = this.state + + if (!title && !show) return null + + return ( + <div className="normal-header" style={config.headerStyle}> + <span className="title">{title}</span> + {show ? <SearchComponent config={config} BID={BID} menuType={menuType} refreshdata={this.props.refresh}/> : null} + </div> + ) + } +} + +export default NormalHeader \ No newline at end of file diff --git a/src/tabviews/custom/components/share/normalheader/index.scss b/src/tabviews/custom/components/share/normalheader/index.scss new file mode 100644 index 0000000..c58253d --- /dev/null +++ b/src/tabviews/custom/components/share/normalheader/index.scss @@ -0,0 +1,41 @@ +.normal-header { + position: relative; + height: 45px; + padding-right: 8px; + border-bottom: 1px solid #e8e8e8; + overflow: hidden; + letter-spacing: 0px; + + .title { + text-decoration: inherit; + font-weight: inherit; + font-style: inherit; + float: left; + line-height: 45px; + margin-left: 10px; + position: relative; + z-index: 1; + } + .top-search { + background: transparent; + text-decoration: unset; + font-weight: normal; + font-style: normal; + letter-spacing: 0px; + >.ant-row { + >.ant-col { + height: 45px; + line-height: 45px; + .ant-input { + height: 28px; + } + .ant-select-selection { + height: 28px; + } + } + } + } +} +.normal-header.hidden { + display: none; +} \ No newline at end of file diff --git a/src/tabviews/custom/components/share/searchLine/index.jsx b/src/tabviews/custom/components/share/searchLine/index.jsx deleted file mode 100644 index ba3aaab..0000000 --- a/src/tabviews/custom/components/share/searchLine/index.jsx +++ /dev/null @@ -1,783 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Button, Select, DatePicker, notification } from 'antd' -import moment from 'moment' - -import Api from '@/api' -import options from '@/store/options.js' -import DateGroup from '@/tabviews/zshare/dategroup' -import Utils from '@/utils/utils.js' -import './index.scss' - -const {MonthPicker, WeekPicker, RangePicker} = DatePicker - -class MainSearch extends Component { - static propTpyes = { - BID: PropTypes.any, // 鐖剁骇Id锛岀敤浜庢煡璇笅鎷夐�夋嫨椤� - menuType: PropTypes.any, // 鑿滃崟鏉冮檺锛屾槸鍚︿负HS - searchlist: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃 - dict: PropTypes.object // 瀛楀吀椤� - } - - state = { - match: null, // 鎼滅储鏉′欢鍖归厤瑙勫垯 - style: null, // 鎼滅储鏉′欢绫诲瀷 - label: null, // 鎻愮ず鏂囧瓧 - required: null, // 鏄惁蹇呭~ - searchlist: null, // 鎼滅储椤� - groups: null, // 缁勫悎鎼滅储椤� - formId: Utils.getuuid() // 鎼滅储琛ㄥ崟Id - } - - UNSAFE_componentWillMount () { - let searchlist = fromJS(this.props.searchlist).toJS() - let match = {} - let label = {} - let style = {} - let required = {} - let _list = [] - let fieldMap = new Map() - let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� - let localItems = [] // 鏈湴鏁版嵁 - let deForms = [] // 娴嬭瘯绯荤粺锛屽崟涓姹� - - searchlist.forEach(item => { - if (fieldMap.has(item.field)) { - item.field = item.field + '@tail@' - } - fieldMap.set(item.field, true) - - match[item.field] = item.match - label[item.field] = item.label - style[item.field] = item.type - required[item.field] = item.required === 'true' - - if (['select', 'link', 'multiselect'].includes(item.type)) { - if (item.setAll === 'true' && item.type !== 'multiselect') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.props.dict['main.all'] - }) - } - - // 鏁版嵁婧愭煡璇㈣鍙� - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _option.sql = _option.sql.replace(/\$@/ig, '/*') - _option.sql = _option.sql.replace(/@\$/ig, '*/') - } else { - _option.sql = _option.sql.replace(/@\$|\$@/ig, '') - } - - // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 - if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { - deForms.push({ - ...item, - arr_field: _option.field, - data_sql: Utils.formatOptions(_option.sql) - }) - } else { // 鍚堝苟璇锋眰锛屽尯鍒嗘湰鍦板強绯荤粺 - if (item.database === 'sso') { - mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) - } else { - localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) - } - } - } - item.oriOptions = fromJS(item.options).toJS() - } - - _list.push(item) - }) - - let _groups = [] - _list = _list.map(item => { - if (item.type === 'link') { - let supItem = _list.filter(form => form.field === item.linkField)[0] - - if (!supItem) { - notification.warning({ - top: 92, - message: '鏈煡璇㈠埌鎼滅储鏉′欢銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', - duration: 5 - }) - item.supInitVal = '' - } else { - item.supInitVal = supItem.initval - item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval) - } - } else if (item.type === 'group' && item.Hide !== 'true') { - _groups.push(fromJS(item).toJS()) - } - - return item - }) - - this.setState({ - match: match, - label: label, - style: style, - required: required, - searchlist: _list, - groups: _groups - }, () => { - if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { - this.improveSimpleSearch(deForms) - } else { - this.improveSearch(mainItems, localItems) - } - }) - } - - // 鏌ヨ涓嬫媺鑿滃崟 - improveSearch = (mainItems, localItems) => { - const { menuType, BID } = this.props - let deffers = [] - - if (menuType !== 'HS' && window.GLOB.systemType !== 'production') { - localItems = [...localItems, ...mainItems] - mainItems = [] - } - - // 鏈湴璇锋眰 - let param = { - func: 'sPC_Get_SelectedList', - LText: localItems.join(' union all '), - obj_name: '', - arr_field: '', - table_type: 'Y' - } - - if (BID) { - param.BID = BID - } - - if (param.LText) { - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - deffers.push( - new Promise(resolve => { - Api.getSystemCacheConfig(param).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - resolve(res) - }) - }) - ) - } - - // 绯荤粺璇锋眰 - let mainparam = { - func: 'sPC_Get_SelectedList', - LText: mainItems.join(' union all '), - obj_name: '', - arr_field: '', - table_type: 'Y' - } - - if (BID) { - mainparam.BID = BID - } - - if (mainparam.LText) { - mainparam.LText = Utils.formatOptions(mainparam.LText) - mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp) - - if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp) - if (options.cloudServiceApi) { - mainparam.rduri = options.cloudServiceApi - mainparam.userid = sessionStorage.getItem('CloudUserID') || '' - mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } - } else if (window.GLOB.mainSystemApi) { - mainparam.rduri = window.GLOB.mainSystemApi - } - - deffers.push( - new Promise(resolve => { - Api.getSystemCacheConfig(mainparam).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - resolve(res) - }) - }) - ) - } - - Promise.all(deffers).then(response => { - let result = {...response[0], ...(response[1] || {})} - - delete result.ErrCode - delete result.ErrMesg - delete result.message - delete result.status - - let _searchlist = this.state.searchlist.map(item => { - if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { - let options = result[item.field].map(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[item.valueField], - Text: cell[item.valueText] - } - - if (item.type === 'link') { - _item.ParentID = cell[item.linkField] - } - - return _item - }) - - item.oriOptions = [...item.oriOptions, ...options] - } - return item - }) - - this.setState({ - searchlist: _searchlist.map(item => { - if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) - } else { - item.options = item.oriOptions - } - } else if (item.type === 'select' || item.type === 'multiselect') { - item.options = item.oriOptions - } - - return item - }) - }) - }) - } - - // 娴嬭瘯绯荤粺鍗曚釜璇锋眰涓嬫媺閫夐」 - improveSimpleSearch = (deForms) => { - if (deForms.length === 0) return - - let deffers = deForms.map(item => { - let param = { - func: 'sPC_Get_SelectedList', - LText: item.data_sql, - obj_name: item.field, - arr_field: item.arr_field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - return ( - new Promise(resolve => { - Api.getSystemCacheConfig(param).then(res => { - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - resolve(res) - }) - }) - ) - }) - - Promise.all(deffers).then(response => { - let result = {} - - response.forEach(res => { - result = {...result, ...res} - }) - - delete result.ErrCode - delete result.ErrMesg - delete result.message - delete result.status - - let _searchlist = this.state.searchlist.map(item => { - if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { - let options = result[item.field].map(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[item.valueField], - Text: cell[item.valueText] - } - - if (item.type === 'link') { - _item.ParentID = cell[item.linkField] - } - - return _item - }) - - item.oriOptions = [...item.oriOptions, ...options] - } - return item - }) - - this.setState({ - searchlist: _searchlist.map(item => { - if (item.type === 'link') { - if (item.supInitVal) { - item.options = item.oriOptions.filter(option => option.ParentID === item.supInitVal) - } else { - item.options = item.oriOptions - } - } else if (item.type === 'select' || item.type === 'multiselect') { - item.options = item.oriOptions - } - - return item - }) - }) - }) - } - - resetform = (formlist, supfields, index, fieldsvalue) => { - index++ - let subfields = [] - - supfields.forEach(supfield => { - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === supfield.field) { - item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval) - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - }) - - if (subfields.length === 0 || index > 6) { - return formlist - } else { - return this.resetform(formlist, subfields, index, fieldsvalue) - } - } - - selectChange = (_field, value) => { - let formlist = fromJS(this.state.searchlist).toJS() - - let subfields = [] - let fieldsvalue = {} - formlist = formlist.map(item => { - if (item.type === 'link' && item.linkField === _field.field) { - item.options = item.oriOptions.filter(option => option.ParentID === value) - item.initval = item.options[0] ? item.options[0].Value : '' - - if (this.props.form.getFieldValue(item.field) !== undefined) { - fieldsvalue[item.field] = item.initval - } - - subfields.push(item) - } - return item - }) - - if (subfields.length === 0) { - this.searchChange() - return - } - - formlist = this.resetform(formlist, subfields, 0, fieldsvalue) - - if (Object.keys(fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - - this.setState({ - searchlist: formlist - }, () => { - this.searchChange() - }) - } - - getFields() { - const { getFieldDecorator } = this.props.form - const fields = [] - - this.state.searchlist.forEach((item, index) => { - if (item.Hide === 'true') return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<Input placeholder="" autoComplete="off" />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - onChange={(value) => {this.selectChange(item, value)}} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById(this.state.formId)} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 涓嬫媺澶氶�� - let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - mode="multiple" - onChange={this.searchChange} - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById(this.state.formId)} - > - {item.options.map((option, i) => - <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval, 'days') : null, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datemonth') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval, 'month') : null, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'dateweek') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'daterange') { - let _defaultValue = [null, null] - - if (item.initval) { - try { - let _initval = JSON.parse(item.initval) - _defaultValue = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch { - _defaultValue = [null, null] - } - } - - fields.push( - <Col className="daterange" span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, - { - initialValue: _defaultValue, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <RangePicker - placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']} - renderExtraFooter={() => 'extra footer'} - onChange={this.searchChange} - getCalendarContainer={() => document.getElementById(this.state.formId)} - /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'group') { - fields.push( - <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label} className={item.required === 'true' ? 'group-required' : ''}> - <DateGroup ref={item.uuid} position={index} card={item} onGroupChange={this.searchChange} /> - </Form.Item> - </Col> - ) - } - }) - - fields.push( - <Col span={6} style={{ whiteSpace: 'nowrap' }} key="actions"> - <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}> - <Button type="primary" htmlType="submit"> - {this.props.dict['main.search']} - </Button> - <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> - {this.props.dict['main.reset']} - </Button> - </Form.Item> - </Col> - ) - - return fields - } - - addHideFieldValue = (values) => { - const { searchlist } = this.state - let hideValue = {} - searchlist.forEach(item => { - if (item.Hide === 'true') { - let value = '' - - if (item.type === 'multiselect') { // 涓嬫媺澶氶�� - value = item.initval ? item.initval.split(',').filter(Boolean) : [] - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - value = item.initval ? moment().subtract(item.initval, 'days') : '' - } else if (item.type === 'datemonth') { - value = item.initval ? moment().subtract(item.initval, 'month') : '' - } else if (item.type === 'dateweek') { - value = item.initval ? moment().subtract(item.initval * 7, 'days') : '' - } else if (item.type === 'daterange') { - if (item.initval) { - try { - let _initval = JSON.parse(item.initval) - value = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] - } catch { - value = '' - } - } - } else if (item.type !== 'group') { - value = item.initval - } - - hideValue[item.field] = value - } - }) - - return {...hideValue, ...values} - } - - handleSearch = (e) => { - // 鍥炶溅鎴栫偣鍑绘悳绱� - e.preventDefault() - this.props.form.validateFields((err, values) => { - if (!err) { - values = this.addHideFieldValue(values) - let searches = this.getFieldsValues(values) - this.props.refreshdata(searches) - } - }) - } - - searchChange = () => { - this.setState({}, () => { - this.props.form.validateFields((err, values) => { - if (!err) { - values = this.addHideFieldValue(values) - let searches = this.getFieldsValues(values) - this.props.refreshdata(searches) - } - }) - }) - } - - /** - * @description 鎼滅储鏉′欢閲嶇疆 - */ - handleReset = () => { - const { groups } = this.state - - if (groups.length > 0) { - groups.forEach(item => { - this.refs[item.uuid].reset() - }) - } - - let searchlist = this.state.searchlist.map(item => { - item.initval = item.oriInitval - return item - }) - - this.setState({searchlist}, () => { - this.props.form.resetFields() - this.props.form.validateFields((err, values) => { - if (!err) { - // 寮傛鑾峰彇鏇存柊鍚庣殑鏃堕棿缁� - this.setState({}, () => { - values = this.addHideFieldValue(values) - let searches = this.getFieldsValues(values) - this.props.refreshdata(searches) - }) - } - }) - }) - } - - getFieldsValues = (values) => { - const { groups } = this.state - // 鑾峰彇鎼滅储鏉′欢鍊� - let search = [] - Object.keys(values).forEach(key => { - let _value = '' - if (this.state.style[key] === 'daterange') { - if (values[key].length > 0 && values[key][0] && values[key][1]) { - _value = [moment(values[key][0]).format('YYYY-MM-DD'), moment(values[key][1]).format('YYYY-MM-DD')] - } - } else if (this.state.style[key] === 'dateweek') { - if (values[key]) { - _value = [moment(values[key]).startOf('week').format('YYYY-MM-DD'), moment(values[key]).endOf('week').format('YYYY-MM-DD')] - } - } else if (this.state.style[key] === 'date') { - if (values[key]) { - _value = moment(values[key]).format('YYYY-MM-DD') - } - } else if (this.state.style[key] === 'datemonth') { - if (values[key]) { - _value = moment(values[key]).format('YYYY-MM') - } - } else if (this.state.style[key] === 'multiselect') { - _value = values[key] || [] - - } else { - _value = (values[key] || values[key] === 0) ? values[key] : '' - - _value = _value.replace(/(^\s*|\s*$)/ig, '') - } - - search.push({ - type: this.state.style[key], - key: key.replace(/@tail@$/, ''), - value: _value, - label: this.state.label[key], - match: this.state.match[key], - required: this.state.required[key] - }) - }) - - if (groups.length > 0) { - groups.forEach(item => { - let items = this.refs[item.uuid].getSearchItems() - search.push(...items) - }) - } - - return search - } - - render() { - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className="header-top-search" id={this.state.formId} onSubmit={this.handleSearch}> - <Row gutter={24}>{this.getFields()}</Row> - </Form> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/tabviews/custom/components/share/searchLine/index.scss b/src/tabviews/custom/components/share/searchLine/index.scss deleted file mode 100644 index 3ab24d8..0000000 --- a/src/tabviews/custom/components/share/searchLine/index.scss +++ /dev/null @@ -1,41 +0,0 @@ -.header-top-search { - padding: 0px 24px 10px; - border-bottom: 1px solid #efefef; - .ant-form-item { - display: flex; - margin-bottom: 0px; - min-height: 60px; - .ant-form-explain { - white-space: nowrap; - } - } - .ant-form-item-control-wrapper { - flex: 1; - width: calc(100% - 100px); - } - .ant-form-item-label { - // width: 100px; - text-overflow: ellipsis; - } - .daterange .ant-calendar-picker-input { - padding: 4px 20px 4px 5px; - font-size: 13px; - } - .ant-select-dropdown { - z-index: 10 !important; - } - .ant-calendar-picker-container { - z-index: 10 !important; - } - .group-required { - label::before { - display: inline-block; - margin-right: 4px; - color: #f5222d; - font-size: 14px; - font-family: SimSun, sans-serif; - line-height: 1; - content: '*'; - } - } -} \ No newline at end of file diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index 5f195b9..c783218 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -14,7 +14,7 @@ // 閫氱敤缁勪欢 const AntvBarAndLine = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-bar-line')) -const MainSearch = asyncComponent(() => import('@/tabviews/custom/components/search/main-search')) +const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const AntvPie = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-pie')) const AntvTabs = asyncComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs')) const DataCard = asyncComponent(() => import('@/tabviews/custom/components/card/data-card')) diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index ddb6a74..3831a8f 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -17,6 +17,7 @@ const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const MainAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) const MainTable = asyncComponent(() => import('@/tabviews/custom/components/share/normalTable')) +const NormalHeader = asyncComponent(() => import('@/tabviews/custom/components/share/normalheader')) class NormalTable extends Component { static propTpyes = { @@ -471,6 +472,7 @@ return ( <div className="custom-normal-table"> + <NormalHeader config={config}/> {searchlist && searchlist.length ? <MainSearch BID={BID} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null } diff --git a/src/tabviews/custom/components/table/normal-table/index.scss b/src/tabviews/custom/components/table/normal-table/index.scss index 191a40e..2b5737c 100644 --- a/src/tabviews/custom/components/table/normal-table/index.scss +++ b/src/tabviews/custom/components/table/normal-table/index.scss @@ -1,8 +1,11 @@ .custom-normal-table { position: relative; + .normal-header { + margin-bottom: 10px; + } .top-search { - padding: 0; + border-bottom: 1px solid #efefef; } >.button-list.toolbar-button { padding: 0; diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index a295a88..728ec34 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -23,7 +23,7 @@ const DataCard = asyncComponent(() => import('./components/card/data-card')) const PropCard = asyncComponent(() => import('./components/card/prop-card')) const TableCard = asyncComponent(() => import('./components/card/table-card')) -const MainSearch = asyncComponent(() => import('./components/search/main-search')) +const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const NormalTable = asyncComponent(() => import('./components/table/normal-table')) class CustomPage extends Component { diff --git a/src/tabviews/subtable/index.scss b/src/tabviews/subtable/index.scss index 92ab7cf..76f5e85 100644 --- a/src/tabviews/subtable/index.scss +++ b/src/tabviews/subtable/index.scss @@ -2,8 +2,9 @@ position: relative; min-height: 200px; - > .top-search { - padding: 0 0px 10px; + >.top-search { + padding: 0px 0px 5px; + border-bottom: 1px solid #efefef; } .sub-action { min-height: 25px; diff --git a/src/tabviews/subtabtable/index.scss b/src/tabviews/subtabtable/index.scss index bf3cc04..85d52e8 100644 --- a/src/tabviews/subtabtable/index.scss +++ b/src/tabviews/subtabtable/index.scss @@ -2,8 +2,9 @@ position: relative; min-height: 200px; padding-top: 16px; - > .top-search { - padding: 0 0px 10px; + >.top-search { + padding: 0px 0px 5px; + border-bottom: 1px solid #efefef; } .box404 { padding-top: 30px; diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 5688593..0b311b0 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -749,10 +749,11 @@ pattern: /^[^']*$/ig, message: formRule.input.quotemsg }] + if (item.regular) { if (item.regular === 'number') { _rules = [{ - pattern: /^[0-9]*$/ig, + pattern: /^[0-9.]*$/ig, message: formRule.input.numbermsg }] } else if (item.regular === 'letter') { @@ -772,6 +773,7 @@ }] } } + fields.push( <Col span={_colspan} key={index}> <Form.Item label={item.tooltip ? @@ -781,7 +783,7 @@ </Tooltip> : item.label }> {getFieldDecorator(item.field, { - initialValue: item.initval, + initialValue: item.initval + '', rules: [ { required: item.required === 'true', diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 161d170..6f1400d 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -12,28 +12,35 @@ import enUS from '@/locales/en-US/main.js' import './index.scss' -const {MonthPicker, WeekPicker, RangePicker} = DatePicker +const { MonthPicker, WeekPicker, RangePicker } = DatePicker class MainSearch extends Component { static propTpyes = { BID: PropTypes.any, // 鐖剁骇Id锛岀敤浜庢煡璇笅鎷夐�夋嫨椤� menuType: PropTypes.any, // 鑿滃崟鏉冮檺锛屾槸鍚︿负HS searchlist: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃 + config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅(鑷畾涔夐〉闈�) + refreshdata: PropTypes.func // 鍒锋柊鏁版嵁 } state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - match: null, // 鎼滅储鏉′欢鍖归厤瑙勫垯 - style: null, // 鎼滅储鏉′欢绫诲瀷 - label: null, // 鎻愮ず鏂囧瓧 - required: null, // 鏄惁蹇呭~ - searchlist: null, // 鎼滅储椤� - groups: null, // 缁勫悎鎼滅储椤� - formId: Utils.getuuid() // 鎼滅储琛ㄥ崟Id + formId: '', // 鎼滅储琛ㄥ崟Id + match: null, // 鎼滅储鏉′欢鍖归厤瑙勫垯 + style: null, // 鎼滅储鏉′欢绫诲瀷 + label: null, // 鎻愮ず鏂囧瓧 + required: null, // 鏄惁蹇呭~ + searchlist: null, // 鎼滅储椤� + groups: null, // 缁勫悎鎼滅储椤� + float: '', // 娴姩 + showButton: true, // 鏄惁鏄剧ず鎼滅储鎸夐挳 + searchStyle: null // 鎼滅储鏉′欢鏍峰紡 } UNSAFE_componentWillMount () { - let searchlist = fromJS(this.props.searchlist).toJS() + const { config, menuType, searchlist } = this.props + + let _searchlist = [] let match = {} let label = {} let style = {} @@ -43,8 +50,27 @@ let mainItems = [] // 浜戠鎴栧崟鐐规暟鎹� let localItems = [] // 鏈湴鏁版嵁 let deForms = [] // 娴嬭瘯绯荤粺锛屽崟涓姹� + let float = '' + let showButton = true + let searchStyle = null + let formId = Utils.getuuid() - searchlist.forEach(item => { + if (searchlist) { + _searchlist = fromJS(searchlist).toJS() + } else if (config) { + _searchlist = fromJS(config.search).toJS() + if (config.type === 'search' && config.subtype === 'mainsearch') { + float = config.wrap.float + showButton = config.wrap.float === 'left' && config.wrap.show === 'true' + searchStyle = config.style + } else { + formId = '' + showButton = false + float = 'right' + } + } + + _searchlist.forEach(item => { if (fieldMap.has(item.field)) { item.field = item.field + '@tail@' } @@ -76,7 +102,7 @@ } // 娴嬭瘯绯荤粺鍗曚釜璇锋眰 - if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { + if (menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { deForms.push({ ...item, arr_field: _option.field, @@ -124,14 +150,18 @@ }) this.setState({ - match: match, - label: label, - style: style, - required: required, + match, + label, + style, + float, + formId, + required, + showButton, + searchStyle, searchlist: _list, groups: _groups }, () => { - if (this.props.menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { + if (menuType !== 'HS' && options.sysType === 'local' && !window.GLOB.systemType) { this.improveSimpleSearch(deForms) } else { this.improveSearch(mainItems, localItems) @@ -431,7 +461,7 @@ getFields() { const { getFieldDecorator } = this.props.form - const { dict } = this.state + const { dict, showButton, formId } = this.state const fields = [] this.state.searchlist.forEach((item, index) => { @@ -440,7 +470,7 @@ if (item.type === 'text') { // 鏂囨湰鎼滅储 fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -449,14 +479,14 @@ message: dict['form.required.input'] + item.label + '!' } ] - })(<Input placeholder="" autoComplete="off" />)} + })(<Input placeholder={item.labelShow === 'false' ? item.label : ''} autoComplete="off" onPressEnter={this.handleSearch} />)} </Form.Item> </Col> ) } else if (item.type === 'select') { // 涓嬫媺鎼滅储 fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -470,7 +500,7 @@ showSearch onChange={(value) => {this.selectChange(item, value)}} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById(this.state.formId)} + getPopupContainer={() => formId ? document.getElementById(formId) : document.body} > {item.options.map((option, i) => <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> @@ -484,7 +514,7 @@ let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(item.field, { initialValue: _initval, rules: [ @@ -499,7 +529,7 @@ mode="multiple" onChange={this.searchChange} filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById(this.state.formId)} + getPopupContainer={() => formId ? document.getElementById(formId) : document.body} > {item.options.map((option, i) => <Select.Option id={`${i}`} title={option.Text} key={`${i}`} value={option.Value}>{option.Text}</Select.Option> @@ -512,7 +542,7 @@ } else if (item.type === 'date') { // 鏃堕棿鎼滅储 fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(item.field, { initialValue: item.initval ? moment().subtract(item.initval, 'days') : null, rules: [ @@ -522,7 +552,7 @@ } ] })( - <DatePicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> + <DatePicker onChange={this.searchChange} getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> )} </Form.Item> </Col> @@ -530,7 +560,7 @@ } else if (item.type === 'datemonth') { fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(item.field, { initialValue: item.initval ? moment().subtract(item.initval, 'month') : null, rules: [ @@ -540,7 +570,7 @@ } ] })( - <MonthPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> + <MonthPicker onChange={this.searchChange} getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> )} </Form.Item> </Col> @@ -548,7 +578,7 @@ } else if (item.type === 'dateweek') { fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(item.field, { initialValue: item.initval ? moment().subtract(item.initval * 7, 'days') : null, rules: [ @@ -558,7 +588,7 @@ } ] })( - <WeekPicker onChange={this.searchChange} getCalendarContainer={() => document.getElementById(this.state.formId)} /> + <WeekPicker onChange={this.searchChange} getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> )} </Form.Item> </Col> @@ -577,7 +607,7 @@ fields.push( <Col className="daterange" span={item.ratio || 6} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''}> {getFieldDecorator(item.field, { initialValue: _defaultValue, @@ -592,7 +622,7 @@ placeholder={['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡']} renderExtraFooter={() => 'extra footer'} onChange={this.searchChange} - getCalendarContainer={() => document.getElementById(this.state.formId)} + getCalendarContainer={() => formId ? document.getElementById(formId) : document.body} /> )} </Form.Item> @@ -601,7 +631,7 @@ } else if (item.type === 'group') { fields.push( <Col span={item.ratio || 6} key={index}> - <Form.Item label={item.label} className={item.required === 'true' ? 'group-required' : ''}> + <Form.Item label={item.labelShow !== 'false' ? item.label : ''} className={item.required === 'true' ? 'group-required' : ''}> <DateGroup ref={item.uuid} position={index} card={item} onGroupChange={this.searchChange} /> </Form.Item> </Col> @@ -609,18 +639,20 @@ } }) - fields.push( - <Col span={6} style={{ whiteSpace: 'nowrap' }} key="actions"> - <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}> - <Button type="primary" htmlType="submit"> - {dict['main.search']} - </Button> - <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> - {dict['main.reset']} - </Button> - </Form.Item> - </Col> - ) + if (showButton) { + fields.push( + <Col span={6} style={{ whiteSpace: 'nowrap' }} key="actions"> + <Form.Item label={' '} colon={false} style={{ minHeight: '40px' }}> + <Button type="primary" onClick={this.handleSearch}> + {dict['main.search']} + </Button> + <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> + {dict['main.reset']} + </Button> + </Form.Item> + </Col> + ) + } return fields } @@ -768,6 +800,7 @@ } render() { + const { float, searchStyle } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -780,7 +813,7 @@ } return ( - <Form {...formItemLayout} className="top-search" id={this.state.formId} onSubmit={this.handleSearch}> + <Form {...formItemLayout} className={`top-search ${float}`} style={searchStyle} id={this.state.formId}> <Row gutter={24}>{this.getFields()}</Row> </Form> ) diff --git a/src/tabviews/zshare/topSearch/index.scss b/src/tabviews/zshare/topSearch/index.scss index b5087da..9388a99 100644 --- a/src/tabviews/zshare/topSearch/index.scss +++ b/src/tabviews/zshare/topSearch/index.scss @@ -1,6 +1,5 @@ .top-search { - padding: 0px 24px 10px; - border-bottom: 1px solid #efefef; + background: #ffffff; .ant-form-item { display: flex; margin-bottom: 0px; @@ -14,7 +13,6 @@ width: calc(100% - 100px); } .ant-form-item-label { - // width: 100px; text-overflow: ellipsis; } .daterange .ant-calendar-picker-input { @@ -38,4 +36,11 @@ content: '*'; } } +} +.top-search.right { + >.ant-row { + >.ant-col { + float: right; + } + } } \ No newline at end of file diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx index f42df42..812ed31 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx @@ -1,6 +1,6 @@ import React from 'react' import { useDrag, useDrop } from 'react-dnd' -import { Icon, Select, DatePicker, Input, Popover } from 'antd' +import { Icon, Select, DatePicker, Input, Popover, Form } from 'antd' import moment from 'moment' import DateGroup from '../dategroup' @@ -65,39 +65,39 @@ <Icon className="close" title="delete" type="close" onClick={() => delCard(id)} /> </div> } trigger="hover"> - <div className="page-card" style={{ opacity: opacity}}> + <div className={'page-card ' + (card.labelShow || '')} style={{ opacity: opacity}}> <div ref={node => drag(drop(node))}> - <div className="ant-row ant-form-item"> - <div className="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8"> - <label className={card.required === 'true' ? 'ant-form-item-required' : ''} title={card.label}>{card.label}</label> - </div> - <div className="ant-col ant-form-item-control-wrapper ant-col-xs-24 ant-col-sm-16"> - {card.type === 'text' ? - <Input style={{marginTop: '4px'}} value={card.initval} /> : 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 === 'dateweek' ? - <WeekPicker value={card.initval ? moment().subtract(card.initval * 7, 'days') : null} /> : null - } - {card.type === 'datemonth' ? - <MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null - } - {card.type === 'daterange' ? - <RangePicker - className="data-range" - placeholder={['BeginTime', 'EndTime']} - renderExtraFooter={() => 'extra footer'} - value={_defaultValue} - /> : null - } - {card.type === 'group' ? <DateGroup card={card} /> : null } - </div> - </div> + <Form.Item + labelCol={{xs: { span: 24 }, sm: { span: 8 }}} + wrapperCol = {{xs: { span: 24 }, sm: { span: 16 }}} + label={card.labelShow !== 'false' ? card.label : ''} + required={card.required === 'true'} + > + {card.type === 'text' ? + <Input style={{marginTop: '4px'}} value={card.initval} /> : 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 === 'dateweek' ? + <WeekPicker value={card.initval ? moment().subtract(card.initval * 7, 'days') : null} /> : null + } + {card.type === 'datemonth' ? + <MonthPicker value={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null + } + {card.type === 'daterange' ? + <RangePicker + className="data-range" + placeholder={['BeginTime', 'EndTime']} + renderExtraFooter={() => 'extra footer'} + value={_defaultValue} + /> : null + } + {card.type === 'group' ? <DateGroup card={card} /> : null } + </Form.Item> </div> </div> </Popover> diff --git a/src/templates/sharecomponent/searchcomponent/index.scss b/src/templates/sharecomponent/searchcomponent/index.scss index 0d857d2..fb53173 100644 --- a/src/templates/sharecomponent/searchcomponent/index.scss +++ b/src/templates/sharecomponent/searchcomponent/index.scss @@ -24,66 +24,43 @@ border-radius: 2px; padding-bottom: 15px; .ant-form-item { - cursor: move; - display: flex; margin-bottom: 0px; - .ant-form-item-label { - height: 40px; - label { - width: 100%; - cursor: move; - overflow: hidden; - display: inline-block; - text-overflow: ellipsis; - white-space: nowrap; - } - } .ant-form-item-control-wrapper { - flex: 1 1; .ant-select { width: 100%; margin-top: 4px; + .ant-select-selection { + height: 32px; + } } .ant-calendar-picker { 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: 2; - } } - .edit { + >div::after { + display: block; + content: ' '; position: absolute; + cursor: move; + top: 0; left: 0; - top: 5px; - color: #1890ff; - cursor: pointer; - display: none; - } - .edit.copy { - left: 20px; - color: #26C281; - } - .edit.close { - left: 40px; - color: #ff4d4f; + right: 0; + bottom: 0; + opacity: 0; + z-index: 2; } } - .page-card:hover { - .edit { - display: inline-block; + .page-card.false { + .ant-form-item-label { + display: none; + } + .ant-form-item-control-wrapper { + width: 100%; } } .ant-calendar-picker { diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx index a1eccb1..51937ed 100644 --- a/src/templates/zshare/editcomponent/index.jsx +++ b/src/templates/zshare/editcomponent/index.jsx @@ -6,7 +6,6 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import PasteForm from '@/templates/zshare/pasteform' -import ReplaceForm from '@/templates/zshare/replaceform' import TransferForm from '@/templates/zshare/basetransferform' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' @@ -26,7 +25,6 @@ thawVisible: false, thawbtnlist: null, pasteVisible: false, - replaceVisible: false } handleMenuClick = e => { @@ -34,8 +32,6 @@ this.handleThaw() } else if (e.key === 'paste') { this.setState({pasteVisible: true}) - } else if (e.key === 'replace') { - this.setState({replaceVisible: true}) } } @@ -278,18 +274,6 @@ }) } - replaceSubmit = () => { - this.replaceFormRef.handleConfirm().then(res => { - this.props.refresh({ - type: 'replace', - ...res - }) - this.setState({ - replaceVisible: false - }) - }) - } - render() { const { MenuID } = this.props const { dict } = this.state @@ -297,7 +281,6 @@ <Menu onClick={this.handleMenuClick}> {MenuID ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null} <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> - {/* <Menu.Item key="replace"><Icon type="retweet" />鏇挎崲</Menu.Item> */} </Menu> ) @@ -332,22 +315,6 @@ <PasteForm dict={dict} wrappedComponentRef={(inst) => this.pasteFormRef = inst} - /> - </Modal> - {/* 鏇挎崲 */} - <Modal - title={'鏇挎崲'} - visible={this.state.replaceVisible} - width={600} - maskClosable={false} - onOk={this.replaceSubmit} - onCancel={() => {this.setState({replaceVisible: false})}} - destroyOnClose - > - <ReplaceForm - dict={dict} - inputSubmit={this.replaceSubmit} - wrappedComponentRef={(inst) => this.replaceFormRef = inst} /> </Modal> </div> diff --git a/src/templates/zshare/replaceform/index.jsx b/src/templates/zshare/replaceform/index.jsx deleted file mode 100644 index 0c0f745..0000000 --- a/src/templates/zshare/replaceform/index.jsx +++ /dev/null @@ -1,119 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio } from 'antd' -import './index.scss' - -class MainSearch extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - inputSubmit: PropTypes.func // 鎻愪氦 - } - - componentDidMount () { - try { - let _form = document.getElementById('origin') - if (_form && _form.select) { - _form.select() - } - } catch { - console.warn('Form focusing error锛�') - } - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - resolve(values) - } else { - reject(err) - } - }) - }) - } - - handleSubmit = (e) => { - e.preventDefault() - - let origin = this.props.form.getFieldValue('origin') - let value = this.props.form.getFieldValue('value') - - if (!origin) { - const input = document.getElementById('origin') - if (input) { - input.focus() - } - } else if (!value) { - const input = document.getElementById('value') - if (input) { - input.focus() - } - } else { - if (this.props.inputSubmit) { - this.props.inputSubmit() - } - } - } - - render() { - const { dict } = this.props - const { getFieldDecorator } = this.props.form - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 12 } - } - } - return ( - <Form {...formItemLayout} className="config-replace-form"> - <Row gutter={24}> - <Col span={24}> - <Form.Item label="绫诲瀷"> - {getFieldDecorator('repType', { - initialValue: 'field' - })( - <Radio.Group> - <Radio value="label">鍚嶇О</Radio> - <Radio value="field">瀛楁</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label="鍘熷��"> - {getFieldDecorator('origin', { - initialValue: '', - rules: [ - { - required: true, - message: dict['form.required.input'] + '鍘熷��!' - }, - ] - })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label="鐩爣鍊�"> - {getFieldDecorator('value', { - initialValue: '', - rules: [ - { - required: true, - message: dict['form.required.input'] + '鐩爣鍊�!' - }, - ] - })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/templates/zshare/replaceform/index.scss b/src/templates/zshare/replaceform/index.scss deleted file mode 100644 index 04aede0..0000000 --- a/src/templates/zshare/replaceform/index.scss +++ /dev/null @@ -1,3 +0,0 @@ -.config-replace-form { - min-height: 150px; -} \ No newline at end of file diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index 464f851..727768a 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -260,12 +260,8 @@ Api.getTouristMsg().then(result => { if (result.status) { - if (!sessionStorage.getItem('UserID') && result.UserID) { - sessionStorage.setItem('UserID', result.UserID) - } - if (!sessionStorage.getItem('LoginUID') && result.LoginUID) { - sessionStorage.setItem('LoginUID', result.LoginUID) - } + result.UserID && sessionStorage.setItem('UserID', result.UserID) + result.LoginUID && sessionStorage.setItem('LoginUID', result.LoginUID) if (result.UserID && result.LoginUID) { this.setState({touristLogin: true}) -- Gitblit v1.8.0