From c10fc10d5fd307a7b334bcde6af5c1175aaa0410 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 28 八月 2024 17:47:28 +0800
Subject: [PATCH] 2024-08-28

---
 src/tabviews/basetable/index.jsx |  254 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 204 insertions(+), 50 deletions(-)

diff --git a/src/tabviews/basetable/index.jsx b/src/tabviews/basetable/index.jsx
index 82a0fe4..c613378 100644
--- a/src/tabviews/basetable/index.jsx
+++ b/src/tabviews/basetable/index.jsx
@@ -13,6 +13,7 @@
 // 閫氱敤缁勪欢
 const AntvTabs = asyncComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs'))
 const MkBaseTable = asyncComponent(() => import('@/tabviews/custom/components/table/base-table'))
+const FlowFloat = asyncComponent(() => import('@/tabviews/zshare/flowFloat'))
 const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent'))
 const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes'))
 const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic'))
@@ -35,7 +36,6 @@
     lostmsg: '',          // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅
     config: null,         // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑
     userConfig: null,     // 鐢ㄦ埛鑷畾涔夎缃�
-    loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
     visible: false,       // 鏍囩椤垫帶鍒�
     shortcuts: null,      // 蹇嵎閿�
     autoMatic: null
@@ -45,7 +45,7 @@
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
-    const { MenuID, MenuName } = this.props
+    const { MenuID, MenuName, param } = this.props
 
     let _param = {
       func: 'sPC_Get_LongParam',
@@ -102,13 +102,54 @@
         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) {
+          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) {
-            shortcuts = userConfig.action
-            userConfig.printers.forEach(item => {
+            shortcuts = userConfig.action || []
+            userConfig.printers && userConfig.printers.forEach(item => {
               window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item)
             })
           }
@@ -120,9 +161,32 @@
       // 鏉冮檺杩囨护
       let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
       let skip = window.GLOB.mkHS
-      let param = this.props.param || {} // url鍙傛暟
+      let urlparam = {} // url鍙傛暟
+      if (param) {
+        Object.keys(param).forEach(key => {
+          if (/^\$/.test(key)) {
+            urlparam[key] = param[key]
+          } else {
+            urlparam[key.toLowerCase()] = param[key]
+          }
+        })
+      }
 
-      window.GLOB.CacheData.set(MenuID, param)
+      window.GLOB.CacheData.set(MenuID, urlparam)
+
+      if (window.backend && config.allSqls) {
+        let keys = Object.keys(urlparam)
+        config.allSqls.forEach(item => {
+          if (item.type === 'datasource') {
+            item.urlkeys = keys
+            item.urlparam = urlparam
+            if (config.flow_code) {
+              item.works_flow_code = config.flow_code
+            }
+          }
+          window.GLOB.CacheData.set('sql_' + item.uuid, item)
+        })
+      }
 
       let userName = sessionStorage.getItem('User_Name') || ''
       let fullName = sessionStorage.getItem('Full_Name') || ''
@@ -140,7 +204,7 @@
       }
       if (config.urlFields) {
         config.urlFields.forEach(field => {
-          let val = `'${param[field] || ''}'`
+          let val = `'${urlparam[field.toLowerCase()] || ''}'`
           regs.push({
             reg: new RegExp('@' + field + '@', 'ig'),
             value: val
@@ -148,7 +212,11 @@
         })
       }
 
-      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID, config.MenuName)
+      if (config.flow_code) {
+        regs.push({ reg: /@works_flow_code@/ig, value: `'${config.flow_code}'` })
+      }
+
+      config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, urlparam, MenuID, config.MenuName, config.process === 'true')
 
       let autoMatic = null
       if (config.autoMatic && config.autoMatic.enable === 'true') {
@@ -163,22 +231,10 @@
           }
         })
       }
-      
+
       // 鑾峰彇涓绘悳绱㈡潯浠�
       config.components.forEach(component => {
         if (component.type === 'tabs') return
-
-        if (param.$searchkey) {
-          component.search = component.search.map(item => {
-            if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) {
-              item.initval = param.$searchval
-            }
-  
-            return item
-          })
-
-          component.$searches = Utils.initMainSearch(component.search)
-        }
 
         if (component.$searches.length) {
           component.$main = true
@@ -191,7 +247,7 @@
         }
       })
 
-      let BID = param.$BID || ''
+      let BID = urlparam.$BID || ''
 
       config.components = this.formatSetting(config.components, regs)
 
@@ -263,10 +319,15 @@
     }
   }
 
-  filterComponent = (components, roleId, permAction, skip, urlparam, pageId, MenuName) => {
+  filterComponent = (components, roleId, permAction, skip, urlparam, pageId, MenuName, process) => {
     return components.filter(item => {
       item.$pageId = pageId
       item.$searchId = pageId
+
+      if (process) {
+        item.$process = process
+        item.$flowId = 'flow' + this.props.MenuID
+      }
 
       item.$menuname = (MenuName || '') + '-' + (item.name || '涓昏〃')
 
@@ -287,7 +348,7 @@
           if (tab.permission !== 'true') { // 鏉冮檺鏈紑鍚笉鍋氭潈闄愭帶鍒�
             skip = true
           }
-          tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId, MenuName)
+          tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId, MenuName, process)
           return tab
         })
 
@@ -295,11 +356,6 @@
       } else {
         item.name = (MenuName || '')
       }
-
-      // 鎼滅储鏉′欢鍒濆鍖�
-      Utils.initSearchVal(item)
-
-      item.$searches = Utils.initMainSearch(item.search)
 
       if (item.setting.supModule) {
         let pid = item.setting.supModule.pop()
@@ -309,6 +365,19 @@
           item.setting.supModule = ''
         }
       }
+
+      // 鎼滅储鏉′欢鍒濆鍖�
+      Utils.initSearchVal(item)
+
+      if (urlparam.$searchkey) {
+        item.search.forEach(cell => {
+          if (urlparam.$searchkey === cell.field.toLowerCase() && ['text', 'select', 'link', 'checkcard'].includes(cell.type)) {
+            cell.initval = urlparam.$searchval
+          }
+        })
+      }
+
+      item.$searches = Utils.initMainSearch(item.search)
 
       let statFields = []
       let getCols = (cols) => {
@@ -321,7 +390,10 @@
             col.type = 'custom'
           }
           
-          if (col.type === 'number') {
+          if (col.type === 'index') {
+            col.field = '$Index'
+            col.type = 'text'
+          } else if (col.type === 'number') {
             if (col.sum === 'true') {
               statFields.push(col)
             }
@@ -347,7 +419,7 @@
                   cell = this.getPrinter(cell, item.uuid)
                 }
 
-                return skip || permAction[cell.uuid]
+                return skip || permAction[cell.uuid] || cell.permission === 'false'
               } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
                 if (!cell.height) {
                   cell.innerHeight = 'auto'
@@ -359,6 +431,22 @@
                   }
                 }
               }
+
+              if (cell.linkmenu && cell.linkmenu.length > 0) {
+                let menu_id = cell.linkmenu.pop()
+                cell.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || ''
+                if (!cell.linkThdMenu) {
+                  cell.link = ''
+                }
+              }
+
+              if (cell.marks && cell.marks.length === 0) {
+                cell.marks = null
+              }
+              if (cell.anchors && cell.anchors.length === 0) {
+                cell.anchors = null
+              }
+
               return true
             })
 
@@ -369,9 +457,13 @@
     
           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 = ''
+          }
+
+          if (col.marks && col.marks.length === 0) {
+            col.marks = null
           }
 
           return true
@@ -394,7 +486,7 @@
             cell = this.getPrinter(cell, item.uuid)
           }
 
-          return skip || permAction[cell.uuid]
+          return skip || permAction[cell.uuid] || cell.permission === 'false'
         })
       }
       
@@ -411,6 +503,11 @@
     cell.$MenuID = this.props.MenuID
     cell.$view = 'popview'
 
+    if (item.$process) {
+      cell.$process = true
+      cell.$flowId = 'flow' + this.props.MenuID
+    }
+
     if (cell.controlField) {
       if (/,/ig.test(cell.controlVal)) {
         cell.controlVals = cell.controlVal.split(',')
@@ -420,12 +517,48 @@
     }
 
     if (cell.OpenType === 'excelOut') { // 瀵煎嚭
-      cell.$menuName = item.name
+      cell.$menuName = item.$menuname
+    } else if (cell.OpenType === 'pop' && cell.modal) {
+      cell.modal.uuid = cell.uuid + 'pop'
+    }
 
-      if (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0) {
-        cell.errorType = 'error1'
-      } else if (cell.intertype === 'system' && cell.verify.dataType !== 'custom' && item.setting.interType !== 'system') {
-        cell.errorType = 'error2'
+    if (cell.verify) {
+      if (cell.verify.invalid === 'true') {
+        if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) {
+          cell.verify.invalid = 'false'
+        } else if (cell.intertype !== 'system' && cell.procMode !== 'system') {
+          cell.verify.invalid = 'false'
+        } else if (cell.sqlType === 'insert') {
+          cell.verify.invalid = 'false'
+        } else if (cell.Ot === 'notRequired') {
+          cell.verify.invalid = 'false'
+        }
+      }
+
+      if (cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) {
+        cell.returnValue = 'true'
+      }
+
+      if (cell.verify.preHandle === 'true') {
+        let script = cell.verify.pre_func
+        if (!/#position-/.test(script) || /#position-init/.test(script)) {
+          try {
+            // eslint-disable-next-line
+            let func = new Function('btn', 'position', 'systemType', script)
+            func(cell, 'init', window.GLOB.systemType)
+          } catch (e) {
+            console.warn(e)
+          }
+        }
+        if (/#position-inner/.test(script)) {
+          cell.$innerScript = script
+        }
+        if (/#position-outer/.test(script)) {
+          cell.$outerScript = script
+        }
+        if (/#position-callback/.test(script)) {
+          cell.$callbackScript = script
+        }
       }
     }
 
@@ -461,6 +594,8 @@
   getPrinter = (item, parentId) => {
     let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
 
+    item.verify.logLabel = item.logLabel
+    
     if (_item) {
       item.printer = _item.printer || ''
       item.verify.defaultPrinter = _item.printer || ''
@@ -500,9 +635,12 @@
 
       if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂
         component.setting.sync = 'false'
+        component.setting.dataresource = ''
         component.setting.laypage = component.setting.laypage === 'true'
         return component
       }
+
+      component.setting.uuid = component.uuid
 
       let _customScript = ''
       let _tailScript = ''
@@ -549,9 +687,13 @@
       component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰
       component.setting.tailScript = _tailScript     // 鍚庣疆鑷畾涔夎剼鏈�
 
-      component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript)
+      component.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(component.setting.dataresource + component.setting.customScript)
 
-      component.setting.delay = delay
+      if (!component.setting.execute || component.setting.custompage) {
+        component.forbidLine = true
+      }
+      
+      component.setting.delay = delay + (component.setting.delay || 0)
       delay += 20
 
       return component
@@ -636,7 +778,6 @@
       loadingview: true,    // 椤甸潰鍔犺浇涓�
       viewlost: false,      // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤
       config: null,         // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑
-      loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
       shortcuts: null,
     }, () => {
       this.loadconfig()
@@ -666,17 +807,30 @@
   }
 
   render() {
-    const { loadingview, viewlost, config, loading, shortcuts, autoMatic } = this.state
+    const { loadingview, viewlost, config, shortcuts, autoMatic } = this.state
+
+    if (!config || viewlost) {
+      return (
+        <div className="custom-table-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-table-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}>
-        {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null}
+      <div className="custom-table-wrap" id={this.state.ContainerId} style={config.style}>
         <Row className="component-wrap">{this.getComponents()}</Row>
-        {config && window.GLOB.breakpoint ? <DebugTable /> : null}
-        {!window.GLOB.mkHS && config && autoMatic ? <AutoMatic autoMatic={autoMatic} tabId={config.MenuID} config={config.components[0]} /> : 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}
+        {window.GLOB.breakpoint ? <DebugTable /> : null}
+        <div className="user-tools">
+          {autoMatic ? <AutoMatic autoMatic={autoMatic} tabId={config.MenuID} config={config.components[0]} /> : null}
+          {config.process === 'true' ? <FlowFloat config={config}/> : null}
+          <SettingComponent config={config} shortcuts={shortcuts || []}/>
+          <TableNodes config={config} />
+        </div>
       </div>
     )
   }

--
Gitblit v1.8.0