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/subtableconfig/index.jsx |  190 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 185 insertions(+), 5 deletions(-)

diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx
index 177d6d8..e5e7ccd 100644
--- a/src/templates/subtableconfig/index.jsx
+++ b/src/templates/subtableconfig/index.jsx
@@ -26,6 +26,7 @@
 import VerifyCardExcelIn from '@/templates/tableshare/verifycardexcelin'
 import VerifyCardExcelOut from '@/templates/tableshare/verifycardexcelout'
 import MenuForm from '@/templates/tableshare/menuform'
+import TransferForm from '@/components/transferform'
 import SourceElement from '@/templates/tableshare/dragelement/source'
 import Source from './source'
 import './index.scss'
@@ -77,7 +78,10 @@
     showColumnName: false,   // 鏄剧ず鍒楀瓧娈靛悕鎺у埗
     tabviews: [],            // 鎵�鏈夋爣绛鹃〉
     profileVisible: false,   // 楠岃瘉淇℃伅妯℃�佹
-    optionLibs: null         // 鑷畾涔変笅鎷夐�夐」搴�
+    optionLibs: null,        // 鑷畾涔変笅鎷夐�夐」搴�
+    thawBtnVisible: false,   // 瑙e喕鎸夐挳寮圭獥
+    thawbtnlist: null,       // 瑙e喕鎸夐挳鍒楄〃
+    thawButtons: []          // 宸查�夋嫨瑕佽В鍐荤殑鎸夐挳
   }
 
   /**
@@ -132,6 +136,21 @@
         return item
       })
     }
+
+    // _config.uuid = Utils.getuuid()
+    // _config.action = _config.action.map(item => {
+    //   let uuid = Utils.getuuid()
+    //   if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�
+    //     _oriActions.push({
+    //       prebtn: JSON.parse(JSON.stringify(item)),
+    //       curuuid: uuid,
+    //       Template: 'Modal'
+    //     })
+    //   }
+
+    //   item.uuid = uuid
+    //   return item
+    // })
 
     this.setState({
       originActions: _oriActions,
@@ -1139,6 +1158,8 @@
   }
 
   deleteElement = (element) => {
+    const { thawButtons } = this.state
+
     let _this = this
     confirm({
       content: `纭畾鍒犻櫎<<${element.card.label}>>鍚楋紵`,
@@ -1157,12 +1178,13 @@
         // 鍒犻櫎鎸夐挳鍏冪礌
         let _delActions = _this.state.delActions
         if (element.type === 'action') {
-          _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() {}
@@ -1264,7 +1286,7 @@
    * @description 鏍囩椤典繚瀛�
    */
   submitConfig = () => {
-    const { delActions, originConfig } = this.state
+    const { delActions, thawButtons, originConfig } = this.state
     let config = JSON.parse(JSON.stringify(this.state.config))
 
     this.menuformRef.handleConfirm().then(res => {
@@ -1445,8 +1467,21 @@
             let deffers = delActions.map(item => {
               let _param = {
                 func: 'sPC_MainMenu_Del',
-                MenuID: item
+                MenuID: item.card.uuid
               }
+
+              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)
@@ -1481,6 +1516,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
@@ -2099,6 +2174,85 @@
     })
   }
 
+  /**
+   * @description 瑙e喕鎸夐挳
+   */
+  handleThaw = () => {
+    const { config } = this.state
+
+    this.setState({
+      thawBtnVisible: true
+    })
+
+    Api.getSystemConfig({
+      func: 'sPC_Get_FrozenMenu',
+      ParentID: config.uuid,
+      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
+      })
+    }
+  }
+
   render () {
     const { modaltype } = this.state
     const configAction = this.state.config.action.filter(_action =>
@@ -2172,6 +2326,19 @@
                   {Source.actionItems.map((item, index) => {
                     return (<SourceElement key={index} content={item}/>)
                   })}
+                </div>
+                <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.length > 0 ?
                   <p className="config-btn-title">
@@ -2458,6 +2625,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