// import { getByCode } from '@/utils/dictUtil'

// 获取boolean值
export function booleanFun (value, defaultBoolean = true) {
  if (value === undefined || value === null) {
    return defaultBoolean
  }
  const type = typeof (value)
  if (type === 'boolean') {
    return value
  }
  if (type === 'function') {
    return booleanFun(value())
  }
  console.error(`booleanFun函数不生效，最终解析结果应为boolean类型，当前解析结果为：${type} 类型`)
}

// 获取选项数据
export async function geItemsData (dict, value, binding) {
  // if (dict) {
  //   return await getByCode(dict)
  // }
  const type = typeof (value)
  if (type === 'function') {
    let itemData = await value()
    if (binding) {
      const split = binding.split('.')
      for (let i = 0; i < split.length; i++) {
        itemData = itemData[split[i]]
      }
      return itemData
    } else {
      return itemData
    }
  }
  return value
}

// 判断不为空
export function notNull (value) {
  return value !== undefined && value != null && value !== ''
}
