From 137fb8ea6af2789b3238b22bac31d80bced41dfe Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 28 七月 2021 11:39:39 +0800 Subject: [PATCH] 2021-07-28 --- src/menu/components/search/main-search/index.jsx | 43 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx index 0ab9015..2de3892 100644 --- a/src/menu/components/search/main-search/index.jsx +++ b/src/menu/components/search/main-search/index.jsx @@ -1,7 +1,7 @@ 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' @@ -9,9 +9,8 @@ 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' @@ -19,6 +18,7 @@ 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')) @@ -31,9 +31,11 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + appType: sessionStorage.getItem('appType'), searchlist: null, // 鎼滅储鏉′欢闆� sqlVerifing: false, // sql楠岃瘉涓� visible: false, // 妯℃�佹鎺у埗 + showField: false, editcard: null // 缂栬緫涓厓绱� } @@ -53,7 +55,7 @@ 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' }, @@ -120,6 +122,20 @@ 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) + } } /** @@ -248,7 +264,7 @@ 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 }) @@ -339,6 +355,14 @@ }) } + onFieldChange = () => { + const { showField } = this.state + + this.setState({ + showField: !showField + }) + } + clickComponent = (e) => { if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { e.stopPropagation() @@ -347,12 +371,15 @@ } 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} @@ -363,7 +390,7 @@ <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> -- Gitblit v1.8.0