BaseTableArguments.js 2.67 KB
// TODO: 组件表单所需的所有参数(未完善类型检测)
export function BaseTableArgumentsTest(listName, loading, List, queryParams, columObj) {
  this.listName = listName
  this.loading = loading
  this.List = List
  this.queryParams = queryParams
  this.columObj = columObj
}

// TODO: 以下导出皆暂时不可用,都未完善

// 查询条件  (检查查询条件的类型)
export function queryParamsType(pageNum, pageSize, pageTotal) {
  if (typeof pageNum !== 'number' && typeof pageSize !== 'number' && typeof pageTotal !== 'number') {
    console.warn('queryParams查询参数的type类型错误!请检查后重新赋值')
    return null
  } else {
    this.pageNum = pageNum
    this.pageSize = pageSize
    this.pageTotal = pageTotal
  }
}

// 操作选项的类型判断
export function operationType(type, label, icon, color, buttonClick, isShow) {
  this.type = type
  this.label = label
  this.icon = icon
  this.color = color
  this.buttonClick = buttonClick | function() {}
  this.isShow = isShow | function(row, $index) {
    return true
  }
}

// 列的类型以及参数判断
export function columnDataType(text, status, ownDefined, isSwitch, image, isOperation, prop, label, width, align, operation) {
  this.text = text
  this.status = status
  this.ownDefined = ownDefined
  this.isSwitch = isSwitch
  this.image = image
  this.isOperation = isOperation

  this.prop = prop
  this.label = label
  this.width = width
  this.align = align

  if (operation instanceof operationType) {
    this.operations = operationType
  } else {
    console.warn('operation参数的type类型错误!请检查后重新赋值')
  }
}

// 组件表单所需的所有参数
export function BaseTableArguments(selection, loading, processList, queryParams, columnData) {
  // TODO: 选择框是否需要存在    (selection判断表单选择框是否需要存在)
  if (typeof selection !== 'boolean') {
    console.warn('selection下拉框参数的type类型错误!请检查后重新赋值')
  } else {
    this.selection = selection

    // TODO: 选择框  (根据条件是否可选)
    this.selectable = (row, index) => {
      if (row.isSwitch) {
        return true
      }
    }
  }

  // 加载进度    (判断是否显示加载进度)
  if (typeof loading !== 'boolean') {
    console.warn('loading进度条参数的type类型错误!请检查后重新赋值')
  } else {
    this.loading = loading
  }

  // 查询参数    (判断查询条件是否符合类型)
  if (queryParams instanceof queryParamsType) {
    this.queryParams = queryParamsType
  }

  //  每一列的参数
  if (columnData instanceof columnDataType) {
    this.columnData = columnData
  }

  this.processList = processList
}