tyler.js 457 Bytes
Newer Older
forevertyler's avatar
forevertyler committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// 检查角色数组是否包含传入的角色
export function hasRole(roles, target) {
  if (typeof target === 'string') {
      return roles.includes(target);
  } else if (Array.isArray(target)) {
      return target.some(role => roles.includes(role));
  }
  return false;
}
//根据id等回显
export function findLabelByValue(arr,value,orgVal,name) {
  const found = arr.find(item => item[value] == orgVal);
  return found ? found[name] : undefined;
}