From 783ab4e467c95e26f7f031151507bd7ad8333a63 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 九月 2023 17:34:47 +0800
Subject: [PATCH] 2023-09-08

---
 src/tabviews/custom/index.jsx |  222 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 174 insertions(+), 48 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index c859a83..6d63982 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -44,13 +44,13 @@
 const Iframe = asyncComponent(() => import('./components/iframe'))
 const Calendar = asyncComponent(() => import('./components/calendar'))
 const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
+const FlowFloat = asyncComponent(() => import('@/tabviews/zshare/flowFloat'))
 const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes'))
 const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces'))
 
 class CustomPage extends Component {
   static propTpyes = {
     param: PropTypes.any,        // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟
-    Tab: PropTypes.string,       // 寮圭獥鏍囩
     MenuID: PropTypes.string,    // 鑿滃崟Id
     MenuName: PropTypes.string,  // 鑿滃崟鍚嶇О
     changeTemp: PropTypes.func
@@ -63,7 +63,6 @@
     viewlost: false,      // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤
     lostmsg: '',          // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅
     config: null,         // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑
-    userConfig: null,     // 鐢ㄦ埛鑷畾涔夎缃�
     loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
     visible: false,       // 鏍囩椤垫帶鍒�
     shortcuts: null,      // 蹇嵎閿�
@@ -134,8 +133,51 @@
         return
       }
 
+      if (config.process === 'true') {
+        let unset = true
+        if (result.works_flow_code && result.works_long_param) {
+          try { // 娴佺▼淇℃伅瑙f瀽
+            let flowConfig = JSON.parse(window.decodeURIComponent(window.atob(result.works_long_param)))
+            flowConfig.flow_code = result.works_flow_code
+            flowConfig.flow_name = result.works_flow_name
+            config.flow_code = result.works_flow_code
+            config.flow_name = result.works_flow_name
+            unset = false
+            
+            window.GLOB.UserCacheMap.set('flow' + MenuID, flowConfig)
+          } catch (e) {
+            unset = true
+            console.warn('Parse Failure')
+          }
+        }
+        
+        if (unset) {
+          config.interfaces = []
+          this.setState({
+            config: config,
+            viewlost: true,
+            loadingview: false,
+            lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭璁剧疆宸ヤ綔娴侊紝璇疯仈绯荤鐞嗗憳銆�'
+          })
+          return
+        }
+      } else if (result.works_flow_code) {
+        Api.getSystemConfig({
+          func: 's_works_flow_param_sso_menu_upt_v6',
+          upt_type: 'del',
+          works_flow_code: '',
+          works_flow_name: '',
+          long_param: '',
+          flow_id: '',
+          menuid: config.MenuID,
+          menuname: config.MenuName,
+          username: sessionStorage.getItem('User_Name') || '',
+          fullName: sessionStorage.getItem('Full_Name') || ''
+        })
+      }
+
       // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆
-      if (result.LongParamUser && !window.GLOB.mkHS) {
+      if (result.LongParamUser) {
         try { // 閰嶇疆淇℃伅瑙f瀽
           let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
           if (userConfig) {
@@ -189,19 +231,13 @@
         })
       }
 
-      let popview = 'CustomPage'
-
-      if (config.version === 2.0) {
-        popview = 'popview'
-      }
-
       config.$cache = config.cacheLocal === 'true'
       config.$time = config.localCacheTime || 0
 
       let initInters = []
 
       config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters)
-      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.$time, config.MenuName, MenuID, MenuID)
+      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true')
 
       let params = []
       let BID = param.$BID || ''
@@ -278,9 +314,7 @@
           this.loadmaindata(params)
         }
 
-        if (!this.props.Tab) {
-          this.setShortcut()
-        }
+        this.setShortcut()
       })
     } else {
       this.setState({
@@ -334,14 +368,32 @@
     }
   }
 
-  filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId) => {
+  filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process) => {
     return components.filter(item => {
       item.$pageId = pageId
-      item.$cache = cache
-      item.$time = time
       item.$searchId = searchId
       item.$syncId = syncId
       
+      if (process) {
+        item.$process = process
+        item.$flowId = 'flow' + this.props.MenuID
+      }
+
+      if (cache) {
+        item.$cache = cache
+        item.$time = time
+
+        if (item.wrap && item.wrap.cacheLocal === 'false') {
+          item.$cache = false
+        } else if (item.plot && item.plot.cacheLocal === 'false') {
+          item.$cache = false
+        }
+
+        if (!item.$cache && item.setting && item.setting.sync === 'true') {
+          item.setting.sync = 'false'
+        }
+      }
+
       if (item.style && item.style.boxShadow) {
         delete item.style.hShadow
         delete item.style.vShadow
@@ -441,7 +493,7 @@
             _searchId = tab.uuid
           }
 
-          tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, _searchId, tab.uuid)
+          tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, _searchId, tab.uuid, process)
           
           if (_searchId === tab.uuid) {
             tab.components.forEach(cell => {
@@ -465,7 +517,7 @@
           return false
         }
 
-        item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId)
+        item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process)
 
         return true
       } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) {
@@ -526,7 +578,7 @@
         item.action = item.action.filter(cell => {
           if (cell.hidden === 'true') return false
 
-          cell = this.resetButton(item, cell, popview)
+          cell = this.resetButton(item, cell)
 
           cell.$toolbtn = true
 
@@ -539,7 +591,6 @@
       }
 
       if (item.type === 'table') {
-        let statFields = []
         let getCols = (cols) => {
           return cols.filter(col => {
             if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
@@ -551,9 +602,6 @@
             }
             
             if (col.type === 'number') {
-              if (col.sum === 'true' && !statFields.includes(col.field)) {
-                statFields.push(col)
-              }
               if (typeof(col.decimal) === 'number') {
                 col.round = Math.pow(10, col.decimal)
                 if (col.format === 'percent') {
@@ -574,7 +622,7 @@
                 if (cell.eleType === 'button') {
                   if (cell.hidden === 'true') return false
 
-                  cell = this.resetButton(item, cell, popview)
+                  cell = this.resetButton(item, cell)
 
                   if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
                     cell = this.getPrinter(cell, item.uuid)
@@ -594,7 +642,7 @@
       
             if (col.linkmenu && col.linkmenu.length > 0) {
               let menu_id = col.linkmenu.pop()
-              col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || ''
+              col.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || ''
             } else {
               col.linkThdMenu = ''
             }
@@ -604,7 +652,6 @@
         }
         
         item.cols = getCols(item.cols)
-        item.statFields = statFields
 
         if (item.subtype === 'editable') {
           item.submit.logLabel = item.$menuname + '-鎻愪氦'
@@ -631,7 +678,7 @@
             if (cell.eleType === 'button') {
               if (cell.hidden === 'true') return false
 
-              cell = this.resetButton(item, cell, popview)
+              cell = this.resetButton(item, cell)
 
               if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
                 cell = this.getPrinter(cell, item.uuid)
@@ -673,7 +720,7 @@
             if (cell.eleType === 'button') {
               if (cell.hidden === 'true') return false
 
-              cell = this.resetButton(item, cell, popview)
+              cell = this.resetButton(item, cell)
 
               if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
                 cell = this.getPrinter(cell, item.uuid)
@@ -697,7 +744,7 @@
           if (cell.eleType === 'button') {
             if (cell.hidden === 'true') return false
 
-            cell = this.resetButton(item, cell, popview)
+            cell = this.resetButton(item, cell)
 
             if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
               cell = this.getPrinter(cell, item.uuid)
@@ -720,6 +767,16 @@
 
           if (!group.subButton.Ot) {
             group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
+          }
+
+          if (item.$process) {
+            group.subButton.$process = true
+            group.subButton.$flowId = 'flow' + this.props.MenuID
+          }
+
+          if (item.$cache && item.$time) {
+            group.$cache = item.$cache
+            group.$time = item.$time
           }
 
           group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : ''
@@ -801,14 +858,19 @@
     })
   }
 
-  resetButton = (item, cell, popview) => {
+  resetButton = (item, cell) => {
     cell.logLabel = item.$menuname + '-' + cell.label
     cell.Ot = cell.Ot || 'requiredSgl'
     cell.ContainerId = this.state.ContainerId
     cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
     cell.$menuId = item.uuid
     cell.$MenuID = this.props.MenuID
-    cell.$view = popview
+    cell.$view = 'popview'
+
+    if (item.$process) {
+      cell.$process = true
+      cell.$flowId = 'flow' + this.props.MenuID
+    }
 
     if (cell.btnstyle) { // 鍏煎
       cell.style = cell.style || {}
@@ -821,6 +883,24 @@
       } else {
         cell.controlVals = [(cell.controlVal || '')]
       }
+    }
+
+    if (cell.OpenType === 'excelOut') { // 瀵煎嚭
+      cell.$menuName = item.name
+
+      if (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0) {
+        cell.errorType = 'error1'
+      } else if (cell.intertype === 'system' && cell.verify.dataType !== 'custom') {
+        if (item.setting.interType !== 'system') {
+          cell.errorType = 'error2'
+        } else if (item.type === 'balcony' || item.subtype === 'propcard') {
+          cell.errorType = 'error2'
+        }
+      }
+    } else if (cell.OpenType === 'pop' && item.$cache && item.$time && cell.modal) {
+      cell.modal.$cache = item.$cache
+      cell.modal.$time = item.$time
+      cell.modal.uuid = cell.uuid + 'pop'
     }
 
     if (cell.syncComponentId) {
@@ -854,6 +934,11 @@
 
   resetElement = (cell) => {
     cell.style = cell.style || {}
+
+    if (cell.style.display === 'inline-block') {
+      cell.style.verticalAlign = 'top'
+    }
+
     if (['text', 'number', 'formula'].includes(cell.eleType)) {
       if (!cell.height) {
         cell.innerHeight = 'auto'
@@ -937,6 +1022,7 @@
         return component
       }
 
+      component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : ''
       component.setting.useMSearch = component.setting.useMSearch === 'true'
       if (component.setting.useMSearch) {
         if (!window.GLOB.SearchBox.has(component.$searchId)) {
@@ -957,9 +1043,15 @@
       }
 
       let _customScript = ''
+      let _tailScript = ''
       component.scripts && component.scripts.forEach(script => {
-        if (script.status !== 'false') {
+        if (script.status === 'false') return
+        if (script.position !== 'back') {
           _customScript += `
+          ${script.sql}
+          `
+        } else {
+          _tailScript += `
           ${script.sql}
           `
         }
@@ -979,20 +1071,26 @@
       if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
         component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
         _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
+        _tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
       } else {
         component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
         _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
+        _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
       }
 
       regs.forEach(cell => {
         component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value)
         _customScript = _customScript.replace(cell.reg, cell.value)
+        _tailScript = _tailScript.replace(cell.reg, cell.value)
       })
 
       component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰
+      component.setting.tailScript = _tailScript     // 鍚庣疆鑷畾涔夎剼鏈�
 
-      if (component.setting.laypage) {
-        component.setting.custompage = /@pageSize@/i.test(component.setting.dataresource + component.setting.customScript)
+      component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript)
+
+      if (!component.setting.execute || component.setting.custompage) {
+        component.forbidLine = true
       }
 
       if (component.setting.sync === 'true') {
@@ -1077,12 +1175,20 @@
         inter.setting.onload = 'false'
       }
 
+      inter.setting.arr_field = inter.columns.map(col => col.field).join(',')
+
       if (inter.setting.interType !== 'system') return inter
 
       let _customScript = ''
+      let _tailScript = ''
       inter.scripts.forEach(script => {
-        if (script.status !== 'false') {
+        if (script.status === 'false') return
+        if (script.position !== 'back') {
           _customScript += `
+          ${script.sql}
+          `
+        } else {
+          _tailScript += `
           ${script.sql}
           `
         }
@@ -1103,17 +1209,23 @@
       if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
         inter.setting.dataresource = inter.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
         _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
+        _tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
       } else {
         inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
         _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
+        _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
       }
 
       regs.forEach(cell => {
         inter.setting.dataresource = inter.setting.dataresource.replace(cell.reg, cell.value)
         _customScript = _customScript.replace(cell.reg, cell.value)
+        _tailScript = _tailScript.replace(cell.reg, cell.value)
       })
 
       inter.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰
+      inter.setting.tailScript = _tailScript     // 鍚庣疆鑷畾涔夎剼鏈�
+
+      inter.setting.custompage = /@pageSize@|@orderBy@/i.test(inter.setting.dataresource + inter.setting.customScript)
 
       return inter
     })
@@ -1123,13 +1235,13 @@
    * @description 涓昏〃鏁版嵁鍔犺浇
    */ 
   loadmaindata = (params) => {
-    const { config } = this.state
-    let param = getStructuredParams(params, config, this.state.BID || '')
+    const { config, BID } = this.state
+    let param = getStructuredParams(params, config, BID || '')
 
     this.setState({loading: true, loadingview: false})
 
     if (config.$cache && config.$time) {
-      Api.getLCacheConfig(params[0].uuid, config.$time).then(res => {
+      Api.getLCacheConfig(params[0].uuid, config.$time, BID).then(res => {
         if (!res.valid) {
           this.getMainData(param, params, config.MenuID)
         } else {
@@ -1201,9 +1313,9 @@
   }
 
   resetActiveMenu = (menuId) => {
-    const { MenuID, Tab } = this.props
+    const { MenuID } = this.props
 
-    if (MenuID !== menuId || Tab) return
+    if (MenuID !== menuId) return
 
     this.setShortcut()
   }
@@ -1519,15 +1631,29 @@
   render() {
     const { loadingview, viewlost, config, loading, shortcuts, BID } = this.state
 
+    if (!config || viewlost) {
+      return (
+        <div className="custom-page-wrap">
+          {loadingview ? <Spin className="view-spin" size="large" /> : null}
+          {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
+          <div className="user-tools">
+            {config && config.process === 'true' ? <FlowFloat init={true} config={config}/> : null}
+          </div>
+        </div>
+      )
+    }
+
     return (
-      <div className={`custom-page-wrap ${config && config.minWidth ? 'mk-scroll' : ''} ${loadingview || loading ? 'loading' : ''} ${config && config.mask === 'false' ? 'mk-no-mask' : ''}`} id={this.state.ContainerId} style={config ? config.style : null}>
-        {(loadingview || (loading && !config.$cache)) ? <Spin className="view-spin" size="large" /> : null}
-        <Row id={config ? 'menu' + config.uuid : ''} style={config && config.minWidth ? {minWidth: config.minWidth} : null} className="component-wrap">{this.getComponents()}</Row>
-        {config && config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null}
-        {config && window.GLOB.breakpoint ? <DebugTable /> : null}
-        {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <TableNodes config={config} /> : null}
-        {!window.GLOB.mkHS && config ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null}
-        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
+      <div className={`custom-page-wrap ${config.minWidth ? 'mk-scroll' : ''} ${loading ? 'loading' : ''} ${config.mask === 'false' ? 'mk-no-mask' : ''}`} id={this.state.ContainerId} style={config.style}>
+        {loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null}
+        <Row id={'menu' + config.uuid} style={{minWidth: config.minWidth || 'unset'}} className="component-wrap">{this.getComponents()}</Row>
+        {config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null}
+        {window.GLOB.breakpoint ? <DebugTable /> : null}
+        <div className="user-tools">
+          {config.process === 'true' ? <FlowFloat config={config}/> : null}
+          <SettingComponent config={config} shortcuts={shortcuts || []}/>
+          <TableNodes config={config} />
+        </div>
       </div>
     )
   }

--
Gitblit v1.8.0