import { listDept } from '@/api/system/dept'; // 部门 import { listWorkOrderDept, listWorkOrderHandler } from '@/api/order'; // 部门 import { listUser } from '@/api/system/user'; import { handleTree } from '@/utils/ruoyi'; const useOrderStore = defineStore('order', { state: () => { return { deptList: [], userList: [], }; }, actions: { getDeptList(data = {}) { /* { deptName: undefined, status: undefined, } */ listWorkOrderDept(data).then(response => { this.deptList = response.data; // this.deptList = handleTree(response.data, 'deptId'); // console.log('🚀 ~ listDept ~ this.deptList:', this.deptList, response); }); }, getUserList(data = {}) { listWorkOrderHandler(data).then(response => { // this.userList = handleTree(response.data, 'deptId'); this.userList = response.data; // console.log('🚀 ~ listUser ~ this.userList:', this.userList, response); }); }, }, persist: { enabled: true, // 自定义持久化参数 strategies: [ { // 自定义key // key: "userInfo", // 自定义存储方式,默认 sessionStorage storage: sessionStorage, // 指定要持久化的数据,默认所有 state 都会进行缓存,可以通过 paths 指定要持久化的字段,其他的则不会进行持久化。 paths: ['deptList'], }, ], }, }); export default useOrderStore;