<!--
 * @Author: micky
 * @Date: 2024-09-05 14:51:52
 * @LastEditors: micky
 * @LastEditTime: 2024-09-07 17:47:55
 * @FilePath: \chargingpile-uniapp\src\pages\overhaul\task\inspection-card.vue
-->
<template>
    <w-order-card>
        <template #title>
            <view class="flex justify-between">
                <view @click="toDetail(item)">工单编号：{{ item.orderNo }}</view>
                <view
                    :style="{ color: inspectWorkOrderColor[item.orderStatus] }"
                    v-if="!activeStatus"
                >
                    {{ inspectWorkOrderStatusMap[item.orderStatus] }}
                </view>
            </view>
        </template>
        <template #content>
            <view class="order-content-wrapper" @click="toDetail(item)">
                <view>
                    <text>客户名称</text>
                    <text>{{ item.clientName }}</text>
                </view>
                <view>
                    <text>设备名称</text>
                    <text>{{ item.equipmentName }}</text>
                </view>
                <view>
                    <text>设备编号</text>
                    <text>{{ item.equipmentNo }}</text>
                </view>
                <view>
                    <text>设备地址</text>
                    <text>{{ item.detailedAddress }}</text>
                </view>
                <view v-if="item.inspectionResult !== null">
                    <text>巡检结果</text>
                    <view :style="{ color: normalColor[item.inspectionResult] }">
                        {{ normalMap[item.inspectionResult] }}
                    </view>
                </view>
                <view v-if="item.orderAccomplishTime">
                    <text>完成时间</text>
                    <text>{{ item.orderAccomplishTime }}</text>
                </view>
            </view>
        </template>
        <template #btns>
            <CardBtn
                :item="item"
                @refresh="refresh"
                pageType="card"
                pageSource="1"
                :activeTab="activeTab"
            />
        </template>
    </w-order-card>
</template>

<script setup lang="ts">
import {
    inspectWorkOrderColor,
    inspectWorkOrderStatusMap,
    normalColor,
    normalMap
} from '@/enums/businessEnums'
import CardBtn from '@/components/order-button/inspection-btn.vue'

defineProps<{
    item: InspectionItem
    activeStatus: number
    activeTab: number
}>()

const emit = defineEmits(['refresh'])

const toDetail = (row: InspectionItem) => {
    uni.navigateTo({
        url: `/bundle/pages/inspection/order-detail?id=${row.id}&pageSource=1`
    })
}

const refresh = () => {
    emit('refresh')
}
</script>
<style scoped lang="scss"></style>
