From c8804ceb1fe2dea76f9949c5ea04423876ee2c81 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 28 六月 2024 14:02:47 +0800
Subject: [PATCH] 2024-06-28

---
 src/views/pcdesign/index.jsx |  126 +++++++++++++++++++++++++++++------------
 1 files changed, 88 insertions(+), 38 deletions(-)

diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx
index 51d198e..d998c92 100644
--- a/src/views/pcdesign/index.jsx
+++ b/src/views/pcdesign/index.jsx
@@ -3,15 +3,14 @@
 import { withRouter } from 'react-router'
 import { is, fromJS } from 'immutable'
 import HTML5Backend from 'react-dnd-html5-backend'
-import { ConfigProvider, notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd'
+import { notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd'
 import { DoubleLeftOutlined, DoubleRightOutlined, HomeOutlined, LoginOutlined, ArrowLeftOutlined, EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'
 import moment from 'moment'
 import md5 from 'md5'
 
 import Api from '@/api'
 import Utils, { setGLOBFuncs } from '@/utils/utils.js'
-import { getTables, getFuncsAndInters } from '@/utils/utils-custom.js'
-import antdZhCN from 'antd/es/locale/zh_CN'
+import { getTables, getFuncsAndInters, getLangTrans } from '@/utils/utils-custom.js'
 import MKEmitter from '@/utils/events.js'
 import MenuUtils from '@/utils/utils-custom.js'
 import asyncComponent from '@/utils/asyncComponent'
@@ -100,12 +99,25 @@
     try {
       let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
 
+      if (param.lang) {
+        sessionStorage.setItem('lang', param.lang)
+      }
+
       if (param.type === 'app') {
         sessionStorage.setItem('appId', param.ID || '')
         sessionStorage.setItem('appName', param.remark || '')
-        sessionStorage.setItem('lang', param.lang || 'zh-CN')
         sessionStorage.setItem('kei_no', param.kei_no || '')
         sessionStorage.setItem('sysBgColor', param.sysBgColor || '#ffffff')
+
+        if (param.applangList) {
+          sessionStorage.setItem('applangList', param.applangList)
+        } else {
+          sessionStorage.removeItem('applangList')
+        }
+
+        if (param.wxAppId) {
+          sessionStorage.setItem('wxAppId', param.wxAppId)
+        }
 
         this.getAppMessage(param.MenuID)
       } else if (param.type === 'view') {
@@ -143,6 +155,10 @@
     MKEmitter.addListener('changePopview', this.initPopview)
     MKEmitter.addListener('changeEditMenu', this.changeEditMenu)
     MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave)
+
+    if (sessionStorage.getItem('wxAppId')) {
+      window.GLOB.WXAppID = sessionStorage.getItem('wxAppId')
+    }
 
     setTimeout(() => {
       this.getRoleFields()
@@ -240,7 +256,8 @@
       MenuID: menu.MenuID,
       copyMenuId: menu.copyMenuId || '',
       clearMenu: menu.clearMenu !== 'false',
-      type: 'view'
+      type: 'view',
+      lang: sessionStorage.getItem('lang')
     }
 
     // param.MenuNo = menu.MenuNo || ''
@@ -287,7 +304,7 @@
         let param = {
           func: 's_kei_link_keyids_addupt',
           BID: sessionStorage.getItem('appId'),
-          exec_type: 'y',
+          exec_type: 'x',
           LText: ''
         }
 
@@ -302,7 +319,7 @@
 
         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.LText = Utils.formatOptions(param.LText, 'x')
   
         param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
         param.secretkey = Utils.encrypt('', param.timestamp)
@@ -316,12 +333,12 @@
             })
           } else {
             sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
-            this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view'}))))
+            this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view', lang: sessionStorage.getItem('lang')}))))
           }
         })
       } else {
         sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
-        this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: MenuID || homeId, type: 'view'}))))
+        this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: MenuID || homeId, type: 'view', lang: sessionStorage.getItem('lang')}))))
       }
     })
   }
@@ -531,6 +548,7 @@
 
         config.uuid = MenuId
         config.MenuID = MenuId
+        config.Template = 'webPage'
         config.open_edition = result.open_edition || ''
         window.GLOB.urlFields = config.urlFields || []
 
@@ -737,6 +755,7 @@
       
       config.uuid = MenuId
       config.MenuID = MenuId
+      config.Template = 'webPage'
       config.open_edition = ''
       config.MenuName = urlParam.MenuName || ''
       config.MenuNo = ''
@@ -875,7 +894,7 @@
           return
         } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
           item.action && item.action.forEach(btn => {
-            if (btn.hidden === 'true') return
+            if (btn.hidden === 'true' || btn.permission === 'false') return
 
             m.children.push({
               key: btn.uuid,
@@ -884,7 +903,7 @@
           })
           item.subcards.forEach(card => {
             card.elements && card.elements.forEach(cell => {
-              if (cell.eleType !== 'button' || cell.hidden === 'true') return
+              if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
 
               m.children.push({
                 key: cell.uuid,
@@ -893,7 +912,7 @@
             })
 
             card.backElements && card.backElements.forEach(cell => {
-              if (cell.eleType !== 'button' || cell.hidden === 'true') return
+              if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
 
               m.children.push({
                 key: cell.uuid,
@@ -903,7 +922,7 @@
           })
         } else if (item.type === 'balcony') {
           item.elements && item.elements.forEach(cell => {
-            if (cell.eleType !== 'button' || cell.hidden === 'true') return
+            if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
 
             m.children.push({
               key: cell.uuid,
@@ -921,7 +940,7 @@
           }
         } else if (item.type === 'table') {
           item.action.forEach(btn => {
-            if (btn.hidden === 'true') return
+            if (btn.hidden === 'true' || btn.permission === 'false') return
 
             m.children.push({
               key: btn.uuid,
@@ -934,7 +953,7 @@
                 loopCol(col.subcols)
               } else if (col.type === 'custom') {
                 col.elements.forEach(cell => {
-                  if (cell.eleType !== 'button' || cell.hidden === 'true') return
+                  if (cell.eleType !== 'button' || cell.hidden === 'true' || cell.permission === 'false') return
                   m.children.push({
                     key: cell.uuid,
                     title: cell.label,
@@ -1138,6 +1157,18 @@
 
     if (!this.checkBase()) {
       return
+    } else if (this.checklog()) {
+      if (sessionStorage.getItem('applangList') && !config.trans) {
+
+      } else {
+        notification.success({
+          top: 92,
+          message: '褰撳墠閰嶇疆鏈慨鏀癸紝鏃犻渶淇濆瓨銆�',
+          duration: 5
+        })
+        MKEmitter.emit('completeSave')
+        return
+      }
     }
 
     this.setState({
@@ -1206,6 +1237,7 @@
 
       let interfaces = getFuncsAndInters(config)
       roleParam.interfaces = interfaces
+      let langSql = getLangTrans(config)
 
       let param = {
         func: 'sPC_TrdMenu_AddUpt',
@@ -1222,12 +1254,16 @@
         PageParam: JSON.stringify({Template: 'webPage', interfaces}),
         menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))),
         open_edition: config.open_edition,
-        LText: '',
-        LTexttb: '',
+        // LText: '',
+        // LTexttb: '',
         menus_used_list,
         debug_md5: key,
         debug_url: url,
         debug_list: window.btoa(tbs)
+      }
+
+      if (langSql) {
+        param.lang_translation = window.btoa(window.encodeURIComponent(langSql))
       }
 
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -1308,8 +1344,8 @@
               PageParam: JSON.stringify({Template: NavBar.type}),
               menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roles))),
               open_edition: NavBar.open_edition,
-              LText: '',
-              LTexttb: ''
+              // LText: '',
+              // LTexttb: ''
             }
 
             _param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(NavBar)))
@@ -1350,13 +1386,13 @@
                   let kparam = {
                     func: 's_kei_link_keyids_addupt',
                     BID: sessionStorage.getItem('appId'),
-                    exec_type: 'y',
+                    exec_type: 'x',
                     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)
+                  kparam.LText = Utils.formatOptions(kparam.LText, 'x')
             
                   kparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
                   kparam.secretkey = Utils.encrypt('', kparam.timestamp)
@@ -1405,10 +1441,10 @@
             duration: 2
           })
         } else {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 5
+          Modal.warning({
+            width: 400,
+            title: res.message,
+            okText: '鐭ラ亾浜�'
           })
         }
         MKEmitter.emit('completeSave')
@@ -1548,12 +1584,6 @@
 
     this.setState({config})
     window.GLOB.customMenu = config
-
-    notification.success({
-      top: 92,
-      message: '绮樿创鎴愬姛锛�',
-      duration: 2
-    })
   }
 
   setHomeView = () => {
@@ -1571,7 +1601,7 @@
     let param = {
       func: 's_kei_link_keyids_addupt',
       BID: sessionStorage.getItem('appId'),
-      exec_type: 'y',
+      exec_type: 'x',
       LText: ''
     }
 
@@ -1590,7 +1620,7 @@
 
     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.LText = Utils.formatOptions(param.LText, 'x')
 
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     param.secretkey = Utils.encrypt('', param.timestamp)
@@ -1630,7 +1660,7 @@
     let param = {
       func: 's_kei_link_keyids_addupt',
       BID: sessionStorage.getItem('appId'),
-      exec_type: 'y',
+      exec_type: 'x',
       LText: ''
     }
 
@@ -1649,7 +1679,7 @@
 
     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.LText = Utils.formatOptions(param.LText, 'x')
 
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     param.secretkey = Utils.encrypt('', param.timestamp)
@@ -1676,11 +1706,31 @@
     })
   }
 
+  checklog = () => {
+    const { oriConfig, config } = this.state
+
+    return is(fromJS(oriConfig), fromJS(config))
+  }
+
+  updateLogConfig = (config) => {
+    config.open_edition = this.state.config.open_edition || ''
+    
+    this.setState({
+      config: null
+    }, () => {
+      this.setState({
+        config: config
+      })
+    })
+    
+    window.GLOB.customMenu = config
+  }
+
   render () {
     const { view, loading, comloading, activeKey, settingshow, controlshow, MenuId, config, menuloading, eyeopen, needUpdate } = this.state
 
     return (
-      <ConfigProvider locale={antdZhCN}>
+      <>
         <DndProvider backend={HTML5Backend}>
           {view !== 'popview' ? <div className={'mk-pc-view '} id="mk-pc-design-view">
             {loading ? <Spin className="view-spin" size="large" /> : null}
@@ -1742,7 +1792,7 @@
                 <Button className="mk-border-purple" onClick={this.setLoginView}><LoginOutlined/> 璁句负鐧诲綍椤�</Button>
                 <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                 <Transfer MenuID={MenuId} />
-                <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/>
+                {config ? <Versions MenuId={MenuId} Template="webPage" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null}
                 <Button type="default" onClick={this.closeView}>鍏抽棴</Button>
               </div>
             </div>
@@ -1757,7 +1807,7 @@
         <StyleController />
         <StyleCombController />
         <ModalController />
-      </ConfigProvider>
+      </>
     )
   }
 }

--
Gitblit v1.8.0