RoleDrawerStores.ts 734 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { defineStore } from 'pinia';
  2. import { RoleDrawerType } from '../types';
  3. /**
  4. * 权限配置:抽屉
  5. */
  6. const initialState: RoleDrawerType = {
  7. drawerVisible: false,
  8. roleId: undefined,
  9. roleName: undefined,
  10. users: [],
  11. };
  12. export const RoleDrawerStores = defineStore('RoleDrawerStores', {
  13. state: (): RoleDrawerType => ({
  14. ...initialState,
  15. }),
  16. actions: {
  17. /**
  18. * 打开权限修改抽屉
  19. */
  20. handleDrawerOpen(row: any) {
  21. this.drawerVisible = true;
  22. this.set_state(row);
  23. },
  24. set_state(row: any) {
  25. this.roleName = row.name;
  26. this.roleId = row.id;
  27. this.users = row.users;
  28. },
  29. /**
  30. * 关闭权限修改抽屉
  31. */
  32. handleDrawerClose() {
  33. Object.assign(this.$state, initialState);
  34. },
  35. },
  36. });