From 95afd40fc2741ac0ce59c2091f6cfce1f98877d4 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 24 六月 2021 09:15:45 +0800
Subject: [PATCH] 2021-06-24

---
 src/views/pcdesign/index.jsx |  184 +++++++++++++++++++++++++++++++---------------
 1 files changed, 124 insertions(+), 60 deletions(-)

diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx
index a6c55e8..584f7b0 100644
--- a/src/views/pcdesign/index.jsx
+++ b/src/views/pcdesign/index.jsx
@@ -8,7 +8,7 @@
 import { ConfigProvider, notification, Modal, Collapse, Switch, Button, Icon, message, Spin } from 'antd'
 
 import Api from '@/api'
-import Utils from '@/utils/utils.js'
+import Utils, { setGLOBFuncs } from '@/utils/utils.js'
 import zhCN from '@/locales/zh-CN/mob.js'
 import enUS from '@/locales/en-US/mob.js'
 import antdEnUS from 'antd/es/locale/en_US'
@@ -16,7 +16,6 @@
 import MKEmitter from '@/utils/events.js'
 import MenuUtils from '@/utils/utils-custom.js'
 import asyncComponent from '@/utils/asyncComponent'
-import { modifyCustomMenu } from '@/store/action'
 
 import './index.scss'
 
@@ -26,11 +25,13 @@
 const MenuForm = asyncComponent(() => import('./menuform'))
 const MenuShell = asyncComponent(() => import('@/pc/menushell'))
 const SourceWrap = asyncComponent(() => import('@/pc/modulesource'))
+const CreateView = asyncComponent(() => import('@/pc/createview'))
 const BgController = asyncComponent(() => import('@/pc/bgcontroller'))
 const Quotecomponent = asyncComponent(() => import('@/pc/quotecomponent'))
 const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
 const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
 const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
+const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent'))
 const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
 const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
 const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller'))
@@ -40,9 +41,12 @@
 sessionStorage.setItem('isEditState', 'true')
 sessionStorage.setItem('editMenuType', 'menu') // 缂栬緫鑿滃崟绫诲瀷
 sessionStorage.setItem('appType', 'pc')        // 搴旂敤绫诲瀷
+sessionStorage.setItem('typename', 'pc')
 document.body.className = ''
 window.GLOB.UserComponentMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夌粍浠�
 window.GLOB.CacheIndependent = new Map()
+window.GLOB.urlFields = []               // url鍙橀噺
+window.GLOB.customMenu = null            // 淇濆瓨鑿滃崟淇℃伅
 
 class MenuDesign extends Component {
   state = {
@@ -75,7 +79,6 @@
         sessionStorage.setItem('appId', param.ID || '')
         sessionStorage.setItem('lang', param.lang || 'zh-CN')
         sessionStorage.setItem('kei_no', param.kei_no || '')
-        sessionStorage.setItem('link_type', param.link_type || 'true')
         sessionStorage.setItem('role_type', param.role_type || 'true')
         sessionStorage.setItem('login_types', param.login_types || 'true')
 
@@ -125,6 +128,8 @@
     setTimeout(() => {
       this.updateCustomComponent()
       this.getAppPictures()
+      this.getSmStemp()
+      setGLOBFuncs()
     }, 1000)
   }
 
@@ -162,11 +167,8 @@
       type: 'view'
     }
 
-    if (menu.fixed && menu.MenuNo && menu.MenuName) {
-      param.fixed = true
-      param.MenuNo = menu.MenuNo
-      param.MenuName = menu.MenuName
-    }
+    param.MenuNo = menu.MenuNo || ''
+    param.MenuName = menu.MenuName || ''
 
     param = window.btoa(window.encodeURIComponent(JSON.stringify(param)))
 
@@ -247,6 +249,39 @@
     })
   }
 
+  getSmStemp = () => {
+    let _sql = `select ID,TemplateCode,SignName from (select * from bd_msn_sms_temp where deleted=0 and status=20 ) a 
+      inner join (select openid from sapp where id='${window.GLOB.appkey}') b
+      on a.openid=b.openid`
+
+    _sql = Utils.formatOptions(_sql)
+
+    let param = {
+      func: 'sPC_Get_SelectedList',
+      LText: _sql,
+      obj_name: 'data',
+      arr_field: 'ID,TemplateCode,SignName'
+    }
+    
+    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+    param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉
+    
+    Api.getSystemConfig(param).then(res => {
+      let msgs = []
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+      } else if (res.data) {
+        msgs = res.data
+      }
+      sessionStorage.setItem('msgTemplate', JSON.stringify(msgs))
+    })
+  }
+
   getAppPictures = () => {
     if (sessionStorage.getItem('app_videos') || sessionStorage.getItem('app_pictures')) return
 
@@ -259,6 +294,12 @@
     }).then(res => {
       if (res.status) {
         sessionStorage.setItem('app_pictures', JSON.stringify(res.data || []))
+      } else if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
       }
 
       Api.getSystemConfig({
@@ -270,6 +311,12 @@
       }).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
+          })
         }
       })
     })
@@ -278,10 +325,17 @@
   updateCustomComponent = () => {
     Api.getSystemConfig({
       func: 's_get_custom_components',
+      typename: 'pc',
       typecharone: ''
     }).then(res => {
       let coms = []
-      if (res.cus_list && res.cus_list.length > 0) {
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+      } else if (res.cus_list && res.cus_list.length > 0) {
         res.cus_list.forEach(item => {
           let config = ''
 
@@ -432,8 +486,8 @@
             MenuID: MenuId,
             Template: 'webPage',
             enabled: false,
-            MenuName: '',
-            MenuNo: '',
+            MenuName: urlParam.MenuName || '',
+            MenuNo: urlParam.MenuNo || '',
             tables: [],
             components: [],
             viewType: 'menu',
@@ -446,12 +500,7 @@
         config.uuid = MenuId
         config.MenuID = MenuId
         config.open_edition = result.open_edition || ''
-
-        if (urlParam.fixed) {
-          config.fixed = true
-          config.MenuName = urlParam.MenuName
-          config.MenuNo = urlParam.MenuNo
-        }
+        window.GLOB.urlFields = config.urlFields || []
 
         let indeComs = []
         config.components.forEach(item => {
@@ -466,8 +515,8 @@
             config: fromJS(config).toJS(),
             loading: false
           })
-  
-          this.props.modifyCustomMenu(config)
+
+          window.GLOB.customMenu = config
         } else {
           this.jointComponents(config, indeComs, isCreate)
         }
@@ -567,6 +616,8 @@
       config.uuid = MenuId
       config.MenuID = MenuId
       config.open_edition = ''
+      config.MenuName = urlParam.MenuName || ''
+      config.MenuNo = urlParam.MenuNo || ''
 
       let indeComs = []
       config.components.forEach(item => {
@@ -581,8 +632,7 @@
           config: fromJS(config).toJS(),
           loading: false
         })
-
-        this.props.modifyCustomMenu(config)
+        window.GLOB.customMenu = config
       } else {
         this.jointComponents(config, indeComs, true)
       }
@@ -658,7 +708,7 @@
         loading: false
       })
 
-      this.props.modifyCustomMenu(config)
+      window.GLOB.customMenu = config
     })
   }
 
@@ -867,7 +917,7 @@
                 SndID: parMenuId,
                 ParentID: parMenuId,
                 MenuID: item.uuid,
-                MenuNo: item.wrap.MenuNo || '',
+                MenuNo: item.wrap.MenuNo || Utils.getuuid(),
                 EasyCode: '',
                 Template: item.type,
                 TypeCharOne: sessionStorage.getItem('kei_no'),
@@ -993,21 +1043,21 @@
             })
 
             if (appViewList.length > _length) {
-              let param = {
+              let kparam = {
                 func: 's_kei_link_keyids_addupt',
                 BID: sessionStorage.getItem('appId'),
                 exec_type: 'y',
                 LText: ''
               }
     
-              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)
+              kparam.LText = appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
+              kparam.LText = kparam.LText.join(' union all ')
+              kparam.LText = Utils.formatOptions(kparam.LText)
         
-              param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-              param.secretkey = Utils.encrypt('', param.timestamp)
+              kparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+              kparam.secretkey = Utils.encrypt('', kparam.timestamp)
     
-              Api.getSystemConfig(param).then(result => {
+              Api.getSystemConfig(kparam).then(result => {
                 if (!result.status) {
                   notification.warning({
                     top: 92,
@@ -1266,25 +1316,44 @@
     const { config } = this.state
     let error = ''
 
-    config.components.forEach(item => {
-      if (error) return
-      if (['propcard', 'brafteditor', 'sandbox'].includes(item.subtype) && item.wrap.datatype === 'static') return
+    let check = (components) => {
+      components.forEach(item => {
+        if (error) return
+        if (item.type === 'tabs') {
+          item.subtabs.forEach(tab => {
+            check(tab.components)
+          })
+          return
+        } else if (item.type === 'group') {
+          check(item.components)
+          return
+        }
+        if (['propcard', 'brafteditor', 'sandbox', 'stepform'].includes(item.subtype) && item.wrap.datatype === 'static') return
+  
+        if (item.setting) {
+          if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) {
+            error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒`
+          } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) {
+            error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒`
+          } else if (!item.setting.primaryKey) {
+            error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣
+          }
+        }
+        if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') {
+          if (!item.plot.Xaxis) {
+            error = `缁勪欢銆�${item.name}銆嬪浘琛ㄥ瓧娈靛皻鏈缃紒`
+          }
+        } else if (item.type === 'dashboard' && !item.plot.valueField) {
+          error = `缁勪欢銆�${item.name}銆嬫樉绀哄�煎皻鏈缃紒`
+        } else if (item.type === 'scatter' && (!item.plot.Xaxis || !item.plot.Yaxis || !item.plot.gender)) {
+          error = `缁勪欢銆�${item.name}銆嬪潗鏍囪酱灏氭湭璁剧疆锛乣
+        } else if (item.type === 'tree' && (!item.wrap.valueField || !item.wrap.labelField || !item.wrap.parentField)) {
+          error = `缁勪欢銆�${item.name}銆嬪熀鏈俊鎭皻鏈缃紒`
+        }
+      })
+    }
 
-      if (item.setting) {
-        if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) {
-          error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒`
-        } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) {
-          error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒`
-        } else if (item.setting.interType && !item.setting.primaryKey) {
-          error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣
-        }
-      }
-      if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') {
-        if (!item.plot.Xaxis) {
-          error = `缁勪欢銆�${item.name}銆嬪浘琛ㄥ瓧娈靛皻鏈缃紒`
-        }
-      }
-    })
+    check(config.components)
 
     if (show && error) {
       notification.warning({
@@ -1303,7 +1372,7 @@
       config: config
     })
 
-    this.props.modifyCustomMenu(config)
+    window.GLOB.customMenu = config
   }
 
   insert = (item) => {
@@ -1312,7 +1381,7 @@
     config.components.push(item)
 
     this.setState({config})
-    this.props.modifyCustomMenu(config)
+    window.GLOB.customMenu = config
   }
 
   refreshView = () => {
@@ -1326,11 +1395,6 @@
       })
       return
     }
-
-    // Api.getSystemConfig({
-    //   func: 'sPC_MainMenu_Del',
-    //   MenuID: '1614740497468ku800sbg853vupf65v4'
-    // })
 
     sessionStorage.removeItem('sysRoles')
     sessionStorage.removeItem('permFuncField')
@@ -1424,6 +1488,7 @@
                       MenuId={MenuId}
                       updateConfig={this.updateConfig}
                     /> : null}
+                    {config ? <UrlFieldComponent config={config} updateConfig={this.updateConfig}/> : null}
                     {/* 琛ㄥ悕娣诲姞 */}
                     {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null}
                   </Panel>
@@ -1447,6 +1512,7 @@
               </div>
               <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} />
               <StyleCombControlButton menu={config} />
               <SysInterface config={config} updateConfig={this.updateConfig}/>
@@ -1454,7 +1520,7 @@
               <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 type="default" onClick={this.closeView}>{dict['mob.return']}</Button>
+              <Button type="default" onClick={this.closeView}>鍏抽棴</Button>
             </div>
             <div className={'menu-body ' + (menuloading ? 'saving' : '')}>
               {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null}
@@ -1475,10 +1541,8 @@
   }
 }
 
-const mapDispatchToProps = (dispatch) => {
-  return {
-    modifyCustomMenu: (customMenu) => dispatch(modifyCustomMenu(customMenu))
-  }
+const mapDispatchToProps = () => {
+  return {}
 }
 
 export default withRouter(connect(mapStateToProps, mapDispatchToProps)(MenuDesign))
\ No newline at end of file

--
Gitblit v1.8.0