From 3140b58a56be4b1693766121dacb83fe6f6f21df Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 26 九月 2023 14:48:30 +0800 Subject: [PATCH] 2023-09-26 --- src/utils/utils.js | 242 ++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 192 insertions(+), 50 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 4633e68..f7bd5ee 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -39,26 +39,6 @@ export default class Utils { /** - * @description 鑾峰彇浼氬憳绛夌骇 - * @return {String} level - */ - static getMemberLevel () { - let _level = 10 - let _Mlevel = sessionStorage.getItem('Member_Level') - - if (_Mlevel) { - if (_Mlevel === md5('mksoft' + window.GLOB.appkey + new Date().getFullYear() + new Date().getMonth() + 10)) { - _level = 10 - } else if (_Mlevel === md5('mksoft' + window.GLOB.appkey + new Date().getFullYear() + new Date().getMonth() + 20)) { - _level = 20 - } else if (_Mlevel === md5('mksoft' + window.GLOB.appkey + new Date().getFullYear() + new Date().getMonth() + 30)) { - _level = 30 - } - } - return _level - } - - /** * @description 鑾峰彇鍥捐〃楂樺害 */ static getHeight (val) { @@ -158,7 +138,7 @@ ] if (type === 'customscript') { - chars = chars.filter(char => !['insert', 'delete', 'update', 'set', 'if', 'exec'].includes(char.key)) + chars = chars.filter(char => !['create', 'insert', 'delete', 'update', 'set', 'drop', 'if', 'exec'].includes(char.key)) } let error = '' @@ -295,6 +275,10 @@ let roleId = sessionStorage.getItem('role_id') || '' let required = false let keys = [] + let values = null + if (config.wrap && config.wrap.cacheSearch === 'true') { + values = window.GLOB.SearchBox.get(config.$searchId + 'cache') + } config.search = config.search.map(item => { item.hidden = item.Hide === 'true' @@ -407,6 +391,10 @@ item.oriInitval = item.initval + if (values) { + item.initval = values[item.field] || '' + } + if (item.blacklist && item.blacklist.length > 0 && !item.hidden) { if (item.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { item.hidden = true @@ -419,6 +407,10 @@ } if (item.type === 'text' || item.type === 'select') { + if (/@username@|@fullName@/ig.test(item.initval)) { + item.initval = item.initval.replace(/@username@/ig, sessionStorage.getItem('User_Name') || '').replace(/@fullName@/ig, sessionStorage.getItem('Full_Name') || '') + item.oriInitval = item.initval + } if (/,/.test(item.field)) { item.field.split(',').forEach(field => { keys.push(field.toLowerCase()) @@ -558,8 +550,16 @@ } } - newsearches[item.key] = _startval - newsearches[item.key + '1'] = _endval + let _skey = item.key + let _ekey = item.key + '1' + + if (/,/.test(item.key)) { + _skey = item.key.split(',')[0] + _ekey = item.key.split(',')[1] + } + + newsearches[_skey] = _startval + newsearches[_ekey] = _endval } else if (item.type === 'text' || item.type === 'select') { item.key.split(',').forEach(field => { // 缁煎悎鎼滅储锛屾墍瀛楁鎷兼帴 newsearches[field] = item.value @@ -650,7 +650,15 @@ _endval = val[1] + '.000' } - searchText.push('(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')') + let _skey = item.key + let _ekey = item.key + + if (/,/.test(item.key)) { + _skey = item.key.split(',')[0] + _ekey = item.key.split(',')[1] + } + + searchText.push('(' + _skey + ' >= \'' + _startval + '\' AND ' + _ekey + ' < \'' + _endval + '\')') } else if (item.type === 'range') { let val = item.value.split(',') @@ -866,7 +874,9 @@ sql = sql.replace(/@db@/ig, window.GLOB.externalDatabase) } + sql = sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) + sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) return { @@ -943,6 +953,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 + '' @@ -975,7 +987,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 + '鏃堕棿涓鸿礋鍊兼垨澶ぇ') @@ -983,7 +995,14 @@ if (val < 60) { // 1900-2-29锛宔xcel涓瓨鍦紝瀹為檯涓嶅瓨鍦� 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, '') @@ -1018,9 +1037,9 @@ let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� let isDM = sessionStorage.getItem('dataM') === 'true' let regs = [ - {reg: new RegExp('(^|\\s)@' + sheet + '(\\s|$)', 'ig'), value: `#${sheet} `}, - {reg: new RegExp('(^|\\s)@' + sheet + '\\(', 'ig'), value: `#${sheet}(`}, - {reg: new RegExp('(^|\\s)@' + sheet + '\\)', 'ig'), value: `#${sheet})`}, + {reg: new RegExp('(^|\\s)@' + sheet + '(\\s|$)', 'ig'), value: ` #${sheet} `}, + {reg: new RegExp('(^|\\s)@' + sheet + '\\(', 'ig'), value: ` #${sheet}(`}, + {reg: new RegExp('(^|\\s)@' + sheet + '\\)', 'ig'), value: ` #${sheet})`}, {reg: /@ID@/ig, value: `'${primaryId || ''}'`}, {reg: /@BID@/ig, value: `'${BID}'`}, {reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`}, @@ -1032,6 +1051,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 @@ -1225,9 +1248,9 @@ let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� let isDM = sessionStorage.getItem('dataM') === 'true' let regs = [ - {reg: new RegExp('(^|\\s)@' + sheet + '(\\s|$)', 'ig'), value: `#${sheet} `}, - {reg: new RegExp('(^|\\s)@' + sheet + '\\(', 'ig'), value: `#${sheet}(`}, - {reg: new RegExp('(^|\\s)@' + sheet + '\\)', 'ig'), value: `#${sheet})`}, + {reg: new RegExp('(^|\\s)@' + sheet + '(\\s|$)', 'ig'), value: ` #${sheet} `}, + {reg: new RegExp('(^|\\s)@' + sheet + '\\(', 'ig'), value: ` #${sheet}(`}, + {reg: new RegExp('(^|\\s)@' + sheet + '\\)', 'ig'), value: ` #${sheet})`}, {reg: /@BID@/ig, value: `'${BID}'`}, {reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`}, {reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`}, @@ -1238,6 +1261,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 @@ -1461,7 +1488,7 @@ if (!_vars.includes(_key)) { _vars.push(_key) - if (form.fieldlen && form.fieldlen > 2048) { + if (form.fieldlen && form.fieldlen > 4000) { form.fieldlen = 'max' } @@ -1515,7 +1542,7 @@ if (col.datatype) { _declarefields.push(`@${_key} ${col.datatype}`) } else { - if (col.fieldlength && col.fieldlength > 2048) { + if (col.fieldlength && col.fieldlength > 4000) { col.fieldlength = 'max' } @@ -2080,6 +2107,135 @@ ` } + if (btn.$process && verify.workFlow === 'true' && window.GLOB.UserCacheMap.has(btn.$flowId)) { + let flow = window.GLOB.UserCacheMap.get(btn.$flowId) + let node = null + let line = null + let target = null + let status = 0 + let statusName = '' + let detailId = '' + + if (verify.flowType === 'start') { + target = flow.cells.filter(cell => cell.mknode === 'start')[0] + + if (target) { + detailId = target.id + status = target.mkdata.status + statusName = target.mkdata.statusName + } + } else if (_data.works_flow_param) { + node = JSON.parse(window.decodeURIComponent(window.atob(_data.works_flow_param))) + + if (node) { + let lines = flow.cells.filter(cell => cell.shape === 'edge' && cell.source.cell === node.id) + if (verify.flowType === 'reject') { + line = lines.filter(cell => cell.mkdata.flowType === 'reject')[0] + } else { + line = lines.filter(cell => cell.mkdata.flowType !== 'reject')[0] + } + } + + if (line) { + detailId = line.id + status = line.mkdata.status + statusName = line.mkdata.statusName + target = flow.cells.filter(cell => cell.id === line.target.cell)[0] + } + } + + if (verify.flowSql === 'true' && target) { + if (verify.flowType === 'start') { + _sql += ` + /* 宸ヤ綔娴侀粯璁ql */ + insert into s_my_works_flow (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,work_group,works_flow_detail_id,work_grade,bid,createuserid,CreateUser,CreateStaff,upid) + select @ID@,@works_flow_code@,@works_flow_name@,@works_flow_param@,@status@,@statusname@,@work_group@,@works_flow_detail_id@,@work_grade@,@bid@,@UserID@,@UserName,@FullName,@time_id@ + insert into s_my_works_flow_log (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,works_flow_detail_id,work_group,work_grade,upid) + select @ID@,@works_flow_code@,@works_flow_name@ ,@works_flow_param@,@status@,@statusname@,@works_flow_detail_id@,@work_group@,@work_grade@,@time_id@ + insert into s_my_works_flow_notice (works_flow_id,works_flow_code,works_flow_detail_id,userid,notice_type,createuserid,CreateUser,CreateStaff,upid) + select @ID@,@works_flow_code@,@works_flow_detail_id@,@userid@,@start_type@,@userid@,@UserName,@FullName,@time_id@ + ` + } else { + _sql += ` + /* 宸ヤ綔娴侀粯璁ql */ + update s_my_works_flow set status=@status@,statusname=@statusname@,modifydate=getdate(),modifyuserid=@userid@,modifyuser=@username,modifystaff=@fullname + where works_flow_id=@ID@ and works_flow_code=@works_flow_code@ and deleted=0 + insert into s_my_works_flow_log (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,works_flow_detail_id,work_group,work_grade,upid) + select @ID@,@works_flow_code@,@works_flow_name@ ,@works_flow_param@,@status@,@statusname@,@works_flow_detail_id@,@work_group@,@work_grade@,@time_id@ + if @check_userids@ != '' + begin + delete s_my_works_flow_role where works_flow_id=@ID@ and works_flow_code=@works_flow_code@ and deleted=0 + insert into s_my_works_flow_role (works_flow_id,works_flow_code,userid,works_flow_detail_id,createuserid,CreateUser,CreateStaff,upid) + select @ID@,@works_flow_code@,ID,@works_flow_detail_id@,@userid@,@UserName,@FullName,@time_id@ from dbo.SplitComma(@check_userids@) + insert into s_my_works_flow_notice (works_flow_id,works_flow_code,works_flow_detail_id,userid,notice_type,createuserid,CreateUser,CreateStaff,upid) + select @ID@,@works_flow_code@,@works_flow_detail_id@,ID,@check_type@,@userid@,@UserName,@FullName,@time_id@ from dbo.SplitComma(@check_userids@) + end + if @notice_userids@ != '' + begin + delete n + from (select * from s_my_works_flow_notice where works_flow_id=@ID@ and works_flow_code=@works_flow_code@ and deleted=0) n + inner join (select ID from dbo.SplitComma(@notice_userids@)) s + on n.userid = s.id + insert into s_my_works_flow_notice (works_flow_id,works_flow_code,works_flow_detail_id,userid,notice_type,createuserid,CreateUser,CreateStaff,upid) + select @ID@,@works_flow_code@,@works_flow_detail_id@,ID,@notice_type@,@userid@,@UserName,@FullName,@time_id@ from dbo.SplitComma(@notice_userids@) + end + ` + } + } else if (verify.flowSql === 'true') { + target = flow.cells.filter(cell => cell.mknode === 'start')[0] + + if (target) { + detailId = target.id + } + + status = 0 + statusName = '寮傚父' + _sql += ` + /* 宸ヤ綔娴佸紓甯竤ql */ + update s_my_works_flow set status=@status@,statusname=@statusname@,modifydate=getdate(),modifyuserid=@userid@,modifyuser=@username,modifystaff=@fullname + where works_flow_id=@ID@ and works_flow_code=@works_flow_code@ and deleted=0 + insert into s_my_works_flow_log (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,works_flow_detail_id,work_group,work_grade,upid) + select @ID@,@works_flow_code@,@works_flow_name@ ,@works_flow_param@,@status@,@statusname@,@works_flow_detail_id@,@work_group@,@work_grade@,@time_id@ + ` + } + + if (verify.flowType !== 'start') { + if (line) { + let checkIds = [] + let noticeIds = [] + line.mkdata.members && line.mkdata.members.forEach(item => { + checkIds.push(item.worker_id) + }) + line.mkdata.copys && line.mkdata.copys.forEach(item => { + noticeIds.push(item.worker_id) + }) + _sql = _sql.replace(/@check_userids@/ig, `'${checkIds.join(',')}'`) + _sql = _sql.replace(/@notice_userids@/ig, `'${noticeIds.join(',')}'`) + } else { + _sql = _sql.replace(/@check_userids@/ig, `''`) + _sql = _sql.replace(/@notice_userids@/ig, `''`) + } + } + + _sql = _sql.replace(/@start_type@/ig, `'寮�濮�'`) + _sql = _sql.replace(/@check_type@/ig, verify.flowType === 'reject' ? `'椹冲洖'` : `'瀹℃牳'`) + _sql = _sql.replace(/@notice_type@/ig, `'鎶勯��'`) + + _sql = _sql.replace(/@works_flow_code@/ig, `'${flow.flow_code}'`) + _sql = _sql.replace(/@works_flow_name@/ig, `'${flow.flow_name}'`) + if (target) { + let msg = {...target.mkdata, id: target.id} + _sql = _sql.replace(/@works_flow_param@/ig, `'${window.btoa(window.encodeURIComponent(JSON.stringify(msg)))}'`) + } else { + _sql = _sql.replace(/@works_flow_param@/ig, `''`) + } + _sql = _sql.replace(/@works_flow_detail_id@/ig, `'${detailId}'`) + _sql = _sql.replace(/@status@/ig, `'${status}'`) + _sql = _sql.replace(/@statusname@/ig, `'${statusName}'`) + _sql = _sql.replace(/@work_group@/ig, `'${sessionStorage.getItem('work_group') || ''}'`) + _sql = _sql.replace(/@work_grade@/ig, `'${sessionStorage.getItem('work_grade') || 0}'`) + } + if (_backCustomScript) { _sql += _backCustomScript } @@ -2119,9 +2275,9 @@ _sql = _sql.replace(/@typename@/ig, `'admin'`) if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _sql = _sql.replace(/@datam@/ig, '\'Y\'') + _sql = _sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`) } else { - _sql = _sql.replace(/@datam@/ig, '\'\'') + _sql = _sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`) } if (window.GLOB.debugger === true) { @@ -2130,20 +2286,6 @@ } if (retmsg) { - _callbacksql = _callbacksql.replace(/@ID@/ig, `'${primaryId || ''}'`) - _callbacksql = _callbacksql.replace(/@BID@/ig, `'${BID}'`) - _callbacksql = _callbacksql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) - _callbacksql = _callbacksql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) - _callbacksql = _callbacksql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) - _callbacksql = _callbacksql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) - _callbacksql = _callbacksql.replace(/@typename@/ig, `'admin'`) - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _callbacksql = _callbacksql.replace(/@datam@/ig, '\'Y\'') - } else { - _callbacksql = _callbacksql.replace(/@datam@/ig, '\'\'') - } - return { sql: _sql, callbacksql: _callbacksql -- Gitblit v1.8.0