From ba7c54e0029456e6b1bf7f0e0d31af69a3d74db3 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 02 三月 2020 15:34:51 +0800
Subject: [PATCH] 2020-03-02

---
 src/templates/comtableconfig/index.jsx |  232 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 215 insertions(+), 17 deletions(-)

diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx
index 06fd07b..4710693 100644
--- a/src/templates/comtableconfig/index.jsx
+++ b/src/templates/comtableconfig/index.jsx
@@ -29,6 +29,7 @@
 import VerifyCardPrint from '@/templates/tableshare/verifycardprint'
 import MenuForm from '@/templates/tableshare/menuform'
 import TabDragElement from '@/templates/tableshare/tabdragelement'
+import TransferForm from '@/components/transferform'
 import SourceElement from '@/templates/tableshare/dragelement/source'
 import Source from './source'
 import './index.scss'
@@ -73,7 +74,10 @@
     showColumnName: false,   // 鏄剧ず鍒楀瓧娈靛悕鎺у埗
     tabviews: [],            // 鎵�鏈夋爣绛鹃〉
     profileVisible: false,   // 楠岃瘉淇℃伅妯℃�佹
-    optionLibs: null         // 鑷畾涔変笅鎷夐�夐」搴�
+    optionLibs: null,        // 鑷畾涔変笅鎷夐�夐」搴�
+    thawBtnVisible: false,   // 瑙e喕鎸夐挳寮圭獥
+    thawbtnlist: null,       // 瑙e喕鎸夐挳鍒楄〃
+    thawButtons: []          // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳
   }
 
   /**
@@ -123,6 +127,10 @@
       _config.action = _config.action.map(item => {
         let uuid = Utils.getuuid()
 
+        if (item.linkTab) {
+          item.linkTab = ''
+        }
+
         if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(琛ㄥ崟)
           _oriActions.push({
             prebtn: JSON.parse(JSON.stringify(item)),
@@ -146,6 +154,10 @@
         _config[group] = _config[group].map(tab => {
           tab.uuid = Utils.getuuid()
           
+          if (tab.linkTab) {
+            tab.linkTab = ''
+          }
+
           return tab
         })
       })
@@ -1364,7 +1376,7 @@
   }
 
   deleteElement = (element) => {
-    const { config } = this.state
+    const { config, thawButtons } = this.state
     let _this = this
 
     confirm({
@@ -1403,12 +1415,13 @@
         // 鍒犻櫎鎸夐挳鍏冪礌
         let _delActions = _this.state.delActions
         if (element.type === 'action' || element.type === 'tabs') {
-          _delActions.push(element.card.uuid)
+          _delActions.push(element)
         }
 
         _this.setState({
           config: _config,
-          delActions: _delActions
+          delActions: _delActions,
+          thawButtons: thawButtons.filter(key => key !== element.card.uuid)
         })
       },
       onCancel() {}
@@ -1544,7 +1557,7 @@
    */
   submitConfig = () => {
     const { menu } = this.props
-    const { originMenu, delActions } = this.state
+    const { originMenu, delActions, thawButtons } = this.state
 
     let config = JSON.parse(JSON.stringify(this.state.config))
 
@@ -1782,8 +1795,23 @@
             let deffers = delActions.map(item => {
               let _param = {
                 func: 'sPC_MainMenu_Del',
-                MenuID: item
+                MenuID: item.card.uuid
               }
+
+              if (item.type === 'action') {
+                let _ParentParam = null
+
+                try {
+                  _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card)))
+                } catch (e) {
+                  _ParentParam = null
+                }
+
+                if (_ParentParam) {
+                  _param.ParentParam = _ParentParam
+                }
+              }
+
               return new Promise(resolve => {
                 Api.getSystemConfig(_param).then(response => {
                   resolve(response)
@@ -1818,6 +1846,46 @@
             })
           } else if (delActions.length === 0) {
             resolve(true)
+          }
+        }).then(resp => {
+          if (resp === false) return
+
+          if (thawButtons.length > 0) {
+            let defers = thawButtons.map(item => {
+              return new Promise((resolve) => {
+                Api.getSystemConfig({
+                  func: 'sPC_MainMenu_ReDel',
+                  MenuID: item
+                }).then(res => {
+                  if (res.status) {
+                    resolve('')
+                  } else {
+                    resolve(res.message)
+                  }
+                })
+              })
+            })
+
+            return Promise.all(defers)
+          } else {
+            return true
+          }
+        }).then(res => {
+          if (res === true || res === false) return res
+
+          let msg = res.filter(Boolean)[0]
+          if (msg) {
+            notification.warning({
+              top: 92,
+              message: msg,
+              duration: 10
+            })
+            return false
+          } else {
+            this.setState({
+              thawButtons: []
+            })
+            return true
           }
         }).then(resp => {
           if (resp === false) return
@@ -1970,13 +2038,17 @@
                 try {
                   _subconfig.action = _subconfig.action.map(_btn => {
                     _btn.uuid = Utils.getuuid()
-  
+
                     return _btn
                   })
                   _subconfig.tabgroups.forEach(_groupId => {
                     _subconfig[_groupId] = _subconfig[_groupId].map(_tab => {
                       _tab.uuid = Utils.getuuid()
   
+                      if (_tab.linkTab) {
+                        _tab.linkTab = ''
+                      }
+
                       return _tab
                     })
                   })
@@ -1984,9 +2056,11 @@
                 } catch {
                   _subconfig = ''
                 }
-              }
 
-              _LongParam = _subconfig
+                _LongParam = _subconfig
+              } else if (_subconfig) {
+                _LongParam = result.LongParam
+              }
             }
 
             if (_LongParam) {
@@ -2642,6 +2716,105 @@
   }
 
   /**
+   * @description 瑙e喕鎸夐挳
+   */
+  handleThaw = () => {
+    const { menu } = this.props
+
+    this.setState({
+      thawBtnVisible: true
+    })
+
+    Api.getSystemConfig({
+      func: 'sPC_Get_FrozenMenu',
+      ParentID: menu.MenuID,
+      TYPE: 40
+    }).then(res => {
+      if (res.status) {
+        let _list = []
+
+        res.data.forEach(menu => {
+          let _conf = ''
+
+          if (menu.ParentParam) {
+            try {
+              _conf = JSON.parse(window.decodeURIComponent(window.atob(menu.ParentParam)))
+            } catch (e) {
+              _conf = ''
+            }
+          }
+
+          if (_conf) {
+            _list.push({
+              key: menu.MenuID,
+              title: menu.MenuName,
+              btnParam: _conf
+            })
+          }
+        })
+
+        this.setState({
+          thawbtnlist: _list
+        })
+      } else {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 10
+        })
+      }
+    })
+  }
+
+  /**
+   * @description 瑙e喕鎸夐挳鎻愪氦
+   */
+  thawBtnSubmit = () => {
+    const { thawButtons, config, thawbtnlist } = this.state
+    // 涓夌骇鑿滃崟瑙i櫎鍐荤粨
+    if (this.refs.trawmenu.state.targetKeys.length === 0) {
+      notification.warning({
+        top: 92,
+        message: this.state.dict['form.required.select'] + this.state.dict['header.form.thawbutton'],
+        duration: 10
+      })
+    } else {
+
+      thawbtnlist.forEach(item => {
+        if (this.refs.trawmenu.state.targetKeys.includes(item.key)) {
+          config.action.push(item.btnParam)
+        }
+      })
+
+      this.setState({
+        thawButtons: [...thawButtons, ...this.refs.trawmenu.state.targetKeys],
+        config: config,
+        thawBtnVisible: false
+      })
+    }
+  }
+
+  handleGroup = (index, type) => {
+    let config = JSON.parse(JSON.stringify(this.state.config))
+    
+    if (type === 'up') {
+      config.tabgroups.splice(index, 0, config.tabgroups.splice(index - 1, 1)[0])
+    } else {
+      config.tabgroups.splice(index, 0, config.tabgroups.splice(index + 1, 1)[0])
+    }
+
+    this.setState({
+      config: config
+    })
+
+    notification.success({
+      top: 92,
+      message: '璋冩暣鎴愬姛',
+      duration: 2
+    })
+  }
+
+  /**
    * @description 閫夋嫨涓嶄繚瀛樻椂锛屽鏈夊鍒舵寜閽紝鍒欏垹闄�
    */
   notsave = () => {
@@ -2734,14 +2907,19 @@
                     return (<SourceElement key={index} content={item}/>)
                   })}
                 </div>
-                {configAction.length > 0 ?
-                  <p className="config-btn-title">
-                    <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��">
-                      <Icon type="question-circle" />
-                    </Tooltip>
-                    {this.state.dict['header.menu.action.configurable']}
-                  </p> : null
-                }
+                <div className="config-btn">
+                  {configAction.length > 0 ?
+                    <p className="config-btn-title">
+                      <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫寜閽厤缃俊鎭��">
+                        <Icon type="question-circle" />
+                      </Tooltip>
+                      {this.state.dict['header.menu.action.configurable']}
+                    </p> : null
+                  }
+                  <div className="thawbutton" title={this.state.dict['header.form.thawbutton']} onClick={this.handleThaw}>
+                    <Icon type="unlock" />
+                  </div>
+                </div>
                 {configAction.map((item, index) => {
                   return (
                     <div key={index}>
@@ -2821,6 +2999,9 @@
                 <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃寜閽�嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬寜閽嫋鑷虫澶勬坊鍔狅紝濡傞�夋嫨鎸夐挳绫诲瀷涓鸿〃鍗曘�佹柊鏍囩椤电瓑鍚湁閰嶇疆椤甸潰鐨勬寜閽紝鍙湪宸︿晶宸ュ叿鏍�-鎸夐挳-鍙厤缃寜閽锛岀偣鍑绘寜閽畬鎴愮浉鍏抽厤缃�傛敞锛氬綋璁剧疆鎸夐挳鏄剧ず浣嶇疆涓鸿〃鏍兼椂锛屾樉绀哄垪浼氬鍔犳搷浣滃垪銆�">
                   <Icon type="question-circle" />
                 </Tooltip>
+                {/* <div className="thawbutton" title={this.state.dict['header.form.thawbutton']} onClick={this.handleThaw}>
+                  <Icon type="unlock" />
+                </div> */}
                 <DragElement
                   type="action"
                   list={this.state.config.action}
@@ -2859,6 +3040,10 @@
                     {index === 0 ? <Tooltip placement="bottomLeft" overlayClassName="middle" title="鍦ㄥ乏渚у伐鍏锋爮銆婃爣绛鹃〉銆嬩腑锛岄�夋嫨瀵瑰簲绫诲瀷鐨勬爣绛鹃〉鎷栬嚦姝ゅ娣诲姞銆�">
                       <Icon type="question-circle" />
                     </Tooltip> : null}
+                    {index !== (this.state.config.tabgroups.length - 1) ?
+                      <Icon type="arrow-down" onClick={() => {this.handleGroup(index, 'down')}} /> : null
+                    }
+                    {index !== 0 ? <Icon type="arrow-up" onClick={() => {this.handleGroup(index, 'up')}} /> : null}
                     {index === 0 ? <Icon type="plus" onClick={this.addTabGroup} /> : null}
                     {index !== 0 ? <Icon type="delete" onClick={() => {this.delTabGroup(groupId)}} /> : null}
                     <TabDragElement
@@ -3097,6 +3282,19 @@
         >
           {this.state.dict['header.menu.config.placeholder']}
         </Modal>
+        {/* 瑙e喕鎸夐挳妯℃�佹 */}
+        <Modal
+          title={this.state.dict['header.form.thawbutton']}
+          okText={this.state.dict['header.confirm']}
+          cancelText={this.state.dict['header.cancel']}
+          visible={this.state.thawBtnVisible}
+          onOk={this.thawBtnSubmit}
+          onCancel={() => {this.setState({thawBtnVisible: false, thawbtnlist: null})}}
+          destroyOnClose
+        >
+          {!this.state.thawbtnlist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />}
+          {this.state.thawbtnlist && <TransferForm ref="trawmenu" dict={this.state.dict} menulist={this.state.thawbtnlist}/>}
+        </Modal>
         {this.state.loading && <Spin size="large" />}
       </div>
     )

--
Gitblit v1.8.0