From 1da6506bf58270bacc2a4345002c6b082835580e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 21 十月 2021 23:17:08 +0800
Subject: [PATCH] 2021-10-21

---
 src/views/mobdesign/index.jsx |  138 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 109 insertions(+), 29 deletions(-)

diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index 762e998..92afeab 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -5,7 +5,7 @@
 import { is, fromJS } from 'immutable'
 import moment from 'moment'
 import HTML5Backend from 'react-dnd-html5-backend'
-import { ConfigProvider, notification, Modal, Collapse, Switch, Button, message, Spin, Icon } from 'antd'
+import { ConfigProvider, notification, Modal, Collapse, Switch, Button, message, Spin, Icon, Typography } from 'antd'
 
 import Api from '@/api'
 import Utils, { setGLOBFuncs } from '@/utils/utils.js'
@@ -21,12 +21,14 @@
 
 const { Panel } = Collapse
 const { confirm } = Modal
+const { Paragraph } = Typography
 
 const Header = asyncComponent(() => import('@/mob/header'))
 const MenuForm = asyncComponent(() => import('./menuform'))
 const MobShell = asyncComponent(() => import('@/mob/mobshell'))
 const CreateView = asyncComponent(() => import('@/pc/createview'))
 const Transfer = asyncComponent(() => import('@/pc/transfer'))
+const Versions = asyncComponent(() => import('@/menu/versions'))
 const SourceWrap = asyncComponent(() => import('@/mob/modulesource'))
 const BgController = asyncComponent(() => import('@/pc/bgcontroller'))
 const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
@@ -88,7 +90,7 @@
           localedict: sessionStorage.getItem('lang') !== 'en-US' ? antdZhCN : antdEnUS,
           dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
         })
-        this.getAppMessage()
+        this.getAppMessage(param.MenuID)
       } else if (param.type === 'view') {
         window.GLOB.winWidth = 420
         window.GLOB.winHeight = 738
@@ -108,7 +110,7 @@
           this.getMenuParam(param)
         })
       }
-    } catch {
+    } catch (e) {
       notification.warning({
         top: 92,
         message: '鑿滃崟淇℃伅瑙f瀽閿欒锛�',
@@ -218,7 +220,7 @@
     this.props.history.push('/mobdesign/' + param)
   }
 
-  getAppMessage = () => {
+  getAppMessage = (MenuID) => {
     Api.getSystemConfig({
       func: 's_get_keyids',
       bid: sessionStorage.getItem('appId')
@@ -232,9 +234,9 @@
         return
       }
 
-      let homeId = ''
+      let homeId = MenuID || ''
       let appViewList = []
-      if (res.data && res.data.length > 0) {
+      if (!homeId && res.data && res.data.length > 0) {
         appViewList = res.data
         appViewList.forEach(item => {
           if (item.keys_type === 'index') {
@@ -311,6 +313,17 @@
       }).then(res => {
         if (res.status) {
           sessionStorage.setItem('app_videos', JSON.stringify(res.data || []))
+        }
+      })
+      Api.getSystemConfig({
+        func: 's_url_db_adduptdel',
+        PageIndex: 0,  // 0 浠h〃鍏ㄩ儴
+        PageSize: 0,   // 0 浠h〃鍏ㄩ儴
+        typecharone: 'color',
+        type: 'search'
+      }).then(res => {
+        if (res.status) {
+          sessionStorage.setItem('app_colors', JSON.stringify(res.data || []))
         }
       })
     })
@@ -567,6 +580,7 @@
         }
       } else {
         config.components = MenuUtils.resetConfig(config.components)
+        config.enabled = false
         message.success('澶嶅埗鎴愬姛锛屼繚瀛樺悗鐢熸晥銆�')
       }
       
@@ -681,7 +695,7 @@
           children: []
         }
 
-        if (item.type === 'topbar' || item.type === 'login') {
+        if (item.type === 'topbar' || item.type === 'login' || item.type === 'navbar') {
           return null
         } else if (item.type === 'tabs') {
           let tabs = []
@@ -819,23 +833,6 @@
     }
   }
 
-  filterConfig = (components) => {
-    return components.map(item => {
-      if (item.type === 'tabs') {
-        item.subtabs.forEach(tab => {
-          tab.components = this.filterConfig(tab.components)
-        })
-      } else if (item.type === 'group') {
-        item.components = this.filterConfig(item.components)
-      } else if (item.type === 'table' && item.subtype === 'normaltable') {
-        item.search = item.search.filter(a => !a.origin)
-        item.action = item.action.filter(a => !a.origin)
-        item.cols = item.cols.filter(a => !a.origin)
-      }
-      return item
-    })
-  }
-
   submitConfig = () => {
     let config = fromJS(this.state.config).toJS()
 
@@ -857,14 +854,16 @@
     })
 
     setTimeout(() => {
-      config.components = this.filterConfig(config.components)
-
       if (config.enabled && this.verifyConfig()) {
         config.enabled = false
       }
 
       let roleParam = {type: 'view', key: config.uuid, title: config.MenuName, children: []}
       roleParam.children = this.getMenuMessage()
+
+      if (config.components.findIndex(item => item.type === 'login') > -1) {
+        roleParam.login = true
+      }
 
       let param = {
         func: 'sPC_TrdMenu_AddUpt',
@@ -944,7 +943,7 @@
                 Typename: sessionStorage.getItem('typename'),
                 MenuName: item.name || '',
                 PageParam: JSON.stringify({Template: item.type}),
-                open_edition: item.open_edition || '',
+                open_edition: _item.open_edition || '',
                 menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roles))),
                 LText: '',
                 LTexttb: ''
@@ -1144,6 +1143,8 @@
             error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒`
           } else if (!item.setting.primaryKey) {
             error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣
+          } else if (!item.setting.supModule && item.type !== 'navbar') {
+            error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婄骇缁勪欢锛乣
           }
         }
         if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') {
@@ -1183,10 +1184,25 @@
   insert = (item) => {
     let config = fromJS(this.state.config).toJS()
 
+    if (item.type === 'topbar' && config.components.findIndex(m => m.type === 'topbar') > -1) {
+      notification.warning({
+        top: 92,
+        message: '瀵艰埅鏍忎笉鍙噸澶嶆坊鍔狅紒',
+        duration: 5
+      })
+      return
+    }
+
     config.components.push(item)
 
     this.setState({config})
     window.GLOB.customMenu = config
+
+    notification.success({
+      top: 92,
+      message: '绮樿创鎴愬姛锛�',
+      duration: 2
+    })
   }
 
   refreshView = () => {
@@ -1268,6 +1284,67 @@
     })
   }
 
+  setLoginView = () => {
+    const { oriConfig, config } = this.state
+
+    if (!oriConfig || !is(fromJS(oriConfig), fromJS(config))) {
+      notification.warning({
+        top: 92,
+        message: '閰嶇疆淇℃伅鏈繚瀛橈紒',
+        duration: 5
+      })
+      return
+    }
+
+    let param = {
+      func: 's_kei_link_keyids_addupt',
+      BID: sessionStorage.getItem('appId'),
+      exec_type: 'y',
+      LText: ''
+    }
+
+    let appViewList = sessionStorage.getItem('appViewList')
+    appViewList = appViewList ? JSON.parse(appViewList) : []
+    appViewList = appViewList.filter(item => item.keys_type !== 'login')
+
+    appViewList.unshift({
+      appkey: window.GLOB.appkey || '',
+      bid: sessionStorage.getItem('appId') || '',
+      kei_no: sessionStorage.getItem('kei_no') || '',
+      keys_id: config.MenuID,
+      keys_type: 'login',
+      remark: config.MenuName
+    })
+
+    param.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
+    param.LText = param.LText.join(' union all ')
+    param.LText = Utils.formatOptions(param.LText)
+
+    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    param.secretkey = Utils.encrypt('', param.timestamp)
+
+    let hasLogin = config.components.findIndex(item => item.type === 'login') > -1
+
+    confirm({
+      title: '纭畾璁剧疆鏈〉闈负鐧诲綍椤靛悧锛�',
+      content: hasLogin ? '' : '褰撳墠椤甸潰灏氭湭娣诲姞鐧诲綍缁勪欢銆�',
+      onOk() {
+        Api.getSystemConfig(param).then(result => {
+          if (!result.status) {
+            notification.warning({
+              top: 92,
+              message: result.message,
+              duration: 5
+            })
+          } else {
+            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
+          }
+        })
+      },
+      onCancel() {}
+    })
+  }
+
   changeView = (val) => {
     if (val !== 'vertical') {
       window.GLOB.winWidth = 992
@@ -1331,6 +1408,7 @@
                     {config ? <UrlFieldComponent config={config} updateConfig={this.updateConfig}/> : null}
                     {/* 琛ㄥ悕娣诲姞 */}
                     {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null}
+                    {config ? <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>鑿滃崟ID</Paragraph> : null}
                   </Panel>
                   {/* 缁勪欢娣诲姞 */}
                   <Panel header={dict['mob.component']} key="component">
@@ -1354,15 +1432,17 @@
                 <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
                 <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config && config.enabled} onChange={this.onEnabledChange} />
                 <CreateView resetmenu={this.getAppMenus} />
-                <PasteController type="menu" Tab={null} insert={this.insert} />
+                <PasteController insert={this.insert} />
                 <StyleCombControlButton menu={config} />
                 <SysInterface config={config} updateConfig={this.updateConfig}/>
                 <PictureController/>
                 <Quotecomponent config={config} updateConfig={this.updateConfig}/>
                 <Button className="mk-border-green" icon="home" onClick={this.setHomeView}>璁句负棣栭〉</Button>
-                <Button className="mk-border-danger" icon="redo" onClick={this.refreshView}>寮哄埗鍒锋柊</Button>
+                <Button className="mk-border-purple" icon="login" onClick={this.setLoginView}>璁句负鐧诲綍椤�</Button>
                 <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                 <Transfer MenuID={MenuId} />
+                <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/>
+                <Button className="mk-border-danger" icon="redo" onClick={this.refreshView}>寮哄埗鍒锋柊</Button>
                 <Button type="default" onClick={this.closeView}>鍏抽棴</Button>
               </div>
             </div>

--
Gitblit v1.8.0