From 876a5e6657d67df66bb525d02dd6d147ba81cae5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 05 一月 2023 09:53:37 +0800
Subject: [PATCH] 2023-01-05

---
 src/tabviews/custom/components/iframe/index.jsx |   46 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/tabviews/custom/components/iframe/index.jsx b/src/tabviews/custom/components/iframe/index.jsx
index e8d4fd5..62981a9 100644
--- a/src/tabviews/custom/components/iframe/index.jsx
+++ b/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'
@@ -82,8 +82,17 @@
   }
 
   componentDidMount () {
+    const { config } = this.state
+
     MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
+
+    if (config.wrap.linkType === 'input' && config.wrap.focus !== 'false') {
+      setTimeout(() => {
+        let node = document.getElementById(config.uuid)
+        node && node.select && node.select()
+      }, 200)
+    }
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -183,13 +192,9 @@
 
       this.setState({
         linkUrl: _data[config.wrap.linkField] || '',
-        data: _data,
-        loading: false
+        data: _data
       })
     } else {
-      this.setState({
-        loading: false
-      })
       if (result.ErrCode === 'N') {
         Modal.error({
           title: result.message,
@@ -215,30 +220,43 @@
     }
 
     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}}>
+          {loading ? <div className="mask"><Spin size="large" /></div> : null}
           {linkUrl ? <iframe title="mk" className="iframe" src={linkUrl} frameBorder="0"></iframe> : <Empty description={false}/>}
         </div>
       </div>

--
Gitblit v1.8.0