From 7da23c8a73681703f42c4c5a4c907dc17acf8b8f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 26 三月 2024 21:22:17 +0800 Subject: [PATCH] 2024-03-26 --- src/utils/utils.js | 131 ++++++++++++++++++++++++++----------------- 1 files changed, 79 insertions(+), 52 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index fb3811a..6d953ff 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1,7 +1,7 @@ import React from 'react' import moment from 'moment' import md5 from 'md5' -// import NodeRSA from 'node-rsa' +import CryptoJS from 'crypto-js' const formatKeys = [ { key: 'select', value: ' msltk ' }, @@ -124,46 +124,33 @@ if (!value) return '' value = value.replace(/\n/ig, ' \n ') - // 鏇挎崲鍏抽敭瀛� - formatKeys.forEach(item => { - let reg = new RegExp('(^|\\s)' + item.key + '(\\s|$)', 'ig') - value = value.replace(reg, item.value) - }) - // 鏇挎崲%绗︼紙鏁版嵁搴撲腑瑙f瀽鍚巗ql鎶ラ敊锛� - value = value.replace(/%/ig, ' mpercent ') + // 澶栬仈鏁版嵁搴撴浛鎹� if (window.GLOB.externalDatabase !== null) { value = value.replace(/@db@/ig, window.GLOB.externalDatabase) } - // if (exec_type === 'x') { - // // let publicKey = `-----BEGIN PUBLIC KEY----- - // // MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwGxFURiCrk5a2xfWuM3W - // // 2lkS3ioZhUFXpkK1inMivItsA/J8MTaBB3EAVxC29xdVCU+xOzs512PuD2b1sjzX - // // jwO6kx433NtB2okqGiP4RkzhEJHwdyc9dPUKdjirDznUWI9R7WayAf5Z4COhMsj2 - // // IbkyJgkb6Ivn0UgU0GSWc92HqJJmnb3Ti2gk6A2+oybz2RE3+xB/yOaNu3xav4yi - // // xxo6harVLNBiaU+D7aDed1W3kE20gLOnEAvcLMjpe3n/QvF5RtELsm3T+vH3TIT2 - // // GI9+8cT20NZ2d7i41+j/AQZiPJNS3MVmc3aIhuyCOsNPLmvbZZi1KPSJIqkCwdEg - // // mQIDAQAB - // // -----END PUBLIC KEY-----` + // 鏇挎崲%绗︼紙鏁版嵁搴撲腑瑙f瀽鍚巗ql鎶ラ敊锛� + value = value.replace(/%/ig, ' mpercent ') - // // let pubKey = new NodeRSA(publicKey, 'pkcs8-public') + if (exec_type === 'x') { + let key = CryptoJS.enc.Utf8.parse('D1185ED7B32568C9') + let iv = CryptoJS.enc.Utf8.parse('') + let srcs = CryptoJS.enc.Utf8.parse(value) - // // value = window.encodeURIComponent(value) - // // value = pubKey.encrypt(value, 'base64') + let encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }) + value = encrypted.toString() - // // const priKey = new NodeRSA(privateKey, 'pkcs8-private') - // // const res = priKey.decrypt(value, 'utf8') - // } else { + // let wordArray = CryptoJS.enc.Base64.parse(value) + // let decryptedWordArray = CryptoJS.AES.decrypt({ ciphertext: wordArray }, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }) + // let decryptedText = CryptoJS.enc.Utf8.stringify(decryptedWordArray) + } else { + // 鏇挎崲鍏抽敭瀛� + formatKeys.forEach(item => { + let reg = new RegExp('(^|\\s)' + item.key + '(\\s|$)', 'ig') + value = value.replace(reg, item.value) + }) // encode缂栫爜锛堜腑鏂囧瓧绗﹁秴鍑篵ase64鍔犲瘑鑼冨洿锛� - // let str = window.encodeURIComponent(value) - - // if (str.length % 3 === 1) { - // str += '%2F*123*%2F' - // } else if (str.length % 3 === 2) { - // str += '%2F*12*%2F' - // } - value = window.btoa(window.encodeURIComponent(value)) // 鎻掑叆瀛楃 let salt = 'minKe' // 鐩愬�� @@ -171,7 +158,7 @@ value = value.slice(0, index) + salt + value.slice(index) // base64鍔犲瘑 value = window.btoa(value) - // } + } return value } @@ -217,6 +204,13 @@ values = window.GLOB.SearchBox.get(config.$searchId + 'cache') } + let supModule = '' + if (config.setting && config.setting.supModule) { + supModule = config.setting.supModule + } else if (config.wrap && config.wrap.supModule) { + supModule = config.wrap.supModule + } + config.search = config.search.map(item => { item.hidden = item.Hide === 'true' item.required = !item.hidden && item.required === 'true' @@ -247,12 +241,14 @@ } else { item.$initval = item.initval item.$supId = config.$pageId - if (config.setting && config.setting.supModule) { - item.$supId = config.setting.supModule + if (supModule) { + item.$supId = supModule config.checkBid = true - config.setting.checkBid = true item.checkShift = true + if (config.setting) { + config.setting.checkBid = true + } } item.initval = '' @@ -309,12 +305,14 @@ } else { item.$initval = item.initval item.$supId = config.$pageId - if (config.setting && config.setting.supModule) { - item.$supId = config.setting.supModule + if (supModule) { + item.$supId = supModule config.checkBid = true - config.setting.checkBid = true item.checkShift = true + if (config.setting) { + config.setting.checkBid = true + } } item.initval = '' @@ -406,10 +404,12 @@ item.initType = '' } } else if ((item.type === 'select' || item.type === 'link') && item.resourceType === '1') { - if (/@BID@/ig.test(item.dataSource) && config.setting && config.setting.supModule) { + if (/@BID@/ig.test(item.dataSource) && supModule) { config.checkBid = true - config.setting.checkBid = true item.checkBid = true + if (config.setting) { + config.setting.checkBid = true + } } if (item.initval === '$first') { item.initval = '' @@ -551,6 +551,11 @@ newsearches[item.key] = _startval newsearches[item.key + '1'] = _endval } + } else if (item.type === 'range') { + let val = item.value.split(',') + + newsearches[item.key] = val[0] || -999999 + newsearches[item.key + '1'] = val[1] || 999999 } else if (item.type === 'dateweek') { let _startval = '' let _endval = '' @@ -698,7 +703,7 @@ } else if (item.type === 'range') { let val = item.value.split(',') - searchText.push('(' + item.key + ' >= \'' + val[0] + '\' AND ' + item.key + ' < \'' + val[1] + '\')') + searchText.push('(' + item.key + ' >= ' + (val[0] || -999999) + ' AND ' + item.key + ' < ' + (val[1] || 999999) + ')') } else { searchText.push('(' + item.key + ' ' + item.match + ' \'' + item.value + '\')') } @@ -734,9 +739,9 @@ if (item.type === 'date') { if (!item.value) { if (['>=', '>'].includes(item.match)) { - item.value = '1970-01-01 00:00:00.000' + item.value = '1900-01-01 00:00:00.000' } else if (['<=', '<'].includes(item.match)) { - item.value = '2050-01-01 00:00:00.000' + item.value = '3000-01-01 00:00:00.000' } } else if (search.precision === 'day') { if (['>=', '>'].includes(item.match)) { @@ -757,8 +762,8 @@ if (item.match === '=') { options.push(item) } else { - let _startval = item.value ? moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000' : '1970-01-01 00:00:00.000' - let _endval = item.value ? moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' : '2050-01-01 00:00:00.000' + let _startval = item.value ? moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000' : '1900-01-01 00:00:00.000' + let _endval = item.value ? moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' : '3000-01-01 00:00:00.000' let copy = JSON.parse(JSON.stringify(item)) copy.key = copy.key + '1' @@ -769,9 +774,20 @@ options.push(item) options.push(copy) } + } else if (item.type === 'range') { + let val = item.value.split(',') + + let copy = JSON.parse(JSON.stringify(item)) + copy.key = copy.key + '1' + copy.value = val[1] || 999999 + + item.value = val[0] || -999999 + + options.push(item) + options.push(copy) } else if (item.type === 'dateweek') { - let _startval = item.value ? moment(item.value, 'YYYY-MM-DD').startOf('week').format('YYYY-MM-DD') + ' 00:00:00.000' : '1970-01-01 00:00:00.000' - let _endval = item.value ? moment(item.value, 'YYYY-MM-DD').endOf('week').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' : '2050-01-01 00:00:00.000' + let _startval = item.value ? moment(item.value, 'YYYY-MM-DD').startOf('week').format('YYYY-MM-DD') + ' 00:00:00.000' : '1900-01-01 00:00:00.000' + let _endval = item.value ? moment(item.value, 'YYYY-MM-DD').endOf('week').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000' : '3000-01-01 00:00:00.000' let copy = JSON.parse(JSON.stringify(item)) copy.key = copy.key + '1' @@ -782,8 +798,8 @@ options.push(item) options.push(copy) } else if (item.type === 'daterange') { - let _startval = '1970-01-01 00:00:00.000' - let _endval = '2050-01-01 00:00:00.000' + let _startval = '1900-01-01 00:00:00.000' + let _endval = '3000-01-01 00:00:00.000' if (item.value) { let val = item.value.split(',') @@ -1153,7 +1169,7 @@ end ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid='' - Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${sheet} b on ${_fields_} + Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${database}${sheet} b on ${_fields_} If @tbid!='' Begin @@ -1373,7 +1389,7 @@ end ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid='' - Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${sheet} b on ${_fields_} + Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${database}${sheet} b on ${_fields_} If @tbid!='' Begin @@ -1633,6 +1649,14 @@ _sql = `/* 绯荤粺鐢熸垚 */ Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@mk_deleted int,@bid nvarchar(50)${_declarefields} ` + + if (btn.$process && verify.workFlow === 'true' && window.GLOB.UserCacheMap.has(btn.$flowId)) { + _sql += ` + /* 宸ヤ綔娴佸彉閲忓畾涔変笌璧嬪�� */ + Declare @works_flow_code nvarchar(50),@works_flow_name nvarchar(50),@works_flow_param nvarchar(4000),@works_flow_detail_id nvarchar(50),@status int,@statusname nvarchar(50), @work_group nvarchar(50),@work_grade int, @start_type nvarchar(50),@check_type nvarchar(50),@notice_type nvarchar(50),@check_userids nvarchar(512),@notice_userids nvarchar(512) + select @works_flow_code=@works_flow_code@,@works_flow_name=@works_flow_name@,@works_flow_param=@works_flow_param@,@works_flow_detail_id=@works_flow_detail_id@,@status=@status@,@statusname=@statusname@,@work_group=@work_group@,@work_grade=@work_grade@, @start_type=@start_type@,@check_type=@check_type@,@notice_type=@notice_type@,@check_userids=@check_userids@,@notice_userids=@notice_userids@ + ` + } let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' @@ -2310,6 +2334,9 @@ _sql = _sql.replace(/@check_userids@/ig, `''`) _sql = _sql.replace(/@notice_userids@/ig, `''`) } + } else { + _sql = _sql.replace(/@check_userids@/ig, `''`) + _sql = _sql.replace(/@notice_userids@/ig, `''`) } _sql = _sql.replace(/@start_type@/ig, `'寮�濮�'`) -- Gitblit v1.8.0