king
2023-01-05 876a5e6657d67df66bb525d02dd6d147ba81cae5
src/utils/utils-custom.js
@@ -872,17 +872,36 @@
}
/**
 * @description 获取图表高度
 */
export function getHeight (val) {
  if (typeof(val) === 'string') {
    if (val.indexOf('px') > -1) {
      val = parseFloat(val)
    } else if (val.indexOf('vw') > -1) {
      val = parseFloat(val)
      val = document.body.clientWidth * val / 100
    } else if (val.indexOf('vh') > -1) {
      val = parseFloat(val)
      val = document.body.clientHeight * val / 100
    }
  }
  return parseInt(val || 400) - 30
}
/**
 * @description 获取表名
 */
export function getTables (config, pops) {
  let tables = []
  let cuts = []
  let cutreg = /(from|update|insert\s+into)\s+(@db@)?[a-z_]+/ig
  let cutreg = /(from|update|insert\s+into)\s+(@db@)?[a-z0-9_]+/ig
  let trimreg = /(from|update|insert\s+into)\s+(@db@)?/ig
  if (config.setting && (!config.wrap || !config.wrap.datatype || config.wrap.datatype === 'dynamic')) {
    if (config.setting.interType === 'system') {
      if (config.setting.execute !== 'false') {
      if (config.setting.execute !== 'false' && config.setting.dataresource) {
        let tbs = config.setting.dataresource.match(cutreg)
        tbs && cuts.push(...tbs)
      }
@@ -924,6 +943,8 @@
        if (cell.eleType !== 'button') return
        if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
          action.push(cell)
        } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
          action.push(cell)
        } else if (cell.OpenType === 'popview') {
          if (pops) {
            pops.push({...cell, parentId: config.uuid})
@@ -937,6 +958,8 @@
        item.backElements.forEach(cell => {
          if (cell.eleType !== 'button') return
          if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
            action.push(cell)
          } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
            action.push(cell)
          } else if (cell.OpenType === 'popview') {
            if (pops) {
@@ -955,6 +978,8 @@
      col.elements.forEach(cell => {
        if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
          action.push(cell)
        } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
          action.push(cell)
        } else if (cell.OpenType === 'popview') {
          if (pops) {
            pops.push({...cell, parentId: config.uuid})
@@ -970,6 +995,8 @@
    if (cell.eleType !== 'button') return
    if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
      action.push(cell)
    } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
      action.push(cell)
    } else if (cell.OpenType === 'popview') {
      if (pops) {
        pops.push({...cell, parentId: config.uuid})
@@ -981,6 +1008,8 @@
  config.action && config.action.forEach(cell => {
    if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
      action.push(cell)
    } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) {
      action.push(cell)
    } else if (cell.OpenType === 'popview') {
      if (pops) {
@@ -1002,6 +1031,19 @@
      }
      if (btn.intertype === 'system' && btn.verify.scripts) {
        btn.verify.scripts.forEach(script => {
          if (script.status === 'false') return
          let tbs = script.sql.match(cutreg)
          tbs && cuts.push(...tbs)
        })
      }
    } else if (btn.OpenType === 'funcbutton') {
      if (btn.intertype !== 'system' || !btn.verify || !btn.verify.setting) return
      if (btn.verify.dataType === 'custom') {
        if (btn.verify.setting.defaultSql !== 'false') {
          let tbs = btn.verify.setting.dataresource.match(cutreg)
          tbs && cuts.push(...tbs)
        }
        btn.verify.scripts && btn.verify.scripts.forEach(script => {
          if (script.status === 'false') return
          let tbs = script.sql.match(cutreg)
          tbs && cuts.push(...tbs)
@@ -1083,7 +1125,7 @@
  cuts = cuts.map(item => item.replace(trimreg, ''))
  tables.push(...cuts)
  tables = tables.filter(Boolean)
  tables = tables.filter(tb => tb && tb !== 'dbo' && tb.length > 1)
  tables = Array.from(new Set(tables))
  return tables