RoleUsersStores.ts 571 B

123456789101112131415161718192021222324
  1. import { defineStore } from 'pinia';
  2. import { RoleUsersType } from '../types';
  3. import { getAllUsers } from '../components/api';
  4. import XEUtils from 'xe-utils';
  5. /**
  6. * 权限抽屉:角色-用户
  7. */
  8. export const RoleUsersStores = defineStore('RoleUsersStores', {
  9. state: (): RoleUsersType => ({
  10. all_users: [],
  11. right_users: [],
  12. }),
  13. actions: {
  14. get_all_users() {
  15. getAllUsers().then((res: any) => {
  16. this.$state.all_users = res;
  17. });
  18. },
  19. set_right_users(users: any) {
  20. this.$state.right_users = XEUtils.map(users, (item: any) => item.id);
  21. },
  22. },
  23. });