| | |
| | | |
| | | val = val.replace(/(^\s*$)|\t*|\v*/ig, '') |
| | | |
| | | let limitlen = col.type.match(/\d+/)[0] |
| | | |
| | | if (!val && col.required === 'true') { // 必填校验 |
| | | let _error = _position + dict['main.excel.content.emptyerror'] |
| | | errors.push(_error) |
| | | } else if (val.length > limitlen) { // 长度校验 |
| | | } else if (val.length > col.limit) { // 长度校验 |
| | | let _error = _position + dict['main.excel.content.maxlimit'] |
| | | errors.push(_error) |
| | | } else { // 关键字校验 |
| | |
| | | }) |
| | | } |
| | | } else if (/^int/ig.test(col.type)) { |
| | | if (typeof(val) !== 'number' || parseInt(val) < parseFloat(val)) { // 检验是否为整数 |
| | | let _error = _position + dict['main.excel.content.interror'] |
| | | if (!val) { |
| | | let _error = _position + dict['main.excel.content.emptyerror'] |
| | | errors.push(_error) |
| | | } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 |
| | | let _error = _position + dict['main.excel.content.limitmin'] |
| | | errors.push(_error) |
| | | } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 |
| | | let _error = _position + dict['main.excel.content.limitmax'] |
| | | errors.push(_error) |
| | | } else { |
| | | let _val = val + '' |
| | | |
| | | if (!/^(([^0][0-9]+|0)$)|^(([1-9]+)$)/.test(_val)) { // 检验是否为整数 |
| | | let _error = _position + dict['main.excel.content.interror'] |
| | | errors.push(_error) |
| | | } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 |
| | | let _error = _position + dict['main.excel.content.limitmin'] |
| | | errors.push(_error) |
| | | } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 |
| | | let _error = _position + dict['main.excel.content.limitmax'] |
| | | errors.push(_error) |
| | | } |
| | | } |
| | | } else if (/^Decimal/ig.test(col.type)) { |
| | | let _val = val + '' |
| | | _val = _val.split('.') |
| | | let limitlen = col.type.match(/\d+/ig)[1] |
| | | if (!val) { |
| | | let _error = _position + dict['main.excel.content.emptyerror'] |
| | | errors.push(_error) |
| | | } else { |
| | | let _val = val + '' |
| | | let _vals = _val.split('.') |
| | | |
| | | if (typeof(val) !== 'number') { // 检验是否为浮点数 |
| | | let _error = _position + dict['main.excel.content.floaterror'] |
| | | errors.push(_error) |
| | | } else if (_val[0].length > 18) { // 检验整数位 |
| | | let _error = _position + dict['main.excel.content.floatIntover'] |
| | | errors.push(_error) |
| | | } else if (_val[1] && _val[1].length > limitlen) { // 最小值检验 |
| | | let _error = _position + dict['main.excel.content.floatPointover'] |
| | | errors.push(_error) |
| | | } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 |
| | | let _error = _position + dict['main.excel.content.limitmin'] |
| | | errors.push(_error) |
| | | } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 |
| | | let _error = _position + dict['main.excel.content.limitmax'] |
| | | errors.push(_error) |
| | | if (!/^(([^0][0-9]+|0)\.([0-9]+)$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]+)$)|^(([1-9]+)$)/.test(_val)) { // 检验是否为浮点数 |
| | | let _error = _position + dict['main.excel.content.floaterror'] |
| | | errors.push(_error) |
| | | } else if (_vals[0].length > 18) { // 检验整数位 |
| | | let _error = _position + dict['main.excel.content.floatIntover'] |
| | | errors.push(_error) |
| | | } else if (_vals[1] && _vals[1].length > col.limit) { // 最小值检验 |
| | | let _error = _position + dict['main.excel.content.floatPointover'] |
| | | errors.push(_error) |
| | | } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 |
| | | let _error = _position + dict['main.excel.content.limitmin'] |
| | | errors.push(_error) |
| | | } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 |
| | | let _error = _position + dict['main.excel.content.limitmax'] |
| | | errors.push(_error) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | fields = fields.join(',') |
| | | |
| | | let _insert = '' |
| | | |
| | | if (btn.default !== 'false') { |
| | | _insert = ` |
| | | Insert into ${item.sheet} (${fields},createuserid,createuser,createstaff,bid) |
| | | Select ${fields},@userid@,@username,@fullname,@BID@ From @${item.sheet} |
| | | ` |
| | | } |
| | | |
| | | if (btn.scripts && btn.scripts.length > 0) { |
| | | btn.scripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | |
| | | _insert += ` |
| | | ${script.sql} |
| | | ` |
| | | }) |
| | | } |
| | | |
| | | _sql = `declare @${item.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) |
| | | Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) |
| | | |
| | |
| | | |
| | | Insert into @${item.sheet} (${fields},jskey) |
| | | ${_Ltext} |
| | | |
| | | Insert into ${item.sheet} (${fields},createuserid,createuser,createstaff,bid) |
| | | Select ${fields},@userid@,@username,@fullname,@BID@ From @${item.sheet} |
| | | |
| | | ${_insert} |
| | | Delete @${item.sheet} |
| | | |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | |
| | | config.search.forEach(item => { |
| | | if (item.field) { |
| | | let type = '' |
| | | let _f = item.field |
| | | |
| | | if (item.type.match(/date/ig)) { |
| | | type = 'datetime=null' |
| | |
| | | type = 'nvarchar(50)=\'\'' |
| | | } |
| | | |
| | | if (_fields.has(item.field)) { |
| | | _f = _f + '1' |
| | | } |
| | | |
| | | _fields.set(item.field, true) |
| | | formParam = formParam + `mchr13k@${_f} ${type},` |
| | | item.field.split(',').forEach(cell => { |
| | | let _f = cell |
| | | if (_fields.has(cell)) { |
| | | _f = _f + '1' |
| | | } |
| | | |
| | | _fields.set(cell, true) |
| | | formParam = formParam + `mchr13k@${_f} ${type},` |
| | | }) |
| | | } |
| | | }) |
| | | } |