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.
58 lines
1.8 KiB
58 lines
1.8 KiB
var app = new Vue({
|
|
el: '#app',
|
|
data() {
|
|
return {
|
|
title: "产品",
|
|
url: config.baseUrl + '/Home/IndexData',
|
|
gateway: null,
|
|
events: ['IoTDeviceEntityInserted', 'IoTDeviceEntityUpdated', 'IoTDeviceEntityDeleted']
|
|
};
|
|
},
|
|
mounted: function () {
|
|
app = this;
|
|
this.subscribe();
|
|
this.load();
|
|
},
|
|
beforeDestroy: function () {
|
|
PubSub.unsubscribes(this.events);
|
|
},
|
|
methods: {
|
|
subscribe: function () {
|
|
PubSub.subscribes(this.events, function (method, data) {
|
|
app.load();
|
|
});
|
|
},
|
|
load: function () {
|
|
axios.post(this.url).then(function (response) {
|
|
app.gateway = response.data;
|
|
});
|
|
},
|
|
upload: function () {
|
|
$.get(config.baseUrl + 'Home/Upload', function () {
|
|
alert('操作完成');
|
|
app.load();
|
|
});
|
|
},
|
|
searchGateway: function () {
|
|
if (confirm('确认查询全部网关吗?')) {
|
|
$.get(config.baseUrl + '/Gateway/Refresh', function () {
|
|
app.load();
|
|
});
|
|
};
|
|
},
|
|
searchDevice: function (number) {
|
|
if (confirm('确认查询网关吗?')) {
|
|
$.get(config.baseUrl + '/Gateway/X81?number='+number, function () {
|
|
app.load();
|
|
});
|
|
};
|
|
},
|
|
remove: function (gateway, number) {
|
|
if (confirm('确认从网关移除编号为:' + 'number' + '的设备吗?')) {
|
|
$.get(config.baseUrl + '/Gateway/X95?gateway=' + gateway + '&number=' + number, function () {
|
|
app.load();
|
|
});
|
|
};
|
|
}
|
|
}
|
|
}); |