From 3d4bc79a80eb9cff0f8ef7c53f9685c9ff9fbd2d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 02 九月 2021 23:17:36 +0800 Subject: [PATCH] 2021-09-02 --- src/utils/utils.js | 58 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index a113202..da742ae 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -246,7 +246,7 @@ return searches.map(item => { item.hidden = item.Hide === 'true' - item.required = item.required === 'true' + item.required = !item.hidden && item.required === 'true' item.advanced = item.advanced === 'true' if (item.type === 'date') { // 鏃堕棿鎼滅储 @@ -261,7 +261,7 @@ let _initval = JSON.parse(item.initval) let _vals = [moment().subtract(_initval[0], 'days').format('YYYY-MM-DD'), moment().subtract(_initval[1], 'days').format('YYYY-MM-DD')] item.initval = _vals.join(',') - } catch { + } catch (e) { item.initval = '' } } @@ -309,7 +309,7 @@ } else if (_type === 'customized') { try { _val = JSON.parse(_val) - } catch { + } catch (e) { _val = [0, 0] } _dateRange = [moment().subtract(_val[0], 'days').format('YYYY-MM-DD'), @@ -329,6 +329,7 @@ if (item.blacklist && item.blacklist.length > 0 && !item.hidden) { if (item.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { item.hidden = true + item.required = false } } @@ -499,6 +500,10 @@ let _endval = moment(val[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')' + } else if (item.type === 'range') { + let val = item.value.split(',') + + searchText += '(' + item.key + ' >= \'' + val[0] + '\' AND ' + item.key + ' < \'' + val[1] + '\')' } else { searchText += '(' + item.key + ' ' + item.match + ' \'' + item.value + '\')' } @@ -760,15 +765,25 @@ let keys = ['delete', 'drop', 'insert', 'truncate', 'update'] let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' + let RoleID = sessionStorage.getItem('role_id') || '' + let departmentcode = sessionStorage.getItem('departmentcode') || '' + let organization = sessionStorage.getItem('organization') || '' let city = sessionStorage.getItem('city') || '' + let _sheet = item.sheet if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' fullName = sessionStorage.getItem('CloudFullName') || '' } - let database = item.sheet.match(/(.*)\.(.*)\./ig) || '' - let sheet = item.sheet.replace(/(.*)\.(.*)\./ig, '') + if (window.GLOB.externalDatabase !== null) { + _sheet = _sheet.replace(/@db@/ig, window.GLOB.externalDatabase) + } + + let database = _sheet.match(/(.*)\.(.*)\./ig) + let sheet = _sheet.replace(/(.*)\.(.*)\./ig, '') + + database = database ? (database[0] || '') : '' let getuuid = () => { let uuid = [] @@ -814,6 +829,11 @@ // 鎺у埗鍙版墦鍗版暟鎹� let conLtext = [] + let cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] + for (let i = 0; i < 26; i++) { + cols.push('A' + cols[i]) + } + let _Ltext = data.map((item, lindex) => { let vals = [] let convals = [] @@ -821,14 +841,15 @@ if (col.import === 'false') return let val = item[col.Column] !== undefined ? item[col.Column] : '' - let _position = (_topline + lindex + 1) + dict['main.excel.line'] + ' ' + (cindex + 1) + dict['main.excel.column'] + ' ' + let _colindex = cols[cindex] || (cindex + 1) + let _position = (_topline + lindex + 1) + dict['main.excel.line'] + ' ' + _colindex + dict['main.excel.column'] + ' ' if (/^Nvarchar/ig.test(col.type)) { if (typeof(val) === 'number') { val = val.toString() } - val = val.replace(/(^\s*$)|\t*|\v*/ig, '') + val = val.replace(/(^\s*$)|\t*|\v*|'*/ig, '') if (!val && col.required === 'true') { // 蹇呭~鏍¢獙 errors.push(_position + dict['main.excel.content.emptyerror']) @@ -994,9 +1015,9 @@ _sql = ` /* 绯荤粺鐢熸垚 */ declare @${sheet} table (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50) ) - Declare @UserName nvarchar(50),@FullName nvarchar(50),@login_city nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) + Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@departmentcode nvarchar(50),@organization nvarchar(50),@login_city nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) - Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}', @login_city='${city}' + Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @departmentcode='${departmentcode}', @organization='${organization}', @login_city='${city}' ${_initCustomScript} ` _sqlInsert = `Insert into @${sheet} (${fields},jskey,BID)` @@ -1029,9 +1050,9 @@ _sql = ` /* 绯荤粺鐢熸垚 */ declare @${sheet} table (jskey nvarchar(50)) - Declare @UserName nvarchar(50),@FullName nvarchar(50),@login_city nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) + Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@departmentcode nvarchar(50),@organization nvarchar(50),@login_city nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) - Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}', @login_city='${city}' + Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @departmentcode='${departmentcode}', @organization='${organization}', @login_city='${city}' ` } @@ -1170,6 +1191,10 @@ if (!_initvars.includes(_key)) { let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' + if (col.datatype && /^date/ig.test(col.datatype) && !_val) { + _val = '1900-01-01' + } + _initvars.push(_key) _initColfields.push(`@${_key}='${_val}'`) } @@ -1217,7 +1242,7 @@ _declarefields = ',' + _declarefields } _sql = `/* 绯荤粺鐢熸垚 */ - Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@login_city nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} + Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@departmentcode nvarchar(50),@organization nvarchar(50),@login_city nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} ` // 琛ㄥ崟鍙橀噺璧嬪�� @@ -1251,6 +1276,9 @@ let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' + let RoleID = sessionStorage.getItem('role_id') || '' + let departmentcode = sessionStorage.getItem('departmentcode') || '' + let organization = sessionStorage.getItem('organization') || '' let city = sessionStorage.getItem('city') || '' if (sessionStorage.getItem('isEditState') === 'true') { @@ -1261,7 +1289,7 @@ // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁 _sql += ` /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */ - select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @login_city='${city}', @BillCode='', @ModularDetailCode='' + select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @departmentcode='${departmentcode}', @organization='${organization}', @login_city='${city}', @BillCode='', @ModularDetailCode='' ` if (retmsg) { @@ -1736,6 +1764,9 @@ _sql += ` aaa: if @ErrorCode!='' insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@` + } else if (btn.output) { + _sql += ` + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` } else { _sql += ` aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` @@ -1793,7 +1824,6 @@ } } } - } /** -- Gitblit v1.8.0