<template>
    <global-page
        title="协议单位工作监察"
        isDataList
        refresherEnabled
        loadingMoreEnabled
        auto
        ref="paging"
        :api="getRepairWorkSupervisionListApi"
        :pageSize="20"
        :padding="24"
    >
        <template #default="{ item }">
            <view class="work-item" @tap="goTo(item)">
                {{ item.taskName }}
                <up-icon name="arrow-right"></up-icon>
            </view>
        </template>
    </global-page>
</template>

<script setup>
import { getRepairTaskInfoListApi, getRepairWorkSupervisionListApi } from 'mocp/api/workSupervision'

const goTo = async (row) => {
    const res = await getRepairTaskInfoListApi({ id: row.id }, { loading: true })
    if (res.code == 200) {
        if (res.data?.length) {
            uni.$mocpJump.navigateTo('/panel/workSupervision/answerQuestion', { templateId: row.templateId, belongId: res.data[0].id })
        } else {
            uni.$mocpMessage.error('请下发任务')
        }
    } else {
        uni.$mocpMessage.error(res.message)
    }
}
</script>
<style lang="scss" scoped>
.work-item {
    background: #fff;
    margin-bottom: 16rpx;
    border-radius: 12rpx;
    padding: 24rpx;
    font-size: 28rpx;
    color: $mocp-text-5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
</style>
