king
2022-05-12 b8aa5da1b2873bea760483cc5ab335fde9fb6de6
src/menu/components/search/main-search/index.jsx
@@ -1,7 +1,8 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Modal, notification, Popover, Icon, Switch } from 'antd'
import { Modal, notification, Popover, Switch } from 'antd'
import { PlusOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
import moment from 'moment'
import Api from '@/api'
@@ -10,6 +11,7 @@
import enUS from '@/locales/en-US/model.js'
import { getSearchForm } from '@/templates/zshare/formconfig'
import { resetStyle } from '@/utils/utils-custom.js'
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
import DragElement from './dragsearch'
import getWrapForm from './options'
@@ -19,7 +21,7 @@
const { confirm } = Modal
const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
const FieldsComponent = asyncIconComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
const SearchForm = asyncIconComponent(() => import('@/templates/sharecomponent/searchcomponent/searchform'))
const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent'))
@@ -51,7 +53,6 @@
      let _card = {
        uuid: card.uuid,
        type: card.type,
        floor: card.floor,
        tabId: card.tabId || '',
        parentId: card.parentId || '',
        width: 24,
@@ -76,6 +77,7 @@
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
    MKEmitter.addListener('plusSearch', this.plusSearch)
  }
  /**
@@ -86,6 +88,7 @@
      return
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
    MKEmitter.removeListener('plusSearch', this.plusSearch)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -165,12 +168,14 @@
    let linkableFields = []
    card.search.forEach(item => {
      if (item.uuid !== cell.uuid && (item.type === 'select' || item.type === 'link')) {
        linkableFields.push({
          value: item.field,
          text: item.label
        })
      }
      if (item.uuid === card.uuid) return
      if (!['select', 'link', 'checkcard'].includes(item.type)) return
      if (item.type === 'checkcard' && item.multiple === 'true') return
      linkableFields.push({
        value: item.field,
        text: item.label
      })
    })
    this.setState({
@@ -365,10 +370,28 @@
    })
  }
  updatefields = (config) => {
    this.setState({card: config}, ()=> {
      this.props.updateConfig(config)
    })
  plusSearch = (MenuId, item, type) => {
    const { card } = this.state
    if (MenuId !== card.uuid) return
    let _card = fromJS(card).toJS()
    if (type === 'simple') {
      _card.search.push(item)
      this.setState({
        card: _card,
      }, () => {
        this.props.updateConfig(_card)
      })
    } else if (type === 'multil') {
      _card.search.push(...item)
      this.setState({
        card: _card,
      }, () => {
        this.props.updateConfig(_card)
      })
    }
  }
  getWrapForms = () => {
@@ -394,7 +417,7 @@
    return (
      <div className={`main-search-edit-list ${card.wrap.float} ${card.wrap.show || ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}>
        <FieldsComponent config={card} type="search" updatefield={this.updatefields} />
        <FieldsComponent config={card} type="search" />
        <Switch checkedChildren={dict['model.switch.open']} size="small" unCheckedChildren={dict['model.switch.close']} defaultChecked={showField} onChange={this.onFieldChange} />
        <DragElement
          list={card.search}
@@ -402,22 +425,22 @@
          handleList={this.handleList}
          handleMenu={this.handleSearch}
          deleteMenu={this.deleteElement}
          placeholder={dict['header.form.search.placeholder']}
        />
        <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" />
            <PlusOutlined className="plus" title="添加" onClick={this.addSearch}/>
            <NormalForm title="搜索设置" width={800} update={this.updateWrap} getForms={this.getWrapForms}>
              <Icon type="edit" style={{color: '#1890ff'}} title="编辑"/>
              <EditOutlined style={{color: '#1890ff'}} title="编辑"/>
            </NormalForm>
            <CopyComponent type="mainsearch" card={card}/>
            <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)} />
            <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/>
            <DeleteOutlined className="close" onClick={() => this.props.deletecomponent(card.uuid)} />
          </div>
        } trigger="hover">
          <Icon type="tool" />
          <ToolOutlined />
        </Popover>
        <div className="component-name"><div className="center">{card.name}</div></div>
        {/* 编辑搜索条件 */}
        <Modal
          title="搜索条件-编辑"