dictionary.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { store } from "@/store";
  2. import { defineStore } from "pinia";
  3. import { getUserDicts } from "@/api/auth";
  4. export const useDictionaryStore = defineStore("dictionaryStore", () => {
  5. const types = [
  6. "station_type",
  7. "station_operate_type",
  8. "applicable_platforms",
  9. "material_properties",
  10. "quality_testing_plan",
  11. "material_level",
  12. "packaging_method",
  13. "quality_grade",
  14. "selection_type",
  15. "device_type",
  16. "stage",
  17. "danwei_type",
  18. "process_type",
  19. "workshop_section",
  20. "skill_requirements",
  21. "accessories_type",
  22. "danwei_type",
  23. "trace_type",
  24. "skill_type",
  25. "drawing_type",
  26. "vehicle_level",
  27. "fault_current_state",
  28. "escalation_fault_state",
  29. "defect_mana",
  30. "disposal_measures_type",
  31. ];
  32. const dicts = ref<{ [key: string]: any[] }>({});
  33. function checkDicts() {
  34. if (JSON.stringify(dicts.value) === "{}") {
  35. getUserDicts(types).then((res) => {
  36. if (res.data) {
  37. dicts.value = res?.data ?? [];
  38. }
  39. });
  40. }
  41. }
  42. return {
  43. types,
  44. dicts,
  45. checkDicts,
  46. };
  47. });
  48. export function useDictionaryStoreHook() {
  49. // console.log('dicts:',useDictionaryStore(store))
  50. return useDictionaryStore(store);
  51. }