From b69b5f6329ca5f87932436b7a6c1ddfc3377e10f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 16 五月 2024 10:56:41 +0800
Subject: [PATCH] 2024-05-16

---
 src/tabviews/zshare/actionList/changeuserbutton/index.jsx |  206 +++++++++++++++++++++------------------------------
 1 files changed, 84 insertions(+), 122 deletions(-)

diff --git a/src/tabviews/zshare/actionList/changeuserbutton/index.jsx b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx
index 5f0839b..06cb05f 100644
--- a/src/tabviews/zshare/actionList/changeuserbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx
@@ -4,8 +4,6 @@
 import { Button, notification, Modal } from 'antd'
 
 import Api from '@/api'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import MKEmitter from '@/utils/events.js'
 import MkIcon from '@/components/mk-icon'
 // import './index.scss'
@@ -14,7 +12,6 @@
 
 class NewPageButton extends Component {
   static propTpyes = {
-    show: PropTypes.any,              // 鎸夐挳鏄剧ず鏍峰紡鎺у埗
     MenuID: PropTypes.any,            // 鑿滃崟ID
     BData: PropTypes.any,             // 涓昏〃鏁版嵁
     BID: PropTypes.string,            // 涓昏〃ID
@@ -22,42 +19,20 @@
     selectedData: PropTypes.any,      // 瀛愯〃涓�夋嫨鏁版嵁
     setting: PropTypes.any,           // 椤甸潰閫氱敤璁剧疆
     disabled: PropTypes.any,          // 琛屾寜閽鐢�
-    lineId: PropTypes.any,            // 琛岀储寮�+涓婚敭鍊硷紝鐢ㄤ簬琛屾寜閽弻鍑�
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     disabled: false,
     hidden: false,
     loading: false
   }
 
   UNSAFE_componentWillMount () {
-    const { btn, selectedData, BData } = this.props
-    let disabled = false
+    const { btn, selectedData, BData, disabled } = this.props
 
-    if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
-      selectedData.forEach(item => {
-        let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
-        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-          disabled = true
-        }
-      })
-      this.setState({hidden: disabled && btn.control === 'hidden'})
-    } else if (btn.control === 'parent') {
-      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
-        this.setState({hidden: true})
-      } else {
-        let s = BData[btn.controlField] + ''
-        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-          this.setState({hidden: true})
-        } else {
-          this.setState({hidden: false})
-        }
-      }
-    }
-
-    if (this.props.disabled || disabled) {
+    if (btn.controlField) {
+      this.setStatus(btn, selectedData || [], BData, disabled)
+    } else if (disabled) {
       this.setState({disabled: true})
     }
   }
@@ -71,36 +46,12 @@
   }
 
   UNSAFE_componentWillReceiveProps (nextProps) {
-    const { btn, selectedData, BData } = this.props
+    const { btn } = this.props
 
-    let disabled = false
-    if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
-      if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒�
-        nextProps.selectedData.forEach(item => {
-          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
-          if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-            disabled = true
-          }
-        })
-      }
-      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
-    } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) {
-      if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) {
-        this.setState({hidden: true})
-      } else {
-        let s = nextProps.BData[btn.controlField] + ''
-        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
-          this.setState({hidden: true})
-        } else {
-          this.setState({hidden: false})
-        }
-      }
-    }
-
-    if (nextProps.disabled || disabled) {
-      this.setState({disabled: true})
+    if (btn.controlField) {
+      this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled)
     } else {
-      this.setState({disabled: false})
+      this.setState({disabled: nextProps.disabled === true})
     }
   }
 
@@ -110,21 +61,54 @@
     }
     MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
   }
+
+  setStatus = (btn, data, BData, disprop) => {
+    let disabled = false
+    let hidden = false
+
+    if (btn.control !== 'parent') {
+      if (data.length > 0) {
+        data.forEach(item => {
+          let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : ''
+          if (btn.controlVals.includes(s)) {
+            disabled = true
+          }
+        })
+      } else if (btn.controlVals.includes('')) {
+        disabled = true
+      }
+    } else {
+      if (!BData || !BData.hasOwnProperty(btn.controlField)) {
+        hidden = true
+      } else {
+        let s = BData[btn.controlField] + ''
+        if (btn.controlVals.includes(s)) {
+          hidden = true
+        }
+      }
+    }
+
+    if (disabled && btn.control === 'hidden') {
+      hidden = true
+    }
+
+    if (disprop) {
+      disabled = true
+    }
+
+    this.setState({hidden, disabled})
+  }
   
   /**
    * @description 瑙﹀彂鎸夐挳鎿嶄綔
    */
-  actionTrigger = (triggerId, record, type) => {
-    const { setting, selectedData, btn, MenuID } = this.props
+  actionTrigger = (triggerId, record, type, lid) => {
+    const { setting, selectedData, btn, MenuID, LID } = this.props
     const { loading, disabled } = this.state
     
     if (loading || disabled) return
-    if (triggerId) {
-      if (btn.uuid !== triggerId) return
-      if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) {
-        return
-      }
-    }
+    if (triggerId && btn.uuid !== triggerId) return
+    if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return
 
     if (btn.funcType === 'closetab') {
       MKEmitter.emit('closeTabView', MenuID || btn.$MenuID)
@@ -133,10 +117,6 @@
         MKEmitter.emit('reloadMenuView', btn.refreshTab[btn.refreshTab.length - 1], 'table')
       }
       return
-    } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
-      if (record[0].$Index !== selectedData[0].$Index) {
-        return
-      }
     }
     
     let data = record || selectedData || []
@@ -145,15 +125,7 @@
       // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁
       notification.warning({
         top: 92,
-        message: this.state.dict['main.action.confirm.selectSingleLine'],
-        duration: 5
-      })
-      return
-    } else if (!setting.primaryKey) {
-      // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿�
-      notification.warning({
-        top: 92,
-        message: '鏈缃富閿紒',
+        message: '璇烽�夋嫨鍗曡鏁版嵁锛�',
         duration: 5
       })
       return
@@ -173,7 +145,10 @@
     let _this = this
 
     let param = {
-      func: 'webapi_ChangeUser'
+      func: 'webapi_ChangeUser',
+      login_city: sessionStorage.getItem('city') || '',
+      login_id_address: sessionStorage.getItem('ipAddress') || '',
+      domain_name: window.btoa(window.encodeURIComponent(window.GLOB.host)),
     }
 
     if (this.props.BID) {
@@ -187,7 +162,7 @@
     param[setting.primaryKey] = primaryId
 
     confirm({
-      title: this.state.dict['main.action.confirm.tip'],
+      title: '纭畾瑕佹墽琛屽悧?',
       onOk() {
         return new Promise(resolve => {
           Api.genericInterface(param).then(res => {
@@ -199,12 +174,18 @@
               sessionStorage.setItem('Full_Name', res.FullName)
               sessionStorage.setItem('avatar', res.icon || '')
               sessionStorage.setItem('dataM', res.dataM ? 'true' : '')
-              sessionStorage.setItem('localDataM', res.dataM ? 'true' : '')
               sessionStorage.setItem('debug', res.debug || '')
               sessionStorage.setItem('role_id', res.role_id || '')
               sessionStorage.setItem('departmentcode', res.departmentcode || '')
               sessionStorage.setItem('organization', res.organization || '')
-              sessionStorage.setItem('localRole_id', res.role_id || '')
+              sessionStorage.setItem('mk_user_type', res.mk_user_type || '')
+
+              if (res.paas_externalDatabase) {
+                sessionStorage.setItem('externalDatabase', res.paas_externalDatabase)
+                window.GLOB.externalDatabase = `[${res.paas_externalDatabase}]..`
+              } else {
+                sessionStorage.removeItem('externalDatabase')
+              }
               
               sessionStorage.removeItem('CloudAvatar')
               sessionStorage.removeItem('cloudDataM')
@@ -217,7 +198,7 @@
             } else {
               notification.error({
                 top: 92,
-                message: res.message || res.ErrMesg,
+                message: res.message || '鎵ц澶辫触锛�',
                 duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10
               })
               _this.setState({loading: false})
@@ -235,51 +216,32 @@
   }
 
   render() {
-    const { btn, show } = this.props
+    const { btn } = this.props
     const { loading, disabled, hidden } = this.state
 
     if (hidden) return null
 
-    if (show === 'actionList') {
-      return (
-        <Button
-          icon={btn.icon}
-          loading={loading}
-          disabled={disabled}
-          title={disabled ? (btn.reason || '') : ''}
-          className={'mk-btn mk-' + btn.class}
-          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
-        >{btn.label}</Button>
-      )
-    } else { // icon銆乼ext銆� all 鍗$墖
-      let label = ''
-      let icon = ''
+    let label = ''
 
-      if (show === 'button') {
-        label = btn.label
-        icon = btn.icon || ''
-      } else if (show === 'link') {
-        label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span>
-        icon = ''
-      } else if (show === 'icon') {
-        icon = btn.icon || ''
-      // } else if (show === 'text') {
-      } else {
-        label = btn.label
-      }
-
-      return (
-        <Button
-          type="link"
-          title={disabled ? (btn.reason || '') : (show === 'icon' ? btn.label : '')}
-          loading={loading}
-          disabled={disabled}
-          style={btn.style}
-          icon={icon}
-          onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
-        >{label}</Button>
-      )
+    if (btn.show === 'link') {
+      label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span>
+    } else if (btn.show === 'icon') {
+      label = !loading ? <MkIcon type={btn.icon} /> : null
+    } else {
+      label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{btn.label}</span>
     }
+
+    return (
+      <Button
+        type="link"
+        title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')}
+        loading={loading}
+        disabled={disabled}
+        style={btn.style}
+        className={btn.hover || ''}
+        onClick={(e) => {e.stopPropagation(); this.actionTrigger()}}
+      >{label}</Button>
+    )
   }
 }
 

--
Gitblit v1.8.0