| | |
| | | </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 ( |
| | |
| | | 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' |
| | |
| | | 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; |
| | |
| | | title: '对比方式', |
| | | dataIndex: 'match', |
| | | width: '18%', |
| | | render: text => { |
| | | return text === 'regexp' ? '正则表达式' : text |
| | | } |
| | | }, |
| | | { |
| | | title: '对比值', |
| | |
| | | <Select.Option value="!="> != </Select.Option> |
| | | <Select.Option value=">"> > </Select.Option> |
| | | <Select.Option value="<"> < </Select.Option> |
| | | <Select.Option value="regexp"> 正则表达式 </Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | |
| | | } |
| | | |
| | | let formItem = null |
| | | let type = '' |
| | | if (card.type === 'text') { |
| | | if (card.inputType !== 'search') { |
| | | formItem = <Input placeholder={card.label} value={card.initval} /> |
| | |
| | | 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 |
| | |
| | | <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 + '%'}}} |
| | |
| | | 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' |
| | |
| | | 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; |
| | |
| | | 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' |
| | |
| | | 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) => { |
| | |
| | | { 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' }, |
| | | ] |
| | | }, |
| | | { |
| | |
| | | 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 |
| | |
| | | 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); |
| | |
| | | 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 |
| | |
| | | position: relative; |
| | | // z-index: 1; |
| | | } |
| | | .ant-table-placeholder { |
| | | border-top-color: var(--mk-table-border-color); |
| | | } |
| | | .ant-table { |
| | | color: inherit; |
| | | font-size: inherit; |
| | |
| | | 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 = { |
| | |
| | | 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) { |
| | |
| | | this.props.form.validateFields((err, values) => { |
| | | if (err) return |
| | | |
| | | this.props.advanceSubmit(values) |
| | | setTimeout(() => { |
| | | this.props.advanceSubmit(values) |
| | | }, 10) |
| | | }) |
| | | } |
| | | |
| | |
| | | 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 = { |
| | |
| | | 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) { |
| | |
| | | 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 = '' |
| | | } |
| | | |
New file |
| | |
| | | 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 |
New file |
| | |
| | | .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; |
| | | } |
| | | } |
| | | } |
| | |
| | | }, |
| | | { |
| | | type: 'search', |
| | | label: '数值(区间)', |
| | | subType: 'range', |
| | | url: '' |
| | | }, |
| | | { |
| | | type: 'search', |
| | | label: '日期(组合)', |
| | | subType: 'group', |
| | | url: '' |
| | |
| | | |
| | | 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' |
| | | |
| | |
| | | } |
| | | |
| | | 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) |
| | | }) |
| | | } |
| | | } |
| | | |
| | |
| | | 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(', ') |
| | | }) |
| | | } |
| | | |
| | |
| | | </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 |
| | |
| | | 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' |
| | |
| | | } |
| | | } |
| | | } |
| | | .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; |
| | |
| | | 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 { |
| | |
| | | |
| | | 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, |
| | |
| | | _val = '' |
| | | } |
| | | |
| | | if (item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') { |
| | | if (['datemonth', 'dateweek', 'daterange', 'range'].includes(item.type)) { |
| | | fields = [item.field, item.field] |
| | | } |
| | | |
| | |
| | | _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 + '@') |
| | | } |
| | |
| | | |
| | | 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' |
| | |
| | | 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() |
| | | }) |
| | | } |
| | |
| | | value: 'group', |
| | | text: '日期(组合)' |
| | | }, { |
| | | value: 'range', |
| | | text: '数值(区间)' |
| | | }, { |
| | | value: 'switch', |
| | | text: '开关' |
| | | }, { |
| | |
| | | forbid: item.query === 'false' |
| | | }) |
| | | } else { |
| | | let value = item.initval |
| | | let value = '0' |
| | | let type = item.type |
| | | |
| | | if (item.type === 'date') { |
| | |
| | | } 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, |
| | |
| | | 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 + '\')') |
| | |
| | | }) |
| | | } |
| | | |
| | | } 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'), |
| | |
| | | }, { |
| | | 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 === '=') { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @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 重置移动端style |
| | | * @return {Object} style |
| | | */ |
| | |
| | | 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 = '' |
| | |
| | | } 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 + '\')') |
| | | } |
| | |
| | | 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' |
| | |
| | | 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: [ |