| | |
| | | import { Form, Row, Col, Button, notification, Modal, Drawer } from 'antd' |
| | | import { CloseOutlined, DownOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | import md5 from 'md5' |
| | | |
| | | import Api from '@/api' |
| | | import options from '@/store/options.js' |
| | |
| | | |
| | | const MutilForm = asyncSpinComponent(() => import('./advanceform')) |
| | | const MKCheckCard = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheckCard')) |
| | | const MKCheck = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkCheck')) |
| | | const MKSwitch = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkSwitch')) |
| | | const MKSelect = asyncComponent(() => import('./mkSelect')) |
| | | const DateGroup = asyncComponent(() => import('./dategroup')) |
| | | const MKDatePicker = asyncComponent(() => import('./mkDatePicker')) |
| | |
| | | } |
| | | |
| | | record = {} |
| | | sign = '' |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config, searchlist, setting } = this.props |
| | |
| | | _setting.labelwidth = config.wrap.searchLwidth !== undefined ? config.wrap.searchLwidth : 33.3 |
| | | _setting.labelCol = {style: {width: _setting.labelwidth + '%'}} |
| | | _setting.wrapperCol = {style: {width: (100 - _setting.labelwidth) + '%'}} |
| | | _setting.borderRadius = config.wrap.borderRadius |
| | | } |
| | | _setting.style = null |
| | | |
| | | if (config.type === 'search') { |
| | | _setting.float = config.wrap.float || 'left' |
| | | _setting.style = config.style |
| | | } else if (config.type === 'table' && config.subtype !== 'tablecard') { |
| | | } else if (config.type === 'table') { |
| | | _setting.float = 'left' |
| | | } else { |
| | | _setting.float = 'right' |
| | |
| | | if (item.resourceType === '1' && item.dataSource) { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | console.info(_option.sql) |
| | | } |
| | | |
| | | // 测试系统单个请求 |
| | | if (!window.GLOB.mkHS && options.sysType === 'local' && !window.GLOB.systemType) { |
| | | deForms.push({ |
| | |
| | | }) |
| | | } 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`) |
| | | mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`) |
| | | } else { |
| | | localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql))}' as LText`) |
| | | localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`) |
| | | } |
| | | } |
| | | } |
| | |
| | | }, () => { |
| | | if (!window.GLOB.mkHS && options.sysType === 'local' && window.GLOB.systemType !== 'production') { |
| | | this.improveSimpleSearch(deForms) |
| | | } else { |
| | | } else if (mainItems.length > 0 || localItems.length > 0) { |
| | | this.improveSearch(mainItems, localItems) |
| | | } |
| | | }) |
| | |
| | | improveSearch = (mainItems, localItems) => { |
| | | const { BID } = this.props |
| | | let deffers = [] |
| | | |
| | | if (!window.GLOB.mkHS && options.sysType !== 'local') { |
| | | localItems = [...localItems, ...mainItems] |
| | | mainItems = [] |
| | | } |
| | | |
| | | // 本地请求 |
| | | let param = { |
| | |
| | | if (['select', 'link', 'multiselect', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) { |
| | | let options = [] |
| | | let map = new Map() |
| | | let all = false |
| | | result[item.field].forEach(cell => { |
| | | let _item = { |
| | | key: Utils.getuuid(), |
| | |
| | | _item.Value = cell[item.valueField] |
| | | _item.Text = cell[item.valueText] + '' |
| | | |
| | | if (!_item.Text || map.has(_item.ParentID + _item.Value)) return |
| | | if (map.has(_item.ParentID + _item.Value)) return |
| | | if (!_item.Text) { |
| | | if (!all) { |
| | | _item.Text = '全部' |
| | | all = true |
| | | } else { |
| | | return |
| | | } |
| | | } |
| | | |
| | | map.set(_item.ParentID + _item.Value, 0) |
| | | } else { |
| | | _item.$value = cell[item.cardValField] |
| | | _item = {..._item, ...cell} |
| | | |
| | | if (item.urlField) { |
| | | _item.$url = cell[item.urlField] || '' |
| | | } else if (item.colorField) { |
| | | _item.$color = cell[item.colorField] || '' |
| | | } |
| | | |
| | | if (map.has(_item.ParentID + _item.$value)) return |
| | | |
| | |
| | | content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} /> |
| | | } else if (item.type === 'checkcard') { |
| | | content = <MKCheckCard config={item} onChange={(val) => this.cardChange(val, item)} /> |
| | | } else if (item.type === 'check') { |
| | | 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)} /> |
| | | } |
| | | |
| | | if (content) { |
| | |
| | | }) |
| | | |
| | | if (setting.show || setting.showAdv) { |
| | | let style = {} |
| | | if (setting.borderRadius) { |
| | | style.borderRadius = setting.borderRadius |
| | | } |
| | | |
| | | fields.push( |
| | | <Col span={setting.ratio} style={{ whiteSpace: 'nowrap' }} className="mk-search-col search-button" key="actions"> |
| | | <Form.Item |
| | |
| | | labelCol={setting.labelCol} |
| | | wrapperCol={setting.wrapperCol} |
| | | > |
| | | {setting.show ? <Button type="primary" onClick={this.handleSubmit}> |
| | | {setting.show ? <Button style={style} type="primary" onClick={this.handleSubmit}> |
| | | 搜索 |
| | | </Button> : null} |
| | | {setting.show ? <Button style={{ marginLeft: 8 }} onClick={this.handleReset}> |
| | | {setting.show ? <Button style={{ marginLeft: 8, ...style }} onClick={this.handleReset}> |
| | | 重置 |
| | | </Button> : null} |
| | | {setting.showAdv ? <Button className={visible ? 'visible' : ''} type="link" onClick={this.handleAdvance}> |
| | |
| | | } |
| | | } |
| | | |
| | | let sign = md5(JSON.stringify(searches)) |
| | | |
| | | if (sign === this.sign) return |
| | | |
| | | this.sign = sign |
| | | setTimeout(() => { |
| | | this.sign = '' |
| | | }, 2000) |
| | | |
| | | this.props.refreshdata(searches) |
| | | }) |
| | | }) |
| | |
| | | |
| | | return ( |
| | | <> |
| | | <Form {...formItemLayout} className={`top-search mk-float-${setting.float}`} style={setting.style}> |
| | | <Form {...formItemLayout} className={`mk-search-wrap mk-float-${setting.float}`} style={setting.style}> |
| | | <Row gutter={24}>{this.getFields()}</Row> |
| | | {advanceValues.length && (setting.advanceType !== 'pulldown' || (setting.advanceType === 'pulldown' && !visible)) ? <Row gutter={24}> |
| | | <div className="advanced-list"> |