<template>
    <uni-card
        :title="device.equipmentName"
        :sub-title="device.mac"
        :extra="device.isPrimaryUser == 1 ? '主用户' : '分享用户'"
        padding="0"
        @click="jump(device)"
        :thumbnail="deviceIcon(device.runStatus)"
    >
        <template v-slot:title>
            <slot name="title"></slot>
        </template>
        <view class="device-body">
            <view class="device-body-item">
                <text>工程名称</text>
                <text>{{ device.engineeringName }}</text>
            </view>
            <view class="device-body-item mt6">
                <text>项目名称</text>
                <text>{{ device.projectName }}</text>
            </view>
            <view class="device-body-item mt6" v-if="device.process == 2 || device.process == 3">
                <text>调试阶段</text>
                <text>{{ device.process == 2 ? '功能调试' : '出厂调试' }}</text>
            </view>
        </view>
    </uni-card>
</template>
<script>
export default {
    data() {
        return {}
    },
    props: {
        device: {
            type: Object,
            default: () => {},
        },
    },
    methods: {
        deviceIcon(e) {
            let str = ''
            switch (e) {
                case 1:
                    str = '/static/device_bad.png'
                    break
                case 2:
                    str = '/static/device.png'
                    break
                default:
                    str = '/static/device.png'
                    break
            }
            return str
        },
        jump() {
            uni.navigateTo({
                url:
                    '/pages/device/APF/detail?id=' +
                    this.device.equipmentId +
                    '&isPrimaryUser=' +
                    this.device.isPrimaryUser +
                    '&process=' +
                    this.device.process,
            })
        },
    },
}
</script>
<style lang="scss">
.device-body {
    padding: 20rpx;

    .device-body-item {
        display: flex;
        justify-content: space-between;
    }
}
</style>
