| | |
| | | import React, { Component } from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Modal, notification, Popover, Icon } from 'antd' |
| | | import { Modal, notification, Popover, Icon, Switch } from 'antd' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import { getSearchForm } from '@/templates/zshare/formconfig' |
| | | |
| | | import { resetStyle } from '@/utils/utils-custom.js' |
| | | import asyncIconComponent from '@/utils/asyncIconComponent' |
| | | import SearchForm from '@/templates/sharecomponent/searchcomponent/searchform' |
| | | import DragElement from './dragsearch' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | |
| | | const { confirm } = Modal |
| | | |
| | | const WrapComponent = asyncIconComponent(() => import('./wrapsetting')) |
| | | const SearchForm = asyncIconComponent(() => import('@/templates/sharecomponent/searchcomponent/searchform')) |
| | | const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) |
| | | const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) |
| | | |
| | |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | appType: sessionStorage.getItem('appType'), |
| | | searchlist: null, // 搜索条件集 |
| | | sqlVerifing: false, // sql验证中 |
| | | visible: false, // 模态框控制 |
| | | showField: false, |
| | | editcard: null // 编辑中元素 |
| | | } |
| | | |
| | |
| | | width: 24, |
| | | name: card.name, |
| | | subtype: card.subtype, |
| | | wrap: { name: card.name, width: 24, show: 'true', float: 'left' }, |
| | | wrap: { name: card.name, width: 24, show: this.state.appType === 'mob' ? 'false' : 'true', float: 'left' }, |
| | | style: { |
| | | marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' |
| | | }, |
| | |
| | | component.name = component.wrap.name |
| | | |
| | | this.props.updateConfig(component) |
| | | } |
| | | |
| | | checkComponent = (component) => { |
| | | this.updateComponent(component) |
| | | |
| | | let _item = null |
| | | component.search.forEach(item => { |
| | | if (!_item && item.focus) { |
| | | _item = item |
| | | } |
| | | }) |
| | | if (_item) { |
| | | this.handleSearch(_item) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | |
| | | if (['select', 'multiselect', 'link'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) { |
| | | if (['select', 'multiselect', 'link', 'checkcard'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) { |
| | | this.setState({ |
| | | sqlVerifing: true |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | onFieldChange = () => { |
| | | const { showField } = this.state |
| | | |
| | | this.setState({ |
| | | showField: !showField |
| | | }) |
| | | } |
| | | |
| | | clickComponent = (e) => { |
| | | if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { |
| | | e.stopPropagation() |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { dict, card, visible, sqlVerifing } = this.state |
| | | const { dict, card, visible, sqlVerifing, showField } = this.state |
| | | let _style = resetStyle(card.style) |
| | | |
| | | return ( |
| | | <div className={`main-search-edit-list ${card.wrap.float} ${card.wrap.show || ''}`} onClick={this.clickComponent} id={card.uuid} style={card.style}> |
| | | <div className={`main-search-edit-list ${card.wrap.float} ${card.wrap.show || ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}> |
| | | <Switch checkedChildren={dict['model.switch.open']} size="small" unCheckedChildren={dict['model.switch.close']} defaultChecked={showField} onChange={this.onFieldChange} /> |
| | | <DragElement |
| | | list={card.search} |
| | | showField={showField} |
| | | handleList={this.handleList} |
| | | handleMenu={this.handleSearch} |
| | | deleteMenu={this.deleteElement} |
| | |
| | | <Icon className="plus" title="添加" onClick={this.addSearch} type="plus" /> |
| | | <WrapComponent config={card} updateConfig={this.updateComponent}/> |
| | | <CopyComponent type="mainsearch" card={card}/> |
| | | <PasteComponent config={card} options={['search', 'form']} updateConfig={this.updateComponent} /> |
| | | <PasteComponent config={card} options={['search', 'form']} updateConfig={this.checkComponent} /> |
| | | <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors" /> |
| | | <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> |
| | | </div> |