From 13fcf5880bd38bafe92f0b4a3ede7fd7d5e2448b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 03 四月 2024 17:54:16 +0800
Subject: [PATCH] 2024-04-03

---
 src/utils/utils-custom.js |  125 ++++++++++++++++++++++++++++++++---------
 1 files changed, 98 insertions(+), 27 deletions(-)

diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js
index 44a9750..209bc75 100644
--- a/src/utils/utils-custom.js
+++ b/src/utils/utils-custom.js
@@ -6,7 +6,7 @@
    * @description 鑾峰彇涓嬬骇妯″潡
    * @return {String}  selfId  褰撳墠缁勪欢id
    */
-  static getSubModules (components, selfId, supId, has) {
+  static getSubModules (components, selfId, supId, interfaces) {
     let modules = []
     components.forEach(item => {
       if (item.uuid === selfId || item.type === 'navbar') {
@@ -49,7 +49,7 @@
                 type: 'tab',
                 value: f_tab.uuid,
                 label: f_tab.label,
-                children: this.getSubModules(f_tab.components, selfId, supId, has)
+                children: this.getSubModules(f_tab.components, selfId, supId)
               }
   
               if (subItem.children.length === 0) {
@@ -94,6 +94,15 @@
         }
       }
     })
+
+    if (interfaces && interfaces.length > 0) {
+      interfaces.forEach(item => {
+        modules.push({
+          value: item.uuid,
+          label: item.name
+        })
+      })
+    }
 
     return modules
   }
@@ -719,7 +728,7 @@
   * @description 閲嶇疆缁勪欢閰嶇疆
   * @return {String}  item 缁勪欢淇℃伅
   */
-  static resetComponentConfig = (item, appType) => {
+  static resetComponentConfig = (item, appType, commonId) => {
     if (item.type === 'navbar') {
       return item
     }
@@ -727,9 +736,6 @@
     if (item.subtype === 'tablecard') { // 鍏煎
       item.type = 'card'
     }
-
-    item.uuid = this.getuuid()
-    let commonId = this.getuuid()
 
     // 閲嶇疆缁勪欢鍚嶇О
     let sign = this.getSignName()
@@ -954,20 +960,6 @@
       })
     }
 
-    if (item.setting && item.setting.supModule && item.setting.supModule[0] !== 'empty') {
-      item.setting.supModule = ''
-    }
-    
-    if (item.wrap && item.wrap.supType === 'multi') {
-      item.wrap.supType = 'single'
-
-      delete item.supNodes
-    }
-    
-    if (item.wrap && item.wrap.supModule) {
-      item.wrap.supModule = ''
-    }
-
     if (item.wrap && item.wrap.doubleClick) {
       item.wrap.doubleClick = md5(commonId + item.wrap.doubleClick)
     }
@@ -1001,7 +993,7 @@
         forbid: item.query === 'false'
       })
     } else {
-      let value = item.initval
+      let value = '0'
       let type = item.type
 
       if (item.type === 'date') {
@@ -1017,13 +1009,11 @@
       } else if (item.type === 'daterange') {
         value = '1949-10-01 00:00:00.000,1949-10-02 00:00:00.000'
       } else if (item.type === 'range') {
-        value = `${item.minValue},${item.maxValue}`
+        value = item.initval || `${item.minValue || '-999999999'},${item.maxValue || '999999999'}`
       } else if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) {
         type = 'multi'
-        value = '0'
-      } else {
-        value = '0'
       }
+
       newsearches.push({
         key: item.field,
         match: item.match,
@@ -1063,9 +1053,12 @@
       searchText.push(`('${item.value}' ${item.match} '%'+${item.key}+'%')`)
     } else if (item.type === 'date') {
       searchText.push('(' + item.key + ' ' + item.match + ' \'' + item.value + '\')')
-    } else if (item.type === 'dateweek' || item.type === 'range') {
+    } else if (item.type === 'dateweek') {
       let val = item.value.split(',')
       searchText.push('(' + item.key + ' >= \'' + val[0] + '\' AND ' + item.key + ' < \'' + val[1] + '\')')
+    } else if (item.type === 'range') {
+      let val = item.value.split(',')
+      searchText.push('(' + item.key + ' >= ' + (val[0] || -999999999) + ' AND ' + item.key + ' <= ' + (val[1] || 999999999) + ')')
     } else if (item.type === 'datemonth') {
       if (item.match === '=') {
         searchText.push('(' + item.key + ' = \'' + item.value + '\')')
@@ -1116,7 +1109,7 @@
         })
       }
       
-    } else if (['dateweek', 'range'].includes(item.type)) {
+    } else if (item.type === 'dateweek') {
       let val = item.value.split(',')
       options.push({
         reg: new RegExp('@' + item.key + '@', 'ig'),
@@ -1124,6 +1117,15 @@
       }, {
         reg: new RegExp('@' + item.key + '1@', 'ig'),
         value: `'${val[1]}'`
+      })
+    } else if (item.type === 'range') {
+      let val = item.value.split(',')
+      options.push({
+        reg: new RegExp('@' + item.key + '@', 'ig'),
+        value: `${val[0] || -999999999}`
+      }, {
+        reg: new RegExp('@' + item.key + '1@', 'ig'),
+        value: `${val[1] || 999999999}`
       })
     } else if (item.type === 'datemonth') {
       if (item.match === '=') {
@@ -1174,6 +1176,57 @@
   })
 
   return options
+}
+
+/**
+ * @description 鑾峰彇鎼滅储瀛楁
+ */
+export function getSearchFields (searches) {
+  if (!searches) return ''
+
+  let _usefulFields = []
+  searches.forEach(item => {
+    let key = item.key || item.field
+    
+    if (!key) return
+
+    if (item.type === 'group') {
+      _usefulFields.push(key)
+      if (item.datefield) {
+        _usefulFields.push(item.datefield)
+        _usefulFields.push(item.datefield + '1')
+      }
+    } else if (item.type === 'dateweek') {
+      _usefulFields.push(key)
+      _usefulFields.push(key + '1')
+    } else if (item.type === 'datemonth') {
+      if (item.match === '=') {
+        _usefulFields.push(key)
+      } else {
+        _usefulFields.push(key)
+        _usefulFields.push(key + '1')
+      }
+    } else if (item.type === 'range') {
+      _usefulFields.push(key)
+      _usefulFields.push(key + '1')
+    } else if (item.type === 'daterange') {
+      let _skey = key
+      let _ekey = key + '1'
+
+      if (/,/.test(key)) {
+        _skey = key.split(',')[0]
+        _ekey = key.split(',')[1]
+      }
+      _usefulFields.push(_skey)
+      _usefulFields.push(_ekey)
+    } else if (item.type === 'date' && _usefulFields.includes(key)) {
+      _usefulFields.push(key + '1')
+    } else {
+      _usefulFields.push(key)
+    }
+  })
+
+  return _usefulFields.join(', ')
 }
 
 /**
@@ -1596,6 +1649,16 @@
 
   if (card.$c_ds) {
     columns = card.columns.map(c => c.field)
+
+    if (card.setting.primaryKey && !columns.includes(card.setting.primaryKey)) {
+      let key = card.setting.primaryKey.toLowerCase()
+      columns.forEach(f => {
+        if (f.toLowerCase() === key) {
+          card.setting.primaryKey = f
+        }
+      })
+    }
+
     if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) {
       errors.push({ level: 0, detail: '鏈缃暟鎹簮锛�'})
     } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) {
@@ -1656,6 +1719,14 @@
         }
       }
     }
+
+    if (['pop', 'prompt', 'exec'].includes(cell.OpenType) && cell.verify && !cell.output) {
+      if (cell.verify.noteEnable === 'true') {
+        errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濇湭璁剧疆杩斿洖鍊肩煭淇″彂閫佹棤鏁堬紒`})
+      } else if (cell.verify.emailEnable === 'true') {
+        errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濇湭璁剧疆杩斿洖鍊奸偖浠跺彂閫佹棤鏁堬紒`})
+      }
+    }
   }
 
   if (card.$c_ac) {

--
Gitblit v1.8.0