123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import {
- getHDIncidentList,
- IncidentItem,
- IncidentItemDetail,
- } from '@/api/incident';
- import {
- getAllResources,
- getAllsingleDevice, ResourceItemDetail,
- SingleDeviceItem,getAllvideoDevice
- } from "@/api/resource";
- import {
- PENDING_DISPOSAL_INCIDENT,
- PENDING_INCIDENT,
- // EMERGENCY_VEHICLES,
- VIDEO_SURVEILLANCE,
- WARNING_INCIDENT,
- SINGLE_PAWN,
- // EMERGENCY_TEAM,
- } from '@/components/MarkerMap/constants';
- import { type } from 'os';
- import { defineStore } from 'pinia';
- type AllResources = NonNullable<IncidentItemDetail['baseInfo']> &
- NonNullable<SingleDeviceItem> & ResourceItemDetail;
- type Simply<T> = { [K in keyof T]: T[K] };
- export interface MarkerType extends Simply<AllResources> {
- locations?: string;
- marker?: any;
- popup?: any;
- // [key: string]: any;
- }
- export interface MarkerStateType {
- warningIncident: MarkerType[];
- pendingIncident: MarkerType[];
- pendingDisposalIncident: MarkerType[];
- videoSurveillance: MarkerType[];
- emergencyVehicles: MarkerType[];
- emergencyTeam: MarkerType[];
- emergencyWarehouse: MarkerType[];
- singleDevice: SingleDeviceItem[];
- /** 详情页面 点击监控点位 打开视频 */
- livevideovisible: boolean;
- livevideos: MarkerType[];
- incident: MarkerType[];
- loading: boolean;
- currentIncident: MarkerType;
- }
- export interface MainActionsType {
- toggleLoading(): void;
- getHDIncidentList(): void;
- getAllResources(): void;
- getAllsingleDevice(): void;
- }
- export default defineStore<'marker', MarkerStateType, {}, MainActionsType>(
- 'marker',
- {
- state: () => ({
- currentIncident: {},
- incident: [],
- warningIncident: [],
- pendingIncident: [],
- pendingDisposalIncident: [],
- videoSurveillance: [],
- emergencyVehicles: [],
- emergencyTeam: [],
- singleDevice: [],
- emergencyWarehouse: [],
- livevideos: [],
- livevideovisible: false,
- loading: false,
- }),
- actions: {
- toggleLoading() {
- this.loading = !this.loading;
- },
- async getHDIncidentList() {
- try {
- this.toggleLoading();
- const { data } = await getHDIncidentList();
- this.incident = (data as MarkerType[]) ?? [];
- } finally {
- this.toggleLoading();
- }
- },
- async getAllsingleDevice() {
- try {
- this.toggleLoading();
- const { data } = await getAllsingleDevice();
- this.singleDevice = [];
- this.singleDevice = Object.values(data).map((item) => ({
- ...item,
- locations: `${item.gpsX},${item.gpsY}`,
- }));
- console.log(this.singleDevice);
- } finally {
- this.toggleLoading();
- }
- },
- async getAllvideoDevice() {
- try {
- this.toggleLoading();
- const { data } = await getAllvideoDevice();
- let videoData = [];
- for(var index in data){
- if(data[index].gpsX){
- console.log(index);
- videoData.push(data[index]);
- }
- }
- this.videoSurveillance = [];
- this.videoSurveillance = Object.values(videoData).map((item) => ({
- ...item,
- locations: `${item.gpsX},${item.gpsY}`,
- }));
- console.log(this.videoSurveillance);
- } finally {
- this.toggleLoading();
- }
- },
- async getAllResources() {
- try {
- this.toggleLoading();
- const { data } = await getAllResources();
- // @ts-ignore
- this.emergencyVehicles =
- data.应急车队.map((i) => ({
- ...i,
- locations: `${i.longitude},${i.latitude}`,
- })) ?? [];
- // @ts-ignore
- this.emergencyTeam =
- data.应急队伍.map((i) => ({
- ...i,
- locations: `${i.longitude},${i.latitude}`,
- })) ?? [];
- // @ts-ignore
- this.emergencyWarehouse =
- data.应急仓库.map((i) => ({
- ...i,
- locations: `${i.longitude},${i.latitude}`,
- })) ?? [];
- } finally {
- this.toggleLoading();
- }
- },
- },
- },
- );
|