import {defineStore} from "pinia";
import {CHECK_STORE_KEY} from "@/stores/constant";
import type {CheckData} from "@/api/check/interface";
import type {Plan} from '@/api/plan/interface'


export const useCheckStore = defineStore("check", {
    id: CHECK_STORE_KEY,

    state: () => ({
        devices: Array<CheckData.Device>(),
        plan: Object<Plan.ResPlan>(),
        selectTestItems: Object<CheckData.SelectTestItem>({preTest: true, timeTest: true, channelsTest: false, test: true}),
        checkType:1
    }),

    getters: {},

    actions: {
        addDevices(device: CheckData.Device[]) {
            this.devices.push(...device);
        },
        setPlan(plan: Plan.ResPlan) {
            this.plan = plan
        },
        clearDevices() {
            this.devices = [];
        },
        initSelectTestItems() {
            this.selectTestItems.preTest = true
            this.selectTestItems.channelsTest = false
            this.selectTestItems.test = true
        },
        setSelectTestItems(selectTestItems: CheckData.SelectTestItem) {
            this.selectTestItems = selectTestItems
        },
        setCheckType(checkType: number) {
            this.checkType = checkType
        }
    }
});