king
2021-05-08 6afdec0062dacbded57e166230eb22cc55ced0c1
src/menu/components/search/main-search/index.jsx
@@ -1,8 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
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'
@@ -10,7 +9,7 @@
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'
@@ -20,6 +19,8 @@
const { confirm } = Modal
const WrapComponent = asyncIconComponent(() => import('./wrapsetting'))
const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent'))
class MainSearchComponent extends Component {
  static propTpyes = {
@@ -29,10 +30,11 @@
  }
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    searchlist: null,    // 搜索条件集
    sqlVerifing: false,  // sql验证中
    visible: false,      // 模态框控制
    showField: false,
    editcard: null       // 编辑中元素
  }
@@ -52,7 +54,7 @@
        width: 24,
        name: card.name,
        subtype: card.subtype,
        wrap: { name: card.name, width: 24 },
        wrap: { name: card.name, width: 24, show: 'true', float: 'left' },
        style: {
          marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px'
        },
@@ -142,7 +144,6 @@
   * @description 搜索条件编辑,获取搜索条件表单信息
   */
  handleSearch = (cell) => {
    const { menu } = this.props
    const { card } = this.state
    let linkableFields = []
@@ -158,7 +159,7 @@
    this.setState({
      visible: true,
      editcard: cell,
      formlist: getSearchForm(cell, menu.sysRoles, linkableFields)
      formlist: getSearchForm(cell, linkableFields)
    })
  }
@@ -235,14 +236,14 @@
      if (fieldrepet) {
        notification.warning({
          top: 92,
          message: this.state.dict['model.field.exist'] + ' !',
          message: '字段已存在!',
          duration: 5
        })
        return
      } else if (labelrepet) {
        notification.warning({
          top: 92,
          message: this.state.dict['model.name.exist'] + ' !',
          message: '名称已存在!',
          duration: 5
        })
        return
@@ -255,6 +256,7 @@
        let param = {
          func: 's_debug_sql',
          exec_type: 'y',
          LText: res.dataSource
        }
@@ -262,7 +264,7 @@
        
        param.LText = Utils.formatOptions(param.LText)
        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
        param.secretkey = Utils.encrypt(param.LText, param.timestamp)
        param.secretkey = Utils.encrypt('', param.timestamp)
        if (window.GLOB.mainSystemApi && res.database === 'sso') {
          param.rduri = window.GLOB.mainSystemApi
@@ -338,14 +340,31 @@
    })
  }
  onFieldChange = () => {
    const { showField } = this.state
    this.setState({
      showField: !showField
    })
  }
  clickComponent = (e) => {
    if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
      e.stopPropagation()
      MKEmitter.emit('clickComponent', this.state.card)
    }
  }
  render() {
    const { menu } = this.props
    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" 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}
@@ -354,7 +373,9 @@
        <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <Icon className="plus" title="添加" onClick={this.addSearch} type="plus" />
            <WrapComponent config={card} sysRoles={menu ? menu.sysRoles : []} updateConfig={this.updateComponent}/>
            <WrapComponent config={card} updateConfig={this.updateComponent}/>
            <CopyComponent type="mainsearch" card={card}/>
            <PasteComponent config={card} options={['search', 'form']} updateConfig={this.updateComponent} />
            <Icon className="style" title="调整样式" onClick={this.changeStyle} type="font-colors" />
            <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} />
          </div>
@@ -363,7 +384,7 @@
        </Popover>
        {/* 编辑搜索条件 */}
        <Modal
          title={dict['model.searchCriteria'] + '-' + dict['model.edit']}
          title="搜索条件-编辑"
          visible={visible}
          width={850}
          maskClosable={false}
@@ -384,14 +405,5 @@
    )
  }
}
const mapStateToProps = (state) => {
  return {
    menu: state.customMenu
  }
}
const mapDispatchToProps = () => {
  return {}
}
export default connect(mapStateToProps, mapDispatchToProps)(MainSearchComponent)
export default MainSearchComponent