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/menu/debug/index.jsx |  202 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 194 insertions(+), 8 deletions(-)

diff --git a/src/menu/debug/index.jsx b/src/menu/debug/index.jsx
index 2df2119..faff4b8 100644
--- a/src/menu/debug/index.jsx
+++ b/src/menu/debug/index.jsx
@@ -27,6 +27,8 @@
   sqlList = []
   verSqls = []
   linkMain = null
+  modules = null
+  supError = null
 
   trigger = () => {
     let config = fromJS(this.props.config).toJS()
@@ -61,6 +63,30 @@
     if (error) {
       Modal.warning({
         title: error,
+        okText: '鐭ラ亾浜�'
+      })
+      return
+    }
+
+    this.modules = {}
+    this.supError = null
+
+    this.getModules(config.components, config.interfaces)
+
+    config.interfaces && config.interfaces.forEach(item => {
+      if (item.setting && item.setting.supModule && item.setting.supModule[0] !== 'empty') {
+        let id = item.setting.supModule[item.setting.supModule.length - 1]
+        if (!this.modules[id]) {
+          this.supError = item.name + '锛堝叕鍏辨暟鎹簮锛�'
+        }
+      }
+    })
+
+    this.checklink(config.components)
+
+    if (this.supError) {
+      Modal.warning({
+        title: this.supError + '锛氫笂绾х粍浠朵笉瀛樺湪锛�',
         okText: '鐭ラ亾浜�'
       })
       return
@@ -284,6 +310,122 @@
     })
 
     this.sqlList = []
+  }
+
+  getModules = (components, interfaces, sups = []) => {
+    components.forEach(item => {
+      this.modules[item.uuid] = [...sups, item.uuid]
+      if (item.type === 'tabs') {
+        item.subtabs.forEach(f_tab => {
+          this.getModules(f_tab.components, null, [...sups, item.uuid, f_tab.uuid])
+        })
+      } else if (item.type === 'group') {
+        item.components.forEach(cell => {
+          this.modules[cell.uuid] = [...sups, item.uuid, cell.uuid]
+        })
+      }
+    })
+
+    if (interfaces && interfaces.length > 0) {
+      interfaces.forEach(item => {
+        this.modules[item.uuid] = [item.uuid]
+      })
+    }
+  }
+
+  checklink = (components, suplabel = '') => {
+    if (this.supError) return
+    components.forEach(item => {
+      if (this.supError) return
+      if (item.type === 'tabs') {
+        item.subtabs.forEach(f_tab => {
+          this.checklink(f_tab.components, suplabel)
+        })
+      } else if (item.type === 'group' ) {
+        item.components && this.checklink(item.components, suplabel)
+      } else {
+        if (item.wrap && item.wrap.supType === 'multi') {
+          if (item.setting && item.setting.supModule) {
+            item.setting.supModule = ''
+          }
+          if (item.supNodes) {
+            item.supNodes.forEach(cell => {
+              let id = cell.nodes[cell.nodes.length - 1]
+              if (!this.modules[id]) {
+                this.supError = suplabel + item.name
+              }
+            })
+          }
+        } else if ((item.wrap && item.wrap.datatype === 'static') || (['mainsearch', 'voucher'].includes(item.subtype))) {
+          if (item.wrap && item.wrap.supModule && item.wrap.supModule[0]) {
+            let id = item.wrap.supModule[item.wrap.supModule.length - 1]
+            if (!this.modules[id]) {
+              this.supError = suplabel + item.name
+            }
+          }
+        } else if (item.setting && item.setting.supModule && item.setting.supModule[0] !== 'empty') {
+          let id = item.setting.supModule[item.setting.supModule.length - 1]
+          if (!this.modules[id]) {
+            this.supError = suplabel + item.name
+          }
+        }
+
+        if (this.supError) return
+
+        if (['card', 'carousel', 'timeline'].includes(item.type)) {
+          item.subcards.forEach(card => {
+            card.elements && card.elements.forEach(cell => {
+              if (cell.eleType === 'button' && cell.OpenType === 'popview') {
+                if (cell.config && cell.config.components && cell.config.enabled) {
+                  this.checklink(cell.config.components, item.name + '-' + cell.label + '锛堝脊绐楁爣绛撅級-')
+                }
+              }
+            })
+            card.backElements && card.backElements.forEach(cell => {
+              if (cell.eleType === 'button' && cell.OpenType === 'popview') {
+                if (cell.config && cell.config.components && cell.config.enabled) {
+                  this.checklink(cell.config.components, item.name + '-' + cell.label + '锛堝脊绐楁爣绛撅級-')
+                }
+              }
+            })
+          })
+        } else if (item.type === 'balcony') {
+          item.elements && item.elements.forEach(cell => {
+            if (cell.eleType === 'button' && cell.OpenType === 'popview') {
+              if (cell.config && cell.config.components && cell.config.enabled) {
+                this.checklink(cell.config.components, item.name + '-' + cell.label + '锛堝脊绐楁爣绛撅級-')
+              }
+            }
+          })
+        } else if (item.type === 'table' && item.cols) {
+          let loopCol = (cols) => {
+            cols.forEach(col => {
+              if (col.type === 'colspan' && col.subcols) {
+                loopCol(col.subcols)
+              } else if (col.type === 'custom' && col.elements) {
+                col.elements.forEach(cell => {
+                  if (cell.eleType === 'button' && cell.OpenType === 'popview') {
+                    if (cell.config && cell.config.components && cell.config.enabled) {
+                      this.checklink(cell.config.components, item.name + '-' + cell.label + '锛堝脊绐楁爣绛撅級-')
+                    }
+                  }
+                })
+              }
+            })
+          }
+    
+          loopCol(item.cols)
+        }
+    
+        item.action && item.action.forEach(cell => {
+          if (cell.OpenType === 'popview') {
+            if (cell.config && cell.config.components && cell.config.enabled) {
+              this.checklink(cell.config.components, item.name + '-' + cell.label + '锛堝脊绐楁爣绛撅級-')
+            }
+          }
+        })
+      }
+    })
   }
 
   filterComponent = (components, mainSearch, regs, process, ispop = false) => {
@@ -783,6 +925,11 @@
             writein: item.writein !== 'false',
             type: item.type
           }
+
+          if (item.type === 'linkMain' && item.verifyVal === 'true') {
+            _item.$verify = true
+            _item.label = item.label
+          }
     
           if (_item.type === 'datemonth') {
             _item.type = 'text'
@@ -832,6 +979,11 @@
             writein: item.writein !== 'false',
             type: item.type
           }
+
+          if (item.type === 'linkMain' && item.verifyVal === 'true') {
+            _item.$verify = true
+            _item.label = item.label
+          }
     
           if (_item.type === 'datemonth') {
             _item.type = 'text'
@@ -869,8 +1021,20 @@
         key: 'mk_n_id'
       })
     }
+
+    let verifyValSql = ''
     // 鑾峰彇瀛楁閿�煎
     formdata && formdata.forEach(form => {
+      if (form.$verify) {
+        verifyValSql += `
+        if @${form.key}=${form.type === 'number' ? 0 : `''`}
+        begin
+          select @errorcode='E',@retmsg='${form.label}锛屽叧鑱斾富琛ㄥけ鏁�'
+          goto aaa
+        end
+        `
+      }
+
       let _key = form.key.toLowerCase()
       if (!_initvars.includes(_key)) {
         _initvars.push(_key)
@@ -1111,22 +1275,21 @@
   
       verify.billcodes.forEach(item => {
         let _key = item.field.toLowerCase()
-        let _linkKey = item.linkField ? item.linkField.toLowerCase() : ''
   
         if (!keys.includes(_key)) return // 琛ㄥ崟涓笉鍚崟鍙风敓鎴愬瓧娈�
   
         let _lpline = ''
         if (item.TypeCharOne === 'Lp') {
-          if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
+          if (/^BID$/ig.test(item.linkField)) {
             _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)`
           } else {
-            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)`
+            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField},48)`
           }
         } else if (item.TypeCharOne === 'BN') {
-          if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
+          if (/^BID$/ig.test(item.linkField)) {
             _lpline = `set @ModularDetailCode= 'BN'+ right(@BID@,48)`
           } else {
-            _lpline = `set @ModularDetailCode= 'BN'+ right(@${_linkKey},48)`
+            _lpline = `set @ModularDetailCode= 'BN'+ right(@${item.linkField},48)`
           }
         } else {
           _lpline = `set @ModularDetailCode= right('${item.ModularDetailCode}',50)`
@@ -1236,15 +1399,20 @@
     let hasvoucher = false
   
     // 鍑瘉-鏄剧ず鍒椾腑閫夊彇,蹇呴』閫夎
-    if (verify.voucher && verify.voucher.enabled && btn.Ot !== 'requiredOnce') {
+    if (verify.voucher && verify.voucher.enabled) {
       let _voucher = verify.voucher
+      let linkField = `@${_voucher.linkField}`
   
+      if (/^BID$/ig.test(_voucher.linkField)) {
+        linkField = `'${BID}'`
+      }
+
       hasvoucher = true
   
       _sql += `
         /* 鍒涘缓鍑瘉 */
         exec s_BVoucher_Create
-          @Bill = @${_voucher.linkField},
+          @Bill = ${linkField},
           @BVoucherType ='${_voucher.BVoucherType}',
           @VoucherTypeOne ='${_voucher.VoucherTypeOne}',
           @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}',
@@ -1507,6 +1675,10 @@
       }
     } else if (_backCustomScript) {
       _sql += _backCustomScript
+    }
+
+    if (verifyValSql) {
+      _sql += verifyValSql
     }
   
     if (btn.procMode === 'system') {
@@ -1937,6 +2109,7 @@
         let _fields = unique.field.split(',')
         let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`)
         _fields_ = _fields_.join(' and ')
+        _fields_ += ` and a.jskey != b.${setting.primaryKey || 'id'}`
 
         let _where = []
         _fields.forEach(f => {
@@ -1993,6 +2166,7 @@
 
     let declarefields = []
     let fields = []
+    let upFields = []
 
     forms.forEach(col => {
       let key = col.field.toLowerCase()
@@ -2000,15 +2174,27 @@
 
       declarefields.push(`${col.field} ${col.datatype}`)
       fields.push(col.field)
+      upFields.push(`${col.field}=t.${col.field}`)
     })
 
     fields = fields.join(',')
+    upFields = upFields.join(',')
 
     let _insert = ''
     if (btn.default !== 'false') {
       _insert = `
       /* 榛樿sql */
-      Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) 
+      update a set ${upFields},modifydate=getdate(),modifyuserid='${sessionStorage.getItem('UserID') || ''}',modifyuser=@username,modifystaff=@fullname,deleted=0
+      from (select * from #${sheet} where data_type='upt') t
+      inner join ${database}${sheet} a on t.jskey=a.${setting.primaryKey || 'id'}
+
+      update a set deleted=1,modifydate=getdate(),modifyuserid='${sessionStorage.getItem('UserID') || ''}',modifyuser=@username,modifystaff=@fullname 
+      from (select * from #${sheet} where data_type='del') t
+      inner join ${database}${sheet} a on t.jskey=a.${setting.primaryKey || 'id'}
+
+      delete t from #${sheet} t inner join ${database}${sheet} a on t.jskey=a.${setting.primaryKey || 'id'}
+
+      Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid)
       Select ${fields},'${sessionStorage.getItem('UserID') || ''}',@username,@fullname,'${BID}' From #${sheet}
       `
     }

--
Gitblit v1.8.0