king
2 天以前 047dbd742341e268ca772eda8d2ff0b6ba09cb44
src/utils/utils.js
@@ -192,8 +192,10 @@
   * @param {Array}   searches     搜索条件
   */
  static initSearchVal (config) {
    if (!config.search) {
    if (!config.search || config.search.length === 0) {
      config.search = []
      config.$s_keys = []
      config.$s_req = false
      return
    }
@@ -247,9 +249,6 @@
              config.checkBid = true
              item.checkShift = true
              if (config.setting) {
                config.setting.checkBid = true
              }
            }
            item.initval = ''
@@ -315,9 +314,6 @@
              config.checkBid = true
              item.checkShift = true
              if (config.setting) {
                config.setting.checkBid = true
              }
            }
            item.initval = ''
@@ -416,9 +412,6 @@
        if (/@BID@/ig.test(item.dataSource) && supModule) {
          config.checkBid = true
          item.checkBid = true
          if (config.setting) {
            config.setting.checkBid = true
          }
        }
        if (item.initval === '$first') {
          item.initval = ''
@@ -466,6 +459,15 @@
      return item
    })
    if (config.checkBid) {
      if (config.setting) {
        config.setting.checkBid = true
      }
      if (config.type !== 'search') {
        config.$checkBid = true
      }
    }
    config.$s_keys = keys
    config.$s_req = required
@@ -1140,16 +1142,34 @@
    cols.push('A' + cols[i])
  }
  let columns = JSON.parse(JSON.stringify(btn.columns))
  columns = columns.filter((col, index) => {
    col.colIndex = cols[index] || (index + 1)
    if (col.import !== 'init' && (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type))) {
      col.declen = 0
      if (/^Decimal/ig.test(col.type)) {
        col.declen = +col.type.match(/\d+/g)[1]
      }
      col.declen = col.declen || 0
    }
    if (col.required === 'false') {
      delete col.min
      delete col.max
    }
    return col.import !== 'false'
  })
  let _Ltext = data.map((item, lindex) => {
    let vals = []
    btn.columns.forEach((col, cindex) => {
      if (col.import === 'false') return
    columns.forEach(col => {
      let val = item[col.Column] !== undefined ? item[col.Column] : ''
      let _colindex = cols[cindex] || (cindex + 1)
      let _position = (_topline + lindex + 1) + '行 ' + _colindex + '列 '
      let _position = (_topline + lindex + 1) + '行 ' + col.colIndex + '列 '
      let eLen = errors.length
      if (col.import === 'init') {
      if (col.$error) {
      } else if (col.import === 'init') {
        if (/^Nvarchar/ig.test(col.type)) {
          val = ''
        } else if (/^Decimal/ig.test(col.type) || /^int/ig.test(col.type)) {
@@ -1168,6 +1188,10 @@
        val = val.replace(/(^\s+$)|\t+|\v+/ig, '')
        if (col.interception !== 'false') {
          val = val.replace(/^\s+|\s+$/g, '')
        }
        if (!val && col.required === 'true') {            // 必填校验
          errors.push(_position + '内容不可为空')
        } else if (col.limit && val.length > col.limit) { // 长度校验
@@ -1185,14 +1209,24 @@
          if (!val || isNaN(val)) {
            val = 0
          }
        } else if (!val && val !== 0) {
        }
        if (!val && val !== 0) {
          errors.push(_position + '内容不可为空')
        } else if (isNaN(val)) {                                  // 检验是否为数值
          errors.push(_position + '内容应为数值')
        } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验
        } else if (typeof(col.min) === 'number' && val < col.min) { // 最小值检验
          errors.push(_position + '小于最小值')
        } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验
        } else if (typeof(col.max) === 'number' && val > col.max) { // 最大值检验
          errors.push(_position + '大于最大值')
        } else {
          let _float = (val + '').split('.')[1]
          if (_float && _float.length > col.declen) {
            if (col.declen) {
              errors.push(_position + `数值不可大于${col.declen}位小数`)
            } else {
              errors.push(_position + '数值应为整数')
            }
          }
        }
      } else if (col.type === 'date' || col.type === 'datetime') {
        if (typeof(val) === 'number') {
@@ -1227,6 +1261,10 @@
        } else {                                    // 时间格式错误
          errors.push(_position + '时间格式错误')
        }
      }
      if (errors.length > eLen) {
        col.$error = true
      }
      vals.push(`'${val}'`)
@@ -1843,6 +1881,7 @@
  let _initColfields = []
  let _declarefields = []
  let verifyValSql = ''
  let datavars = {}
  // 获取字段键值对
  formdata && formdata.forEach(form => {
@@ -1857,6 +1896,7 @@
    }
    let _key = form.key.toLowerCase()
    datavars[_key] = form.value
    if (!_initvars.includes(_key)) {
      _initvars.push(_key)
@@ -1911,6 +1951,8 @@
  // 添加数据中字段,表单值优先(按钮不选行或多行拼接时跳过)
  if (data && btn.Ot !== 'notRequired' && columns && columns.length > 0) {
    datavars = {..._data, ...datavars}
    const setField = (col) => {
      if (!col.field) return
      let _key = col.field.toLowerCase()
@@ -2205,7 +2247,7 @@
      item.field.split(',').forEach((_field, index) => {
        let _key = _field.toLowerCase()
        let _val = ''
        let _val2 = ''
        let _val2 = datavars[_key] !== undefined ? datavars[_key] : ''
        arr.push(_key)
        if (_key === 'bid') {
@@ -2216,8 +2258,6 @@
        
        if (_key === 'bid') {
          _val2 = BID
        } else {
          _val2 = `' + @${_field} + '`
        }
        
        _fieldValue.push(`${_key}=${_val}`)