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/pcdesign/index.jsx |  144 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 113 insertions(+), 31 deletions(-)

diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx
index b54bdbc..84fd928 100644
--- a/src/views/pcdesign/index.jsx
+++ b/src/views/pcdesign/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, Icon, message, Spin } from 'antd'
+import { ConfigProvider, notification, Modal, Collapse, Switch, Button, Icon, message, Spin, Typography } from 'antd'
 
 import Api from '@/api'
 import Utils, { setGLOBFuncs } from '@/utils/utils.js'
@@ -21,10 +21,12 @@
 
 const { Panel } = Collapse
 const { confirm } = Modal
+const { Paragraph } = Typography
 
 const MenuForm = asyncComponent(() => import('./menuform'))
 const Transfer = asyncComponent(() => import('@/pc/transfer'))
 const PopviewController = asyncComponent(() => import('@/menu/popview'))
+const Versions = asyncComponent(() => import('@/menu/versions'))
 const MenuShell = asyncComponent(() => import('@/pc/menushell'))
 const SourceWrap = asyncComponent(() => import('@/pc/modulesource'))
 const CreateView = asyncComponent(() => import('@/pc/createview'))
@@ -91,7 +93,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') {
         this.setState({
           MenuId: param.MenuID
@@ -99,7 +101,7 @@
           this.getMenuParam(param)
         })
       }
-    } catch {
+    } catch (e) {
       notification.warning({
         top: 92,
         message: '鑿滃崟淇℃伅瑙f瀽閿欒锛�',
@@ -193,7 +195,7 @@
     this.props.history.push('/pcdesign/' + param)
   }
 
-  getAppMessage = () => {
+  getAppMessage = (MenuID) => {
     Api.getSystemConfig({
       func: 's_get_keyids',
       bid: sessionStorage.getItem('appId')
@@ -207,9 +209,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') {
@@ -325,6 +327,23 @@
       }).then(res => {
         if (res.status) {
           sessionStorage.setItem('app_videos', JSON.stringify(res.data || []))
+        } else if (!res.status) {
+          notification.warning({
+            top: 92,
+            message: res.message,
+            duration: 5
+          })
+        }
+      })
+      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 || []))
         } else if (!res.status) {
           notification.warning({
             top: 92,
@@ -633,6 +652,7 @@
         }
       } else {
         config.components = MenuUtils.resetConfig(config.components)
+        config.enabled = false
         message.success('澶嶅埗鎴愬姛锛屼繚瀛樺悗鐢熸晥銆�')
       }
       
@@ -747,7 +767,7 @@
           title: item.name,
           children: []
         }
-        if (item.type === 'login') {
+        if (item.type === 'login' || item.type === 'navbar') {
           return null
         } else if (item.type === 'tabs') {
           let tabs = []
@@ -847,7 +867,7 @@
               title: m.setting.title
             }
           })
-        } else if (item.type === 'table' && item.subtype === 'normaltable') {
+        } else if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
           item.action && item.action.forEach(btn => {
             this.checkBtn(btn)
             m.children.push({
@@ -886,6 +906,10 @@
     nodes.children = trees
     nodes.popviews = popviews
 
+    if (config.components.findIndex(item => item.type === 'login') > -1) {
+      nodes.login = true
+    }
+
     return nodes
   }
 
@@ -907,23 +931,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 = () => {
@@ -949,8 +956,6 @@
     })
 
     setTimeout(() => {
-      config.components = this.filterConfig(config.components)
-
       if (config.enabled && this.verifyConfig()) {
         config.enabled = false
       }
@@ -1239,7 +1244,9 @@
 
                 Api.getSystemConfig({
                   func: 'sPC_Get_LongParam',
-                  MenuID: item.$originUuid
+                  MenuID: item.$originUuid,
+                  TypeCharOne: sessionStorage.getItem('kei_no'),
+                  typename: 'pc',
                 }).then(result => {
                   if (result.status) {
                     let _conf = ''
@@ -1256,6 +1263,7 @@
                       _conf.uuid = item.uuid
                       _conf.MenuID = item.uuid
                       _conf.Template = 'webPage'
+                      _conf.enabled = false
                     } else {
                       resolve({
                         status: true
@@ -1271,7 +1279,9 @@
                       Template: 'webPage',
                       MenuName: item.label,
                       PageParam: JSON.stringify({Template: 'webPage'}),
-                      LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_conf)))
+                      LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_conf))),
+                      TypeCharOne: sessionStorage.getItem('kei_no'),
+                      Typename: 'pc',
                     }
             
                     Api.getSystemConfig(_param).then(response => {
@@ -1397,6 +1407,8 @@
             error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒`
           } else if (!item.setting.primaryKey) {
             error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣
+          } else if (!item.setting.supModule) {
+            error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婄骇缁勪欢锛乣
           }
         }
         if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') {
@@ -1455,6 +1467,12 @@
 
     this.setState({config})
     window.GLOB.customMenu = config
+
+    notification.success({
+      top: 92,
+      message: '绮樿创鎴愬姛锛�',
+      duration: 2
+    })
   }
 
   refreshView = () => {
@@ -1536,6 +1554,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() {}
+    })
+  }
+
   render () {
     const { localedict, loading, visible, popBtn, comloading, activeKey, settingshow, controlshow, dict, MenuId, config, menuloading, customComponents } = this.state
 
@@ -1563,6 +1642,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">
@@ -1586,15 +1666,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