<template>
    <global-page
        ref="paging"
        :api="routineWorkListApi"
        :padding="24"
        auto
        isDataList
        loadingMoreEnabled
        refresherEnabled
        title="我的今天签单"
        :params="{
            tody: 1,
            userId: userStore.userInfo?.id
        }"
    >
        <template #default="{ item }">
            <view class="item" @tap="goDetails(item)">
                <view class="item-title">
                    <view class="left">
                        <text class="txt">{{ item.acreg }}</text>
                    </view>
                    <view class="right">
                        <text class="txt">{{ baseStore.getTerminalObject[item.station] }}</text>
                    </view>
                </view>
                <view class="item-content">
                    <text class="txt">{{ item.aircaraftoperator }}</text>
                    <text class="txt">{{ item.model }}</text>
                    <text class="txt">{{ item.overnightAfPf == '1' ? '过夜维护AF+PF' : '' }}</text>
                </view>
                <view class="item-footer">
                    <view class="label">
                        <global-icon icon="calendar"></global-icon>
                        <text class="txt">
                            {{ timeStampFormat(item.createTime, { format: 'YYYY/MM/DD' }) }}
                        </text>
                    </view>
                </view>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { routineWorkListApi } from 'mocp/api/electronicBill'
import { timeStampFormat } from 'mocp/utils/tool'
import useBaseStore from 'mocp/store/base'
import useUserStore from 'mocp/store/user'
import { formData } from './constants/add.compositions'
import { ref } from 'vue'
import { onUnload } from '@dcloudio/uni-app'

const baseStore = useBaseStore()
const userStore = useUserStore()
const goDetails = (data) => {
    Object.assign(formData, data)
    uni.$mocpJump.navigateTo('/panel/electronicBill/routineWork/add')
}
//刷新
const paging = ref()
uni.$on('routineWorkReload', () => {
    paging.value?.reload()
})
onUnload(() => {
    uni.$off('routineWorkReload')
})
</script>
<style lang="scss" scoped>
@import 'mocpStatic/css/list.scss';
</style>
