king
2025-02-06 d1cd5af5adb53e91efdd278328e1b6f8ad834fb5
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) => {
@@ -784,6 +926,11 @@
            type: item.type
          }
    
          if (item.type === 'linkMain' && item.verifyVal === 'true') {
            _item.$verify = true
            _item.label = item.label
          }
          if (_item.type === 'datemonth') {
            _item.type = 'text'
          } else if (_item.type === 'number' || _item.type === 'rate') {
@@ -833,6 +980,11 @@
            type: item.type
          }
    
          if (item.type === 'linkMain' && item.verifyVal === 'true') {
            _item.$verify = true
            _item.label = item.label
          }
          if (_item.type === 'datemonth') {
            _item.type = 'text'
          } else if (_item.type === 'number' || _item.type === 'rate') {
@@ -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,14 +2174,26 @@
      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 */
      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}
      `