dictionary.ts 1.1 KB

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