/*
 * @Author: micky
 * @Date: 2024-08-12 11:46:16
 * @LastEditors: micky
 * @LastEditTime: 2024-09-05 15:18:16
 * @FilePath: \chargingpile-uniapp\src\pages\overhaul\task\index.ts
 */
import { optionsMap } from '@/config/options'
import { ref, watch, unref, computed } from 'vue'
import { WorkOrderTypeEnum } from '@/enums/businessEnums'

const inspection = WorkOrderTypeEnum.INSPECTION //巡检单
export function useCommon() {
    const tabList = optionsMap.taskOptions
    const activeTab = ref(tabList[0].value)
    const activeStatus = ref<any>('')
    const statusTab = computed(() => {
        const options =
            unref(activeTab) == inspection
                ? optionsMap.inspectionStatusOptions
                : optionsMap.overhaulStatusOptions
        return options
    })

    watch(
        () => [unref(statusTab)],
        () => {
            activeStatus.value = unref(statusTab)[0].value
        },
        {
            immediate: true
        }
    )
    return {
        tabList,
        activeTab,
        statusTab,
        activeStatus
    }
}
