From f0602b981659c6d1ff18e8dba4ca1ce89c5f5610 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 22 三月 2020 21:18:34 +0800 Subject: [PATCH] 2020-03-22 --- src/utils/utils.js | 132 ++++++++++++++++++++++++++++++++++++-------- 1 files changed, 108 insertions(+), 24 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 6de456a..a3abb26 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1,5 +1,6 @@ import moment from 'moment' import md5 from 'md5' +import options from '@/store/options.js' const service = window.GLOB.service ? (/\/$/.test(window.GLOB.service) ? window.GLOB.service : window.GLOB.service + '/') : '' @@ -193,7 +194,9 @@ key: search.field, match: search.match, type: search.type, - value: search.initval + label: search.label, + value: search.initval, + required: search.required === 'true' } if (item.type === 'date') { item.value = item.value ? moment().subtract(item.value, 'days').format('YYYY-MM-DD') : '' @@ -286,6 +289,12 @@ newsearches[item.key] = item.value.join(',') } else { newsearches[item.key] = item.value + } + }) + + Object.keys(newsearches).forEach(key => { + if (!newsearches[key]) { + delete newsearches[key] } }) @@ -391,6 +400,7 @@ */ static getrealurl (url) { if (!url) return '' + let baseurl = '' if (process.env.NODE_ENV === 'production') { baseurl = document.location.origin + '/' + service @@ -402,6 +412,24 @@ // } let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url return realurl + } + + /** + * @description 鑾峰彇浜戠鍥剧墖鐪熷疄璺緞 + * @return {String} url 鍥剧墖璺緞 + */ + static getcloudurl (url) { + if (!url) return '' + + let baseurl = '' + + if (options.cloudServiceApi) { + baseurl = options.cloudServiceApi.replace(/webapi(.*)$/, '') + } else { + baseurl = document.location.origin + '/' + service + } + + return url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url } /** @@ -550,6 +578,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) @@ -559,10 +606,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` @@ -591,13 +635,13 @@ // 闇�瑕佸0鏄庣殑鍙橀噺闆� // let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] - let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname'] + let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode'] // 涓婚敭瀛楁 let primaryKey = setting.primaryKey || 'id' // 绯荤粺鍙橀噺澹版槑涓庤缃垵濮嬪�� - let _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) + let _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),@ModularDetailCode nvarchar(50) ` // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 宸茶祴鍊煎瓧娈甸泦 @@ -812,16 +856,24 @@ if (verify.billcodes && verify.billcodes.length > 0) { verify.billcodes.forEach(item => { let _ModularDetailCode = '' - if (item.TypeCharOne === 'Lp' || item.TypeCharOne === 'BN') { + let _lpline = '' + if (item.TypeCharOne === 'Lp') { + if (item.linkField === 'BID' && BID) { // 鏇挎崲bid + _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@BID@,48)` + } else { + _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@${item.linkField},48)` + } + _ModularDetailCode = '@ModularDetailCode' + } else if (item.TypeCharOne === 'BN') { let _val = '' if (item.linkField === 'BID' && BID) { // 鏇挎崲bid _val = BID } else if (data && data.hasOwnProperty(item.linkField)) { _val = data[item.linkField] } - _ModularDetailCode = item.TypeCharOne + _val + _ModularDetailCode = `'${item.TypeCharOne + _val}'` } else { - _ModularDetailCode = item.ModularDetailCode + _ModularDetailCode = `'${item.ModularDetailCode}'` } let _declare = '' @@ -833,9 +885,10 @@ } _sql += `${_declare} - select @BillCode='', @${_key}='' + select @BillCode='', @${_key}='', @ModularDetailCode='' + ${_lpline} exec s_get_BillCode - @ModularDetailCode='${_ModularDetailCode}', + @ModularDetailCode=${_ModularDetailCode}, @Type=${item.Type}, @TypeCharOne='${item.TypeCharOne}', @TypeCharTwo ='${item.TypeCharTwo}', @@ -1013,15 +1066,20 @@ static getTableFunc (param, menu, config) { let form = '' let formParam = '' + let _vars = ['bid', 'pageindex', 'pagesize', 'ordercol', 'ordertype', 'exceltype', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg'] let _columns = [] let primaryKey = config.setting.primaryKey || 'ID' + + if (!_vars.includes(primaryKey.toLowerCase())) { + _vars.push(primaryKey.toLowerCase()) + formParam = `mchr13k@${primaryKey} nvarchar(50)='',` + } if (config.search && config.search.length > 0) { let _fields = new Map() config.search.forEach(item => { if (item.field) { let type = '' - let _f = item.field if (item.type.match(/date/ig)) { type = 'datetime=null' @@ -1029,12 +1087,19 @@ type = 'nvarchar(50)=\'\'' } - if (_fields.has(item.field)) { - _f = _f + '1' - } + item.field.split(',').forEach(cell => { + let _f = cell + if (_fields.has(cell)) { + _f = _f + '1' + } + + _fields.set(cell, true) - _fields.set(item.field, true) - formParam = formParam + `mchr13k@${_f} ${type},` + if (!_vars.includes(_f.toLowerCase())) { + _vars.push(_f.toLowerCase()) + formParam = formParam + `mchr13k@${_f} ${type},` + } + }) } }) } @@ -1055,8 +1120,8 @@ let Ltext = `create proc ${param.innerFunc} ( /*${menu.MenuName}*/ - @BID nvarchar(50)='', - @${primaryKey} nvarchar(50)='',${formParam} + @appkey nvarchar(50)='', + @BID nvarchar(50)='',${formParam} @PageIndex nvarchar(50)='', @PageSize nvarchar(50)='', @OrderCol nvarchar(50)='', @@ -1141,8 +1206,14 @@ static getfunc (param, btn, menu, config) { let form = '' let formParam = '' + let _vars = ['bid', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg'] let columns = config.columns let primaryKey = config.setting.primaryKey || 'ID' + + if (!_vars.includes(primaryKey.toLowerCase())) { + _vars.push(primaryKey.toLowerCase()) + formParam = `mchr13k@${primaryKey} nvarchar(50)='',` + } if (param.fields && param.fields.length > 0) { let _fields = [] @@ -1156,7 +1227,11 @@ } else { type = 'nvarchar(50)=\'\'' } - formParam = formParam + `mchr13k@${item.field} ${type},` + + if (!_vars.includes(item.field.toLowerCase())) { + _vars.push(item.field.toLowerCase()) + formParam = formParam + `mchr13k@${item.field} ${type},` + } _fields.push(item.field) } @@ -1203,10 +1278,16 @@ ` } + // 鎵撳嵃鑷畾涔夋ā鏉垮瓧娈垫彁绀� + let _printRemark = '' + if (btn.funcType === 'print') { + _printRemark = '/* 鑷畾涔夋暟鎹墦鍗版ā鏉挎椂锛岃浣跨敤TemplateID瀛楁 */' + } + let Ltext = `create proc ${param.funcName} ( /*${menu.MenuName} ${btn.label}*/ - @BID nvarchar(50)='', - @${primaryKey} nvarchar(50)='',${formParam} + @appkey nvarchar(50)='', + @BID nvarchar(50)='',${formParam} @sEPTMenuNo nvarchar(50)='${param.menuNo}', @lang nvarchar(50)='', @debug nvarchar(50)='', @@ -1226,7 +1307,7 @@ /*浜嬪姟鎿嶄綔*/ BEGIN TRAN /*鍏蜂綋涓氬姟鎿嶄綔*/ - + ${_printRemark} /* select top 10 * from sProcExcep order by id desc @@ -1313,10 +1394,13 @@ let Ltext = `create proc ${param.funcName} ( /*${menu.MenuName} ${btn.label}*/ + @appkey nvarchar(50)='', @ID nvarchar(50)='', @BID nvarchar(50)='', @Ltext nvarchar(max)='', @sEPTMenuNo nvarchar(50)='${param.menuNo}', + @secretkey nvarchar(50)='', + @timestamp nvarchar(50)='', @lang nvarchar(50)='', @LoginUID nvarchar(50)='', @SessionUid nvarchar(50)='', -- Gitblit v1.8.0