king
2023-06-25 5025901e459ae49d85210573ad38fb3f3c1d9230
src/tabviews/custom/components/iframe/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Input, Modal, notification, Empty } from 'antd'
import { Input, Modal, notification, Empty, Spin } from 'antd'
import Api from '@/api'
import UtilsDM from '@/utils/utils-datamanage.js'
@@ -63,6 +63,10 @@
      if (_config.wrap.linkType !== 'input') {
        linkUrl = _config.wrap.linkUrl || ''
      }
    }
    if (_config.wrap.height === '100vh') {
      _config.wrap.height = 'calc(100vh - 92px)'
    }
    this.setState({
@@ -192,18 +196,29 @@
      this.setState({
        linkUrl: _data[config.wrap.linkField] || '',
        data: _data,
        loading: false
        data: _data
      })
      if (result.message) {
        if (result.ErrCode === 'Y') {
          Modal.success({
            title: result.message
          })
        } else if (result.ErrCode === 'S') {
          notification.success({
            top: 92,
            message: result.message,
            duration: 2
          })
        }
      }
    } else {
      this.setState({
        loading: false
      })
      if (!result.message) return
      if (result.ErrCode === 'N') {
        Modal.error({
          title: result.message,
        })
      } else {
      } else if (result.ErrCode !== '-2') {
        notification.error({
          top: 92,
          message: result.message,
@@ -224,31 +239,44 @@
    }
    if (submit) {
      this.setState({linkUrl: val}, () => {
        let node = document.getElementById(this.state.config.uuid)
        node && node.select && node.select()
      this.setState({linkUrl: '', loading: true}, () => {
        this.setState({linkUrl: val})
      })
      setTimeout(() => {
        this.setState({loading: false}, () => {
          let node = document.getElementById(this.state.config.uuid)
          node && node.select && node.select()
        })
      }, 500)
    }
  }
  enterUrl = (val) => {
    this.setState({linkUrl: val}, () => {
      let node = document.getElementById(this.state.config.uuid)
      node && node.select && node.select()
    this.setState({linkUrl: '', loading: true}, () => {
      this.setState({linkUrl: val})
    })
    setTimeout(() => {
      this.setState({loading: false}, () => {
        let node = document.getElementById(this.state.config.uuid)
        node && node.select && node.select()
      })
    }, 500)
  }
  render() {
    const { config, linkUrl } = this.state
    const { config, linkUrl, loading } = this.state
    return (
      <div className="menu-iframe-box" style={config.style}>
        {config.wrap.title || config.wrap.linkType === 'input' ? <div className="iframe-header" style={config.headerStyle}>
          <span className="title">{config.wrap.title}</span>
          {config.wrap.linkType === 'input' ? <Search id={config.uuid} placeholder="请输入地址" onChange={this.inputUrl} onSearch={this.enterUrl} enterButton="确定"/> : null}
          {config.wrap.linkType === 'input' ? <Search id={config.uuid} disabled={loading} placeholder="请输入地址" onChange={this.inputUrl} onSearch={this.enterUrl} enterButton="确定"/> : null}
        </div> : null}
        <div className="iframe-wrap" style={{height: config.wrap.height}}>
          {linkUrl ? <iframe title="mk" className="iframe" src={linkUrl} frameBorder="0"></iframe> : <Empty description={false}/>}
          {loading ? <div className="mask"><Spin size="large" /></div> : null}
          {linkUrl ? <iframe title="mk" className="iframe" src={linkUrl.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID'))} frameBorder="0"></iframe> : <Empty description={false}/>}
        </div>
      </div>
    )