<template>
    <global-page
        title="AOG列表"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        auto
        ref="paging"
        :params="searchData"
        showNavRight
        navRightType="icon"
        navRightIcon="saixuan-01"
        @handleRightClick="handleRightClick"
        :api="getAogListApi"
        :padding="24"
    >
        <template #default="{ item }">
            <view class="item" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="left">
                        <custom-state :value="useGetDictByValue('aog_state', item.state)" :CLOSEStyle="{ color: '#1d2129' }"></custom-state>
                        <text class="txt u-line-1" v-if="item.aogNum">{{ item.aogNum }}</text>
                    </view>
                </view>
                <view class="item-content u-line-3">
                    {{ item.faultDesc || '无' }}
                </view>
                <view class="item-footer">
                    <view class="left">
                        <text class="txt u-line-1" v-if="item.machineNumber">{{ item.machineNumber }}</text>
                        <text class="txt u-line-1" v-if="item.model">{{ item.model }}</text>
                        <text class="txt u-line-1" v-if="item.aviation">
                            {{ useGetDictByValue('', item.aviation, { data: getAirlineSelect() }) }}
                        </text>
                    </view>
                    <view class="right">
                        <text class="txt u-line-1" v-if="item.terminal">{{ item.terminal }}</text>
                    </view>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { ref } from 'vue'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import { storeToRefs } from 'pinia'
import { onUnload } from '@dcloudio/uni-app'
import useAogStore from 'mocp/store/aog'
import { getAogListApi } from 'mocp/api/aog'
import { getAirlineSelect } from 'mocp/utils/permission'

//跳转
const aogStore = useAogStore()
const { searchData } = storeToRefs(aogStore)
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/aog/details', { workbenchId: data.workbenchId }).then(() => {
        aogStore.setState('details', data)
    })
}
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateBack()
}
//刷新
const paging = ref()
uni.$on('aogReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('aogReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
