From 2d1ecb2628680c31ed075261b40d6f16ca6363dd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 11 三月 2020 13:39:29 +0800
Subject: [PATCH] 2020-03-11

---
 src/components/tabview/index.jsx             |   29 +++++++--
 src/tabviews/tableshare/verifycard/index.jsx |    8 ++
 src/components/tabview/index.scss            |   22 +++++++
 src/tabviews/formtab/index.jsx               |   31 ++++++++++
 src/api/index.js                             |   11 ++-
 src/utils/utils.js                           |    8 ++
 src/tabviews/tableshare/actionList/index.jsx |   21 ++++++
 7 files changed, 114 insertions(+), 16 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index 20e1874..ed5c5de 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -33,7 +33,7 @@
   }
 }
 
-let GlobMap = new Map()
+window.GLOB.CacheMap = new Map()
 
 axios.interceptors.response.use((response) => {
   if (response.data.ErrCode === 'LoginError') {
@@ -260,8 +260,8 @@
     _param = JSON.stringify(_param)
     _param  = md5(_param)
 
-    if (GlobMap.has(_param)) {
-      return Promise.resolve(GlobMap.get(_param))
+    if (window.GLOB.CacheMap.has(_param)) {
+      return Promise.resolve(window.GLOB.CacheMap.get(_param))
     } else {
       param.nonc = Utils.getuuid()
       
@@ -283,8 +283,9 @@
           url: '/webapi/dostars',
           data: param
         }).then(res => {
-
-          GlobMap.set(_param, res)
+          if (res.status) {
+            window.GLOB.CacheMap.set(_param, res)
+          }
           resolve(res)
         })
       })
diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx
index 8dbe85e..a15b7b9 100644
--- a/src/components/tabview/index.jsx
+++ b/src/components/tabview/index.jsx
@@ -3,7 +3,7 @@
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import {Tabs, Icon, Button, ConfigProvider, message, BackTop} from 'antd'
-import {modifyTabview, toggleIsiframe} from '@/store/action'
+import {modifyTabview, toggleIsiframe, refreshTabView} from '@/store/action'
 // import asyncComponent from '@/utils/asyncComponent'
 import asyncComponent from '@/utils/asyncLoadComponent'
 import NotFount from '@/components/404'
@@ -38,7 +38,7 @@
     locale: (!sessionStorage.getItem('lang') || sessionStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS
   }
 
-  handleTabview (e, menu) {
+  handleTabview = (e, menu) => {
     e.stopPropagation()
     // 鍏抽棴tab椤碉紝閲嶆柊閫夋嫨鏄剧ず椤�
     let tabs = JSON.parse(JSON.stringify(this.state.tabviews))
@@ -53,7 +53,18 @@
     this.props.modifyTabview(tabs)
   }
 
-  changeTab (e, menu) {
+  refreshTabview = (e, menu) => {
+    e.stopPropagation()
+    window.GLOB.CacheMap = new Map()
+
+    let _menu = {
+      MenuID: menu.MenuID,
+      position: 'view'
+    }
+    this.props.refreshTabView(_menu)
+  }
+
+  changeTab = (e, menu) => {
     e.stopPropagation()
     // 绐楀彛鍒囨崲
     let tabs = JSON.parse(JSON.stringify(this.state.tabviews))
@@ -74,7 +85,7 @@
     this.props.modifyTabview(tabs)
   }
 
-  selectcomponent (view) {
+  selectcomponent = (view) => {
     // 鏍规嵁tab椤典腑鑿滃崟淇℃伅锛岄�夋嫨鎵�闇�鐨勭粍浠�
     if (view.type === 'Home') {
       return (<Comps.Home MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>)
@@ -97,7 +108,7 @@
     }
   }
 
-  resetWindow (view) {
+  resetWindow = (view) => {
     // 绐楀彛鍦╥frame涓庢櫘閫氶〉闈㈠垏鎹㈡椂锛屼慨鏀瑰乏渚ц彍鍗曟爮鏍峰紡
     if (!view) return
     let _isiframe = this.props.isiframe
@@ -210,10 +221,15 @@
                       className="test"
                       tab={
                         <span className="tab-control">
+                          {['CommonTable', 'FormTab'].includes(view.type) ?
+                            <Icon type="redo" onClick={(e) => {this.refreshTabview(e, view)}}/> : null
+                          }
                           <span className="tab-name" onClick={(e) => {this.changeTab(e, view)}}>
                             {view.MenuName}
                           </span>
-                          {view.type !== 'Home' ? <Icon type="close" onClick={(e) => {this.handleTabview(e, view)}}/> : null}
+                          {view.type !== 'Home' ?
+                            <Icon type="close" onClick={(e) => {this.handleTabview(e, view)}}/> : null
+                          }
                         </span>
                       }
                       key={view.MenuID}
@@ -258,6 +274,7 @@
 const mapDispatchToProps = (dispatch) => {
   return {
     modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)),
+    refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)),
     toggleIsiframe: (isiframe) => dispatch(toggleIsiframe(isiframe))
   }
 }
diff --git a/src/components/tabview/index.scss b/src/components/tabview/index.scss
index afc15ea..1705069 100644
--- a/src/components/tabview/index.scss
+++ b/src/components/tabview/index.scss
@@ -14,7 +14,7 @@
     .ant-tabs-tab {
       padding: 18px 16px 6px 6px;
       cursor: default;
-      span.tab-control i {
+      span.tab-control i.anticon-close {
         position: absolute;
         right: -7px;
         top: 10px;
@@ -23,11 +23,31 @@
         padding: 5px;
         cursor: pointer;
       }
+      span.tab-control i.anticon-redo {
+        position: absolute;
+        left: -5px;
+        top: 18px;
+        font-size: 14px;
+        margin: 0px;
+        padding: 3px;
+        cursor: pointer;
+        display: none;
+      }
       span.tab-name {
         cursor: pointer;
         padding: 6px 0px 6px 10px;
       }
     }
+    .ant-tabs-tab-active.ant-tabs-tab {
+      span.tab-name {
+        cursor: default;
+      }
+    }
+    .ant-tabs-tab-active.ant-tabs-tab:hover {
+      span.tab-control i.anticon-redo {
+        display: inline-block;
+      }
+    }
     iframe {
       width: 100%;
       height: calc(100vh - 115px);
diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx
index dcafbe6..0ef451a 100644
--- a/src/tabviews/formtab/index.jsx
+++ b/src/tabviews/formtab/index.jsx
@@ -568,11 +568,42 @@
     return this.formGroupRef.handleConfirm()
   }
 
+  reloadview = () => {
+    this.setState({
+      loadingview: true,
+      viewlost: false,
+      lostmsg: '',
+      config: {},
+      groups: null,
+      actions: null,
+      arr_field: '',
+      setting: null,
+      data: null,
+      configMap: {},
+      BIDs: {},
+      setsingle: false,
+      pickup: false,
+      popData: false,
+      visible: false,
+      primaryId: null,
+      refreshtabs: null
+    }, () => {
+      this.loadconfig()
+    })
+  }
+
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
   }
 
+  UNSAFE_componentWillReceiveProps(nextProps) {
+    if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) {
+      this.reloadview()
+      this.props.refreshTabView('')
+    }
+  }
+
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
   }
diff --git a/src/tabviews/tableshare/actionList/index.jsx b/src/tabviews/tableshare/actionList/index.jsx
index 51cfdbe..92f83e0 100644
--- a/src/tabviews/tableshare/actionList/index.jsx
+++ b/src/tabviews/tableshare/actionList/index.jsx
@@ -627,7 +627,17 @@
         })
       }
     }
-    console.log(JSON.stringify(printdata))
+
+    if (list.length === 0) {
+      notification.warning({
+        top: 92,
+        message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�',
+        duration: 10
+      })
+      this.setState({loadingUuid: ''})
+      return
+    }
+
     if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + item.verify.linkUrl) {
       socket = new WebSocket('ws://' + item.verify.linkUrl)
     } else {
@@ -685,7 +695,7 @@
         }
       }
 
-      if (data && data.defaultPrinter) {
+      if (data && data.cmd === 'getPrinters' && data.status) {
         printdata.task.printer = data.defaultPrinter
         this.setState({loadingUuid: ''})
         notification.success({
@@ -694,6 +704,13 @@
           duration: 2
         })
         socket.send(JSON.stringify(printdata))
+      } else if (data && data.message && !data.status) {
+        notification.warning({
+          top: 92,
+          message: data.message,
+          duration: 10
+        })
+        this.setState({loadingUuid: ''})
       }
     }
 
diff --git a/src/tabviews/tableshare/verifycard/index.jsx b/src/tabviews/tableshare/verifycard/index.jsx
index b46a5a6..199789e 100644
--- a/src/tabviews/tableshare/verifycard/index.jsx
+++ b/src/tabviews/tableshare/verifycard/index.jsx
@@ -137,7 +137,7 @@
             data = ''
           }
 
-          if (data && data.defaultPrinter) {
+          if (data && data.cmd === 'getPrinters' && data.status) {
             let printers = Array.from(new Set(data.printers))
             
             let _config = JSON.parse(JSON.stringify(this.state.config))
@@ -158,6 +158,12 @@
             this.setState({
               config: _config
             })
+          } else if (data && data.cmd === 'getPrinters' && !data.status) {
+            notification.warning({
+              top: 92,
+              message: data.message,
+              duration: 10
+            })
           }
         }
 
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 9edfb85..461e3b8 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -1269,6 +1269,12 @@
       `
     }
 
+    // 鎵撳嵃鑷畾涔夋ā鏉垮瓧娈垫彁绀�
+    let _printRemark = ''
+    if (btn.funcType === 'print') {
+      _printRemark = '/* 鑷畾涔夋暟鎹墦鍗版ā鏉挎椂锛岃浣跨敤TemplateID瀛楁 */'
+    }
+
     let Ltext = `create proc ${param.funcName}
     ( /*${menu.MenuName}  ${btn.label}*/
     @BID nvarchar(50)='',${formParam}
@@ -1291,7 +1297,7 @@
       /*浜嬪姟鎿嶄綔*/
       BEGIN TRAN
         /*鍏蜂綋涓氬姟鎿嶄綔*/
-        
+        ${_printRemark}
         /* 
         select top 10 * from sProcExcep order by id desc
         

--
Gitblit v1.8.0