From a6be5cfd9c6fb084af584b77f79100fe32b385c1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 30 十一月 2023 16:20:54 +0800
Subject: [PATCH] 2023-11-30

---
 src/tabviews/custom/popview/index.jsx |  183 ++++++++++++++++++++++++++++-----------------
 1 files changed, 115 insertions(+), 68 deletions(-)

diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx
index 9b2324c..eb22032 100644
--- a/src/tabviews/custom/popview/index.jsx
+++ b/src/tabviews/custom/popview/index.jsx
@@ -4,8 +4,6 @@
 import { notification, Spin, Row, Col, Modal } from 'antd'
 
 import Api from '@/api'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import Utils from '@/utils/utils.js'
 import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js'
 import MKEmitter from '@/utils/events.js'
@@ -52,7 +50,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     BID: '',              // 椤甸潰璺宠浆鏃舵惡甯D
     viewlost: false,      // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤
     lostmsg: '',          // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅
@@ -91,7 +88,7 @@
     if (!config.enabled) {
       this.setState({
         viewlost: true,
-        lostmsg: this.state.dict['main.view.unenabled']
+        lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭鍚敤锛岃鑱旂郴绠$悊鍛樸��'
       })
       return
     }
@@ -114,11 +111,6 @@
     let userName = sessionStorage.getItem('User_Name') || ''
     let fullName = sessionStorage.getItem('Full_Name') || ''
 
-    if (sessionStorage.getItem('isEditState') === 'true') {
-      userName = sessionStorage.getItem('CloudUserName') || ''
-      fullName = sessionStorage.getItem('CloudFullName') || ''
-    }
-
     let regs = [
       { reg: /@userName@/ig, value: `'${userName}'` },
       { reg: /@fullName@/ig, value: `'${fullName}'` }
@@ -131,6 +123,11 @@
       })
     }
 
+    if (Tab.$process && window.GLOB.UserCacheMap.has(Tab.$flowId)) {
+      let flow = window.GLOB.UserCacheMap.get(Tab.$flowId)
+      regs.push({ reg: /@works_flow_code@/ig, value: `'${flow.flow_code || ''}'` })
+    }
+
     config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, Tab.uuid, Tab.uuid)
     
     // 鑾峰彇涓绘悳绱㈡潯浠�
@@ -139,7 +136,7 @@
 
       if (param.$searchkey) {
         component.search = component.search.map(item => {
-          if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) {
+          if (['text', 'select', 'link', 'checkcard'].includes(item.type) && param.$searchkey === item.field) {
             item.initval = param.$searchval
           }
 
@@ -161,7 +158,7 @@
 
     config.components = this.formatSetting(config.components, params, regs, balMap)
 
-    if ([...balMap.keys()].length > 0) {
+    if (balMap.size > 0) {
       config.components = this.filterBalcony(config.components, balMap)
     }
 
@@ -180,6 +177,11 @@
       item.$pageId = Tab.uuid
       item.$searchId = searchId
       item.$syncId = syncId
+
+      if (Tab.$process) {
+        item.$process = true
+        item.$flowId = Tab.$flowId
+      }
       
       if (item.style && item.style.boxShadow) {
         delete item.style.hShadow
@@ -188,7 +190,7 @@
         delete item.style.shadowColor
       }
 
-      item.$menuname = (Tab.label || '') + '-' + (item.name || '')
+      item.$menuname = (Tab.logLabel || Tab.label || '') + '-' + (item.name || '')
 
       if (item.type === 'tabs') {
         if (
@@ -274,16 +276,22 @@
 
           let _searchId = searchId
 
-          tab.components.forEach(cell => {
-            if (cell.type !== 'search') return
-            _searchId = cell.uuid
-            window.GLOB.SearchBox.set(cell.uuid, cell.$searches)
-            if (cell.$s_req) {
-              window.GLOB.SearchBox.set(cell.uuid + 'required', true)
-            }
-          })
+          if (tab.components.findIndex(cell => cell.type === 'search') > -1) {
+            _searchId = tab.uuid
+          }
 
           tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, _searchId, tab.uuid)
+
+          if (_searchId === tab.uuid) {
+            tab.components.forEach(cell => {
+              if (cell.type !== 'search') return
+              window.GLOB.SearchBox.set(_searchId, cell.$searches)
+              if (cell.$s_req) {
+                window.GLOB.SearchBox.set(_searchId + 'required', true)
+              }
+            })
+          }
+
           return tab
         })
 
@@ -316,9 +324,7 @@
       }
 
       // 鎼滅储鏉′欢鍒濆鍖�
-      if (item.type === 'search' && item.search.length === 0) {
-        return false
-      } else if (item.search) {
+      if (item.search) {
         Utils.initSearchVal(item)
 
         item.$searches = Utils.initMainSearch(item.search)
@@ -348,7 +354,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) {
@@ -360,9 +365,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') {
@@ -398,9 +400,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
@@ -408,7 +414,6 @@
         }
         
         item.cols = getCols(item.cols)
-        item.statFields = statFields
 
         if (item.subtype === 'editable') {
           item.submit.logLabel = item.$menuname + '-鎻愪氦'
@@ -503,25 +508,14 @@
       } else if (item.type === 'form') {
         item.subcards = item.subcards.map(group => {
           group.subButton.uuid = group.uuid
-          group.subButton.$menuId = group.uuid
-          group.subButton.$MenuID = Tab.$MenuID
           group.subButton.OpenType = 'formSubmit'
           group.subButton.execError = 'never'
-          group.subButton.logLabel = item.$menuname + '-' + group.subButton.label
-          group.subButton.$tabId = Tab.uuid
 
           if (!group.subButton.Ot) {
             group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
           }
 
-          group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : ''
-
-          if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) {
-            group.subButton.syncComponentId = ''
-            if (group.subButton.execSuccess === 'grid') {
-              group.subButton.execSuccess = 'mainline'
-            }
-          }
+          group.subButton = this.resetButton(item, group.subButton, Tab)
 
           group.fields = group.fields.map(cell => {
             // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗�
@@ -595,6 +589,11 @@
     cell.$MenuID = Tab.$MenuID
     cell.$tabId = Tab.uuid
 
+    if (Tab.$process) {
+      cell.$process = true
+      cell.$flowId = Tab.$flowId
+    }
+
     if (cell.btnstyle) { // 鍏煎
       cell.style = cell.style || {}
       cell.style = {...cell.style, ...cell.btnstyle}
@@ -605,6 +604,44 @@
         cell.controlVals = cell.controlVal.split(',')
       } 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'
+        }
+      }
+    }
+
+    if (cell.verify && cell.verify.invalid === 'true') {
+      if (item.wrap && item.wrap.datatype === 'static') {
+        cell.verify.invalid = 'false'
+      } else if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) {
+        cell.verify.invalid = 'false'
+      } else if (cell.sqlType === 'insert') {
+        cell.verify.invalid = 'false'
+      } else if (cell.Ot === 'notRequired') {
+        cell.verify.invalid = 'false'
+      } else if (cell.intertype !== 'system' && cell.procMode !== 'system') {
+        cell.verify.invalid = 'false'
+      }
+    }
+
+    if (cell.verify && cell.verify.preHandle === 'true') {
+      try {
+        // eslint-disable-next-line
+        let func = new Function('btn', 'systemType', cell.verify.pre_func)
+        func(cell, window.GLOB.systemType)
+      } catch (e) {
+        console.warn(e)
       }
     }
 
@@ -639,6 +676,15 @@
 
   resetElement = (cell) => {
     cell.style = cell.style || {}
+
+    if (cell.style.display === 'inline-block') {
+      cell.style.verticalAlign = 'top'
+    }
+
+    if (cell.marks && cell.marks.length === 0) {
+      cell.marks = null
+    }
+
     if (['text', 'number', 'formula'].includes(cell.eleType)) {
       if (!cell.height) {
         cell.innerHeight = 'auto'
@@ -674,24 +720,6 @@
     return cell
   }
 
-  getPrinter = (item, parentId) => {
-    let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
-
-    if (_item) {
-      item.printer = _item.printer || ''
-      item.verify.defaultPrinter = _item.printer || ''
-      if (item.verify.printerTypeList && _item.printerList) {
-        item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
-          cell.printer = _item.printerList[cell.Value] || ''
-
-          return cell
-        })
-      }
-    }
-
-    return item
-  }
-
   // 鏍煎紡鍖栭粯璁よ缃�
   formatSetting = (components, params, regs, balMap) => {
     let delay = 20
@@ -705,12 +733,8 @@
       } else if (component.type === 'group') {
         component.components = this.formatSetting(component.components, params, regs, balMap)
         return component
-      } else if (component.wrap && component.wrap.datatype === 'public') {
-        component.setting.useMSearch = false
-        component.setting.sync = 'false'
-
-        return component
-      } else if (component.wrap && component.wrap.datatype === 'static') {
+      } else if (component.wrap && (component.wrap.datatype === 'static' || component.wrap.datatype === 'public')) {
+        component.wrap.datatype = 'static'
         component.format = ''
         component.setting = component.setting || {}
         component.setting.useMSearch = false
@@ -721,7 +745,10 @@
         return component
       }
 
+      component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : ''
       component.setting.useMSearch = component.setting.useMSearch === 'true'
+      component.setting.laypage = component.setting.laypage === 'true'   // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡
+
       if (component.setting.useMSearch) {
         if (!window.GLOB.SearchBox.has(component.$searchId)) {
           component.setting.useMSearch = false
@@ -730,16 +757,27 @@
         }
       }
 
+      if (component.format === 'object') {
+        component.setting.laypage = false
+        component.setting.$top = true
+      }
+
       if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂
         component.setting.sync = 'false'
-        component.setting.laypage = component.setting.laypage === 'true'
+        component.setting.dataresource = ''
         return component
       }
 
       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}
           `
         }
@@ -747,7 +785,6 @@
       delete component.scripts
       component.setting.$name = component.$menuname || ''
       component.setting.execute = component.setting.execute !== 'false'  // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡
-      component.setting.laypage = component.setting.laypage === 'true'   // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡
 
       if (!component.setting.execute) {
         component.setting.dataresource = ''
@@ -759,17 +796,27 @@
       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     // 鍚庣疆鑷畾涔夎剼鏈�
+
+      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') {
         // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ

--
Gitblit v1.8.0