You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.0 KiB
55 lines
2.0 KiB
<template>
|
|
<layout v-bind:title="title">
|
|
<div class="row overlay-wrapper">
|
|
<div class="col-md-2 col-sm-4 col-xs-6" v-for="item in products">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3 class="card-title">{{item.name}}</h3>
|
|
<div class="card-tools"><span data-toggle="tooltip" class="badge bg-green">{{item.count}}</span></div>
|
|
</div>
|
|
<router-link :to="{path:'/pages/product.html',query:{number:item.number}}" class="card-body" style="display: block; text-align: center;">
|
|
<img :src="config.baseUrl+item.image" style="margin: 0px auto; width: 64px;">
|
|
</router-link>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</layout>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
data: function () {
|
|
return {
|
|
title: '产品列表',
|
|
url: '/IoTCenter/api/v1/product/getProducts',
|
|
products: [],
|
|
events: ['ProductEntityInserted', 'ProductEntityUpdated', 'ProductEntityDeleted',
|
|
'DeviceEntityInserted', 'DeviceEntityUpdated', 'DeviceEntityDeleted']
|
|
}
|
|
},
|
|
mounted: function () {
|
|
this.subscribe();
|
|
this.load();
|
|
},
|
|
methods: {
|
|
load() {
|
|
var url = config.baseUrl + this.url;
|
|
var vm = this;
|
|
axios.post(url).then(function (response) {
|
|
vm.products = response.data;
|
|
});
|
|
},
|
|
subscribe() {
|
|
var vm = this;
|
|
subscribe(this.events, function (method, data) {
|
|
vm.load();
|
|
});
|
|
},
|
|
unsubscribe() {
|
|
this.unsubscribe(this.events);
|
|
}
|
|
},
|
|
beforeDestroy: function () {
|
|
unsubscribe();
|
|
}
|
|
}
|
|
</script> |