dictionary.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. "station_type",
  22. "danwei_type",
  23. "trace_type",
  24. "skill_type",
  25. ];
  26. const dicts = ref<{ [key: string]: any[] }>({});
  27. function checkDicts() {
  28. if (JSON.stringify(dicts.value) === "{}") {
  29. getUserDicts(types).then((res) => {
  30. if (res.data) {
  31. dicts.value = res?.data ?? [];
  32. }
  33. });
  34. }
  35. }
  36. return {
  37. types,
  38. dicts,
  39. checkDicts,
  40. };
  41. });
  42. export function useDictionaryStoreHook() {
  43. // console.log('dicts:',useDictionaryStore(store))
  44. return useDictionaryStore(store);
  45. }