<template>
    <global-page
        title="航站不正常事件"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        auto
        ref="paging"
        :params="searchData"
        showNavRight
        navRightType="icon"
        navRightIcon="saixuan-01"
        @handleRightClick="handleRightClick"
        :api="getAdverseEventsListApi"
        :padding="24"
    >
        <template #default="{ item }">
            <view class="item" :class="rowClassName(item)" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="left">
                        <custom-state :value="useGetDictByValue('aem_state', item.state)"></custom-state>
                    </view>
                    <view class="right">
                        <text class="txt u-line-1" v-if="item.terminal">{{ item.terminal }}</text>
                        <text class="txt u-line-1" v-if="item.aviation">
                            {{ useGetDictByValue('', item.aviation, { data: getAirlineSelect() }) }}
                        </text>
                    </view>
                </view>
                <view class="item-content u-line-3">
                    {{ item.eventDescription || '无' }}
                </view>
                <view class="item-footer">
                    <view class="label">
                        <global-icon icon="calendar"></global-icon>
                        <text class="txt">
                            {{ timeStampFormat(item.occurrenceTime, { format: 'YYYY/MM/DD' }) }}
                        </text>
                    </view>
                    <view class="label">
                        审核状态：
                        <global-text-status :value="item.reviewedState" dictkey="aem_auditListSelect"></global-text-status>
                    </view>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { ref } from 'vue'
import { timeStampFormat } from 'mocp/utils/tool'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import { storeToRefs } from 'pinia'
import { onUnload } from '@dcloudio/uni-app'
import useAbnormalEventManageStore from 'mocp/store/abnormalEventManage'
import { getAdverseEventsListApi } from 'mocp/api/abnormalEventManage'
import { rowClassName } from './constants/list.functionals'
import { getAirlineSelect } from 'mocp/utils/permission'

//跳转
const abnormalEventManageStore = useAbnormalEventManageStore()
const { searchData } = storeToRefs(abnormalEventManageStore)
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/abnormalEventManage/details').then(() => {
        abnormalEventManageStore.setState('details', data)
    })
}
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateTo('/panel/abnormalEventManage/search')
}
//刷新
const paging = ref()
uni.$on('abnormalEventManageReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('abnormalEventManageReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
.warning-class {
    background: linear-gradient(138.51deg, #ffede3 6.14%, #ffffff 125.66%);
}
.wrong-class {
    background: linear-gradient(138.51deg, #ffe1e1 6.14%, #ffffff 125.66%);
}
.cancel-class {
    background: #fff;
    opacity: 0.5;
}
</style>
