king
2022-10-25 373067f784dee77fa98b593992f8e324f9cde46d
src/utils/utils-custom.js
@@ -4,44 +4,51 @@
   * @return {String}  selfId  当前组件id
   */
  static getSubModules (components, selfId, supId) {
    let modules = components.map(item => {
    let modules = []
    components.forEach(item => {
      if (item.uuid === selfId || item.type === 'navbar') {
        return {
          children: null
        }
        return
      } else if (item.format) { // 数据格式,存在数据源
        return {
        modules.push({
          value: item.uuid,
          label: item.name,
          disabled: supId === item.uuid
        }
        })
      } else if (item.type === 'tabs') {
        let _item = {
          type: 'tabs',
          value: item.uuid,
          label: item.name,
          children: item.subtabs.map(f_tab => {
            let subItem = {
              type: 'tab',
              value: f_tab.uuid,
              label: f_tab.label,
              children: this.getSubModules(f_tab.components, selfId)
            }
            if (!subItem.children || subItem.children.length === 0) {
              return {children: null}
            }
            return subItem
        if (item.subtype === 'tabletabs') {
          item.subtabs.forEach(tab => {
            modules.push({
              value: tab.components[0].uuid,
              label: tab.label,
              disabled: supId === tab.components[0].uuid
            })
          })
        } else {
          let _item = {
            type: 'tabs',
            value: item.uuid,
            label: item.name,
            children: item.subtabs.map(f_tab => {
              let subItem = {
                type: 'tab',
                value: f_tab.uuid,
                label: f_tab.label,
                children: this.getSubModules(f_tab.components, selfId, supId)
              }
              if (subItem.children.length === 0) {
                return {children: null}
              }
              return subItem
            })
          }
          _item.children = _item.children.filter(t => t.children !== null)
          if (_item.children.length > 0) {
            modules.push(_item)
          }
        }
        _item.children = _item.children.filter(t => t.children !== null)
        if (_item.children.length === 0) {
          return {children: null}
        }
        return _item
      } else if (item.type === 'group') {
        let _item = {
          value: item.uuid,
@@ -54,7 +61,8 @@
            } else if (f_tab.format) {
              return {
                value: f_tab.uuid,
                label: f_tab.name
                label: f_tab.name,
                disabled: supId === f_tab.uuid
              }
            }
            return {
@@ -65,23 +73,12 @@
        _item.children = _item.children.filter(t => t.children !== null)
        if (_item.children.length === 0) {
          return {children: null}
        }
        return _item
      } else {
        return {
          children: null
        if (_item.children.length > 0) {
          modules.push(_item)
        }
      }
    })
    modules = modules.filter(mod => mod.children !== null)
    if (modules.length === 0) {
      return null
    }
    return modules
  }
@@ -175,11 +172,10 @@
   * @return {String}  selfId  当前组件id
   */
  static getSupModules (components, selfId) {
    let modules = components.map(item => {
    let modules = []
    components.forEach(item => {
      if (item.uuid === selfId) {
        return {
          children: null
        }
      } else if (item.switchable) { // 数据可切换
        let disabled = false
        if (item.type === 'card') {
@@ -187,41 +183,51 @@
        } else if (item.type === 'table') {
          disabled = item.wrap.tableType === ''
        }
        return {
        modules.push({
          value: item.uuid,
          label: item.name,
          disabled: disabled
        }
        })
      } else if (item.type === 'form') { // 数据格式,存在数据源
        return {
        modules.push({
          value: item.uuid,
          label: item.name
        }
        })
      } else if (item.type === 'tabs') {
        let _item = {
          value: item.uuid,
          label: item.name,
          children: item.subtabs.map(f_tab => {
            let subItem = {
              value: f_tab.uuid,
              label: f_tab.label,
              children: this.getSupModules(f_tab.components, selfId)
            }
        if (item.subtype === 'tabletabs') {
          item.subtabs.forEach(tab => {
            if (tab.components[0].uuid === selfId) return
            if (!subItem.children || subItem.children.length === 0) {
              return {children: null}
            }
            return subItem
            modules.push({
              value: tab.components[0].uuid,
              label: tab.label,
              disabled: tab.components[0].wrap.tableType === ''
            })
          })
        } else {
          let _item = {
            value: item.uuid,
            label: item.name,
            children: item.subtabs.map(f_tab => {
              let subItem = {
                value: f_tab.uuid,
                label: f_tab.label,
                children: this.getSupModules(f_tab.components, selfId)
              }
              if (subItem.children.length === 0) {
                return {children: null}
              }
              return subItem
            })
          }
          _item.children = _item.children.filter(t => t.children !== null)
          if (_item.children.length > 0) {
            modules.push(_item)
          }
        }
        _item.children = _item.children.filter(t => t.children !== null)
        if (_item.children.length === 0) {
          return {children: null}
        }
        return _item
      } else if (item.type === 'group') {
        let _item = {
          value: item.uuid,
@@ -232,9 +238,16 @@
                children: null
              }
            } else if (f_tab.switchable) {
              let disabled = false
              if (f_tab.type === 'card') {
                disabled = f_tab.wrap.cardType === ''
              } else if (f_tab.type === 'table') {
                disabled = f_tab.wrap.tableType === ''
              }
              return {
                value: f_tab.uuid,
                label: f_tab.name
                label: f_tab.name,
                disabled: disabled
              }
            }
            return {
@@ -245,23 +258,12 @@
        _item.children = _item.children.filter(t => t.children !== null)
        if (_item.children.length === 0) {
          return {children: null}
        }
        return _item
      } else {
        return {
          children: null
        if (_item.children.length > 0) {
          modules.push(_item)
        }
      }
    })
    modules = modules.filter(mod => mod.children !== null)
    if (modules.length === 0) {
      return null
    }
    return modules
  }
@@ -937,7 +939,7 @@
/**
 * @description 获取表名
 */
export function getTables (config) {
export function getTables (config, pops) {
  let tables = []
  let cuts = []
  let cutreg = /(from|update|insert\s+into)\s+(@db@)?[a-z_]+/ig
@@ -971,15 +973,21 @@
  } else if (config.subcards) {
    config.subcards.forEach(item => {
      item.elements.forEach(cell => {
        if (cell.eleType === 'button' && ['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
        if (cell.eleType !== 'button') return
        if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
          action.push(cell)
        } else if (pops && cell.OpenType === 'popview') {
          pops.push({...cell, parentId: config.uuid})
        }
      })
  
      if (item.backElements && item.setting.type === 'multi') {
        item.backElements.forEach(cell => {
          if (cell.eleType === 'button' && ['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
          if (cell.eleType !== 'button') return
          if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
            action.push(cell)
          } else if (pops && cell.OpenType === 'popview') {
            pops.push({...cell, parentId: config.uuid})
          }
        })
      }
@@ -990,20 +998,27 @@
      col.elements.forEach(cell => {
        if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
          action.push(cell)
        } else if (pops && cell.OpenType === 'popview') {
          pops.push({...cell, parentId: config.uuid})
        }
      })
    }
  })
  config.elements && config.elements.forEach(cell => {
    if (cell.eleType === 'button' && ['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
    if (cell.eleType !== 'button') return
    if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
      action.push(cell)
    } else if (pops && cell.OpenType === 'popview') {
      pops.push({...cell, parentId: config.uuid})
    }
  })
  config.action && config.action.forEach(cell => {
    if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) {
      action.push(cell)
    } else if (pops && cell.OpenType === 'popview') {
      pops.push({...cell, parentId: config.uuid})
    }
  })