From 95f2f60ba9eb343c2605e1ae68c221443d75f704 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 30 十一月 2019 00:55:07 +0800 Subject: [PATCH] commontable-update --- src/utils/utils.js | 161 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 146 insertions(+), 15 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index a126695..407b182 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -10,7 +10,7 @@ for (let i = 0; i < 19; i++) { uuid.push(options.substr(Math.floor(Math.random() * 0x20), 1)) } - uuid = uuid.join('') + timestamp + uuid = timestamp + uuid.join('') return uuid } @@ -30,23 +30,138 @@ } /** + * @description sql鍔犲瘑 + * @return {String} value + */ + static formatOptions (value) { + // 浜х敓涓�涓柊鐨凣UID鍊� + let format = [{ + key: 'select', + value: ' msltk ' + }, { + key: 'from', + value: ' mfrmk ' + }, { + key: 'where', + value: ' mwhrk ' + }, { + key: 'order by', + value: ' modbk ' + }, { + key: 'asc', + value: ' modack ' + }, { + key: 'desc', + value: ' moddesk ' + }, { + key: 'top', + value: ' mtpk ' + }, { + key: 'like', + value: ' mlkk ' + }, { + key: 'not like', + value: ' mnlkk ' + }, { + key: 'between', + value: ' mbtnk ' + }, { + key: 'and', + value: ' madk ' + }, { + key: 'insert', + value: ' mistk ' + }, { + key: 'into', + value: ' mitk ' + }, { + key: 'update', + value: ' muptk ' + }, { + key: 'delete', + value: ' mdelk ' + }, { + key: 'begin', + value: ' mbgink ' + }, { + key: 'end', + value: ' medk ' + }, { + key: 'if', + value: ' mefk ' + }, { + key: 'while', + value: ' mwilk ' + }, { + key: 'create', + value: ' mcrtk ' + }, { + key: 'alter', + value: ' matek ' + }, { + key: 'len', + value: ' mlnk ' + }, { + key: 'left', + value: ' mlftk ' + }, { + key: 'right', + value: ' mritk ' + }, { + key: 'union', + value: ' munok ' + }, { + key: 'varchar', + value: ' mvcrk ' + }, { + key: 'getdate', + value: ' mgtdtk ' + }, { + key: 'TRY', + value: ' mtryonek ' + }, { + key: 'TRAN', + value: ' mtrnk ' + }, { + key: 'goto', + value: ' mgtk ' + }, { + key: 'set', + value: ' mstk ' + }, { + key: 'ROLLBACK', + value: ' mrlbkk ' + }] + format.forEach(item => { + let reg = new RegExp('(^|\\s)' + item.key + '(\\s|$)', 'ig') + value = value.replace(reg, item.value) + }) + value = value.replace(/(^\s|\s$)/ig, '') + value = window.btoa(window.encodeURIComponent(value)) + let index = Math.floor(Math.random() * value.length) + value = value.slice(0, index) + 'minKe' + value.slice(index) + value = window.btoa(value) + // value = value.replace(/%/ig, 'mpercent') + // .replace(/>/ig, 'greateror') + // .replace(/</ig, 'lessor') + // .replace(/!=/ig, 'noequal') + // .replace(/=/ig, 'equal') + // .replace(/,/ig, 'comma') + // .replace(/>=/ig, 'greaterorequal') + // .replace(/<=/ig, 'lessorequal') + // .replace(/@/ig, 'matk') + // .replace(/\(/ig, 'mlbrktsk') + // .replace(/\)/ig, 'mrbrktsk') + // .replace(/\*/ig, 'mastrsk') + // .replace(/'/ig, 'mqotek') + // .replace(/\s/ig, 'mspace') + return value + } + + /** * @description 鎷兼帴鎼滅储鏉′欢 * @param {Array} searches 鎼滅储鏉′欢 * @return {String} searchText 鎷兼帴缁撴灉 - * ---杩囨护鏉′欢锛堟湭浣跨敤锛�--- - * greaterorequal: ' >= ' - * lessorequal: ' <= ' - * like: ' LIKE ' - * less: ' < ' - * greater: ' > ' - * equal: ' = ' - * notlike: ' notlike ' - * in: ' in ' - * notin: ' notin ' - * leftlike/startwith - * rightlike/endwith - * rightnotlike/endnotwith - * leftnotlike/startnotwith */ static jointsearchkey (searches) { if (!searches || searches.length === 0) return '' @@ -75,4 +190,20 @@ }) return searchText } + + /** + * @description 鑾峰彇鍥剧墖鐪熷疄璺緞 + * @return {String} url 鍥剧墖璺緞 + */ + static getrealurl (url) { + if (!url) return '' + let baseurl = '' + if (process.env.NODE_ENV === 'production') { + baseurl = document.location.origin + '/' + } else { + baseurl = 'http://qingqiumarket.cn/MKWMS/' + } + let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url + return realurl + } } \ No newline at end of file -- Gitblit v1.8.0