From b9a0e8541f0959db5d848f7b893c8838851ce411 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 09 四月 2020 13:29:49 +0800
Subject: [PATCH] 2020-04-09

---
 src/tabviews/commontable/index.jsx |   69 +++++++++++++++++++++++++++-------
 1 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 202b1a4..8252bca 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -68,6 +68,7 @@
     tabParam: null,       // 琛ㄥ崟鏍囩鍙傛暟
     refreshtabs: null,    // 闇�瑕佸埛鏂扮殑鏍囩闆�
     confirmLoading: false,// 鑷畾涔夎缃ā鎬佹鍔犺浇涓�
+    revertLoading: false, // 鎭㈠榛樿璁剧疆
     settingVisible: false,// 鑷畾涔夎缃ā鎬佹
     triggerBtn: null,     // 鐐瑰嚮琛ㄦ牸涓垨蹇嵎閿Е鍙戠殑鎸夐挳
     tabActive: null       // 鏍囩椤靛睍寮�鎺у埗
@@ -77,7 +78,7 @@
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
-    const { permAction, param } = this.props
+    const { permAction, permMenus, param } = this.props
 
     let _param = {
       func: 'sPC_Get_LongParam',
@@ -234,12 +235,14 @@
       })
 
       // 鐢熸垚鏄剧ず鍒楋紝澶勭悊鍚堝苟鍒椾腑鐨勫瓧娈�
-      config.columns.forEach(col => {
+      config.columns.forEach((col, index) => {
         if (_hideCol.includes(col.uuid)) return
 
-        // if (col.linkThdMenu && !permAction[col.linkThdMenu.MenuID]) {
-        //   col.linkThdMenu = ''
-        // }
+        if (col.linkThdMenu && !permMenus[col.linkThdMenu.MenuID]) {
+          col.linkThdMenu = ''
+        }
+
+        col.sort = index
 
         if (col.type === 'colspan' && col.sublist) {
           let _col = JSON.parse(JSON.stringify(col))
@@ -263,15 +266,17 @@
         })
       }
 
-      let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉
-      config.search.forEach(item => {
-        if (item.type === 'text' && param && param.searchkey === item.field) {
-          item.initval = param.searchval
+      let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉, 鍒濆鎼滅储鏉′欢
+      let initSearch = config.search.map(item => {
+        let _item = JSON.parse(JSON.stringify(item))
+        if (_item.type === 'text' && param && param.searchkey === _item.field) {
+          _item.initval = param.searchval
         }
 
-        if (item.required === 'true' && !item.initval) {
+        if (_item.required === 'true' && !_item.initval) {
           valid = false
         }
+        return _item
       })
 
       if (_curUserConfig) {
@@ -299,7 +304,7 @@
         columns: _columns,
         logcolumns: _logcolumns,
         arr_field: _arrField.join(','),
-        search: Utils.initMainSearch(config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級
+        search: Utils.initMainSearch(initSearch) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級
       }, () => {
         this.improveSearch()
         if (config.setting.onload !== 'false' && valid) { // 鍒濆鍖栧彲鍔犺浇
@@ -1024,7 +1029,8 @@
   controlCustomSetting = () => {
     this.setState({
       settingVisible: true,
-      confirmLoading: false
+      confirmLoading: false,
+      revertLoading: false
     })
   }
 
@@ -1058,6 +1064,37 @@
     }
 
     this.props.modifyTabview(tabs)
+  }
+
+  settingRevert = () => {
+    let param = {
+      func: 's_TrdMenu_UserParam_del',
+      MenuID: this.props.MenuID
+    }
+    this.setState({
+      revertLoading: true
+    })
+
+    Api.getSystemConfig(param).then(result => {
+      if (!result.status) {
+        this.setState({
+          revertLoading: false
+        })
+        notification.warning({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+        return
+      }
+      this.setState({
+        settingVisible: false,
+        revertLoading: false
+      }, () => {
+        window.GLOB.CacheMap = new Map()
+        this.reloadview()
+      })
+    })
   }
 
   settingSubmit = () => {
@@ -1303,9 +1340,12 @@
             maskClosable={false}
             width={950}
             visible={this.state.settingVisible}
-            onOk={this.settingSubmit}
             onCancel={() => { this.setState({ settingVisible: false }) }}
-            confirmLoading={this.state.confirmLoading}
+            footer={[
+              <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.state.dict['main.revert.default']}</Button>,
+              <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['main.cancel']}</Button>,
+              <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.state.dict['main.confirm']}</Button>
+            ]}
             destroyOnClose
           >
             {this.state.settingVisible ?
@@ -1334,6 +1374,7 @@
     tabviews: state.tabviews,
     refreshTab: state.refreshTab,
     permAction: state.permAction,
+    permMenus: state.permMenus,
     permRoles: state.permRoles
   }
 }

--
Gitblit v1.8.0