checkPersonnel(state, payload) { const userId = payload.userId; const orgkey = payload.orgKey; const orgId = payload.orgId;

state.userInfo = state.userInfo.map(userinfo => { if (userinfo.userId === userId) { return { ...userinfo, checked: !userinfo.checked }; } return userinfo; });

this.commit("getUserInfoPersonnel"); this.commit("getUserInfoOrg");

if (orgId) { const userlistByOrg = state.userlistByOrg;

for (let org of userlistByOrg) {
  if (org.orgkey === orgkey) {
    for (let value of org.value) {
      if (value.orgId === orgId) {
        const flag = value.user.every(user => user.checked);
        console.log("find it", value);
        console.log(flag);
        break;
      }
    }
    break;
  }
}

} },

Explanation:

  1. Removed the unnecessary console.log() statements.
  2. Used Array.map() instead of Array.forEach() while updating the state.
  3. Used object destructuring in for loop.
  4. Used Array.every() to check if every user is checked in a given organization.

原文地址: https://www.cveoy.top/t/topic/p1f 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录