dictionary.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { store } from "@/store";
  2. import { defineStore } from "pinia";
  3. // import { getUserList } from "@/api/auth";
  4. export const useDictionaryStore = defineStore("dictionaryStore", () => {
  5. const types = [
  6. "defect_mana",
  7. "stage",
  8. "process_state",
  9. "outsource_state",
  10. "work_order_seq_state",
  11. "accessories_type",
  12. "danwei_type",
  13. "system_message_type",
  14. "plan_work_order_state",
  15. "disposal_measures_type",
  16. "escalation_fault_state",
  17. "excel_type",
  18. "plan_order_state",
  19. ];
  20. const dicts = ref<{ [key: string]: any[] }>({});
  21. // 所有的用户列表
  22. const allUsers = ref<any[]>([]);
  23. function checkAllData() {
  24. // if (allUsers.value.length === 0) {
  25. // getUserList().then((res) => {
  26. // allUsers.value = res.data || [];
  27. // });
  28. // }
  29. }
  30. function getLableByValue(type: string, value: string) {
  31. const dict = dicts.value[type];
  32. if (dict) {
  33. const lable = dict.find((item: any) => item.dictValue === value);
  34. return lable?.dictLabel;
  35. }
  36. return "";
  37. }
  38. return {
  39. types,
  40. dicts,
  41. allUsers,
  42. checkAllData,
  43. getLableByValue,
  44. };
  45. });
  46. export function useDictionaryStoreHook() {
  47. // console.log('dicts:',useDictionaryStore(store))
  48. return useDictionaryStore(store);
  49. }