import { defineStore } from 'pinia'
import useUserStore from 'mocp/store/user'
import { decideTimeRange } from 'mocp/utils/getFlightList'

const userStore = useUserStore()
const listTab = [
    { label: '航班号', selected: true },
    { label: '机号', selected: true },
    { label: '机型', selected: true },
    { label: '机位', selected: true },
    { label: '出发地', selected: true },
    { label: '预/实', selected: true },
    { label: '计划', selected: false },
    { label: '特殊任务', selected: true },
    { label: '状态', selected: false }
]
const listScreen = [
    { name: '进港', value: '进港' },
    { name: '出港', value: '出港' },
    { name: '无航班', value: '无航班' }
]
const time = decideTimeRange(new Date().getTime())
console.log(time)

const useFlightSupportStore = defineStore('informationDisclosure', {
    state: () => {
        return {
            searchData: {
                acOwn: '',//航司
                acOwns2: '',
                acTerminals1: '',
                acType: '',//机型
                acTypes2: '',
                acs1: '',
                isInbound: 1,
                isOut: 0,
                startT: 1721250000000,
                stopT: 1721336400000,
                terminal: userStore.userInfo.terminal//,'WUH',//航站
                //flightNo: '',//航班号
                //ac: '',//机号

                /*startT: '1721163600000',
                stopT: '1721249999000',
                acTerminals2: userStore.userInfo.terminal,//'WUH',
                sortType: 'stdChn',
                apiPwd: 'Ifar$2_0160_525_Mocp',
                isAsc: '1',
                pageIndex: 1,
                pageSize: 50,
                requestFrom: 6,
                realUserId: 10*/
            },
            details: undefined,
            listTab,
            listScreen,
            listScreenCurrent: 1
        }
    },
    getters: {},
    actions: {
        getSelectedList() {
            return listTab.filter(item => item.selected)
        },
        resetForm() {
            this.searchData = {
                startT: '',
                stopT: '',
                acTerminals2: '',
                sortType: '',
                apiPwd: '',
                isAsc: '',
                pageIndex: '',
                pageSize: '',
                requestFrom: '',
                realUserId: ''
            }
        },
        setState(...args) {
            this.$patch({ [args[0]]: args[1] })
        }
    },
    // 配置持久化
    persist: false
})

export default useFlightSupportStore
