From fb64bcf1fab18b33d21470c83f28d4cda8d309ce Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 26 十月 2022 12:15:59 +0800 Subject: [PATCH] 2022-10-26 --- src/utils/utils.js | 88 +++++++++++++++++++++++++------------------ 1 files changed, 51 insertions(+), 37 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 06f55ca..293b254 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -158,7 +158,7 @@ let error = '' - sql = sql.replace(/sys\.fn_sqlvarbasetostr\(HashBytes\('MD5'/ig, '') // 璺宠繃MD5鍔犲瘑 + sql = sql.replace(/sys\.fn_/ig, '') // 璺宠繃sys.fn_楠岃瘉 chars.forEach(char => { if (!error && char.reg.test(sql)) { @@ -730,14 +730,7 @@ static getrealurl (url) { if (!url) return '' - let baseurl = '' - if (process.env.NODE_ENV === 'production') { - baseurl = document.location.origin + '/' + window.GLOB.service - } else { - baseurl = window.GLOB.location + '/' + window.GLOB.service - } - - let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url + let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : window.GLOB.baseurl + url return realurl } @@ -753,7 +746,7 @@ if (options.cloudServiceApi) { baseurl = options.cloudServiceApi.replace(/webapi(.*)$/, '') } else { - baseurl = document.location.origin + '/' + window.GLOB.service + baseurl = window.GLOB.baseurl } return url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url @@ -1376,17 +1369,16 @@ * @return {Object} param 璇锋眰鍙傛暟 * @return {Array} data 鍒楄〃琛屾暟鎹� * @return {Array} columns 鏄剧ず鍒� - * @return {Object} tab 鏍囩淇℃伅 * @return {Boolean} retmsg 鏄惁闇�瑕佹暟鎹繑鍥� */ -export function getSysDefaultSql (btn, setting, formdata, param, data, columns, tab, retmsg = false, moduleParams, getOptions) { +export function getSysDefaultSql (btn, setting, formdata, param, data, columns, retmsg = false, moduleParams, getOptions) { let primaryId = param.ID - let BID = param.BID + let BID = param.BID || '' let verify = btn.verify || {} let datavars = {} // 澹版槑鐨勫彉閲忥紝琛ㄥ崟鍙婃樉绀哄垪 let _actionType = null let _callbacksql = '' - let foreignKey = tab && tab.foreignKey ? tab.foreignKey.toLowerCase() : '' + let foreignKey = setting.foreignKey ? setting.foreignKey.toLowerCase() : '' if (verify.default !== 'false') { // 鍒ゆ柇鏄惁浣跨敤榛樿sql _actionType = btn.sqlType @@ -1441,14 +1433,11 @@ if (form.type === 'number' || form.type === 'rate') { let val = form.value - if (typeof(val) !== 'number') { - val = parseFloat(val) - if (isNaN(val)) { - val = 0 - } + if (isNaN(val)) { + val = 0 } _initFormfields.push(`@${_key}=${val}`) - } else if (['date', 'datemonth', 'datetime'].includes(form.type)) { + } else if (['date', 'datemonth'].includes(form.type)) { _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`) } else { _initFormfields.push(`@${_key}='${form.value}'`) @@ -1483,7 +1472,7 @@ } // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃) - if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') { + if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce' && columns && columns.length > 0) { datavars = {...data, ...datavars} const setField = (col) => { @@ -1525,17 +1514,15 @@ } } - if (columns && columns.length > 0) { - columns.forEach(col => { - if (col.type === 'colspan' || col.type === 'old_colspan') { - col.subcols.forEach(cell => { - setField(cell) - }) - } else { - setField(col) - } - }) - } + columns.forEach(col => { + if (col.type === 'colspan' || col.type === 'old_colspan') { + col.subcols.forEach(cell => { + setField(cell) + }) + } else { + setField(col) + } + }) } // 鍙橀噺澹版槑 @@ -1567,7 +1554,7 @@ // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁 _sql += ` /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */ - select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @BillCode='', @ModularDetailCode='' + select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @bid='${BID}', @BillCode='', @ModularDetailCode='' ` // 琛ㄥ崟鍙橀噺璧嬪�� @@ -1966,11 +1953,14 @@ if (!_arr.includes('submitdate')) { _form.push('submitdate=getdate()') } - if (!_arr.includes('submituserid')) { - _form.push('submituserid=@userid@') - } if (!_arr.includes('submituser')) { _form.push('submituser=@username') + } + if (!_arr.includes('submitstaff')) { + _form.push('submitstaff=@fullname') + } + if (!_arr.includes('submituserid')) { + _form.push('submituserid=@userid@') } } else { if (!_arr.includes('modifydate')) { @@ -1978,6 +1968,9 @@ } if (!_arr.includes('modifyuser')) { _form.push('modifyuser=@username') + } + if (!_arr.includes('modifystaff')) { + _form.push('modifystaff=@fullname') } if (!_arr.includes('modifyuserid')) { _form.push('modifyuserid=@userid@') @@ -2070,6 +2063,20 @@ _sql += _backCustomScript } + if (window.GLOB.breakpoint) { + let start = new RegExp('\\/\\*\\$breakpoint_begin_' + window.GLOB.breakpoint + '@', 'ig') + let end = new RegExp('@breakpoint_end_' + window.GLOB.breakpoint + '\\$\\*\\/', 'ig') + + if (window.GLOB.breakpoint === 'all') { + start = /\/\*\$breakpoint_begin_[0-9a-z_]+@/ig + end = /@breakpoint_end_[0-9a-z_]+\$\*\//ig + } + + _sql = _sql.replace(start, '').replace(end, '').replace(/\$breakpoint_proc@/ig, window.GLOB.breakpoint) + _sql += ` + z_debug_end: select @ErrorCode='E',@retmsg='debug_end' goto aaa` + } + if (retmsg) { _sql += ` aaa: if @ErrorCode!='' @@ -2083,7 +2090,7 @@ } _sql = _sql.replace(/@ID@/ig, `'${primaryId || ''}'`) - _sql = _sql.replace(/@BID@/ig, `'${BID || ''}'`) + _sql = _sql.replace(/@BID@/ig, `'${BID}'`) _sql = _sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) _sql = _sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) _sql = _sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) @@ -2095,6 +2102,13 @@ } 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 || ''}'`) + return { sql: _sql, callbacksql: _callbacksql -- Gitblit v1.8.0