king
2020-04-14 d5e92a5383860b5fcd449507028b84bddf3a41f2
src/utils/utils.js
@@ -164,8 +164,8 @@
    })
    // 1、替换%符(数据库中解析后sql报错),2、去除收尾多余空格
    value = value.replace(/%/ig, 'mpercent')
    value = value.replace(/(^\s|\s$)/ig, '')
    value = value.replace(/%/ig, ' mpercent ')
    // value = value.replace(/(^\s|\s$)/ig, '')
    // 1、encode编码(中文字符超出base64加密范围),2、base64加密
    value = window.btoa(window.encodeURIComponent(value))
@@ -505,7 +505,7 @@
            })
          }
        } else if (/^int/ig.test(col.type)) {
          if (!val) {
          if (!val && val !== 0) {
            let _error =  _position + dict['main.excel.content.emptyerror']
            errors.push(_error)
          } else {
@@ -523,7 +523,7 @@
            }
          }
        } else if (/^Decimal/ig.test(col.type)) {
          if (!val) {
          if (!val && val !== 0) {
            let _error =  _position + dict['main.excel.content.emptyerror']
            errors.push(_error)
          } else {
@@ -667,7 +667,7 @@
   * @return {String} type   执行类型
   * @return {String} table  表名
   */
  static getSysDefaultSql (btn, setting, formdata, param, data, logcolumns) {
  static getSysDefaultSql (btn, setting, formdata, param, data, logcolumns, tab) {
    let primaryId = param.ID
    let BID = param.BID
    let verify = btn.verify || {}
@@ -907,9 +907,9 @@
        let _lpline = ''
        if (item.TypeCharOne === 'Lp') {
          if (item.linkField === 'BID' && BID) { // 替换bid
            _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@BID@,48)`
            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)`
          } else {
            _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@${item.linkField},48)`
            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField},48)`
          }
          _ModularDetailCode = '@ModularDetailCode'
        } else if (item.TypeCharOne === 'BN') {
@@ -964,6 +964,9 @@
          @VoucherTypeOne ='${_voucher.VoucherTypeOne}',
          @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}',
          @Type =${_voucher.Type},
          @UserID=@UserID@,
          @Username=@Username,
          @FullName=@FullName,
          @BVoucher =@BVoucher OUTPUT ,
          @FIBVoucherDate =@FIBVoucherDate OUTPUT ,
          @FiYear =@FiYear OUTPUT ,
@@ -982,8 +985,9 @@
      _actionType = btn.sqlType
    }
    // 添加、修改、逻辑删除、物理删除
    if (_actionType === 'insert') {
    let _insertsql = ''
    let _updatesql = ''
    if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 添加语句
      let keys = []
      let values = []
@@ -1017,14 +1021,18 @@
        values.push('@fullname')
      }
      if (!keys.includes('bid')) {
        keys.push('bid')
        if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) {
          keys.push(tab.foreignKey)
        } else {
          keys.push('bid')
        }
        values.push('@BID@')
      }
      keys = keys.join(',')
      values = values.join(',')
      _sql += `insert into ${btn.sql} (${keys}) select ${values};`
    } else if (_actionType === 'update') {
      _insertsql = `insert into ${btn.sql} (${keys}) select ${values};`
    } else if (_actionType === 'update' || _actionType === 'insertOrUpdate') { // 修改语句
      let _form = []
      let _arr = []
@@ -1059,7 +1067,14 @@
      }
      _form = _form.join(',')
      _sql += `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKeyName};`
      _updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKeyName};`
    }
    // 添加、修改、逻辑删除、物理删除
    if (_actionType === 'insert') {
      _sql += _insertsql
    } else if (_actionType === 'update') {
      _sql += _updatesql
    } else if (_actionType === 'LogicDelete') { // 逻辑删除
      _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKeyName};`
    
@@ -1075,6 +1090,14 @@
        })
      }
      _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@${primaryKeyName},@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};`
    } else if (_actionType === 'insertOrUpdate') {
      _sql += `select @tbid=''
        select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@
        if @tbid=''
          ${_insertsql}
        else
          ${_updatesql}
      `
    }
    // 拼接自定义脚本
@@ -1293,6 +1316,10 @@
        
        update ${param.name} set ${field3},modifydate=getdate(),modifyuserid=@UserID
      `
    } else if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') {
      form = `
        update ${param.name} set ModifyDate=getdate(),ModifyUserID=@UserID where ${primaryKey}=@${primaryKey}
      `
    }
    if (columns) {