123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import { store } from "@/store";
- import { defineStore } from "pinia";
- import { getUserList } from "@/api/auth";
- export const useDictionaryStore = defineStore("dictionaryStore", () => {
- const types = [
- "defect_mana",
- "stage",
- "process_state",
- "outsource_state",
- "work_order_seq_state",
- "station_task_state",
- "accessories_type",
- "danwei_type",
- "system_message_type",
- "plan_work_order_state",
- "disposal_measures_type",
- "escalation_fault_state",
- "excel_type",
- "device_type",
- "station_type",
- ];
- const dicts = ref<{ [key: string]: any[] }>({});
- // 所有的用户列表
- const allUsers = ref<any[]>([]);
- function checkAllData() {
- if (allUsers.value.length === 0) {
- getUserList().then((res) => {
- allUsers.value = res.data || [];
- });
- }
- }
- function getLableByValue(type: string, value: string) {
- const dict = dicts.value[type];
- if (dict) {
- const lable = dict.find((item: any) => item.dictValue === value);
- return lable?.dictLabel;
- }
- return "";
- }
- return {
- types,
- dicts,
- allUsers,
- checkAllData,
- getLableByValue,
- };
- });
- export function useDictionaryStoreHook() {
- // console.log('dicts:',useDictionaryStore(store))
- return useDictionaryStore(store);
- }
|