|
@@ -2,55 +2,55 @@ 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",
|
|
|
- "work_order_seq_state",
|
|
|
- ];
|
|
|
- const dicts = ref<{ [key: string]: any[] }>({});
|
|
|
+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",
|
|
|
+ "work_order_seq_state",
|
|
|
+ ];
|
|
|
+ const dicts = ref<{ [key: string]: any[] }>({});
|
|
|
|
|
|
- // 所有的用户列表
|
|
|
- const allUsers = ref<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 "";
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- 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,
|
|
|
+ getLableByValue,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ {
|
|
|
+ persist: {
|
|
|
+ storage: localStorage,
|
|
|
+ pick: ["dicts", "allUsers"],
|
|
|
+ },
|
|
|
}
|
|
|
-
|
|
|
- return {
|
|
|
- types,
|
|
|
- dicts,
|
|
|
- allUsers,
|
|
|
- checkAllData,
|
|
|
- getLableByValue,
|
|
|
- };
|
|
|
-});
|
|
|
+);
|
|
|
|
|
|
export function useDictionaryStoreHook() {
|
|
|
// console.log('dicts:',useDictionaryStore(store))
|