king
2019-11-26 07acb5f4dc11e484801ccfcd95eee8845128c62a
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) {
    // 产生一个新的GUID值
    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
  }
}