<template>
    <up-collapse-item :title="`运行决策（${getMoveDecisionNum}）`" v-if="getMoveDecisionNum > 0">
        <global-page
            :fixed="false"
            :height="height"
            :showNavbar="false"
            :custom="false"
            isDataList
            refresherEnabled
            loadingMoreEnabled
            :api="getDecisiongetDecisionToDoApi"
            @handleQuery="handleQuery"
            auto
        >
            <template #default="{ item }">
                <view class="item" @tap="goDetails(item)">
                    <view class="item-title">
                        <view class="left">
                            <custom-state :value="useGetDictByValue('md_state', item.state)"></custom-state>
                        </view>
                        <view class="right">
                            <text class="txt u-line-1" v-if="item.machineNumber">{{ item.machineNumber }}</text>
                            <text class="txt u-line-1" v-if="item.aviation">{{ item.aviation }}</text>
                        </view>
                    </view>
                    <view class="item-content u-line-3">
                        {{ item.faultDescription || '无' }}
                    </view>
                    <view class="item-footer">
                        <view class="label">
                            <global-icon icon="calendar"></global-icon>
                            <text class="txt">
                                {{ timeStampFormat(item.filledTime, { format: 'YYYY/MM/DD HH:mm' }) }}
                            </text>
                        </view>
                    </view>
                </view>
            </template>
        </global-page>
    </up-collapse-item>
</template>

<script setup>
import { timeStampFormat } from 'mocp/utils/tool'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import useMoveDecisionStore from 'mocp/store/move-decision'
import { getDecisiongetDecisionToDoApi } from 'mocp/api/my-toDo'
import useMyToDoStore from 'mocp/store/my-toDo'
import { storeToRefs } from 'pinia'

const myToDoStore = useMyToDoStore()
const { getMoveDecisionNum } = storeToRefs(myToDoStore)
const ps = defineProps({
    height: {
        type: String,
        default: ''
    }
})
//跳转
const moveDecisionStore = useMoveDecisionStore()
const goDetails = (data) => {
    uni.$mocpJump.navigateTo('/panel/move-decision/details', { id: data.id }).then(() => {
        moveDecisionStore.setState('details', data)
    })
}
const handleQuery = ({ res }) => {
    myToDoStore.setState('moveDecisionNum', parseInt(res.data.total) || 0)
}
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
