From 000ff61dd8a88eb875048e6a3deca8679d75df18 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 29 八月 2020 11:29:33 +0800
Subject: [PATCH] 2020-08-29

---
 src/views/menudesign/index.jsx |  122 +++++++++++++++++++++++++++++++++-------
 1 files changed, 99 insertions(+), 23 deletions(-)

diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index b7569eb..f7c06e1 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -26,14 +26,16 @@
 // const DataSource = asyncComponent(() => import('@/mob/datasource'))
 const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
 
+sessionStorage.setItem('isEditState', 'true')
+
 class Mobile extends Component {
   state = {
     dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     MenuId: this.props.match.params.MenuId,
     tableFields: [],
     activeKey: 'basedata',
+    menuloading: false,
     oriConfig: null,
-    parentId: '',
     openEdition: '',
     config: null,
     editElem: null
@@ -79,7 +81,20 @@
   }
 
   submitConfig = () => {
-    const { config, openEdition, parentId } = this.state
+    const { config, openEdition } = this.state
+
+    if (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId) {
+      notification.warning({
+        top: 92,
+        message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒',
+        duration: 5
+      })
+      return
+    }
+
+    if (config.enabled && this.verifyConfig()) {
+      config.enabled = false
+    }
 
     let _config = fromJS(config).toJS()
     delete _config.fstMenuList
@@ -87,28 +102,36 @@
     delete _config.sysRoles
     delete _config.tableFields
 
+    let funcs = []
+    _config.components.forEach(component => {
+      if (component.setting && component.setting.innerFunc) {
+        funcs.push(`select '${_config.uuid}' as MenuID,'${component.setting.innerFunc}' as ProcName,'${component.setting.name}' as MenuName`)
+      }
+      if (component.action) {
+        component.action.forEach(item => {
+          if (!item.innerFunc) return
+          funcs.push(`select '${_config.uuid}' as MenuID,'${item.innerFunc}' as ProcName,'${item.label}' as MenuName`)
+        })
+      }
+    })
+
     let param = {
       func: 'sPC_TrdMenu_AddUpt',
-      ParentID: parentId,
-      MenuID: config.uuid,
-      MenuNo: config.MenuNo,
-      EasyCode: '',
-      Template: '',
-      MenuName: '',
-      PageParam: '',
+      FstID: _config.fstMenuId,
+      SndID: _config.parentId,
+      ParentID: _config.parentId,
+      MenuID: _config.uuid,
+      MenuNo: _config.MenuNo,
+      EasyCode: _config.easyCode,
+      Template: 'CustomPage',
+      MenuName: _config.MenuName,
+      PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}),
       LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))),
-      // LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`),
-      // LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`),
-      TypeCharOne: 'mob'
+      LText: funcs.join(' union all '),
+      LTexttb: '', // 琛ㄥ悕
     }
 
-    let _LText = ''
-    // _LText = _LText.join(' union all ')
-    let _LTexttb = ''
-    // _LTexttb = _LTexttb.join(' union all ')
-    
-    param.LText = Utils.formatOptions(_LText)
-    param.LTexttb = Utils.formatOptions(_LTexttb)
+    param.LText = Utils.formatOptions(param.LText)
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
     param.secretkey = Utils.encrypt(param.LText, param.timestamp)
 
@@ -116,13 +139,27 @@
       param.open_edition = openEdition
     }
 
+    this.setState({
+      menuloading: true
+    })
+
     Api.getSystemConfig(param).then(response => {
       if (response.status) {
         this.setState({
           oriConfig: fromJS(config).toJS(),
-          openEdition: response.open_edition || ''
+          openEdition: response.open_edition || '',
+          menuloading: false
+        })
+        notification.success({
+          top: 92,
+          message: '淇濆瓨鎴愬姛',
+          duration: 2
         })
       } else {
+        this.setState({
+          openEdition: response.open_edition || '',
+          menuloading: false
+        })
         notification.warning({
           top: 92,
           message: response.message,
@@ -154,6 +191,7 @@
             version: 1.0,
             uuid: this.props.match.params.MenuId,
             MenuID: this.props.match.params.MenuId,
+            parentId: this.props.match.params.ParentId,
             Template: 'CustomPage',
             easyCode: '',
             enabled: false,
@@ -162,7 +200,11 @@
             tables: [],
             components: []
           }
+        } else {
+          config.uuid = this.props.match.params.MenuId
+          config.MenuID = this.props.match.params.MenuId
         }
+
         this.setState({
           oriConfig: config,
           config: fromJS(config).toJS(),
@@ -212,9 +254,9 @@
     })
   }
 
-  initMenuList = (list) => {
+  initMenuList = (msg) => {
     this.setState({
-      config: {...this.state.config, fstMenuList: list}
+      config: {...this.state.config, ...msg}
     })
   }
 
@@ -247,9 +289,43 @@
   onEnabledChange = () => {
     const { config } = this.state
 
+    if (!config.enabled && this.verifyConfig(true)) {
+      return
+    }
+
     this.setState({
       config: {...config, enabled: !config.enabled}
     })
+  }
+
+  verifyConfig = (show) => {
+    const { config } = this.state
+    let error = ''
+
+    if (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId) {
+      notification.warning({
+        top: 92,
+        message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒',
+        duration: 5
+      })
+      return 'false'
+    }
+
+    config.components.forEach(item => {
+      if (!error && (!item.setting || !item.setting.dataresource)) {
+        error = `缁勪欢銆�${item.setting.name}銆嬫湭璁剧疆鏁版嵁婧恅
+      }
+    })
+
+    if (show && error) {
+      notification.warning({
+        top: 92,
+        message: error,
+        duration: 5
+      })
+    }
+
+    return error
   }
 
   // 鏇存柊閰嶇疆淇℃伅
@@ -322,7 +398,7 @@
                   <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{dict['mob.save']}</Button>
                 </div>
               } style={{ width: '100%' }}>
-                {config ? <MenuShell config={config} handleList={this.updateConfig} deleteCard={this.deleteCard} /> : null}
+                {config && config.components ? <MenuShell config={config} handleList={this.updateConfig} deleteCard={this.deleteCard} /> : null}
               </Card>
             </div>
           </div>

--
Gitblit v1.8.0