From 28483549baee23b4ca11e4ddbc9f93244d5fbb7c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 九月 2023 14:14:41 +0800
Subject: [PATCH] 2023-09-07

---
 src/views/rolemanage/index.jsx       |   13 +
 src/views/design/sidemenu/index.scss |    8 +
 src/views/tabledesign/index.jsx      |    6 
 src/menu/tablenodes/index.jsx        |  221 +++++++++++++++++++++++++++
 src/views/design/sidemenu/index.jsx  |    4 
 src/views/pcdesign/index.jsx         |    6 
 src/utils/utils-custom.js            |  151 ++++++++++++++++++
 src/views/mobdesign/index.jsx        |    6 
 src/views/menudesign/index.jsx       |    6 
 9 files changed, 408 insertions(+), 13 deletions(-)

diff --git a/src/menu/tablenodes/index.jsx b/src/menu/tablenodes/index.jsx
index 26fb797..fcbfdd9 100644
--- a/src/menu/tablenodes/index.jsx
+++ b/src/menu/tablenodes/index.jsx
@@ -109,6 +109,221 @@
     return {tbs, ptbs}
   }
 
+  getFuncAndInterface = (config) => {
+    let ptbs = []
+
+    let filterBtn = (cell, tbs) => {
+      if (cell.intertype === 'inner') {
+        tbs.push({
+          label: cell.innerFunc + ' (' + cell.label + ')',
+          color: 'orange',
+          id: Utils.getuuid(),
+          direction: 'left'
+        })
+      } else if (cell.intertype === 'outer' || cell.intertype === 'custom') {
+        if (cell.innerFunc) {
+          tbs.push({
+            label: cell.innerFunc + ' (' + cell.label + ')',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+        if (cell.outerFunc) {
+          tbs.push({
+            label: cell.outerFunc + ' (' + cell.label + ')',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+        if (cell.interface && cell.sysInterface !== 'true') {
+          tbs.push({
+            label: cell.interface + ' (' + cell.label + ')',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+        if (cell.proInterface) {
+          tbs.push({
+            label: cell.proInterface + ' (' + cell.label + ')',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+        if (cell.callbackFunc) {
+          tbs.push({
+            label: cell.callbackFunc + ' (' + cell.label + ')',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+      }
+    }
+
+    let filterSetting = (item, tbs) => {
+      if (!item.setting) return
+      if (item.setting.interType === 'inner') {
+        tbs.push({
+          label: item.setting.innerFunc + ' (鏁版嵁婧�)',
+          color: 'orange',
+          id: Utils.getuuid(),
+          direction: 'left'
+        })
+      } else if (item.setting.interType === 'outer') {
+        if (item.setting.outerFunc) {
+          tbs.push({
+            label: item.setting.outerFunc + ' (鏁版嵁婧�)',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+        if (item.setting.interface && item.setting.sysInterface !== 'true') {
+          tbs.push({
+            label: item.setting.interface + ' (鏁版嵁婧�)',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+        if (item.setting.proInterface) {
+          tbs.push({
+            label: item.setting.proInterface + ' (鏁版嵁婧�)',
+            color: 'orange',
+            id: Utils.getuuid(),
+            direction: 'left'
+          })
+        }
+      }
+    }
+
+    let traversal = (components, extra) => {
+      components.forEach(item => {
+        if (item.type === 'tabs') {
+          item.subtabs.forEach(tab => {
+            traversal(tab.components, extra)
+          })
+        } else if (item.type === 'group') {
+          traversal(item.components, extra)
+        } else {
+          let tbs = []
+
+          filterSetting(item, tbs)
+
+          if (item.action) {
+            item.action.forEach(cell => {
+              if (cell.OpenType === 'popview') {
+                if (cell.config.components) {
+                  traversal(cell.config.components, `-${cell.label}(寮圭獥)`)
+                }
+              } else {
+                filterBtn(cell, tbs)
+              }
+            })
+          }
+
+          if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
+            item.subcards.forEach(card => {
+              card.elements && card.elements.forEach(cell => {
+                if (cell.eleType !== 'button') return
+                
+                if (cell.OpenType === 'popview') {
+                  if (cell.config.components) {
+                    traversal(cell.config.components, `-${cell.label}(寮圭獥)`)
+                  }
+                } else {
+                  filterBtn(cell, tbs)
+                }
+              })
+              card.backElements && card.backElements.forEach(cell => {
+                if (cell.eleType !== 'button') return
+                
+                if (cell.OpenType === 'popview') {
+                  if (cell.config.components) {
+                    traversal(cell.config.components, `-${cell.label}(寮圭獥)`)
+                  }
+                } else {
+                  filterBtn(cell, tbs)
+                }
+              })
+            })
+          } else if (item.type === 'balcony') {
+            item.elements && item.elements.forEach(cell => {
+              if (cell.eleType !== 'button') return
+              
+              if (cell.OpenType === 'popview') {
+                if (cell.config.components) {
+                  traversal(cell.config.components, `-${cell.label}(寮圭獥)`)
+                }
+              } else {
+                filterBtn(cell, tbs)
+              }
+            })
+          } else if (item.type === 'table') {
+            let loopCol = (cols) => {
+              cols.forEach(col => {
+                if (col.type === 'colspan') {
+                  loopCol(col.subcols)
+                } else if (col.type === 'custom') {
+                  col.elements.forEach(cell => {
+                    if (cell.eleType !== 'button') return
+                    
+                    if (cell.OpenType === 'popview') {
+                      if (cell.config.components) {
+                        traversal(cell.config.components, `-${cell.label}(寮圭獥)`)
+                      }
+                    } else {
+                      filterBtn(cell, tbs)
+                    }
+                  })
+                }
+              })
+            }
+            loopCol(item.cols)
+          } else if (item.type === 'form') {
+            item.subcards.forEach(group => {
+              filterBtn(group.subButton, tbs)
+            })
+          }
+          
+          if (tbs.length) {
+            ptbs.push({
+              label: item.name + extra,
+              id: Utils.getuuid(),
+              direction: 'left',
+              color: 'orange',
+              children: tbs
+            })
+          }
+        }
+      })
+    }
+
+    if (config.interfaces) {
+      config.interfaces.forEach(item => {
+        let tbs = []
+        filterSetting(item, tbs)
+        if (tbs.length) {
+          ptbs.push({
+            label: item.name,
+            id: Utils.getuuid(),
+            direction: 'left',
+            color: 'orange',
+            children: tbs
+          })
+        }
+      })
+    }
+
+    traversal(config.components, '')
+
+    return ptbs
+  }
+
   trigger = () => {
     const { config } = this.props
 
@@ -172,6 +387,12 @@
           })
         }
 
+        let funcs = this.getFuncAndInterface(config)
+
+        if (funcs.length) {
+          data.children.push(...funcs)
+        }
+
         if (result.tb_list) {
           result.tb_list.sort((a, b) => a.tbname > b.tbname ? 1 : -1)
           let length = result.tb_list.length
diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js
index 5871f20..edd4314 100644
--- a/src/utils/utils-custom.js
+++ b/src/utils/utils-custom.js
@@ -1224,6 +1224,157 @@
 }
 
 /**
+ * @description 鑾峰彇鎺ュ彛鍙婂嚱鏁�
+ */
+export function getFuncsAndInters (config) {
+  let inters = []
+  // let funcs = []
+
+  let filterBtn = (cell) => {
+    if (cell.intertype === 'inner') {
+      // funcs.push(cell.innerFunc)
+    } else if (cell.intertype === 'outer' || cell.intertype === 'custom') {
+      // if (cell.innerFunc) {
+      //   funcs.push(cell.innerFunc)
+      // }
+      // if (cell.outerFunc) {
+      //   funcs.push(cell.outerFunc)
+      // }
+      if (cell.interface && cell.sysInterface !== 'true') {
+        inters.push(cell.interface)
+      }
+      if (cell.proInterface) {
+        inters.push(cell.proInterface)
+      }
+      // if (cell.callbackFunc) {
+      //   funcs.push(cell.callbackFunc)
+      // }
+    }
+  }
+
+  let filterSetting = (item) => {
+    if (!item.setting) return
+    if (item.setting.interType === 'inner') {
+      // funcs.push(item.setting.innerFunc)
+    } else if (item.setting.interType === 'outer') {
+      // if (item.setting.outerFunc) {
+      //   funcs.push(item.setting.outerFunc)
+      // }
+      if (item.setting.interface && item.setting.sysInterface !== 'true') {
+        inters.push(item.setting.interface)
+      }
+      if (item.setting.proInterface) {
+        inters.push(item.setting.proInterface)
+      }
+    }
+  }
+
+  let traversal = (components) => {
+    if (!components) return
+
+    components.forEach(item => {
+      if (item.type === 'tabs') {
+        item.subtabs.forEach(tab => {
+          traversal(tab.components)
+        })
+      } else if (item.type === 'group') {
+        traversal(item.components)
+      } else {
+        filterSetting(item)
+
+        if (item.action) {
+          item.action.forEach(cell => {
+            if (cell.OpenType === 'popview') {
+              if (cell.config) {
+                traversal(cell.config.components)
+              }
+            } else {
+              filterBtn(cell)
+            }
+          })
+        }
+
+        if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
+          item.subcards.forEach(card => {
+            card.elements && card.elements.forEach(cell => {
+              if (cell.eleType !== 'button') return
+              
+              if (cell.OpenType === 'popview') {
+                if (cell.config) {
+                  traversal(cell.config.components)
+                }
+              } else {
+                filterBtn(cell)
+              }
+            })
+            card.backElements && card.backElements.forEach(cell => {
+              if (cell.eleType !== 'button') return
+              
+              if (cell.OpenType === 'popview') {
+                if (cell.config) {
+                  traversal(cell.config.components)
+                }
+              } else {
+                filterBtn(cell)
+              }
+            })
+          })
+        } else if (item.type === 'balcony') {
+          item.elements && item.elements.forEach(cell => {
+            if (cell.eleType !== 'button') return
+            
+            if (cell.OpenType === 'popview') {
+              if (cell.config) {
+                traversal(cell.config.components)
+              }
+            } else {
+              filterBtn(cell)
+            }
+          })
+        } else if (item.type === 'table') {
+          let loopCol = (cols) => {
+            cols.forEach(col => {
+              if (col.type === 'colspan') {
+                loopCol(col.subcols)
+              } else if (col.type === 'custom') {
+                col.elements.forEach(cell => {
+                  if (cell.eleType !== 'button') return
+                  
+                  if (cell.OpenType === 'popview') {
+                    if (cell.config) {
+                      traversal(cell.config.components)
+                    }
+                  } else {
+                    filterBtn(cell)
+                  }
+                })
+              }
+            })
+          }
+          loopCol(item.cols)
+        } else if (item.type === 'form') {
+          item.subcards.forEach(group => {
+            filterBtn(group.subButton)
+          })
+        }
+      }
+    })
+  }
+
+  if (config.interfaces) {
+    config.interfaces.forEach(item => {
+      filterSetting(item)
+    })
+  }
+
+  traversal(config.components)
+
+  // inters = Array.from(new Set(inters))
+
+  return inters.length > 0 ? 'true' : 'false'
+}
+
+/**
  * @description 妫�娴嬬粍浠跺唴瀹�
  */
 export function checkComponent (card) {
diff --git a/src/views/design/sidemenu/index.jsx b/src/views/design/sidemenu/index.jsx
index 3e07e00..959ed2d 100644
--- a/src/views/design/sidemenu/index.jsx
+++ b/src/views/design/sidemenu/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import { is, fromJS } from 'immutable'
 import { Menu, Popover, Modal, notification } from 'antd'
-import { EditOutlined, PlusOutlined, SettingOutlined } from '@ant-design/icons'
+import { EditOutlined, PlusOutlined, SettingOutlined, ApiOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
 import asyncComponent from '@/utils/asyncComponent'
@@ -326,7 +326,7 @@
                 {item.children.map(cell => {
                   return (
                     <Menu.Item key={cell.MenuID}>
-                      <span className="editable-menu-item" onDoubleClick={() => this.editmenu(cell)}>{cell.MenuName}</span>
+                      <span className="editable-menu-item" onDoubleClick={() => this.editmenu(cell)}>{cell.PageParam && cell.PageParam.interfaces === 'true' ? <ApiOutlined title="鑿滃崟涓娇鐢ㄤ簡澶栭儴鎺ュ彛" /> : null}{cell.MenuName}</span>
                     </Menu.Item>
                   )
                 })}
diff --git a/src/views/design/sidemenu/index.scss b/src/views/design/sidemenu/index.scss
index bc55c66..bf1a210 100644
--- a/src/views/design/sidemenu/index.scss
+++ b/src/views/design/sidemenu/index.scss
@@ -12,9 +12,17 @@
       padding-left: 48px;
     }
     .editable-menu-item {
+      position: relative;
       display: block;
       padding-left: 48px;
       cursor: pointer;
+
+      .anticon-api {
+        position: absolute;
+        left: 25px;
+        top: 11px;
+        color: orange;
+      }
     }
   }
   .ant-menu-sub.ant-menu-inline {
diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index 189034b..9ec20db 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -13,7 +13,7 @@
 import Utils, { setGLOBFuncs } from '@/utils/utils.js'
 import antdZhCN from 'antd/es/locale/zh_CN'
 import MKEmitter from '@/utils/events.js'
-import { getTables } from '@/utils/utils-custom.js'
+import { getTables, getFuncsAndInters } from '@/utils/utils-custom.js'
 import asyncComponent from '@/utils/asyncComponent'
 
 import '@/assets/css/design.scss'
@@ -778,6 +778,8 @@
         config.tbkey = key
       }
 
+      let interfaces = getFuncsAndInters(config)
+
       let param = {
         func: 'sPC_TrdMenu_AddUpt',
         FstID: config.fstMenuId || '',
@@ -788,7 +790,7 @@
         EasyCode: config.easyCode || '',
         Template: 'CustomPage',
         MenuName: config.MenuName || '',
-        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false'}),
+        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', interfaces}),
         open_edition: config.open_edition,
         LText: '',
         LTexttb: '',
diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index c2092d2..c0783e1 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -12,7 +12,7 @@
 import Utils, { setGLOBFuncs } from '@/utils/utils.js'
 import antdZhCN from 'antd/es/locale/zh_CN'
 import MKEmitter from '@/utils/events.js'
-import MenuUtils, { getTables } from '@/utils/utils-custom.js'
+import MenuUtils, { getTables, getFuncsAndInters } from '@/utils/utils-custom.js'
 import asyncComponent from '@/utils/asyncComponent'
 
 import '@/assets/css/design.scss'
@@ -1503,6 +1503,8 @@
       let menus_used_list = subMenus.map(m => `'${config.uuid}','${config.MenuName || ''}','${config.MenuNo || ''}','${m.MenuID}','${m.MenuName}'`).join(';')
       menus_used_list = window.btoa(window.encodeURIComponent(menus_used_list || 'del'))
 
+      let interfaces = getFuncsAndInters(config)
+
       let param = {
         func: 'sPC_TrdMenu_AddUpt',
         FstID: 'mk_app',
@@ -1515,7 +1517,7 @@
         TypeCharOne: sessionStorage.getItem('kei_no'),
         Typename: sessionStorage.getItem('typename'),
         MenuName: config.MenuName || '',
-        PageParam: JSON.stringify({Template: 'webPage'}),
+        PageParam: JSON.stringify({Template: 'webPage', interfaces}),
         open_edition: config.open_edition,
         menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))),
         LText: '',
diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx
index 9a139f7..be2d635 100644
--- a/src/views/pcdesign/index.jsx
+++ b/src/views/pcdesign/index.jsx
@@ -10,7 +10,7 @@
 
 import Api from '@/api'
 import Utils, { setGLOBFuncs } from '@/utils/utils.js'
-import { getTables } from '@/utils/utils-custom.js'
+import { getTables, getFuncsAndInters } from '@/utils/utils-custom.js'
 import antdZhCN from 'antd/es/locale/zh_CN'
 import MKEmitter from '@/utils/events.js'
 import MenuUtils from '@/utils/utils-custom.js'
@@ -1203,6 +1203,8 @@
         config.tbkey = key
       }
 
+      let interfaces = getFuncsAndInters(config)
+
       let param = {
         func: 'sPC_TrdMenu_AddUpt',
         FstID: 'mk_app',
@@ -1215,7 +1217,7 @@
         TypeCharOne: sessionStorage.getItem('kei_no'),
         Typename: 'pc',
         MenuName: config.MenuName || '',
-        PageParam: JSON.stringify({Template: 'webPage'}),
+        PageParam: JSON.stringify({Template: 'webPage', interfaces}),
         menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))),
         open_edition: config.open_edition,
         LText: '',
diff --git a/src/views/rolemanage/index.jsx b/src/views/rolemanage/index.jsx
index ce7203b..a3b8471 100644
--- a/src/views/rolemanage/index.jsx
+++ b/src/views/rolemanage/index.jsx
@@ -3,8 +3,8 @@
 import { Spin, notification, Button, Table, Modal, ConfigProvider, Tree, Input, Empty } from 'antd'
 import moment from 'moment'
 import md5 from 'md5'
-import enUS from 'antd/es/locale/en_US'
 import zhCN from 'antd/es/locale/zh_CN'
+import { ApiOutlined } from '@ant-design/icons'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -15,7 +15,6 @@
 const { TreeNode } = Tree
 const { Search } = Input
 
-const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
 const Header = asyncComponent(() => import('./header'))
 const TransferForm = asyncComponent(() => import('@/templates/zshare/basetransferform'))
 
@@ -29,6 +28,8 @@
         title: '鑿滃崟鍚嶇О', dataIndex: 'MenuName', key: 'MenuName', align: 'center', render: (text, record) => {
           if (record.extra) {
             return <span style={{color: '#1890ff'}}>{text}</span>
+          } else if (record.interfaces === 'true') {
+            return <span><ApiOutlined style={{color: 'orange', marginRight: '5px'}} title="鑿滃崟涓娇鐢ㄤ簡澶栭儴鎺ュ彛" />{text}</span>
           }
           return text
         }
@@ -136,6 +137,12 @@
         let menus = result.menus.map(item => {
           item.nodes = ''
           item.type = 'view'
+          if (item.PageParam) {
+            try {
+              let PageParam = JSON.parse(item.PageParam)
+              item.interfaces = PageParam.interfaces || 'false'
+            } catch (e) {}
+          }
           if (item.menus_rolelist) {
             try {
               let pageParam = JSON.parse(window.decodeURIComponent(window.atob(item.menus_rolelist)))
@@ -886,7 +893,7 @@
 
     return (
       <div className="mk-role-manage">
-        <ConfigProvider locale={_locale}>
+        <ConfigProvider locale={zhCN}>
           <Header app={app} />
           {loading ?
             <div className="loading-mask">
diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx
index 3954522..ab31a4f 100644
--- a/src/views/tabledesign/index.jsx
+++ b/src/views/tabledesign/index.jsx
@@ -12,7 +12,7 @@
 import Utils, { setGLOBFuncs } from '@/utils/utils.js'
 import antdZhCN from 'antd/es/locale/zh_CN'
 import MKEmitter from '@/utils/events.js'
-import { getTables } from '@/utils/utils-custom.js'
+import { getTables, getFuncsAndInters } from '@/utils/utils-custom.js'
 import SourceElement from '@/templates/zshare/dragsource'
 import asyncComponent from '@/utils/asyncComponent'
 import Source from './source'
@@ -579,6 +579,8 @@
         config.tbkey = key
       }
 
+      let interfaces = getFuncsAndInters(config)
+
       let param = {
         func: 'sPC_TrdMenu_AddUpt',
         FstID: config.fstMenuId || '',
@@ -589,7 +591,7 @@
         EasyCode: config.easyCode || '',
         Template: 'BaseTable',
         MenuName: config.MenuName || '',
-        PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false'}),
+        PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', interfaces}),
         open_edition: config.open_edition,
         LText: '',
         LTexttb: '',

--
Gitblit v1.8.0