From 5891206952e2ff63e87aed2f47df5324b019d32e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 25 十月 2022 00:39:38 +0800
Subject: [PATCH] 2022-10-25

---
 src/views/tabledesign/index.jsx |  280 ++++++++++++++------------------------------------------
 1 files changed, 70 insertions(+), 210 deletions(-)

diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx
index f57afa6..c834d07 100644
--- a/src/views/tabledesign/index.jsx
+++ b/src/views/tabledesign/index.jsx
@@ -52,10 +52,8 @@
     menuloading: false,
     oriConfig: null,
     config: null,
-    customComponents: [],
     comloading: false,
     settingshow: true,
-    modalStatus: false       // 寮圭獥鏄惁寮�鍚紝鍒ゆ柇ctrl+s鏄惁鍙敤
   }
 
   UNSAFE_componentWillMount() {
@@ -91,20 +89,9 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('modalStatus', this.modalStatus)
     MKEmitter.addListener('changePopview', this.initPopview)
     MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave)
-    MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
     setTimeout(() => {
-      if (sessionStorage.getItem('app_custom_components')) {
-        let list = sessionStorage.getItem('app_custom_components')
-        list = JSON.parse(list)
-
-        this.setCustomComponent(list)
-      } else {
-        this.updateCustomComponent()
-      }
-      this.getAppPictures()
       this.getPrintTemp()
       this.getRoleFields()
       setGLOBFuncs()
@@ -129,10 +116,23 @@
       let _shortcut = `${preKey}+${keyCode}`
 
       if (_shortcut === 'ctrl+83') {
-        if (this.state.modalStatus) {
+        let modals = document.querySelectorAll('.mk-pop-modal')
+        let msg = null
+        for (let i = 0; i < modals.length; i++) {
+          if (msg) {
+            break
+          }
+
+          let node = modals[i].querySelector('.mk-com-name')
+
+          if (node) {
+            msg = node.innerText
+          }
+        }
+        if (msg) {
           notification.warning({
             top: 92,
-            message: '璇蜂繚瀛�' + this.state.modalStatus,
+            message: '璇蜂繚瀛�' + msg,
             duration: 5
           })
           return false
@@ -158,14 +158,8 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('modalStatus', this.modalStatus)
     MKEmitter.removeListener('changePopview', this.initPopview)
     MKEmitter.removeListener('triggerMenuSave', this.triggerMenuSave)
-    MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent)
-  }
-
-  modalStatus = (val) => {
-    this.setState({modalStatus: val})
   }
 
   triggerMenuSave = () => {
@@ -214,93 +208,6 @@
         }
       })
     }
-  }
-
-  getAppPictures = () => {
-    if (sessionStorage.getItem('app_videos') || sessionStorage.getItem('app_pictures')) return
-    
-    Api.getSystemConfig({
-      func: 's_url_db_adduptdel',
-      PageIndex: 0,  // 0 浠h〃鍏ㄩ儴
-      PageSize: 0,   // 0 浠h〃鍏ㄩ儴
-      typecharone: 'image',
-      type: 'search'
-    }).then(res => {
-      if (res.status) {
-        sessionStorage.setItem('app_pictures', JSON.stringify(res.data || []))
-      }
-
-      Api.getSystemConfig({
-        func: 's_url_db_adduptdel',
-        PageIndex: 0,  // 0 浠h〃鍏ㄩ儴
-        PageSize: 0,   // 0 浠h〃鍏ㄩ儴
-        typecharone: 'video',
-        type: 'search'
-      }).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 || []))
-        }
-      })
-    })
-  }
-
-  updateCustomComponent = () => {
-    Api.getSystemConfig({
-      func: 's_get_custom_components',
-      typename: '',
-      typecharone: ''
-    }).then(res => {
-      if (!res.status) {
-        notification.warning({
-          top: 92,
-          message: res.message,
-          duration: 5
-        })
-      } else if (res.cus_list) {
-        sessionStorage.setItem('app_custom_components', JSON.stringify(res.cus_list))
-        this.setCustomComponent(res.cus_list)
-      }
-    })
-  }
-
-  setCustomComponent = (cus_list) => {
-    let coms = []
-
-    cus_list.forEach(item => {
-      let config = ''
-
-      try {
-        config = JSON.parse(window.decodeURIComponent(window.atob(item.long_param)))
-      } catch (e) {
-        console.warn('Parse Failure')
-        config = ''
-      }
-
-      if (!config || !item.c_name) return
-
-      window.GLOB.UserComponentMap.set(item.c_id, item.c_name)
-      coms.push({
-        uuid: item.c_id,
-        type: 'menu',
-        title: item.c_name,
-        url: item.images,
-        component: config.type,
-        subtype: config.subtype,
-        config
-      })
-    })
-    this.setState({customComponents: coms})
   }
 
   initPopview = (card, btn) => {
@@ -424,7 +331,7 @@
     })
   }
 
-  getMenuMessage = (delButtons, tbs) => {
+  getMenuMessage = (tbs) => {
     const { config } = this.state
     let buttons = []
     let _sort = 1
@@ -435,23 +342,27 @@
           if (tab.components[0].$tables) {
             tbs.push(...tab.components[0].$tables)
           }
+
+          if (tab.permission !== 'true' || tab.hide === 'true') return
+
+          buttons.push(`select '${tab.components[0].uuid}' as menuid, '${tab.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
+          _sort++
+
+          let _s = 1
+
           tab.components[0].action.forEach(btn => {
-            if (btn.hidden === 'true') {
-              delButtons.push(btn.uuid)
-              return
-            }
-            buttons.push(`select '${btn.uuid}' as menuid, '${tab.label + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`)
-            _sort++
+            if (btn.hidden === 'true') return
+
+            buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`)
+            _s++
           })
           tab.components[0].cols.forEach(col => {
             if (col.type !== 'action') return
             col.elements.forEach(btn => {
-              if (btn.hidden === 'true') {
-                delButtons.push(btn.uuid)
-                return
-              }
-              buttons.push(`select '${btn.uuid}' as menuid, '${tab.label + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`)
-              _sort++
+              if (btn.hidden === 'true') return
+
+              buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`)
+              _s++
             })
           })
         })
@@ -460,21 +371,17 @@
           tbs.push(...item.$tables)
         }
         item.action.forEach(btn => {
-          if (btn.hidden === 'true') {
-            delButtons.push(btn.uuid)
-            return
-          }
-          buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort`)
+          if (btn.hidden === 'true') return
+
+          buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
           _sort++
         })
         item.cols.forEach(col => {
           if (col.type !== 'action') return
           col.elements.forEach(btn => {
-            if (btn.hidden === 'true') {
-              delButtons.push(btn.uuid)
-              return
-            }
-            buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort`)
+            if (btn.hidden === 'true') return
+
+            buttons.push(`select '${btn.uuid}' as menuid,  '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`)
             _sort++
           })
         })
@@ -506,8 +413,7 @@
       }
 
       let tbs = []
-      let delButtons = []
-      let btns = this.getMenuMessage(delButtons, tbs)
+      let btns = this.getMenuMessage(tbs)
       let arr = []
       tbs = tbs.filter(tb => {
         let _tb = tb.toLowerCase()
@@ -567,100 +473,54 @@
         ParentID: config.uuid,
         MenuNo: config.MenuNo,
         Template: 'BaseTable',
-        PageParam: '',
-        LongParam: '',
-        LText: []
+        button_proc_edition: 'Y'
       }
 
-      btnParam.LText = btns
-      btnParam.LText = btnParam.LText.join(' union all ')
+      btnParam.LText = btns.join(' union all ')
 
       btnParam.LText = Utils.formatOptions(btnParam.LText)
       btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
 
       new Promise(resolve => {
-        resolve(true)
-      }).then(res => { // 鎸夐挳鍒犻櫎
-        if (delButtons.length === 0) {
-          return {
-            status: true
-          }
-        } else {
-          let _param = {
-            func: 'sPC_MainMenu_Del',
-            MenuID: delButtons.join(',')
-          }
-          return Api.getSystemConfig(_param)
-        }
-      }).then(res => { // 椤甸潰淇濆瓨
-        if (!res) return
-
-        if (res.status) {
-          return Api.getSystemConfig(param)
-        } else {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 5
-          })
-          return false
-        }
-      }).then(res => { // 椤甸潰鎸夐挳鍏崇郴淇濆瓨
-        if (!res) return
-
-        if (res.status) {
-          let ori = this.state.oriConfig
-          if (config.MenuName !== ori.MenuName || config.MenuNo !== ori.MenuNo || config.parentId !== ori.parentId) {
-            localStorage.setItem('menuUpdate', new Date().getTime())
-          }
-          config.open_edition = res.open_edition || ''
-          this.setState({
-            config,
-            oriConfig: fromJS(config).toJS(),
-          })
-
-          if (btnParam.LText) {
-            return Api.getSystemConfig(btnParam)
-          } else {
-            return {
-              status: true
-            }
-          }
-        } else {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 5
-          })
-          return false
-        }
-      }).then(res => { // 鎸夐挳澶嶅埗
-        if (!res) return
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 5
-          })
-          return false
-        }
+        Api.getSystemConfig(param).then(res => {
+          resolve(res)
+        })
       }).then(res => {
-        if (res && res.status) {
-          this.setState({
-            menuloading: false
-          })
+        if (!res || !res.status) return res
+
+        let ori = this.state.oriConfig
+        if (config.MenuName !== ori.MenuName || config.MenuNo !== ori.MenuNo || config.parentId !== ori.parentId) {
+          localStorage.setItem('menuUpdate', new Date().getTime())
+        }
+        config.open_edition = res.open_edition || ''
+        this.setState({
+          config,
+          oriConfig: fromJS(config).toJS(),
+        })
+
+        return Api.getSystemConfig(btnParam)
+      }).then(res => {
+        this.setState({
+          menuloading: false
+        })
+
+        if (!res) return
+
+        if (res.status) {
           notification.success({
             top: 92,
             message: '淇濆瓨鎴愬姛',
             duration: 2
           })
+          MKEmitter.emit('completeSave')
         } else {
-          this.setState({
-            menuloading: false
+          notification.warning({
+            top: 92,
+            message: res.message,
+            duration: 5
           })
         }
-        MKEmitter.emit('completeSave')
       })
     }, 300 + (+sessionStorage.getItem('mkDelay')))
   }

--
Gitblit v1.8.0