agent.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {defineStore} from "pinia";
  2. import {ref} from "vue";
  3. import { getCoachList,getQuestionnaireList,getCoachProgramList,getTeamListById } from '@/api/agent/index.js'
  4. export const useAgentStore = defineStore('agent', () => {
  5. const companyList = ref([]);
  6. const companyMap = ref(new Map());
  7. const getCompanyData = () => {
  8. getCoachProgramList({enterpriseName:''}).then((res) => {
  9. companyList.value = res.data;
  10. const map = new Map();
  11. companyList.value.forEach((supplier) => {
  12. map.set(supplier.id, supplier);
  13. });
  14. companyMap.value = map;
  15. });
  16. };
  17. const teamList = ref([]);
  18. const teamMap = ref(new Map());
  19. const getTeamData = () => {
  20. getTeamListById({enterpriseId:''}).then((res) => {
  21. teamList.value = res.data;
  22. const map = new Map();
  23. teamList.value.forEach((supplier) => {
  24. map.set(supplier.id, supplier);
  25. });
  26. teamMap.value = map;
  27. });
  28. };
  29. const coachList = ref([]);
  30. const coachMap = ref(new Map());
  31. const getCoachData = () => {
  32. getCoachList({page:1,limit:-1}).then((res) => {
  33. coachList.value = res.data.list;
  34. const map = new Map();
  35. coachList.value.forEach((supplier) => {
  36. map.set(supplier.id, supplier);
  37. });
  38. coachMap.value = map;
  39. });
  40. };
  41. const questionnaireList = ref([]);
  42. const questionnaireMap = ref(new Map());
  43. const getQuestionnaireData = () => {
  44. getQuestionnaireList({page:1,limit:-1}).then((res) => {
  45. questionnaireList.value = res.data.list;
  46. const map = new Map();
  47. questionnaireList.value.forEach((supplier) => {
  48. map.set(supplier.id, supplier);
  49. });
  50. questionnaireMap.value = map;
  51. });
  52. };
  53. return {
  54. companyList,
  55. companyMap,
  56. getCompanyData,
  57. teamList,
  58. teamMap,
  59. getTeamData,
  60. coachList,
  61. coachMap,
  62. getCoachData,
  63. questionnaireList,
  64. questionnaireMap,
  65. getQuestionnaireData,
  66. };
  67. })