From d1cd5af5adb53e91efdd278328e1b6f8ad834fb5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 06 二月 2025 21:11:56 +0800
Subject: [PATCH] Merge branch 'positec' into dms

---
 src/tabviews/custom/index.jsx |  128 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 102 insertions(+), 26 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index b3f0872..61a6a47 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -3,6 +3,7 @@
 import { is, fromJS } from 'immutable'
 import { notification, Spin, Row, Col, Modal } from 'antd'
 import moment from 'moment'
+import md5 from 'md5'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -68,7 +69,8 @@
     loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
     visible: false,       // 鏍囩椤垫帶鍒�
     shortcuts: null,      // 蹇嵎閿�
-    loadinginter: false
+    loadinginter: false,
+    noParam: false
   }
 
   stepInter = null
@@ -78,6 +80,7 @@
    */
   async loadconfig () {
     const { MenuID, MenuName, param } = this.props
+    const { noParam } = this.state
 
     let _param = {
       func: 'sPC_Get_LongParam',
@@ -208,16 +211,35 @@
       let skip = config.permission === 'false' || window.GLOB.mkHS
       let urlparam = {} // url鍙傛暟
       if (param) {
-        Object.keys(param).forEach(key => {
-          if (/^\$/.test(key)) {
-            urlparam[key] = param[key]
-          } else {
-            urlparam[key.toLowerCase()] = param[key]
-          }
-        })
+        if (!noParam) {
+          Object.keys(param).forEach(key => {
+            if (/^\$/.test(key)) {
+              urlparam[key] = param[key]
+            } else {
+              urlparam[key.toLowerCase()] = param[key]
+            }
+          })
+        } else {
+          urlparam.$BID = param.$BID
+        }
       }
 
       window.GLOB.CacheData.set(MenuID, urlparam)
+
+      if (window.backend && config.allSqls) {
+        let keys = Object.keys(urlparam)
+        config.allSqls.forEach(item => {
+          item.id = md5(window.GLOB.appkey + item.v_id)
+          if (['datasource', 'interface', 'excelOut'].includes(item.type)) {
+            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') || ''
@@ -285,7 +307,7 @@
         }
       })
 
-      config.components = this.formatSetting(config.components, params, inherit, config.interfaces, balMap, tbMap)
+      config.components = this.formatSetting(config.components, params, inherit, config.interfaces, balMap, tbMap, BID)
 
       if (initInters.length > 0) {
         this.stepInter = {
@@ -567,8 +589,9 @@
         Utils.initSearchVal(item)
 
         if (urlparam.$searchkey) {
+          let reg = new RegExp('(^|,)' + urlparam.$searchkey + '($|,)', 'ig')
           item.search.forEach(cell => {
-            if (urlparam.$searchkey === cell.field.toLowerCase() && ['text', 'select', 'link', 'checkcard'].includes(cell.type)) {
+            if (reg.test(cell.field) && ['text', 'select', 'link', 'checkcard'].includes(cell.type)) {
               cell.initval = urlparam.$searchval
             }
           })
@@ -680,9 +703,16 @@
 
         if (item.hasExtend) {
           item.setting.hasExtend = true
+          item.setting.sync = 'false'
           item.setting.tableMode = 'compatible'
           item.setting.extendTime = moment().format('YYYY-MM-DD HH:mm:ss')
           item.colsCtrls = null
+        }
+
+        if (item.wrap.tree === 'true') {
+          item.setting.sync = 'false'
+          item.$cache = false
+          item.setting.$tree = true
         }
 
         if (item.subtype === 'editable') {
@@ -698,6 +728,9 @@
           }
         }
       } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
+        if (item.wrap.datatype === 'public') {
+          balMap.set(item.wrap.publicId + 'public', true)
+        }
         item.subcards && item.subcards.forEach(card => {
           if (card.style.boxShadow) {
             delete card.style.hShadow
@@ -804,6 +837,13 @@
 
           group.subButton = this.resetButton(item, group.subButton)
 
+          if (group.subButton.linkmenu) {
+            if (Array.isArray(group.subButton.linkmenu) && group.subButton.linkmenu.length > 0) {
+              group.subButton.openmenu = group.subButton.linkmenu
+            }
+            delete group.subButton.linkmenu
+          }
+
           if (item.$cache && item.$time) { // 琛ㄥ崟缂撳瓨
             group.$cache = item.$cache
             group.$time = item.$time
@@ -902,13 +942,17 @@
 
           item.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)
 
+          if (item.setting.$tree) {
+            item.setting.custompage = true
+          }
+
           if (!item.setting.execute || item.setting.custompage) {
             item.forbidLine = true
           }
 
           if (item.setting.sync === 'true') {
             // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ
-            if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true') {
+            if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true' && !_tailScript) {
 
             } else {
               item.setting.sync = 'false'
@@ -961,12 +1005,13 @@
         cell.modal.$cache = item.$cache
         cell.modal.$time = item.$time
       }
-      cell.modal.uuid = cell.uuid + 'pop'
+      cell.modal.uuid = cell.uuid + '_pop'
     }
 
     if (cell.verify) {
+      let isStatic = item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')
       if (cell.verify.invalid === 'true') {
-        if (item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')) {
+        if (isStatic) {
           cell.verify.invalid = 'false'
         } else if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) {
           cell.verify.invalid = 'false'
@@ -977,6 +1022,9 @@
         } else if (cell.Ot === 'notRequired') {
           cell.verify.invalid = 'false'
         }
+      }
+      if (cell.verify.uniques && cell.verify.uniques.length > 0 && cell.Ot === 'requiredOnce' && isStatic) {
+        cell.verify.uniques = []
       }
 
       if (cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) {
@@ -996,12 +1044,20 @@
         }
         if (/#position-inner/.test(script)) {
           cell.$innerScript = script
+
+          if (window.backend && window.GLOB.CacheData.has('sql_' + cell.uuid) && !/\$backend/.test(script)) {
+            window.GLOB.CacheData.delete('sql_' + cell.uuid)
+          }
         }
         if (/#position-outer/.test(script)) {
           cell.$outerScript = script
         }
         if (/#position-callback/.test(script)) {
           cell.$callbackScript = script
+
+          if (window.backend && window.GLOB.CacheData.has('sql_back_' + cell.uuid) && !/\$backend/.test(script)) {
+            window.GLOB.CacheData.delete('sql_back_' + cell.uuid)
+          }
         }
       }
     }
@@ -1014,6 +1070,7 @@
         }
       } else if (cell.syncComponentId === 'multiComponent') {
         let ids = cell.syncComponents.map(m => {
+          if (Array.isArray(m)) return m.pop() || ''
           return m.syncComId.pop() || ''
         })
 
@@ -1122,18 +1179,18 @@
   }
 
   // 鏍煎紡鍖栭粯璁よ缃�
-  formatSetting = (components, params, inherit, interfaces, balMap, tbMap) => {
+  formatSetting = (components, params, inherit, interfaces, balMap, tbMap, BID) => {
     let delay = 20
     return components.map(component => {
       if (component.type === 'tabs') {
         component.subtabs = component.subtabs.map(tab => {
-          tab.components = this.formatSetting(tab.components, null, inherit, interfaces, balMap, tbMap)
+          tab.components = this.formatSetting(tab.components, null, inherit, interfaces, balMap, tbMap, BID)
           tab = {...tab, ...inherit}
           return tab
         })
         return component
       } else if (component.type === 'group') {
-        component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap)
+        component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap, BID)
         return component
       }
 
@@ -1208,6 +1265,8 @@
 
       if (component.setting.interType !== 'system') return component
 
+      component.setting.uuid = component.uuid
+
       // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О
       if (component.setting.sync === 'true') {
         component.dataName = 'mk' + component.uuid.slice(-18)
@@ -1229,12 +1288,22 @@
             component.setting.sync = 'false'
             component.setting.onload = 'false'
           } else {
-            params.push(getStructDefaultParam(component, searchlist, params.length === 0))
+            let backend = false
+            if (window.backend && params.length === 0 && window.GLOB.CacheData.has('sql_' + component.uuid)) {
+              backend = true
+            } else if (window.backend && params[0] && params[0].exps) {
+              backend = true
+            }
+            if (backend && !window.GLOB.CacheData.has('sql_' + component.uuid)) {
+              component.setting.sync = 'false'
+            } else {
+              params.push(getStructDefaultParam(component, searchlist, params.length === 0, BID))
+            }
           }
         }
       }
       
-      component.setting.delay = delay
+      component.setting.delay = delay + (component.setting.delay || 0)
       delay += 20
 
       return component
@@ -1260,7 +1329,7 @@
     let delay = 15
     return interfaces.map(inter => {
       inter.MenuID = MenuID
-      inter.setting.delay = delay
+      inter.setting.delay = delay + (inter.setting.delay || 0)
       inter.$searchId = MenuID
       delay += 15
 
@@ -1283,6 +1352,8 @@
       inter.setting.arr_field = inter.columns.map(col => col.field).join(',')
 
       if (inter.setting.interType !== 'system') return inter
+
+      inter.setting.uuid = inter.uuid
 
       let _customScript = ''
       let _tailScript = ''
@@ -1345,7 +1416,11 @@
     this.setState({loading: true, loadingview: false})
 
     if (config.$cache && config.$time) {
-      Api.getLCacheConfig(params[0].uuid, config.$time, BID).then(res => {
+      let uuid = params[0].uuid || ''
+      if (params[0].id) {
+        uuid = window.GLOB.CacheData.get('first_' + params[0].id) || ''
+      }
+      Api.getLCacheConfig(uuid, config.$time, BID).then(res => {
         if (!res.valid) {
           this.getMainData(param, params, config.MenuID)
         } else {
@@ -1381,11 +1456,11 @@
         }
 
         params.forEach((item) => {
-          let _data = result[item.name] || ''
+          let _data = result[item.dataName] || ''
           if (_data && !Array.isArray(_data)) {
             _data = [_data]
           }
-          window.GLOB.SyncData.set(item.name, _data)
+          window.GLOB.SyncData.set(item.dataName, _data)
         })
 
         MKEmitter.emit('transferSyncData', MenuID)
@@ -1412,12 +1487,12 @@
     })
   }
 
-  reloadMenuView = (menuId) => {
+  reloadMenuView = (menuId, clear) => {
     const { MenuID } = this.props
 
     if (MenuID !== menuId) return
 
-    this.reloadview()
+    this.reloadview(clear)
   }
 
   resetActiveMenu = (menuId) => {
@@ -1512,7 +1587,7 @@
     })
   }
 
-  reloadview = () => {
+  reloadview = (clear) => {
     window.GLOB.CacheData.delete(this.props.MenuID)
     
     if (this.state.config) {
@@ -1530,7 +1605,8 @@
       viewlost: false,      // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤
       config: null,         // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑
       loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
-      shortcuts: null
+      shortcuts: null,
+      noParam: clear === true
     }, () => {
       this.loadconfig()
     })

--
Gitblit v1.8.0