dictionary.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { store } from "@/store";
  2. import { defineStore } from "pinia";
  3. import { getUserDicts } from "@/api/auth";
  4. export const useDictionaryStore = defineStore(
  5. "dictionaryStore",
  6. () => {
  7. const types = [
  8. "station_type",
  9. "station_operate_type",
  10. "applicable_platforms",
  11. "material_properties",
  12. "quality_testing_plan",
  13. "material_level",
  14. "packaging_method",
  15. "quality_grade",
  16. "selection_type",
  17. "device_type",
  18. "stage",
  19. "danwei_type",
  20. "process_type",
  21. "workshop_section",
  22. "skill_requirements",
  23. "accessories_type",
  24. "trace_type",
  25. "skill_type",
  26. "drawing_type",
  27. "vehicle_level",
  28. "fault_current_state",
  29. "escalation_fault_state",
  30. "defect_mana",
  31. "disposal_measures_type",
  32. "process_check_result",
  33. "excel_states",
  34. "process_state"
  35. ];
  36. const dicts = ref<{ [key: string]: any[] }>({});
  37. return {
  38. types,
  39. dicts,
  40. };
  41. },
  42. {
  43. // 持久化配置
  44. persist: {
  45. enabled: true,
  46. strategies: [
  47. {
  48. key: "mes-dictionaryData", // 自定义存储键名
  49. storage: localStorage, // 使用 localStorage
  50. paths: ["dicts"], // 只持久化 dicts 数据
  51. },
  52. ],
  53. },
  54. }
  55. );
  56. export function useDictionaryStoreHook() {
  57. // console.log('dicts:',useDictionaryStore(store))
  58. return useDictionaryStore(store);
  59. }