From 1e4a7720c748bc0206b02b30f4a2e0b3dafb54f3 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 19 二月 2024 13:31:13 +0800 Subject: [PATCH] 2024-02-19 --- src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx | 51 ---- src/tabviews/zshare/topSearch/index.jsx | 5 src/menu/datasource/verifycard/customscript/index.jsx | 45 ---- src/utils/utils-custom.js | 71 +++++++ src/tabviews/custom/components/share/normalTable/index.scss | 4 src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx | 8 src/menu/components/share/searchcomponent/dragsearch/card.jsx | 11 + src/views/tabledesign/source.jsx | 20 ++ src/tabviews/custom/components/share/normalTable/index.jsx | 3 src/menu/components/share/colsControl/markform/index.jsx | 1 src/menu/components/search/main-search/index.scss | 16 + src/utils/utils.js | 18 + src/menu/components/search/main-search/dragsearch/index.jsx | 6 src/menu/components/share/searchcomponent/dragsearch/index.jsx | 6 src/menu/components/share/searchcomponent/index.scss | 16 + src/templates/zshare/formconfig.jsx | 3 src/templates/comtableconfig/source.jsx | 6 src/menu/components/search/main-search/dragsearch/card.jsx | 7 src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx | 6 src/menu/modulecell/index.jsx | 6 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 3 src/tabviews/custom/components/table/edit-table/normalTable/index.scss | 3 src/templates/zshare/createinterface/index.jsx | 7 src/tabviews/zshare/topSearch/mkNumber/index.jsx | 79 ++++++++ src/tabviews/zshare/topSearch/mkNumber/index.scss | 16 + src/templates/zshare/customscript/index.jsx | 26 -- src/tabviews/zshare/topSearch/advanceform/index.jsx | 7 src/templates/sharecomponent/searchcomponent/index.scss | 15 + src/menu/components/share/colsControl/index.jsx | 3 src/templates/sharecomponent/searchcomponent/searchform/index.jsx | 52 +++-- 30 files changed, 369 insertions(+), 151 deletions(-) diff --git a/src/menu/components/search/main-search/dragsearch/card.jsx b/src/menu/components/search/main-search/dragsearch/card.jsx index 1b4f6a0..e09f49c 100644 --- a/src/menu/components/search/main-search/dragsearch/card.jsx +++ b/src/menu/components/search/main-search/dragsearch/card.jsx @@ -123,6 +123,13 @@ </Radio.Group>) } else if (card.type === 'check') { formItem = <Checkbox style={{lineHeight: '36px'}} checked={card.initval === card.openVal}>{card.checkTip || ''}</Checkbox> + } else if (card.type === 'range') { + let vals = card.initval.split(',') + formItem = (<> + <Input style={{marginTop: '4px'}} value={vals[0] || ''} /> + 鑷� + <Input style={{marginTop: '4px'}} value={vals[1] || ''} /> + </>) } return ( diff --git a/src/menu/components/search/main-search/dragsearch/index.jsx b/src/menu/components/search/main-search/dragsearch/index.jsx index c290b29..5af808c 100644 --- a/src/menu/components/search/main-search/dragsearch/index.jsx +++ b/src/menu/components/search/main-search/dragsearch/index.jsx @@ -98,11 +98,11 @@ newcard.orderType = 'asc' let _match = 'like' - if (item.subType === 'select' || item.subType === 'link' || item.subType === 'checkcard') { + if (['select', 'link', 'checkcard'].includes(item.subType)) { _match = '=' - } else if (item.subType === 'date' || item.subType === 'datemonth') { + } else if (['date', 'datemonth'].includes(item.subType)) { _match = '>=' - } else if (item.subType === 'dateweek' || item.subType === 'daterange') { + } else if (['dateweek', 'daterange', 'range'].includes(item.subType)) { _match = 'between' } else if (item.subType === 'group') { _match = 'between' diff --git a/src/menu/components/search/main-search/index.scss b/src/menu/components/search/main-search/index.scss index 3411db9..0ad138c 100644 --- a/src/menu/components/search/main-search/index.scss +++ b/src/menu/components/search/main-search/index.scss @@ -89,6 +89,22 @@ color: orange; } } + .page-card.range { + .ant-form-item-control-wrapper { + .ant-form-item-control { + .ant-form-item-children { + display: flex; + line-height: 40px; + .ant-input:first-child { + margin-right: 5px; + } + .ant-input:last-child { + margin-left: 5px; + } + } + } + } + } .page-card.no-query { .ant-form-explain { color: #13c2c2; diff --git a/src/menu/components/share/colsControl/index.jsx b/src/menu/components/share/colsControl/index.jsx index ee34472..882c037 100644 --- a/src/menu/components/share/colsControl/index.jsx +++ b/src/menu/components/share/colsControl/index.jsx @@ -35,6 +35,9 @@ title: '瀵规瘮鏂瑰紡', dataIndex: 'match', width: '18%', + render: text => { + return text === 'regexp' ? '姝e垯琛ㄨ揪寮�' : text + } }, { title: '瀵规瘮鍊�', diff --git a/src/menu/components/share/colsControl/markform/index.jsx b/src/menu/components/share/colsControl/markform/index.jsx index 7a29c8d..b727a79 100644 --- a/src/menu/components/share/colsControl/markform/index.jsx +++ b/src/menu/components/share/colsControl/markform/index.jsx @@ -96,6 +96,7 @@ <Select.Option value="!="> != </Select.Option> <Select.Option value=">"> > </Select.Option> <Select.Option value="<"> < </Select.Option> + <Select.Option value="regexp"> 姝e垯琛ㄨ揪寮� </Select.Option> </Select> )} </Form.Item> diff --git a/src/menu/components/share/searchcomponent/dragsearch/card.jsx b/src/menu/components/share/searchcomponent/dragsearch/card.jsx index 07df0ae..6061187 100644 --- a/src/menu/components/share/searchcomponent/dragsearch/card.jsx +++ b/src/menu/components/share/searchcomponent/dragsearch/card.jsx @@ -67,6 +67,7 @@ } let formItem = null + let type = '' if (card.type === 'text') { if (card.inputType !== 'search') { formItem = <Input placeholder={card.label} value={card.initval} /> @@ -113,6 +114,14 @@ formItem = (<Switch checkedChildren={card.openText || ''} unCheckedChildren={card.closeText || ''} style={{marginTop: '8px'}} checked={card.initval === card.openVal}/>) } else if (card.type === 'check') { formItem = <Checkbox style={{lineHeight: '36px'}} checked={card.initval === card.openVal}>{card.checkTip || ''}</Checkbox> + } else if (card.type === 'range') { + type = 'range-wrap' + let vals = card.initval.split(',') + formItem = (<> + <Input style={{marginTop: '4px'}} value={vals[0] || ''} /> + 鑷� + <Input style={{marginTop: '4px'}} value={vals[1] || ''} /> + </>) } let labelwidth = card.labelwidth || 33.3 @@ -128,7 +137,7 @@ <CloseOutlined className="close" title="鍒犻櫎" onClick={() => delCard(id)} /> </div> } trigger="hover"> - <div className={'page-card ' + (card.labelShow || '')} style={{ opacity: opacity}}> + <div className={`page-card ${type} ${card.labelShow || ''}`} style={{ opacity: opacity}}> <div ref={node => drag(drop(node))}> <Form.Item labelCol={{style: {width: labelwidth + '%'}}} diff --git a/src/menu/components/share/searchcomponent/dragsearch/index.jsx b/src/menu/components/share/searchcomponent/dragsearch/index.jsx index 8a063a7..87b345e 100644 --- a/src/menu/components/share/searchcomponent/dragsearch/index.jsx +++ b/src/menu/components/share/searchcomponent/dragsearch/index.jsx @@ -98,11 +98,11 @@ newcard.orderType = 'asc' let _match = 'like' - if (item.subType === 'select' || item.subType === 'link' || item.subType === 'checkcard') { + if (['select', 'link', 'checkcard'].includes(item.subType)) { _match = '=' - } else if (item.subType === 'date' || item.subType === 'datemonth') { + } else if (['date', 'datemonth'].includes(item.subType)) { _match = '>=' - } else if (item.subType === 'dateweek' || item.subType === 'daterange') { + } else if (['dateweek', 'daterange', 'range'].includes(item.subType)) { _match = 'between' } else if (item.subType === 'group') { _match = 'between' diff --git a/src/menu/components/share/searchcomponent/index.scss b/src/menu/components/share/searchcomponent/index.scss index fccf1bf..fd5bdac 100644 --- a/src/menu/components/share/searchcomponent/index.scss +++ b/src/menu/components/share/searchcomponent/index.scss @@ -56,6 +56,22 @@ float: left; } } + .page-card.range-wrap { + .ant-form-item-control-wrapper { + .ant-form-item-control { + .ant-form-item-children { + display: flex; + line-height: 40px; + .ant-input:first-child { + margin-right: 5px; + } + .ant-input:last-child { + margin-left: 5px; + } + } + } + } + } .page-card.false { .ant-form-item-label { display: none; diff --git a/src/menu/datasource/verifycard/customscript/index.jsx b/src/menu/datasource/verifycard/customscript/index.jsx index a9c6aef..b7ae1f7 100644 --- a/src/menu/datasource/verifycard/customscript/index.jsx +++ b/src/menu/datasource/verifycard/customscript/index.jsx @@ -6,7 +6,7 @@ import Toast from 'antd-mobile/es/components/toast' import Dialog from 'antd-mobile/es/components/dialog' -import { checkSQL } from '@/utils/utils-custom.js' +import { checkSQL, getSearchFields } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import MKEmitter from '@/utils/events.js' import './index.scss' @@ -33,48 +33,17 @@ UNSAFE_componentWillMount() { const { searches } = this.props - this.getSearchField(searches) + this.setState({ + usefulfields: getSearchFields(searches) + }) } UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.props.searches), fromJS(nextProps.searches))) { - this.getSearchField(nextProps.searches) + this.setState({ + usefulfields: getSearchFields(nextProps.searches) + }) } - } - - getSearchField = (searches) => { - let _usefulFields = [] - searches.forEach(item => { - if (item.type === 'dateweek') { - _usefulFields.push(item.key) - _usefulFields.push(item.key + '1') - } else if (item.type === 'datemonth') { - if (item.match === '=') { - _usefulFields.push(item.key) - } else { - _usefulFields.push(item.key) - _usefulFields.push(item.key + '1') - } - } else if (item.type === 'daterange') { - let _skey = item.key - let _ekey = item.key + '1' - - if (/,/.test(item.key)) { - _skey = item.key.split(',')[0] - _ekey = item.key.split(',')[1] - } - _usefulFields.push(_skey) - _usefulFields.push(_ekey) - } else if (item.type === 'date' && _usefulFields.includes(item.key)) { - _usefulFields.push(item.key + '1') - } else { - _usefulFields.push(item.key) - } - }) - - this.setState({ - usefulFields: _usefulFields.join(', ') - }) } edit = (record) => { diff --git a/src/menu/modulecell/index.jsx b/src/menu/modulecell/index.jsx index 66e9f76..4bc5e54 100644 --- a/src/menu/modulecell/index.jsx +++ b/src/menu/modulecell/index.jsx @@ -85,7 +85,11 @@ { subType: 'dateweek', text: '鏃ユ湡锛堝懆锛�', type: 'search' }, { subType: 'datemonth', text: '鏃ユ湡锛堟湀锛�', type: 'search' }, { subType: 'daterange', text: '鏃ユ湡锛堝尯闂达級', type: 'search' }, - { subType: 'group', text: '鏃ユ湡锛堢粍鍚堬級', type: 'search' } + { subType: 'group', text: '鏃ユ湡锛堢粍鍚堬級', type: 'search' }, + { subType: 'range', text: '鏁板�硷紙鍖洪棿锛�', type: 'search' }, + { subType: 'switch', text: '寮�鍏�', type: 'search' }, + { subType: 'radio', text: '鍗曢�夋', type: 'search' }, + { subType: 'check', text: '鍕鹃�夋', type: 'search' }, ] }, { diff --git a/src/tabviews/custom/components/share/normalTable/index.jsx b/src/tabviews/custom/components/share/normalTable/index.jsx index 5f6859a..2b00baa 100644 --- a/src/tabviews/custom/components/share/normalTable/index.jsx +++ b/src/tabviews/custom/components/share/normalTable/index.jsx @@ -651,6 +651,9 @@ result = originVal === contrastVal } else if (item.match === '!=') { result = originVal !== contrastVal + } else if (item.match === 'regexp') { + let reg = new RegExp(item.contrastValue, 'ig') + result = reg.test(originVal) } else { originVal = isNaN(originVal) ? originVal : +originVal contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal diff --git a/src/tabviews/custom/components/share/normalTable/index.scss b/src/tabviews/custom/components/share/normalTable/index.scss index 1a1123c..41dce81 100644 --- a/src/tabviews/custom/components/share/normalTable/index.scss +++ b/src/tabviews/custom/components/share/normalTable/index.scss @@ -13,7 +13,9 @@ top: -22px; z-index: 2; } - + .ant-table-placeholder { + border-top-color: var(--mk-table-border-color); + } .normal-table-footer { padding: 10px 0px; color: rgba(0, 0, 0, 0.65); diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 0272b1c..ee270d7 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -1700,6 +1700,9 @@ result = originVal === contrastVal } else if (item.match === '!=') { result = originVal !== contrastVal + } else if (item.match === 'regexp') { + let reg = new RegExp(item.contrastValue, 'ig') + result = reg.test(originVal) } else { originVal = isNaN(originVal) ? originVal : +originVal contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss index 59af907..1f2fb54 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss @@ -11,6 +11,9 @@ position: relative; // z-index: 1; } + .ant-table-placeholder { + border-top-color: var(--mk-table-border-color); + } .ant-table { color: inherit; font-size: inherit; diff --git a/src/tabviews/zshare/topSearch/advanceform/index.jsx b/src/tabviews/zshare/topSearch/advanceform/index.jsx index cb8a239..d35bba4 100644 --- a/src/tabviews/zshare/topSearch/advanceform/index.jsx +++ b/src/tabviews/zshare/topSearch/advanceform/index.jsx @@ -12,6 +12,7 @@ const MKSwitch = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkSwitch')) const MKRadio = asyncComponent(() => import('../mkRadio')) const MKDatePicker = asyncComponent(() => import('../mkDatePicker')) +const MKNumber = asyncComponent(() => import('../mkNumber')) class AdvanceSearch extends Component { static propTpyes = { @@ -57,6 +58,8 @@ content = <MKCheck config={item}/> } else if (item.type === 'switch') { content = <MKSwitch config={item}/> + } else if (item.type === 'range') { + content = <MKNumber config={item} onInputSubmit={this.handleSubmit} /> } if (content) { @@ -86,7 +89,9 @@ this.props.form.validateFields((err, values) => { if (err) return - this.props.advanceSubmit(values) + setTimeout(() => { + this.props.advanceSubmit(values) + }, 10) }) } diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 7fad33b..4e6d329 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -22,6 +22,7 @@ const MKSelect = asyncComponent(() => import('./mkSelect')) const DateGroup = asyncComponent(() => import('./dategroup')) const MKDatePicker = asyncComponent(() => import('./mkDatePicker')) +const MKNumber = asyncComponent(() => import('./mkNumber')) class MainSearch extends Component { static propTpyes = { @@ -712,6 +713,8 @@ content = <MKCheck config={item} onChange={(val) => this.recordChange(val, false, item)} /> } else if (item.type === 'switch') { content = <MKSwitch config={item} onChange={(val) => this.recordChange(val, false, item)} /> + } else if (item.type === 'range') { + content = <MKNumber config={item} onInputSubmit={this.handleSubmit} /> } if (content) { @@ -885,7 +888,7 @@ let searchlist = this.state.searchlist.map(item => { item.initval = item.oriInitval - if (setting.resetContrl === 'clear' && ['text', 'date', 'datemonth', 'dateweek', 'daterange'].includes(item.type)) { + if (setting.resetContrl === 'clear' && ['text', 'date', 'datemonth', 'dateweek', 'daterange', 'range'].includes(item.type)) { item.initval = '' } diff --git a/src/tabviews/zshare/topSearch/mkNumber/index.jsx b/src/tabviews/zshare/topSearch/mkNumber/index.jsx new file mode 100644 index 0000000..59720ab --- /dev/null +++ b/src/tabviews/zshare/topSearch/mkNumber/index.jsx @@ -0,0 +1,79 @@ +import React, {Component} from 'react' +import { is, fromJS } from 'immutable' +import { InputNumber } from 'antd' + +import './index.scss' + +class MKNumber extends Component { + constructor(props) { + super(props) + + const config = props.config + let vals = config.initval.split(',') + + this.state = { + minValue: vals[0] !== undefined && vals[0] !== '' ? +vals[0] : '', + maxValue: vals[1] !== undefined && vals[1] !== '' ? +vals[1] : '' + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + componentWillUnmount () { + this.setState = () => { + return + } + } + + minChange = (val) => { + this.setState({minValue: val}, () => { + this.onChange() + }) + } + + maxChange = (val) => { + this.setState({maxValue: val}, () => { + this.onChange() + }) + } + + onChange = () => { + const { minValue, maxValue } = this.state + + let vals = [] + if ((!minValue && minValue !== 0) || isNaN(minValue)) { + vals.push('') + } else { + vals.push(minValue) + } + if ((!maxValue && maxValue !== 0) || isNaN(maxValue)) { + vals.push('') + } else { + vals.push(maxValue) + } + + vals = vals.join(',') + + if (vals === ',') { + vals = '' + } + + this.props.onChange(vals) + } + + render() { + const { minValue, maxValue } = this.state + + return ( + <div className="range-wrap"> + <InputNumber defaultValue={minValue} onPressEnter={this.props.onInputSubmit} onChange={this.minChange}/> + 鑷� + <InputNumber defaultValue={maxValue} onPressEnter={this.props.onInputSubmit} onChange={this.maxChange}/> + </div> + ) + } +} + +export default MKNumber \ No newline at end of file diff --git a/src/tabviews/zshare/topSearch/mkNumber/index.scss b/src/tabviews/zshare/topSearch/mkNumber/index.scss new file mode 100644 index 0000000..fac24f9 --- /dev/null +++ b/src/tabviews/zshare/topSearch/mkNumber/index.scss @@ -0,0 +1,16 @@ +.range-wrap { + display: flex; + line-height: 32px; + .ant-input-number:first-child { + margin-right: 5px; + .ant-input-number-handler-wrap { + display: none; + } + } + .ant-input-number:last-child { + margin-left: 5px; + .ant-input-number-handler-wrap { + display: none; + } + } +} \ No newline at end of file diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index f21ac4b..ff23352 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -245,6 +245,12 @@ }, { type: 'search', + label: '鏁板�硷紙鍖洪棿锛�', + subType: 'range', + url: '' + }, + { + type: 'search', label: '鏃ユ湡锛堢粍鍚堬級', subType: 'group', url: '' diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx index 7acae2d..444e507 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx @@ -7,7 +7,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' -import { checkSQL } from '@/utils/utils-custom.js' +import { checkSQL, getSearchFields } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' // import './index.scss' @@ -27,12 +27,16 @@ } UNSAFE_componentWillMount () { - this.resetfield(this.props.searches) + this.setState({ + usefulfields: getSearchFields(this.props.searches) + }) } UNSAFE_componentWillReceiveProps(nextProps) { if (!is(fromJS(this.props.searches), fromJS(nextProps.searches))) { - this.resetfield(nextProps.searches) + this.setState({ + usefulfields: getSearchFields(nextProps.searches) + }) } } @@ -85,47 +89,6 @@ duration: 5 }) } - }) - } - - resetfield = (searches) => { - let _usefulFields = [] - searches.forEach(item => { - if (!item.field) return - - if (item.type === 'group') { - _usefulFields.push(item.field) - _usefulFields.push(item.datefield) - _usefulFields.push(item.datefield + '1') - } else if (item.type === 'dateweek') { - _usefulFields.push(item.field) - _usefulFields.push(item.field + '1') - } else if (item.type === 'datemonth') { - if (item.match === '=') { - _usefulFields.push(item.field) - } else { - _usefulFields.push(item.field) - _usefulFields.push(item.field + '1') - } - } else if (item.type === 'daterange') { - let _skey = item.field - let _ekey = item.field + '1' - - if (/,/.test(item.field)) { - _skey = item.field.split(',')[0] - _ekey = item.field.split(',')[1] - } - _usefulFields.push(_skey) - _usefulFields.push(_ekey) - } else if (item.type === 'date' && _usefulFields.includes(item.field)) { - _usefulFields.push(item.field + '1') - } else { - _usefulFields.push(item.field) - } - }) - - this.setState({ - usefulfields: _usefulFields.join(', ') }) } diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx index 56ea667..db83147 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/card.jsx @@ -125,6 +125,14 @@ </Radio.Group>) } else if (card.type === 'check') { formItem = <Checkbox style={{lineHeight: '36px'}} checked={card.initval === card.openVal}>{card.checkTip || ''}</Checkbox> + } else if (card.type === 'range') { + type = 'range-wrap' + let vals = card.initval.split(',') + formItem = (<> + <Input style={{marginTop: '4px'}} value={vals[0] || ''} /> + 鑷� + <Input style={{marginTop: '4px'}} value={vals[1] || ''} /> + </>) } let labelwidth = card.labelwidth || 33.3 diff --git a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx index fdd7f52..277f247 100644 --- a/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx @@ -101,11 +101,11 @@ newcard.orderType = 'asc' let _match = 'like' - if (item.subType === 'select' || item.subType === 'link' || item.subType === 'checkcard') { + if (['select', 'link', 'checkcard'].includes(item.subType)) { _match = '=' - } else if (item.subType === 'date' || item.subType === 'datemonth') { + } else if (['date', 'datemonth'].includes(item.subType)) { _match = '>=' - } else if (item.subType === 'dateweek' || item.subType === 'daterange') { + } else if (['dateweek', 'daterange', 'range'].includes(item.subType)) { _match = 'between' } else if (item.subType === 'group') { _match = 'between' diff --git a/src/templates/sharecomponent/searchcomponent/index.scss b/src/templates/sharecomponent/searchcomponent/index.scss index 52dda6d..f568c19 100644 --- a/src/templates/sharecomponent/searchcomponent/index.scss +++ b/src/templates/sharecomponent/searchcomponent/index.scss @@ -99,6 +99,21 @@ } } } + .page-card.range-wrap { + .ant-form-item-control-wrapper { + .ant-form-item-control { + .ant-form-item-children { + display: flex; + .ant-input:first-child { + margin-right: 5px; + } + .ant-input:last-child { + margin-left: 5px; + } + } + } + } + } .page-card.advanced { .ant-form-item-label label { color: orange; diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index 898ff9a..52ac1b9 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -110,7 +110,7 @@ group: ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'labelShow', 'query', 'labelwidth'], switch: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'openVal', 'closeVal', 'openText', 'closeText', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'], check: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'openVal', 'closeVal', 'checkTip', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'], - range: ['label', 'type', 'field', 'initval', 'match', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow', 'query', 'labelwidth'] + range: ['label', 'type', 'field', 'initval', 'match', 'ratio', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow', 'query', 'labelwidth', 'advanced'] } class MainSearch extends Component { @@ -831,35 +831,45 @@ if (values.type === 'range') { let error = '' - if (values.maxValue <= values.minValue) { - error = '鏈�澶у�煎繀椤诲ぇ浜庢渶灏忓��' - } else if (values.step <= 0) { - error = '姝ラ暱蹇呴』澶т簬0' - } else { - let s = (values.maxValue - values.minValue) / values.step - if (s !== parseInt(s)) { - error = '姝ラ暱蹇呴』琚� (max - min) 鏁撮櫎' + if (sessionStorage.getItem('appType') === 'mob') { + if (values.maxValue <= values.minValue) { + error = '鏈�澶у�煎繀椤诲ぇ浜庢渶灏忓��' + } else if (values.step <= 0) { + error = '姝ラ暱蹇呴』澶т簬0' + } else { + let s = (values.maxValue - values.minValue) / values.step + if (s !== parseInt(s)) { + error = '姝ラ暱蹇呴』琚� (max - min) 鏁撮櫎' + } } - } - if (!error && values.initval) { + if (!error && values.initval) { + let vals = values.initval.split(',') + if (vals.length !== 2) { + error = '鍒濆鍊艰缃敊璇紒' + } else if (isNaN(parseFloat(vals[0])) || isNaN(parseFloat(vals[1]))) { + error = '鍒濆鍊艰缃敊璇紒' + } else { + let start = parseFloat(vals[0]) + let end = parseFloat(vals[1]) + let s = (values.maxValue - start) / values.step + let e = (values.maxValue - end) / values.step + if (start > end || start < values.minValue || end > values.maxValue) { + error = '鍒濆鍊艰缃敊璇紒' + } else if (s !== parseInt(s) || e !== parseInt(e)) { + error = '鍒濆鍊艰缃敊璇紒' + } + } + } + } else if (values.initval) { let vals = values.initval.split(',') if (vals.length !== 2) { error = '鍒濆鍊艰缃敊璇紒' } else if (isNaN(parseFloat(vals[0])) || isNaN(parseFloat(vals[1]))) { error = '鍒濆鍊艰缃敊璇紒' - } else { - let start = parseFloat(vals[0]) - let end = parseFloat(vals[1]) - let s = (values.maxValue - start) / values.step - let e = (values.maxValue - end) / values.step - if (start > end || start < values.minValue || end > values.maxValue) { - error = '鍒濆鍊艰缃敊璇紒' - } else if (s !== parseInt(s) || e !== parseInt(e)) { - error = '鍒濆鍊艰缃敊璇紒' - } } } + if (error) { notification.warning({ top: 92, diff --git a/src/templates/zshare/createinterface/index.jsx b/src/templates/zshare/createinterface/index.jsx index b5d117a..b059099 100644 --- a/src/templates/zshare/createinterface/index.jsx +++ b/src/templates/zshare/createinterface/index.jsx @@ -55,7 +55,7 @@ _val = '' } - if (item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { + if (['datemonth', 'dateweek', 'daterange', 'range'].includes(item.type)) { fields = [item.field, item.field] } @@ -103,9 +103,12 @@ _fieldMap.set(item.field, true) searchText.push(item.field + ' ' + item.match + ' @' + _field + '@') - } else if (item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { + } else if (['datemonth', 'dateweek', 'daterange'].includes(item.type)) { searchText.push('(' + item.field + ' >= @' + item.field + '@ AND ' + item.field + ' < @' + item.field + '1@)') + } else if (item.type === 'range') { + + searchText.push('(' + item.field + ' >= @' + item.field + '@ AND ' + item.field + ' <= @' + item.field + '1@)') } else { searchText.push(item.field + ' ' + item.match + ' @' + item.field + '@') } diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx index 856acc8..50e6ad5 100644 --- a/src/templates/zshare/customscript/index.jsx +++ b/src/templates/zshare/customscript/index.jsx @@ -7,7 +7,7 @@ import Utils from '@/utils/utils.js' import Api from '@/api' -import { checkSQL } from '@/utils/utils-custom.js' +import { checkSQL, getSearchFields } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' @@ -93,31 +93,9 @@ UNSAFE_componentWillMount() { const { searches, scripts, urlFields } = this.props - let _usefulFields = [] - searches.forEach(item => { - if (['dateweek', 'datemonth'].includes(item.type)) { - _usefulFields.push(item.key) - _usefulFields.push(item.key + '1') - } else if (item.type === 'daterange') { - let _skey = item.key - let _ekey = item.key + '1' - - if (/,/.test(item.key)) { - _skey = item.key.split(',')[0] - _ekey = item.key.split(',')[1] - } - _usefulFields.push(_skey) - _usefulFields.push(_ekey) - } else if (item.type === 'date' && _usefulFields.includes(item.key)) { - _usefulFields.push(item.key + '1') - } else { - _usefulFields.push(item.key.replace(/,/ig, ', ')) - } - }) - this.setState({ urlFields: urlFields ? urlFields.join(', ') : '', - usefulFields: _usefulFields.join(', '), + usefulFields: getSearchFields(searches), scripts: fromJS(scripts).toJS() }) } diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 6f2c88b..6b339c9 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -74,6 +74,9 @@ value: 'group', text: '鏃ユ湡锛堢粍鍚堬級' }, { + value: 'range', + text: '鏁板�硷紙鍖洪棿锛�' + }, { value: 'switch', text: '寮�鍏�' }, { diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index b95c0eb..b426415 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -993,7 +993,7 @@ forbid: item.query === 'false' }) } else { - let value = item.initval + let value = '0' let type = item.type if (item.type === 'date') { @@ -1009,13 +1009,11 @@ } else if (item.type === 'daterange') { value = '1949-10-01 00:00:00.000,1949-10-02 00:00:00.000' } else if (item.type === 'range') { - value = `${item.minValue},${item.maxValue}` + value = item.initval || `${item.minValue || '-999999'},${item.maxValue || '999999'}` } else if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) { type = 'multi' - value = '0' - } else { - value = '0' } + newsearches.push({ key: item.field, match: item.match, @@ -1055,9 +1053,12 @@ searchText.push(`('${item.value}' ${item.match} '%'+${item.key}+'%')`) } else if (item.type === 'date') { searchText.push('(' + item.key + ' ' + item.match + ' \'' + item.value + '\')') - } else if (item.type === 'dateweek' || item.type === 'range') { + } else if (item.type === 'dateweek') { let val = item.value.split(',') searchText.push('(' + item.key + ' >= \'' + val[0] + '\' AND ' + item.key + ' < \'' + val[1] + '\')') + } else if (item.type === 'range') { + let val = item.value.split(',') + searchText.push('(' + item.key + ' >= ' + (val[0] || -999999) + ' AND ' + item.key + ' <= ' + (val[1] || 999999) + ')') } else if (item.type === 'datemonth') { if (item.match === '=') { searchText.push('(' + item.key + ' = \'' + item.value + '\')') @@ -1108,7 +1109,7 @@ }) } - } else if (['dateweek', 'range'].includes(item.type)) { + } else if (item.type === 'dateweek') { let val = item.value.split(',') options.push({ reg: new RegExp('@' + item.key + '@', 'ig'), @@ -1116,6 +1117,15 @@ }, { reg: new RegExp('@' + item.key + '1@', 'ig'), value: `'${val[1]}'` + }) + } else if (item.type === 'range') { + let val = item.value.split(',') + options.push({ + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `${val[0] || -999999}` + }, { + reg: new RegExp('@' + item.key + '1@', 'ig'), + value: `${val[1] || 999999}` }) } else if (item.type === 'datemonth') { if (item.match === '=') { @@ -1169,6 +1179,53 @@ } /** + * @description 鑾峰彇鎼滅储瀛楁 + */ +export function getSearchFields (searches) { + if (!searches) return '' + + let _usefulFields = [] + searches.forEach(item => { + if (!item.field) return + + if (item.type === 'group') { + _usefulFields.push(item.field) + _usefulFields.push(item.datefield) + _usefulFields.push(item.datefield + '1') + } else if (item.type === 'dateweek') { + _usefulFields.push(item.field) + _usefulFields.push(item.field + '1') + } else if (item.type === 'datemonth') { + if (item.match === '=') { + _usefulFields.push(item.field) + } else { + _usefulFields.push(item.field) + _usefulFields.push(item.field + '1') + } + } else if (item.type === 'range') { + _usefulFields.push(item.field) + _usefulFields.push(item.field + '1') + } else if (item.type === 'daterange') { + let _skey = item.field + let _ekey = item.field + '1' + + if (/,/.test(item.field)) { + _skey = item.field.split(',')[0] + _ekey = item.field.split(',')[1] + } + _usefulFields.push(_skey) + _usefulFields.push(_ekey) + } else if (item.type === 'date' && _usefulFields.includes(item.field)) { + _usefulFields.push(item.field + '1') + } else { + _usefulFields.push(item.field) + } + }) + + return _usefulFields.join(', ') +} + +/** * @description 閲嶇疆绉诲姩绔痵tyle * @return {Object} style */ diff --git a/src/utils/utils.js b/src/utils/utils.js index 54eec04..414255a 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -538,6 +538,11 @@ newsearches[item.key] = _startval newsearches[item.key + '1'] = _endval } + } else if (item.type === 'range') { + let val = item.value.split(',') + + newsearches[item.key] = val[0] || -999999 + newsearches[item.key + '1'] = val[1] || 999999 } else if (item.type === 'dateweek') { let _startval = '' let _endval = '' @@ -685,7 +690,7 @@ } else if (item.type === 'range') { let val = item.value.split(',') - searchText.push('(' + item.key + ' >= \'' + val[0] + '\' AND ' + item.key + ' < \'' + val[1] + '\')') + searchText.push('(' + item.key + ' >= ' + (val[0] || -999999) + ' AND ' + item.key + ' <= ' + (val[1] || 999999) + ')') } else { searchText.push('(' + item.key + ' ' + item.match + ' \'' + item.value + '\')') } @@ -756,6 +761,17 @@ options.push(item) options.push(copy) } + } else if (item.type === 'range') { + let val = item.value.split(',') + + let copy = JSON.parse(JSON.stringify(item)) + copy.key = copy.key + '1' + copy.value = val[1] || 999999 + + item.value = val[0] || -999999 + + options.push(item) + options.push(copy) } else if (item.type === 'dateweek') { let _startval = item.value ? moment(item.value, 'YYYY-MM-DD').startOf('week').format('YYYY-MM-DD') + ' 00:00:00.000' : '1970-01-01 00:00:00.000' let _endval = item.value ? moment(item.value, 'YYYY-MM-DD').endOf('week').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' : '2050-01-01 00:00:00.000' diff --git a/src/views/tabledesign/source.jsx b/src/views/tabledesign/source.jsx index 058c775..b324501 100644 --- a/src/views/tabledesign/source.jsx +++ b/src/views/tabledesign/source.jsx @@ -51,6 +51,26 @@ type: 'search', label: '鏃ユ湡锛堢粍鍚堬級', subType: 'group' + }, + { + type: 'search', + label: '鏁板�硷紙鍖洪棿锛�', + subType: 'range' + }, + { + type: 'search', + label: '寮�鍏�', + subType: 'switch' + }, + { + type: 'search', + label: '鍗曢�夋', + subType: 'radio' + }, + { + type: 'search', + label: '鍕鹃�夋', + subType: 'check' } ], actionItems: [ -- Gitblit v1.8.0