From 0c86e5e2eaf907dfcb63aea13e6efac3ccc52cce Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 25 二月 2020 11:06:20 +0800 Subject: [PATCH] 2020-02-25 --- src/utils/utils.js | 123 ++++++++++++++++++++++++---------------- 1 files changed, 73 insertions(+), 50 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 70f0abd..2fa05f9 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -464,12 +464,10 @@ 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 { // 鍏抽敭瀛楁牎楠� @@ -482,36 +480,47 @@ }) } } 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) + } } } @@ -541,6 +550,25 @@ 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) @@ -550,10 +578,7 @@ 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` @@ -1012,7 +1037,6 @@ config.search.forEach(item => { if (item.field) { let type = '' - let _f = item.field if (item.type.match(/date/ig)) { type = 'datetime=null' @@ -1020,12 +1044,15 @@ 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},` + }) } }) } @@ -1287,24 +1314,20 @@ fields = fields.join(',') - let _sql = `declare @${btn.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) - Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) + let _sql = `declare @${btn.sheet} table (${declarefields.join(',')},jskey nvarchar(50)) + Declare @UserName nvarchar(50),@FullName nvarchar(50) - Select @ErrorCode='',@retmsg='' - - select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ + select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID Insert into @${btn.sheet} (${fields},jskey) - exec s_KeyWords_Replace + exec s_KeyWords_Replace @LText=@LText, @BID=@BID,@LoginUID=@LoginUID,@SessionUid=@SessionUid,@UserID=@UserID,@ID=@ID Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid) - Select ${fields},@userid@,@username,@fullname,@BID@ From @${btn.sheet} + Select ${fields},@userid,@username,@fullname,@BID From @${btn.sheet} - Delete @${btn.sheet} - - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + Delete @${btn.sheet}` let Ltext = `create proc ${param.funcName} ( /*${menu.MenuName} ${btn.label}*/ -- Gitblit v1.8.0