From 822bc67061448c6e3a1eb77d39be4ad2b84b416a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 27 二月 2020 09:36:34 +0800
Subject: [PATCH] 2020-02-27

---
 src/tabviews/tableshare/actionList/index.jsx |  213 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 173 insertions(+), 40 deletions(-)

diff --git a/src/tabviews/tableshare/actionList/index.jsx b/src/tabviews/tableshare/actionList/index.jsx
index 8d12a45..6ca24fb 100644
--- a/src/tabviews/tableshare/actionList/index.jsx
+++ b/src/tabviews/tableshare/actionList/index.jsx
@@ -6,6 +6,7 @@
 import MutilForm from '@/tabviews/tableshare/mutilform'
 import ExcelIn from '../excelin'
 import Utils from '@/utils/utils.js'
+import options from '@/store/options.js'
 import Api from '@/api'
 import './index.scss'
 
@@ -13,6 +14,7 @@
 
 class MainAction extends Component {
   static propTpyes = {
+    menuType: PropTypes.any,          // 鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曟垨HS
     BID: PropTypes.string,            // 涓昏〃ID
     BData: PropTypes.any,             // 涓昏〃鏁版嵁
     Tab: PropTypes.any,               // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭�
@@ -164,6 +166,12 @@
       window.open(url)
     } else if (item.OpenType === 'tab' || item.OpenType === 'blank') {
       this.props.triggerPopview(item, data)
+    } else if (item.OpenType === 'funcbutton') {
+      if (item.funcType === 'changeuser') {
+        this.changeUser(item, data)
+      } else if (item.funcType === 'print') {
+        this.triggerPrint(item, data)
+      }
     } else {
       notification.warning({
         top: 92,
@@ -171,6 +179,75 @@
         duration: 10
       })
     }
+  }
+
+  /**
+   * @description 瑙﹀彂鎵撳嵃
+   */
+  triggerPrint = (item, data) => {
+    // socket = new WebSocket('ws://127.0.0.1:13529')
+
+    // // 鎵撳紑Socket
+    // socket.onopen = function(event) {
+    //     // 鐩戝惉娑堟伅
+    //     socket.onmessage = function(event)
+    //     {
+    //         //鍙栨墦鍗版満淇℃伅鐨勮繑鍥炴槸鍦ㄨ繖閲�,鎵�浠ョ涓�娆$殑鎵撳嵃姣旇緝楹荤儲,鐪嬫槸涓嶆槸鍙互鍦ㄨ皟鎵撳嵃鍓嶅厛鍒ゆ柇浣犳湁娌℃湁瀛樻墦鍗版満鍚�
+    //         //,娌℃湁灏辫皟getPrinters鏉ュ彇鎵撳嵃鏈哄幓璁剧疆,瑕佹槸璋冧簡鎵撳嵃鍐嶈皟鍙栨墦鍗版満,绗竴鏉℃墦鍗颁换鍔″氨瑕佸湪杩欓噷閲嶅彂,灏卞お楹荤儲浜�
+    //         //鎻愬墠鍙栨墦鍗版満灏卞彧鑳界敤127.0.0.1:13529鏉ュ彇,杩欎釜鍦板潃灏辫鍐欐浜�
+    //         console.log('Client received a message',event);
+    //     };
+
+    //     // 鐩戝惉Socket鐨勫叧闂�
+    //     socket.onclose = function(event)
+    //     {
+    //         console.log('Client notified socket has closed',event);
+    //     };
+
+    // };
+  }
+
+  /**
+   * @description 鍒囨崲鐢ㄦ埛
+   */
+  changeUser = (btn, data) => {
+    const { setting } = this.props
+
+    let param = {
+      BID: this.props.BID,
+      func: 'webapi_ChangeUser',
+      appkey: window.GLOB.appkey || '',
+      rduri: window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+    }
+
+    param[setting.primaryKey] = data[0][setting.primaryKey]
+
+    confirm({
+      title: this.props.dict['main.action.confirm.tip'],
+      onOk() {
+        return new Promise(resolve => {
+          Api.genericInterface(param).then(res => {
+            resolve()
+            if (res.status) {
+              sessionStorage.setItem('avatar', res.icon || '')
+              sessionStorage.setItem('UserID', res.UserID)
+              sessionStorage.setItem('SessionUid', Utils.getuuid())
+              sessionStorage.setItem('LoginUID', res.LoginUID)
+              sessionStorage.setItem('User_Name', res.UserName)
+              
+              window.location.reload()
+            } else {
+              notification.error({
+                top: 92,
+                message: res.message || res.ErrMesg,
+                duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 15
+              })
+            }
+          })
+        })
+      },
+      onCancel() {}
+    })
   }
 
   /**
@@ -511,11 +588,20 @@
       // 澶栭儴璇锋眰
       _outParam = JSON.parse(JSON.stringify(res))
 
-      if (btn.sysInterface === 'true') {
-        res.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+      if (this.props.menuType === 'HS') {
+        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
+          param.rduri = options.cloudServiceApi
+        } else if (btn.sysInterface !== 'true') {
+          param.rduri = btn.interface
+        }
       } else {
-        res.rduri = btn.interface
+        if (btn.sysInterface === 'true') {
+          param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+        } else {
+          param.rduri = btn.interface
+        }
       }
+
       // res.method = btn.method
       if (btn.outerFunc) {
         res.func = btn.outerFunc
@@ -585,15 +671,15 @@
       })
     } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
-    } else if (res.Relogin === 'true') { // 鍒囨崲鐢ㄦ埛鍔熻兘
-      sessionStorage.setItem('avatar', res.icon || '')
-      sessionStorage.setItem('UserID', res.UserID)
-      sessionStorage.setItem('SessionUid', Utils.getuuid())
-      sessionStorage.setItem('LoginUID', res.LoginUID)
-      sessionStorage.setItem('User_Name', res.UserName)
+    // } else if (res.Relogin === 'true') { // 鍒囨崲鐢ㄦ埛鍔熻兘
+    //   sessionStorage.setItem('avatar', res.icon || '')
+    //   sessionStorage.setItem('UserID', res.UserID)
+    //   sessionStorage.setItem('SessionUid', Utils.getuuid())
+    //   sessionStorage.setItem('LoginUID', res.LoginUID)
+    //   sessionStorage.setItem('User_Name', res.UserName)
       
-      window.location.reload()
-      return
+    //   window.location.reload()
+    //   return
     }
     
     if (btn.OpenType === 'pop' && btn.setting && btn.setting.finish !== 'unclose') {
@@ -939,10 +1025,18 @@
         // 澶栭儴璇锋眰
         _outParam = JSON.parse(JSON.stringify(res))
 
-        if (btn.sysInterface === 'true') {
-          res.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+        if (this.props.menuType === 'HS') {
+          if (btn.sysInterface === 'true' && options.cloudServiceApi) {
+            param.rduri = options.cloudServiceApi
+          } else if (btn.sysInterface !== 'true') {
+            param.rduri = btn.interface
+          }
         } else {
-          res.rduri = btn.interface
+          if (btn.sysInterface === 'true') {
+            param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+          } else {
+            param.rduri = btn.interface
+          }
         }
 
         if (btn.outerFunc) {
@@ -1022,10 +1116,19 @@
         })
       } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟
         let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search)
-        if (btn.sysInterface === 'true') {
-          param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+
+        if (this.props.menuType === 'HS') {
+          if (btn.sysInterface === 'true' && options.cloudServiceApi) {
+            param.rduri = options.cloudServiceApi
+          } else if (btn.sysInterface !== 'true') {
+            param.rduri = btn.interface
+          }
         } else {
-          param.rduri = btn.interface
+          if (btn.sysInterface === 'true') {
+            param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+          } else {
+            param.rduri = btn.interface
+          }
         }
   
         param.appkey = window.GLOB.appkey || ''
@@ -1099,10 +1202,18 @@
         delete res.message
         delete res.status
 
-        if (btn.sysInterface === 'true') {
-          res.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+        if (this.props.menuType === 'HS') {
+          if (btn.sysInterface === 'true' && options.cloudServiceApi) {
+            param.rduri = options.cloudServiceApi
+          } else if (btn.sysInterface !== 'true') {
+            param.rduri = btn.interface
+          }
         } else {
-          res.rduri = btn.interface
+          if (btn.sysInterface === 'true') {
+            param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+          } else {
+            param.rduri = btn.interface
+          }
         }
 
         if (btn.outerFunc) {
@@ -1153,11 +1264,21 @@
 
     } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟
       param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize)
-      if (btn.sysInterface === 'true') {
-        param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+
+      if (this.props.menuType === 'HS') {
+        if (btn.sysInterface === 'true' && options.cloudServiceApi) {
+          param.rduri = options.cloudServiceApi
+        } else if (btn.sysInterface !== 'true') {
+          param.rduri = btn.interface
+        }
       } else {
-        param.rduri = btn.interface
+        if (btn.sysInterface === 'true') {
+          param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
+        } else {
+          param.rduri = btn.interface
+        }
       }
+      
 
       param.appkey = window.GLOB.appkey || ''
 
@@ -1196,9 +1317,38 @@
         let colwidth = []
 
         let hidecolumns = []
+
+        let verifyColumn = {} // 璁板綍楠岃瘉淇℃伅涓殑Excel鍒楅厤缃�
+        if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) {
+          btn.verify.columns.forEach(col => {
+            verifyColumn[col.Column] = col
+          })
+        }
+
         logcolumns.forEach(col => {
           if (col.Hide === 'true') {
             hidecolumns.push(col.field)
+            return
+          }
+          if (!data[0].hasOwnProperty(col.field)) return
+          if (_topRow[col.field]) return
+
+          if (verifyColumn[col.field]) { // 浼樺厛浣跨敤楠岃瘉淇℃伅涓殑鍒楄缃�
+            _header.push(col.field)
+            _topRow[col.field] = verifyColumn[col.field].Text
+  
+            colwidth.push({width: verifyColumn[col.field].Width})
+          } else {
+            _header.push(col.field)
+            _topRow[col.field] = col.label
+  
+            let _colwidth = Math.floor(col.Width / 6)
+  
+            if (!_colwidth || _colwidth < 5) {
+              _colwidth = 5
+            }
+  
+            colwidth.push({width: _colwidth})
           }
         })
 
@@ -1214,23 +1364,6 @@
             colwidth.push({width: col.Width})
           })
         }
-
-        logcolumns.forEach(col => {
-          if (col.Hide === 'true') return
-          if (!data[0].hasOwnProperty(col.field)) return
-          if (_topRow[col.field]) return
-
-          _header.push(col.field)
-          _topRow[col.field] = col.label
-
-          let _colwidth = Math.floor(col.Width / 6)
-
-          if (!_colwidth || _colwidth < 5) {
-            _colwidth = 5
-          }
-
-          colwidth.push({width: _colwidth})
-        })
 
         Object.keys(data[0]).forEach(key => {
           if (hidecolumns.includes(key)) return

--
Gitblit v1.8.0