king
2024-06-03 27d6ff04382d95f360e4dc18769a9bd36dfca4b4
src/menu/components/search/main-search/index.jsx
@@ -1,9 +1,8 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Modal, notification, Popover, Switch } from 'antd'
import { Modal, notification, Popover, Switch, message } from 'antd'
import { PlusOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
import moment from 'moment'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -121,19 +120,19 @@
    this.props.updateConfig(component)
  }
  checkComponent = (component) => {
    this.updateComponent(component)
  // checkComponent = (component) => {
  //   this.updateComponent(component)
    let _item = null
    component.search.forEach(item => {
      if (!_item && item.focus) {
        _item = item
      }
    })
    if (_item) {
      this.handleSearch(_item)
    }
  }
  //   let _item = null
  //   component.search.forEach(item => {
  //     if (!_item && item.focus) {
  //       _item = item
  //     }
  //   })
  //   if (_item) {
  //     this.handleSearch(_item)
  //   }
  // }
  /**
   * @description 搜索条件顺序调整,或拖拽添加
@@ -256,25 +255,17 @@
          sqlVerifing: true
        })
        let param = {
          func: 's_debug_sql',
          exec_type: 'y',
          LText: res.dataSource
        }
        let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
        ${res.dataSource}`
        sql = sql.replace(/@\$|\$@/ig, '')
        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
        param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`)
        param.LText = param.LText.replace(/\n/g, ' ')
        param.LText = Utils.formatOptions(param.LText)
        param.secretkey = Utils.encrypt('', param.timestamp)
        let rduri = ''
        if (window.GLOB.mainSystemApi && res.database === 'sso') {
          param.rduri = window.GLOB.mainSystemApi
          rduri = window.GLOB.mainSystemApi
        }
        
        Api.genericInterface(param).then(result => {
          if (result.status) {
        Api.sDebug(sql, rduri).then(result => {
          if (result.status || result.ErrCode === '-2') {
            this.setState({
              sqlVerifing: false,
              visible: false
@@ -355,6 +346,7 @@
      _card.search.push(item)
      this.updateComponent(_card)
      this.handleSearch(item)
    } else if (type === 'multil') {
      _card.search.push(...item)
@@ -363,9 +355,9 @@
  }
  getWrapForms = () => {
    const { wrap, action } = this.state.card
    const { card } = this.state
    return getWrapForm(wrap, action)
    return getWrapForm(card.wrap, card.uuid)
  }
  updateWrap = (res) => {
@@ -389,7 +381,7 @@
    let _style = resetStyle(card.style)
    return (
      <div className={`main-search-edit-list ${card.wrap.float} ${showField ? 'show-field' : ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}>
      <div className={`main-search-edit-list ${card.wrap.float} ${showField ? 'show-field' : ''} mk-size-${card.wrap.searchSize || ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}>
        <FieldsComponent config={card} type="search" />
        <Switch checkedChildren="开" size="small" unCheckedChildren="关" defaultChecked={showField} onChange={this.onFieldChange} />
        <DragElement
@@ -406,17 +398,29 @@
              <EditOutlined style={{color: '#1890ff'}} title="编辑"/>
            </NormalForm>
            <CopyComponent type="mainsearch" card={card}/>
            <PasteComponent config={card} options={['search', 'form']} updateConfig={this.checkComponent} />
            {/* <PasteComponent config={card} options={['search', 'form']} updateConfig={this.checkComponent} /> */}
            <PasteComponent config={card} options={['search', 'form']} />
            <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/>
            <DeleteOutlined className="close" onClick={() => this.props.deletecomponent(card.uuid)} />
          </div>
        } trigger="hover">
          <ToolOutlined />
        </Popover>
        <div className="component-name"><div className="center">{card.name}</div></div>
        <div className="component-name">
          <div className="center" onDoubleClick={() => {
              let oInput = document.createElement('input')
              oInput.value = 'anchor' + card.uuid
              document.body.appendChild(oInput)
              oInput.select()
              document.execCommand('Copy')
              document.body.removeChild(oInput)
              message.success('复制成功。')
            }}>{card.name}</div>
        </div>
        {/* 编辑搜索条件 */}
        <Modal
          title="搜索条件-编辑"
          wrapClassName="mk-scroll-modal"
          visible={visible}
          width={850}
          maskClosable={false}