<template>
    <global-page-swiper
        title="运行决策"
        refresherEnabled
        loadingMoreEnabled
        :tabList="tabList"
        :api="getDecisionApi"
        :padding="24"
        tabValueField="state"
    >
        <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>
                        <text class="txt u-line-1">{{ item.decisionNumber }}</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 class="label">
                        <global-icon icon="idcard"></global-icon>
                        <text class="txt">{{ item.filledBy }}</text>
                    </view>
                </view>
            </view>
        </template>
    </global-page-swiper>
</template>

<script setup>
import { ref } from 'vue'
import { timeStampFormat } from 'mocp/utils/tool'
import { getDecisionApi } from 'mocp/api/move-decision'
import { useGetDictByValue } from 'mocp/hooks/use-dict/useDict'
import useMoveDecisionStore from 'mocp/store/move-decision'

const tabList = ref([
    { name: 'OPEN', value: 1 },
    { name: 'CLOSE', value: 3 },
    { name: '跟踪', value: 2 },
    { name: '全部', value: null }
])
//跳转
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>
@import './constants/list.scss';
</style>
