From 07acb5f4dc11e484801ccfcd95eee8845128c62a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 26 十一月 2019 22:41:29 +0800 Subject: [PATCH] 2019-11-26-01 --- src/utils/utils.js | 84 ++++++++++++++++++++++++++++++++++------- 1 files changed, 69 insertions(+), 15 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index a126695..d570d6c 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,61 @@ } /** + * @description 鏍煎紡鍖栨悳绱㈡潯浠� + * @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: '%', + value: 'mpercent' + }, { + key: '>', + value: 'greateror' + }, { + key: '<', + value: 'lessor' + }, { + key: '=', + value: 'equal' + }, { + key: 'top', + value: 'mtpk' + }] + + format.forEach(item => { + let reg = new RegExp(item.key, 'ig') + value = value.replace(reg, item.value) + }) + + value = value.replace(/\*/ig, 'mastrsk') + value = value.replace(/'/ig, 'mqotek') + value = value.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 +113,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