<template>
    <view @tap="goDetails(item)" class="item">
        <view class="item-title">
            <view class="left">
                <text v-if="currentTabsIndex == 1 && item.status == '未完成'" class="statusTxt">
                    {{ item.status?.toUpperCase() }}
                </text>
                <custom-state v-else :value="item.status?.toUpperCase()" />
            </view>
            <view class="right inforDisTags">
                <global-tag v-for="tagItem of item.tags" :key="tagItem.text" :type="tagItem.type" class="txt">
                    {{ tagItem.text }}
                </global-tag>
            </view>
        </view>
        <view class="item-content u-line-3">
            <view class="inforDis">
                <text v-if="item.machineNumber">机号：{{ item.machineNumber }}</text>
                <text v-if="item.ATA">ATA：{{ item.ata }}</text>
            </view>
            <text>{{ item.faultDescription || '无' }}</text>
        </view>
        <view class="item-footer inforDisFooter">
            <view class="label">
                <global-icon icon="calendar" />
                <text class="txt">
                    {{ item.time }}
                </text>
            </view>
            <view class="label right">
                <global-icon icon="idcard" />
                <text class="txt">故障报告人：{{ item.filledBy }}</text>
            </view>
        </view>
    </view>
</template>

<script setup>
import { ref } from 'vue'
import useInforDisclosureStore from 'mocp/store/inforDisclosure'
import { storeToRefs } from 'pinia'
import { onUnload } from '@dcloudio/uni-app'

const ps = defineProps({
    item: {
        type: Object,
        default: () => ({})
    }
})
const { item } = ps
const inforDisclosureStore = useInforDisclosureStore()
const { currentTabsIndex } = storeToRefs(inforDisclosureStore)

const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/inforDisclosure/details', { id: data.id }).then(() => {
        inforDisclosureStore.setState('details', data)
    })
}
//刷新
const paging = ref()
uni.$on('inforDisclosureReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('inforDisclosureReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
@import '../constants/inforDisclosure.scss';

.statusTxt {
    font-size: 34rpx;
}
</style>
