EnergyConsumptionMeterCheck.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var vm = new Vue({
  2. el: '#app',
  3. data: {
  4. timer: null,
  5. machineMeterDtos: []
  6. },
  7. mounted() {
  8. this.getMachineMeterDtos()
  9. },
  10. methods: {
  11. getMachineMeterDtos() {
  12. let _this = this
  13. axios
  14. .get('/EnergyConsumptionMeterCheck/GetMachineMeterStates')
  15. .then(function (response) {
  16. _this.machineMeterDtos = response.data;
  17. })
  18. .catch(function (error) {
  19. console.log(error)
  20. });
  21. },
  22. setTimer() {
  23. if (this.timer == null) {
  24. this.timer = setInterval(() => {
  25. this.getMachineMeterDtos()
  26. }, 60000)
  27. }
  28. },
  29. clearTimer() {
  30. clearInterval(this.timer)
  31. this.timer = null
  32. }
  33. },
  34. created: function () {
  35. this.clearTimer()
  36. this.setTimer()
  37. },
  38. destroyed: function () {
  39. this.clearTimer()
  40. }
  41. })