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.
iot/projects/WebMVC/wwwroot/routes/admin/index.html

74 lines
3.5 KiB

<template>
<layout htmltitle="后台首页">
<div v-if="model">
<h2 style="font-size:1.5rem;margin:.5em 0;">产品</h2>
<div class="row">
<div class="col-md-2 col-sm-4 col-xs-6" v-for="item in model.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.deviceCount}}</span></div>
</div>
<router-link :to="'/routes/shared/index.html?area=admin&entity=Device&query.productId='+item.id" class="card-body" style="display:block;text-align:center;">
<img alt="@item.Name" :src="item.image" style="margin:0 auto;width:64px;" />
</router-link>
</div>
</div>
</div>
<h2 style="font-size:1.5rem;margin:.5em 0;">节点</h2>
<div class="row">
<div class="col-md-2 col-sm-4 col-xs-6" v-for="item in model.nodes">
<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.deviceCount}}</span></div>
</div>
<router-link :to="'/routes/shared/index.html?area=admin&entity=Device&query.nodeId='+item.id" class="card-body" style="display:block;text-align:center;">
<img alt="@item.Name" :src="item.image" style="margin:0 auto;width:64px;" />
</router-link>
<div class="card-footer text-center">
<button class="btn btn-success" @click="nodeMethod(item.number,'Upload')">上传</button>
<button class="btn btn-success" @click="nodeMethod(item.number,'Stop')">重启</button>
</div>
</div>
</div>
</div>
</div>
</layout>
</template>
<script>
export default {
data: function () {
return {
model: null
}
},
mounted: function () {
var vm = this;
var url = this.baseUrl + '/IoTCenter/Admin/Home/Index';
axios.get(url).then(function (response) {
vm.model = response.data.model;
});
},
methods: {
nodeMethod: function (number, method) {
axios.post(this.baseUrl + '/IoTCenter/api/v1/node/' + method, '"' + number + '"', { headers: { 'Content-Type': 'application/json;charset=UTF-8' } })
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
},
updateTimer: function () {
axios.post(this.baseUrl + '/IoTCenter/api/v1/site/UpdateTimer')
.then(function (response) {
Swal.fire({ title: '操作完成', timer: 1500 });
})
.catch(function (error) {
Swal.fire({ title: '操作失败', timer: 1500 });
});
}
}
}
</script>