<template>
    <up-collapse-item title="运行决策（2）">
        <global-page
            :fixed="false"
            :height="height"
            :showNavbar="false"
            :custom="false"
            isDataList
            refresherEnabled
            loadingMoreEnabled
            :api="getDecisionApi"
            auto
        >
            <template #="{ dataList }">
                <view class="item" v-for="item in dataList" :key="item.id" @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 { getDecisionApi } from 'mocp/api/move-decision'
import useMoveDecisionStore from 'mocp/store/move-decision'

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)
    })
}
</script>
<style lang="scss" scoped></style>
