king
2023-08-31 3e8101e4b5afb513e21279a00abfa9c98bb81c19
src/utils/utils.js
@@ -923,6 +923,8 @@
          val = 0
        } else if (col.type === 'date') {
          val = '1949-10-01'
        } else if (col.type === 'datetime') {
          val = '1949-10-01 00:00:00'
        }
      } else if (/^Nvarchar/ig.test(col.type)) {
        val = val + ''
@@ -955,7 +957,7 @@
        } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验
          errors.push(_position + '大于最大值')
        }
      } else if (col.type === 'date') {
      } else if (col.type === 'date' || col.type === 'datetime') {
        if (typeof(val) === 'number') {
          if (val > 2958465 || val <= 0) {                 // 时间过大或小于等于0
            errors.push(_position + '时间为负值或太大')
@@ -963,7 +965,14 @@
            if (val < 60) {                                // 1900-2-29,excel中存在,实际不存在
              val++
            }
            val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD')
            if (col.type === 'datetime') {
              val = val - 2
              let day = Math.floor(val)
              let seconds = Math.round((val - day) * 24 * 60 * 60)
              val = moment('19000101', 'YYYYMMDD').add(day, 'days').add(seconds, 'seconds').format('YYYY-MM-DD HH:mm:ss')
            } else {
              val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD')
            }
          }
        } else if (typeof(val) === 'string') {
          val = val.replace(/(^\s+$)|\t+|\v+/ig, '')
@@ -1012,6 +1021,10 @@
      {reg: /@\$/ig, value: isDM ? '*/' : ''},
      {reg: /@datam@/ig, value: isDM ? `'Y'` : `''`},
    ]
    if (window.GLOB.externalDatabase !== null) {
      regs.push({reg: /@db@/ig, value: window.GLOB.externalDatabase})
    }
    btn.scripts && btn.scripts.forEach(script => {
      if (script.status === 'false') return
@@ -1219,6 +1232,10 @@
      {reg: /@datam@/ig, value: isDM ? `'Y'` : `''`},
    ]
    if (window.GLOB.externalDatabase !== null) {
      regs.push({reg: /@db@/ig, value: window.GLOB.externalDatabase})
    }
    btn.scripts && btn.scripts.forEach(script => {
      if (script.status === 'false') return