/*
 * @Author: micky
 * @Date: 2024-08-12 11:46:16
 * @LastEditors: micky
 * @LastEditTime: 2024-09-10 23:26:21
 * @FilePath: \chargingpile-uniapp\src\pages\client\workOrder\index.ts
 */
import { optionsMap } from '@/config/options'
import { ref, watch, unref, computed } from 'vue'
import { WorkOrderTypeEnum } from '@/enums/businessEnums'

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

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