<template>
    <global-page
        ref="paging"
        :api="getMeDataListApi"
        :padding="24"
        :params="searchData"
        auto
        isDataList
        loadingMoreEnabled
        navRightIcon="saixuan-01"
        navRightType="icon"
        refresherEnabled
        showNavRight
        title="机械延误"
        @handleRightClick="handleRightClick"
    >
        <template #default="{ item }">
            <view class="item" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="left">
                        <custom-state :value="useGetDictByValue('mae_isOpen', item.isOpen)"></custom-state>
                    </view>
                    <view class="right">
                        <text class="txt u-line-1" v-if="item.ac">{{ item.ac }}</text>
                        <text class="txt u-line-1" v-if="item.acType">{{ item.acType }}</text>
                        <text class="txt u-line-1" v-if="item.acOwn">{{ item.acOwn }}</text>
                        <text class="txt u-line-1" v-if="item.acTerminal">{{ item.acTerminal }}</text>
                    </view>
                </view>
                <view class="item-content">
                    <view style="margin-bottom: 20rpx">事件编号 : {{ item.eventId }}</view>
                    <view class="u-line-3">发生阶段：{{ item.occurMsg || '无' }}</view>
                    <view class="u-line-3">故障描述：{{ item.faultMsg || '无' }}</view>
                    <view class="u-line-3">处理措施：{{ item.handleMsg || '无' }}</view>
                    <view class="u-line-3">运行影响：{{ item.flyMsg || '无' }}</view>
                    <view class="u-line-3">其他运行影响：{{ item.otherMsg || '无' }}</view>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { getMeDataListApi } from 'mocp/api/mechanicalAbnormalEvents'
import useMechanicalAbnormalEventsStore from 'mocp/store/mechanicalAbnormalEvents'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import { onUnload } from '@dcloudio/uni-app'
import { ref } from 'vue'

//跳转
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/mechanicalAbnormalEvents/details', {
        workbenchId: data.workbenchId
    })
}
//加载下拉框数据
const mechanicalAbnormalEventsStore = useMechanicalAbnormalEventsStore()
const { searchData } = storeToRefs(mechanicalAbnormalEventsStore)
//筛选
const handleRightClick = () => {
    uni.$mocpJump.navigateTo('/panel/mechanicalAbnormalEvents/search')
}
const paging = ref()
uni.$on('mechanicalAbnormalEventsReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('mechanicalAbnormalEventsReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
