king
2023-11-05 ab949bb71eadda3ec1736ccdcfaa1b12b04cce6a
src/utils/utils.js
@@ -116,46 +116,6 @@
  }
  /**
   * @description sql语法验证
   * @return {String}  sql    sql语句
   * @return {String}  type   验证类型
   */
  static verifySql (sql, type) {
    if (!sql) return ''
    let chars = [
      {key: 'create', reg: /(^|\s|\(|\))create\s/ig},
      {key: 'insert', reg: /(^|\s|\(|\))insert\s/ig},
      {key: 'delete', reg: /(^|\s|\(|\))delete\s/ig},
      {key: 'update', reg: /(^|\s|\(|\))update\s/ig},
      {key: 'set', reg: /(^|\s|\(|\))set\s/ig},
      {key: 'drop', reg: /(^|\s|\(|\))drop\s/ig},
      {key: 'alter', reg: /(^|\s|\(|\))alter\s/ig},
      {key: 'truncate', reg: /(^|\s|\(|\))truncate\s/ig},
      {key: 'if', reg: /(^|\s|\(|\))if\s/ig},
      {key: 'exec', reg: /(^|\s|\(|\))exec(\s|\()/ig},
      {key: 'OBJECT', reg: /(^|\s|\(|\))object(\s|\()/ig},
      {key: 'sys.', reg: /(^|\s|\(|\))sys\./ig},
      {key: 'kill', reg: /(^|\s|\(|\))kill\s/ig}
    ]
    if (type === 'customscript') {
      chars = chars.filter(char => !['create', 'insert', 'delete', 'update', 'set', 'drop', 'if', 'exec'].includes(char.key))
    }
    let error = ''
    sql = sql.replace(/sys\.fn_/ig, '') // 跳过sys.fn_验证
    chars.forEach(char => {
      if (!error && char.reg.test(sql)) {
        error = char.key
      }
    })
    return error
  }
  /**
   * @description sql加密
   * @return {String}   value
   */
@@ -979,7 +939,11 @@
          })
        }
      } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) {
        if (!val && val !== 0) {
        if (col.required === 'false') {
          if (!val || isNaN(val)) {
            val = 0
          }
        } else if (!val && val !== 0) {
          errors.push(_position + '内容不可为空')
        } else if (isNaN(val)) {                                  // 检验是否为数值
          errors.push(_position + '内容应为数值')
@@ -2370,6 +2334,10 @@
  _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
  _sql = _sql.replace(/@typename@/ig, `'admin'`)
  if (window.GLOB.externalDatabase !== null) {
    _sql = _sql.replace(/@db@/ig, window.GLOB.externalDatabase)
  }
  if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
    _sql = _sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`)
  } else {
@@ -2394,9 +2362,8 @@
/**
 * @description 获取标记信息
 */
export function getMark (marks, record, style = {}) {
  style = JSON.parse(JSON.stringify(style))
  let res = {style}
export function getMark (marks, record, style) {
  let res = {signType: ''}
  marks.some(mark => {
    let originVal = record[mark.field[0]]
@@ -2431,22 +2398,22 @@
    let type = mark.signType[0]
    if (type === 'font') {
      res.style.color = mark.color
      style.color = mark.color
      res.innerStyle = {color: mark.color}
      res.signType = ' sign-font'
    } else if (type === 'background') {
      res.style.backgroundColor = mark.color
      style.backgroundColor = mark.color
      if (mark.fontColor) {
        res.style.color = mark.fontColor
        style.color = mark.fontColor
        res.innerStyle = {color: mark.fontColor}
      }
    } else if (type === 'underline') {
      res.style.textDecoration = 'underline'
      res.style.color = mark.color
      style.textDecoration = 'underline'
      style.color = mark.color
      res.innerStyle = {color: mark.color, textDecoration: 'underline'}
    } else if (type === 'line-through') {
      res.style.textDecoration = 'line-through'
      res.style.color = mark.color
      style.textDecoration = 'line-through'
      style.color = mark.color
      res.innerStyle = {color: mark.color, textDecoration: 'line-through'}
    } else if (type.indexOf('icon') > -1) {
      res.icon = mark.signType[mark.signType.length - 1]
@@ -2457,7 +2424,7 @@
        res.position = 'back'
      }
    } else if (type === 'indent') {
      res.style.color = mark.color
      style.color = mark.color
      res.space = Array(mark.signType[1] + 1).join(' ')
    } else if (type === 'pointfront') {
      res.position = 'front'