1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { store } from "@/store";
- import { defineStore } from "pinia";
- import { getUserDicts } from "@/api/auth";
- export const useDictionaryStore = defineStore("dictionaryStore", () => {
- const types = [
- "station_type",
- "station_operate_type",
- "applicable_platforms",
- "material_properties",
- "quality_testing_plan",
- "material_level",
- "packaging_method",
- "quality_grade",
- "selection_type",
- "device_type",
- "stage",
- "danwei_type",
- "process_type",
- "workshop_section",
- "skill_requirements",
- "accessories_type",
- "danwei_type",
- "trace_type",
- "skill_type",
- "drawing_type",
- "vehicle_level",
- ];
- const dicts = ref<{ [key: string]: any[] }>({});
- function checkDicts() {
- if (JSON.stringify(dicts.value) === "{}") {
- getUserDicts(types).then((res) => {
- if (res.data) {
- dicts.value = res?.data ?? [];
- }
- });
- }
- }
- return {
- types,
- dicts,
- checkDicts,
- };
- });
- export function useDictionaryStoreHook() {
- // console.log('dicts:',useDictionaryStore(store))
- return useDictionaryStore(store);
- }
|