From cc1a76df575c18f0d0ee96e8658461efdce3a918 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 17 一月 2023 18:01:01 +0800
Subject: [PATCH] 2023-01-17

---
 src/utils/utils-custom.js |  142 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 113 insertions(+), 29 deletions(-)

diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js
index 2ea10f9..1eaf2e9 100644
--- a/src/utils/utils-custom.js
+++ b/src/utils/utils-custom.js
@@ -277,6 +277,31 @@
   }
 
   /**
+   * @description 鑾峰彇涓婄骇妯″潡
+   * @return {String}  selfId  褰撳墠缁勪欢id
+   */
+  static checkSupModules (modules, supId) {
+    let has = false
+
+    let check = (list) => {
+      list.forEach(m => {
+        if (has) return
+        if (supId === m.value) {
+          has = true
+          return
+        }
+        if (m.children) {
+          check(m.children)
+        }
+      })
+    }
+
+    check(modules)
+   
+    return has
+  }
+
+  /**
    * @description 鑾峰彇鍙叧鑱旀ā鍧�
    */
   static getLinkModules (components) {
@@ -598,6 +623,9 @@
         if (em) {
           item.setting.supModule = ''
         }
+        if (item.wrap && item.wrap.supModule) {
+          item.wrap.supModule = item.setting.supModule
+        }
       }
 
       if (item.wrap && item.wrap.doubleClick) {
@@ -805,16 +833,10 @@
     }
 
     if (item.setting && item.setting.supModule && item.setting.supModule[0] !== 'empty') {
-      let em = false
-      item.setting.supModule = item.setting.supModule.map(c => {
-        if (!uuids[c]) {
-          em = true
-        }
-        return uuids[c] || ''
-      })
-      if (em) {
-        item.setting.supModule = ''
-      }
+      item.setting.supModule = ''
+    }
+    if (item.wrap && item.wrap.supModule) {
+      item.wrap.supModule = ''
     }
 
     if (item.wrap && item.wrap.doubleClick) {
@@ -850,46 +872,78 @@
 }
 
 /**
+ * @description 鑾峰彇鍥捐〃楂樺害
+ */
+export function getHeight (val) {
+  if (typeof(val) === 'string') {
+    if (val.indexOf('px') > -1) {
+      val = parseFloat(val)
+    } else if (val.indexOf('vw') > -1) {
+      val = parseFloat(val)
+      val = document.body.clientWidth * val / 100
+    } else if (val.indexOf('vh') > -1) {
+      val = parseFloat(val)
+      val = document.body.clientHeight * val / 100
+    }
+  }
+
+  return parseInt(val || 400) - 30
+}
+
+/**
  * @description 鑾峰彇琛ㄥ悕
  */
 export function getTables (config, pops) {
   let tables = []
   let cuts = []
-  let cutreg = /(from|update|insert\s+into)\s+(@db@)?[a-z_]+/ig
+  let cutreg = /(from|update|insert\s+into)\s+(@db@)?[a-z0-9_]+/ig
   let trimreg = /(from|update|insert\s+into)\s+(@db@)?/ig
 
-  if (!config.wrap || !config.wrap.datatype || config.wrap.datatype === 'dynamic') {
-    if (config.setting) {
-      if (config.setting.interType === 'system') {
-        if (config.setting.execute !== 'false') {
-          let tbs = config.setting.dataresource.match(cutreg)
-          tbs && cuts.push(...tbs)
-        }
-        config.scripts && config.scripts.forEach(script => {
-          if (script.status === 'false') return
-          let tbs = script.sql.match(cutreg)
-          tbs && cuts.push(...tbs)
-        })
-      } else {
-        let tb = config.setting.tableName.replace(/@db@|\s+/ig, '')
-        if (/[a-z_]+/ig.test(tb)) {
-          tables.push(tb)
-        }
+  if (config.setting && (!config.wrap || !config.wrap.datatype || config.wrap.datatype === 'dynamic')) {
+    if (config.setting.interType === 'system') {
+      if (config.setting.execute !== 'false' && config.setting.dataresource) {
+        let tbs = config.setting.dataresource.match(cutreg)
+        tbs && cuts.push(...tbs)
+      }
+      config.scripts && config.scripts.forEach(script => {
+        if (script.status === 'false') return
+        let tbs = script.sql.match(cutreg)
+        tbs && cuts.push(...tbs)
+      })
+    } else if (config.setting.tableName) {
+      let tb = config.setting.tableName.replace(/@db@|\s+/ig, '')
+      if (/[a-z_]+/ig.test(tb)) {
+        tables.push(tb)
       }
     }
   }
+
+  config.search && config.search.forEach(cell => {
+    if (cell.resourceType === '1' && cell.dataSource) {
+      let tbs = cell.dataSource.match(cutreg)
+      tbs && cuts.push(...tbs)
+    }
+  })
 
   let action = []
 
   if (config.type === 'form') {
     config.subcards.forEach(item => {
       action.push(item.subButton)
+      item.fields && item.fields.forEach(cell => {
+        if (cell.resourceType === '1' && cell.dataSource) {
+          let tbs = cell.dataSource.match(cutreg)
+          tbs && cuts.push(...tbs)
+        }
+      })
     })
   } else if (config.subcards) {
     config.subcards.forEach(item => {
       item.elements.forEach(cell => {
         if (cell.eleType !== 'button') return
         if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
+          action.push(cell)
+        } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
           action.push(cell)
         } else if (cell.OpenType === 'popview') {
           if (pops) {
@@ -905,6 +959,8 @@
           if (cell.eleType !== 'button') return
           if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
             action.push(cell)
+          } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
+            action.push(cell)
           } else if (cell.OpenType === 'popview') {
             if (pops) {
               pops.push({...cell, parentId: config.uuid})
@@ -916,10 +972,13 @@
       }
     })
   }
+
   config.cols && config.cols.forEach(col => {
     if (col.type === 'action') {
       col.elements.forEach(cell => {
         if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
+          action.push(cell)
+        } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
           action.push(cell)
         } else if (cell.OpenType === 'popview') {
           if (pops) {
@@ -936,6 +995,8 @@
     if (cell.eleType !== 'button') return
     if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
       action.push(cell)
+    } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
+      action.push(cell)
     } else if (cell.OpenType === 'popview') {
       if (pops) {
         pops.push({...cell, parentId: config.uuid})
@@ -947,6 +1008,8 @@
 
   config.action && config.action.forEach(cell => {
     if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
+      action.push(cell)
+    } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
       action.push(cell)
     } else if (cell.OpenType === 'popview') {
       if (pops) {
@@ -973,6 +1036,19 @@
           tbs && cuts.push(...tbs)
         })
       }
+    } else if (btn.OpenType === 'funcbutton') {
+      if (btn.intertype !== 'system' || !btn.verify || !btn.verify.setting) return
+      if (btn.verify.dataType === 'custom') {
+        if (btn.verify.setting.defaultSql !== 'false') {
+          let tbs = btn.verify.setting.dataresource.match(cutreg)
+          tbs && cuts.push(...tbs)
+        }
+        btn.verify.scripts && btn.verify.scripts.forEach(script => {
+          if (script.status === 'false') return
+          let tbs = script.sql.match(cutreg)
+          tbs && cuts.push(...tbs)
+        })
+      }
     } else if (btn.OpenType === 'excelOut') {
       if (btn.intertype !== 'system' || !btn.verify) return
       if (btn.verify.dataType === 'custom') {
@@ -991,6 +1067,14 @@
         tbs && cuts.push(...tbs)
       }
     } else {
+      if (btn.OpenType === 'pop' && btn.modal && btn.modal.fields) {
+        btn.modal.fields.forEach(cell => {
+          if (cell.resourceType === '1' && cell.dataSource) {
+            let tbs = cell.dataSource.match(cutreg)
+            tbs && cuts.push(...tbs)
+          }
+        })
+      }
       if (btn.intertype === 'inner') return
       if (btn.intertype === 'outer' || btn.intertype === 'custom') {
         if (btn.procMode === 'system' && btn.verify) {
@@ -1041,7 +1125,7 @@
 
   cuts = cuts.map(item => item.replace(trimreg, ''))
   tables.push(...cuts)
-  tables = tables.filter(Boolean)
+  tables = tables.filter(tb => tb && tb !== 'dbo' && tb.length > 1)
   tables = Array.from(new Set(tables))
 
   return tables

--
Gitblit v1.8.0