import { intersectionBy } from 'lodash';
import { Dict } from '@zenview/micro-basic-library';

// 计算全选半选状态
export function computedCheckStatus(list = [], checkedKeys = [], key = 'id') {
  const listKey = list.map((v) => v[key]);
  const temp = intersectionBy(listKey, checkedKeys);
  const checkHalfStatus = temp.length && temp.length < list.length;
  const checkAllStatus = list.length && temp.length === list.length;
  return {
    checkHalfStatus,
    checkAllStatus,
    listKey,
  };
}

export function getAllDeviceTypeDict() {
  const allCameraType = Dict.cacheMap.data['100600'] || [];
  for (const item of allCameraType) {
    item.value = item.code
    item.label = item.name
  }

  return allCameraType;
}