Newer
Older
urbanLifeline_YanAn / src / store / modules / order.js
@zhangzhihui zhangzhihui 1 day ago 1 KB 考核
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: [],
      systemDeptList: [],
      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);
      });
      listDept(data).then(response => {
        // this.systemDeptList = handleTree(response.data, 'deptId');
        this.systemDeptList = response.data;
        // console.log('🚀 ~ listDept ~ this.systemDeptList:', this.systemDeptList, 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', 'systemDeptList', 'userList'],
      },
    ],
  },
});
export default useOrderStore;