onlineStatistics.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. var _this;
  2. var nowTime, nowEnna;
  3. new Vue({
  4. el: '#app',
  5. data: function() {
  6. return {
  7. queryParem: {
  8. devID: "",
  9. endTime: "",
  10. beginTime: "",
  11. type: null,
  12. pageNum: 1,
  13. pageSize: 12
  14. },
  15. onlineData: [],
  16. allTotal: 0,
  17. setupForm: {
  18. insertInterval: 0,
  19. cheakInterval: 0
  20. },
  21. setupRules: {
  22. insertInterval: [{
  23. required: true,
  24. message: '请输入接收间隔',
  25. trigger: 'blur'
  26. }],
  27. cheakInterval: [{
  28. required: true,
  29. message: '请输入检测间隔',
  30. trigger: 'change'
  31. }],
  32. },
  33. dialogVisible: false,
  34. typeOption: [{
  35. value: '1',
  36. label: '心跳'
  37. }, {
  38. value: '2',
  39. label: '掉线'
  40. }, {
  41. value: '3',
  42. label: '重连'
  43. }]
  44. }
  45. },
  46. created() {
  47. _this = this;
  48. nowTime = parseTime(new Date(), '{y}-{m}-{d}');
  49. nowEnna = JSON.parse(localStorage.getItem("nowShip"));
  50. _this.queryParem.endTime = nowTime;
  51. _this.queryParem.beginTime = nowTime;
  52. _this.getList();
  53. },
  54. mounted() {
  55. window.addEventListener('message', (data) => {
  56. nowEnna = JSON.parse(localStorage.getItem("nowShip"));
  57. _this.queryParem.pageNum = 1;
  58. _this.getList();
  59. })
  60. },
  61. methods: {
  62. getList() {
  63. if(nowEnna !=null && nowEnna != "null"&&nowEnna.en_name != ""&&nowEnna.en_name != null){
  64. const loading = this.$loading({
  65. background: 'rgba(0, 0, 0, 0.4)'
  66. })
  67. setTimeout(()=>{
  68. _this.queryParem.devID = nowEnna.en_name;
  69. let _data = _this.queryParem;
  70. getHeartbeat(_this.queryParem).then((_res)=>{
  71. _this.allTotal = _res.total;
  72. _this.onlineData = _res.rows;
  73. loading.close()
  74. })
  75. },200)
  76. }else{
  77. _this.allTotal = 0;
  78. _this.onlineData = [];
  79. }
  80. },
  81. getHBInfo(){
  82. _this.setupForm = {};
  83. getHeartbeatInfo().then((res) => {
  84. if(res.code == 200){
  85. _this.setupForm = res.data;
  86. _this.dialogVisible = true;
  87. }
  88. })
  89. },
  90. handleCurrentChange(val){
  91. if(val != _this.queryParem.pageNum){
  92. _this.queryParem.pageNum = val;
  93. _this.getList();
  94. }
  95. },
  96. searchQuery(){
  97. if(_this.queryParem.beginTime.length){
  98. _this.queryParem.endTime = _this.queryParem.beginTime;
  99. _this.queryParem.pageNum = 1;
  100. _this.getList();
  101. }
  102. },
  103. resetQuery(){
  104. _this.queryParem.endTime = nowTime;
  105. _this.queryParem.beginTime = nowTime;
  106. _this.queryParem.type = null;
  107. _this.queryParem.pageNum = 1;
  108. _this.getList();
  109. },
  110. changeType(val){
  111. _this.queryParem.pageNum = 1;
  112. _this.getList();
  113. },
  114. updateHBInfo(){
  115. updateHeartbeatInfo(_this.setupForm).then((res) => {
  116. if(res.code == 200){
  117. _this.$message({
  118. showClose: true,
  119. message: '更新成功!!!',
  120. type: 'success'
  121. });
  122. _this.dialogVisible = false;
  123. }
  124. })
  125. }
  126. }
  127. })