﻿<template>
    <div class="card device-component">
        <div class="card-header">
            <h3 class="card-title">
                {{device.displayName}}
                <i v-if="device.isOnline" class="text-success ion ion-ios-wifi"></i>
                <i v-else class="text-danger ion ion-ios-wifi"></i>
            </h3>
            <div class="card-tools">
                <span @click="visible = true" title="操作"><i class="ion ion-md-settings"></i></span>
            </div>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-4 align-self-center">
                    <img class="device-image" :src="device.ioTProduct.image" style="width:48px;" />
                </div>
                <div class="col-8 align-self-center">
                    <div class="row">
                        <span>版本：{{getIoTDataValue(device, '版本')}}</span>
                    </div>
                    <div class="row">
                        <span>设备：{{getIoTDataValue(device, '设备数量')}}</span>
                    </div>
                </div>
            </div>
        </div>
        <a-modal v-model="visible" :title="device.displayName" :footer="null">
            <button style="height:32px;" class="btn btn-primary btn-sm" v-on:click="execApi(device.number,'/Gateway/X9d')">刷新设备</button>
            <button style="height:32px;" class="btn btn-primary btn-sm" v-on:click="execApi(device.number,'/Gateway/X81')">查询网关</button>
        </a-modal>
    </div>
</template>
<script>
    export default {
        props: ['device'],
        data: function () {
            return {
                visible: false
            }
        }
    };
</script>