(function(){
    Vue.component('device-section', {
        template: '<div class="panel-box panel-box2">\
                    <h4 class="c-b5e1fc c-f16 c-t-center">健康设备</h4>\
                    <div v-show="hasData" class="device-scroll-panel mt10">\
                        <ul>\
                            <li v-for="(device, index) in deviceInfo" class="ui-grid ui-grid-middle" :class="{mt20: index>0}">\
                                <div class="ui-col-0">\
                                    <img :src="device.photo" class="device-img">\
                                </div>\
                                <div class="ui-col-1">\
                                    <div class="c-f14 c-b5e1fc">{{device.categoryCode == 1 ? "血糖仪" : "血压计"}}</div>\
                                    <div class="c-f12 c-b5e1fc">生产厂商<span class="ml20">{{device.deviceName}}</span></div>\
                                </div>\
                            </li>\
                        </ul>\
                    </div>\
                    <div v-show="!hasData" class="no-result-panel">\
                        <div class="no-result-img">\
                            <img src="../images/wushuju_icon.png">\
                        </div>\
                        <div class="no-result-text">暂无相关设备数据</div>\
                    </div>\
                </div>',
        props: ['patient'],
        data: function() {
            return {
                deviceInfo: [],
                hasData: true
            }
        },
        mounted: function() {
            var vm = this;
            getDeviceInfo(vm);
        },
    });
    
    function getDeviceInfo(vm){
        var params = {
            patient: vm.patient
        };
        patientAPI.getDeviceInfo(params).then(function(res){
            if(res.status == 200){
                vm.deviceInfo = res.data;
                if(res.data.length > 0){
                    vm.hasData = true;
                }else{
                    vm.hasData = false;
                }
            }else{
                console.log(res.msg);
            }
        })
    }
})()