import { get } from "@/utils/http.js";

export default {
    data() {
        return {
            placeTypes: []
        }
    },
    methods: {
        async loadPlaceTypes() {
            const res = await get('/v2/api/dictionary/place_type/items');
            if (res && res.length > 0) {
                this.placeTypes = res;
            }
        },
        parsePlaceType(obj) {
            if (obj.enforce_obj && obj.enforce_obj.place_type && this.placeTypes) {
                const place = this.placeTypes.filter(item => obj.enforce_obj.place_type == item.code);
                if (place.length > 0) {
                    obj.placeType = place[0].name;
                }
            }
        },
    }
}