king
2022-02-09 d59f518f466274b2caeb2e01c10c92deafe7c93b
src/utils/utils.js
@@ -707,14 +707,16 @@
  static getSelectQueryOptions (item) {
    let arrfield = [item.valueField, item.valueText]
    if (item.type === 'link') {
      arrfield.push(item.linkField)
    } else if (item.type === 'checkcard') {
    if (item.type === 'checkcard') {
      arrfield = item.fields.map(f => f.field)
      arrfield.push(item.cardValField)
      if (item.urlField) {
        arrfield.push(item.urlField)
      }
    }
    if (item.linkField) {
      arrfield.push(item.linkField)
    }
    if (['select', 'radio', 'link', 'checkcard'].includes(item.type) && item.linkSubField && item.linkSubField.length > 0) {
      arrfield.push(...item.linkSubField)
@@ -735,9 +737,11 @@
    arrfield = arrfield.join(',')
    if (item.orderBy) {
      sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}`
      // sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}`
      sql = `select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} order by orderfield ${item.orderType}`
    } else {
      sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield} from ${_datasource}) a`
      // sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield} from ${_datasource}) a`
      sql = `select distinct ${arrfield} from ${_datasource}`
    }
    if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
@@ -1381,7 +1385,7 @@
    if (!_initvars.includes(_key)) {
      _initvars.push(_key)
      if (form.type === 'number') {
      if (form.type === 'number' || form.type === 'rate') {
        let val = form.value
        if (typeof(val) !== 'number') {
          val = parseFloat(val)
@@ -1390,6 +1394,8 @@
          }
        }
        _initFormfields.push(`@${_key}=${val}`)
      } else if (['date', 'datemonth', 'datetime'].includes(form.type)) {
        _initFormfields.push(`@${_key}='${form.value || '1900-01-01'}'`)
      } else {
        _initFormfields.push(`@${_key}='${form.value}'`)
      }
@@ -1408,6 +1414,8 @@
        _type = 'datetime'
      } else if (form.type === 'number') {
        _type = `decimal(18,${form.fieldlen})`
      } else if (form.type === 'rate') {
        _type = `decimal(18,2)`
      }
      _declarefields.push(`@${_key} ${_type}`)
@@ -2034,6 +2042,75 @@
}
/**
 * @description 获取标记信息
 */
export function getMark (marks, record, style = {}) {
  let icon = null
  let color = null
  let position = null
  marks.some(mark => {
    let originVal = record[mark.field[0]] + ''
    let contrastVal = ''
    let result = false
    if (mark.field[1] === 'static') {
      contrastVal = mark.contrastValue + ''
    } else {
      contrastVal = record[mark.field[2]] + ''
    }
    if (mark.match === '=') {
      result = originVal === contrastVal
    } else if (mark.match === '!=') {
      result = originVal !== contrastVal
    } else if (mark.match === 'like') {
      result = originVal.indexOf(contrastVal) > -1
    } else if (mark.match === '>') {
      result = parseFloat(originVal) > parseFloat(contrastVal)
    } else if (mark.match === '<') {
      result = parseFloat(originVal) < parseFloat(contrastVal)
    }
    if (!result) return false
    let type = mark.signType[0]
    if (type === 'font') {
      style.color = mark.color
    } else if (type === 'background') {
      style.background = mark.color
      if (mark.fontColor) {
        style.color = mark.fontColor
      }
    } else if (type === 'underline') {
      style.textDecoration = 'underline'
      style.color = mark.color
    } else if (type === 'line-through') {
      style.textDecoration = 'line-through'
      style.color = mark.color
    } else if (type.indexOf('icon') > -1) {
      icon = mark.signType[mark.signType.length - 1]
      color = mark.color
      if (type === 'iconfront' || mark.signType[1] === 'front') {
        position = 'front'
      } else {
        position = 'back'
      }
    }
    return true
  })
  return {
    style,
    icon,
    color,
    position
  }
}
/**
 * @description 生成替换函数列表
 */
export function setGLOBFuncs () {
@@ -2253,6 +2330,8 @@
            type = 'datetime=null'
          } else if (item.type === 'number') {
            type = `decimal(18,${item.decimal})=0`
          } else if (item.type === 'rate') {
            type = `decimal(18,2)=0`
          } else {
            type = 'nvarchar(50)=\'\''
          }