From a4466960bfd628036aa2b6f9aa706f75215482bc Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 21 五月 2024 10:10:39 +0800
Subject: [PATCH] 2024-05-21

---
 src/views/menudesign/index.jsx |   93 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 74 insertions(+), 19 deletions(-)

diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index 3a98723..ad11d1f 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -125,6 +125,7 @@
     
     MKEmitter.addListener('changePopview', this.initPopview)
     MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave)
+    MKEmitter.addListener('changeEditMenu', this.changeEditMenu)
     setTimeout(() => {
       this.getRoleFields()
       setGLOBFuncs()
@@ -196,6 +197,49 @@
     }
     MKEmitter.removeListener('changePopview', this.initPopview)
     MKEmitter.removeListener('triggerMenuSave', this.triggerMenuSave)
+    MKEmitter.removeListener('changeEditMenu', this.changeEditMenu)
+  }
+
+  changeEditMenu = (menu) => {
+    if (menu.MenuID && menu.MenuID.length === 3 && menu.MenuNo && !this.menuLoading) {
+      this.menuLoading = true
+      let param = {
+        func: 'sPC_Get_LongParam',
+        MenuID: menu.MenuID[2]
+      }
+  
+      Api.getCloudConfig(param).then(result => {
+        this.menuLoading = false
+        if (result.status) {
+          let config = null
+  
+          try {
+            config = result.LongParam ? JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) : null
+          } catch (e) {
+            console.warn('Parse Failure')
+            config = null
+          }
+
+          if (config) {
+            let _param = {
+              MenuId: menu.MenuID[2],
+              MenuID: menu.MenuID[2],
+              ParentId: menu.MenuID[1],
+              MenuName: menu.MenuName,
+              MenuNo: menu.MenuNo
+            }
+            if (config.Template === 'BaseTable') {
+              _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
+              window.open(`#/tabledesign/${_param}`)
+            } else if (config.Template === 'CustomPage') {
+              _param.MenuType = 'custom'
+              _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
+              window.open(`#/menudesign/${_param}`)
+            }
+          }
+        }
+      })
+    }
   }
 
   triggerMenuSave = () => {
@@ -610,7 +654,7 @@
         
         if (item.action && item.action.length > 0) {
           item.action.forEach(btn => {
-            if (btn.hidden === 'true') return
+            if (btn.hidden === 'true' || btn.permission === 'false') return
             buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
             _sort++
           })
@@ -625,13 +669,13 @@
           item.subcards.forEach(card => {
             card.elements && card.elements.forEach(cell => {
               if (cell.eleType !== 'button') return
-              if (cell.hidden === 'true') return
+              if (cell.hidden === 'true' || cell.permission === 'false') return
               buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
               _sort++
             })
             card.backElements && card.backElements.forEach(cell => {
               if (cell.eleType !== 'button') return
-              if (cell.hidden === 'true') return
+              if (cell.hidden === 'true' || cell.permission === 'false') return
               buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
               _sort++
             })
@@ -639,7 +683,7 @@
         } else if (item.type === 'balcony') {
           item.elements && item.elements.forEach(cell => {
             if (cell.eleType !== 'button') return
-            if (cell.hidden === 'true') return
+            if (cell.hidden === 'true' || cell.permission === 'false') return
             buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
             _sort++
           })
@@ -650,7 +694,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
                   buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
                   _sort++
                 })
@@ -755,6 +799,11 @@
 
       let tbs = []
       let btns = this.getMenuMessage(config, tbs)
+
+      if (config.permission === 'false') {
+        btns = []
+      }
+
       let arr = []
       tbs = tbs.filter(tb => {
         let _tb = tb.toLowerCase()
@@ -784,6 +833,7 @@
       }
 
       let interfaces = getFuncsAndInters(config)
+      let urlFields = config.urlFields ? config.urlFields.join(',') : ''
 
       let param = {
         func: 'sPC_TrdMenu_AddUpt',
@@ -795,7 +845,7 @@
         EasyCode: config.easyCode || '',
         Template: 'CustomPage',
         MenuName: config.MenuName || '',
-        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces}),
+        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces, urlFields}),
         open_edition: config.open_edition,
         LText: '',
         LTexttb: '',
@@ -805,9 +855,8 @@
         LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config)))
       }
 
-      param.LText = Utils.formatOptions(param.LText)
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+      param.secretkey = Utils.encrypt('', param.timestamp)
 
       let btnParam = {             // 娣诲姞鑿滃崟鎸夐挳
         func: 'sPC_Button_AddUpt',
@@ -815,14 +864,14 @@
         ParentID: config.uuid,
         MenuNo: config.MenuNo,
         Template: 'CustomPage',
-        button_proc_edition: 'Y'
+        button_proc_edition: 'Y',
+        exec_type: 'x'
       }
 
       btnParam.LText = btns.join(' union all ')
-
-      btnParam.LText = Utils.formatOptions(btnParam.LText)
+      btnParam.LText = Utils.formatOptions(btnParam.LText, 'x')
       btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
+      btnParam.secretkey = Utils.encrypt('', btnParam.timestamp)
 
       new Promise(resolve => {
         if (MenuType === 'billPrint') { // 鎵撳嵃鐢熸垚椤甸潰鏁堟灉鍥�
@@ -839,10 +888,21 @@
   
             Api.fileuploadbase64(param).then(result => {
               if (result.status) {
+                let url = result.Images
+                let baseurl = ''
+    
+                if (window.GLOB.cloudServiceApi) {
+                  baseurl = window.GLOB.cloudServiceApi.replace(/webapi(.*)$/, '')
+                } else {
+                  baseurl = window.GLOB.baseurl
+                }
+
+                url = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url
+
                 Api.getCloudConfig({
                   func: 's_PrintTemplateMSub',
                   ID: config.uuid,
-                  Images: Utils.getcloudurl(result.Images),
+                  Images: url,
                   Remark: '',
                   temp_type: 'billprint',
                 }).then(response => {
@@ -1091,12 +1151,6 @@
 
     this.setState({config})
     window.GLOB.customMenu = config
-
-    notification.success({
-      top: 92,
-      message: '绮樿创鎴愬姛锛�',
-      duration: 2
-    })
   }
 
   changeSetting = () => {
@@ -1117,6 +1171,7 @@
   updateLogConfig = (config) => {
     config.fstMenuId = this.state.config.fstMenuId || config.fstMenuId || ''
     config.parentId = this.state.config.parentId || config.parentId || ''
+    config.open_edition = this.state.config.open_edition || ''
     
     this.setState({
       config: null

--
Gitblit v1.8.0