king
2021-05-08 6afdec0062dacbded57e166230eb22cc55ced0c1
src/tabviews/custom/index.jsx
@@ -184,7 +184,7 @@
        config.urlFields.forEach(field => {
          let val = `'${param ? (param[field] || '') : ''}'`
          regs.push({
            reg: new RegExp(field, 'ig'),
            reg: new RegExp('@' + field + '@', 'ig'),
            value: val
          })
        })
@@ -479,7 +479,7 @@
        }
        item.components = this.filterComponent(item.components, roleId, permAction, permMenus)
      } else if (item.type === 'pie' || item.type === 'bar' || item.type === 'line' || item.type === 'dashboard') {
      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter'].includes(item.type)) {
        if (
          item.plot.blacklist && item.plot.blacklist.length > 0 &&
          item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
@@ -508,7 +508,43 @@
        })
      }
      if (item.type === 'table' && item.subtype === 'normaltable') {
        item.cols = this.getCols(item.cols, roleId, permMenus)
        let statFields = []
        let getCols = (cols) => {
          return cols.filter(col => {
            if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
              return false
            } else if (col.Hide === 'true') {
              return false
            }
            if (col.type === 'number' && col.sum === 'true' && !statFields.includes(col.field)) {
              statFields.push(col)
            } else if (col.type === 'colspan') {
              col.subcols = getCols(col.subcols || [])
              if (col.subcols.length === 0) {
                return false
              }
            } else if (col.type === 'custom') {
              col.elements = col.elements.map(cell => {
                if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height) {
                  cell.innerHeight = 'auto'
                }
                return cell
              })
            }
            if (col.linkmenu && col.linkmenu.length > 0) {
              let menu_id = col.linkmenu.pop()
              col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || ''
            } else {
              col.linkThdMenu = ''
            }
            return true
          })
        }
        item.cols = getCols(item.cols)
        item.statFields = statFields
      }
      // 权限过滤
@@ -527,9 +563,15 @@
            cell = this.getPrinter(cell, item.uuid)
          }
          if (cell.btnstyle) { // 兼容
            cell.style = cell.style || {}
            cell.style = {...cell.style, ...cell.btnstyle}
          }
          return isHS || permAction[cell.uuid]
        })
      }
      if (item.type === 'card') {
        item.subcards.forEach(card => {
          let _hasheight = card.style.height && card.style.height !== 'auto'
@@ -552,6 +594,10 @@
              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
                cell = this.getPrinter(cell, item.uuid)
              }
              if (card.btnstyle) { // 兼容
                card.style = card.style || {}
                card.style = {...card.style, ...card.btnstyle}
              }
            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
              cell.innerHeight = 'auto'
            }
@@ -570,6 +616,10 @@
              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
                cell = this.getPrinter(cell, item.uuid)
              }
              if (card.btnstyle) { // 兼容
                card.style = card.style || {}
                card.style = {...card.style, ...card.btnstyle}
              }
            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
              cell.innerHeight = 'auto'
@@ -593,6 +643,11 @@
              if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
                cell = this.getPrinter(cell, item.uuid)
              }
              if (card.btnstyle) { // 兼容
                card.style = card.style || {}
                card.style = {...card.style, ...card.btnstyle}
              }
            } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
              cell.innerHeight = 'auto'
            }
@@ -613,6 +668,11 @@
            if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
              cell = this.getPrinter(cell, item.uuid)
            }
            if (cell.btnstyle) { // 兼容
              cell.style = cell.style || {}
              cell.style = {...cell.style, ...cell.btnstyle}
            }
            return isHS || permAction[cell.uuid]
@@ -658,31 +718,6 @@
    return item
  }
  getCols = (cols, roleId, permMenus) => {
    return cols.filter(col => {
      if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
        return false
      } else if (col.Hide === 'true') {
        return false
      }
      if (col.type === 'colspan') {
        col.subcols = this.getCols(col.subcols || [], roleId, permMenus)
        if (col.subcols.length === 0) {
          return false
        }
      }
      if (col.linkmenu && col.linkmenu.length > 0) {
        let menu_id = col.linkmenu.pop()
        col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || ''
      } else {
        col.linkThdMenu = ''
      }
      return true
    })
  }
  // 格式化默认设置
  formatSetting = (components, params, mainSearch, inherit, regs) => {
    return components.map(component => {
@@ -720,7 +755,7 @@
        }
      })
      delete component.scripts
      component.setting.$name = component.name || ''
      component.setting.execute = component.setting.execute !== 'false'  // 默认sql是否执行,转为boolean 统一格式
      component.setting.laypage = component.setting.laypage === 'true'   // 是否分页,转为boolean 统一格式
@@ -818,8 +853,8 @@
    // 测试系统打印查询语句
    if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) {
      _customScript &&  console.info(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      _dataresource &&  console.info(_dataresource)
      _customScript &&  console.info(`${setting.$name ? `/*组件-${setting.$name} 自定义脚本*/\n` : ''}${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      _dataresource &&  console.info(`${setting.$name ? `/*组件-${setting.$name} 数据源*/\n` : ''}` + _dataresource)
    }
    return {