AlarmHistory.cshtml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. 
  2. <div id="AlarmHistoryDiv" class="tank_table_div">
  3. <form action="" method="post" class="tank_form_div">
  4. <div class="tank_form_head">
  5. <label style="width: 10%" class="tank_form_label">油罐</label>
  6. <label style="width: 10%" class="tank_form_label">油品</label>
  7. <label style="width: 21%" class="tank_form_label">警报描述</label>
  8. <label style="width: 28%" class="tank_form_label">发生时间</label>
  9. <label style="width: 28%" class="tank_form_label">解除时间</label>
  10. </div>
  11. <div v-for="(r, index) in tankAlarmFilter" :key="index" class="tank_form_body">
  12. <label style="width: 10%" class="tank_form_label">{{r.TankNumber}}号</label>
  13. <label style="width: 10%" class="tank_form_label">{{r.Id}}</label>
  14. <label style="width: 21%" class="tank_form_label">{{r.Type}}</label>
  15. <label style="width: 28%" class="tank_form_label">{{r.CreatedTimeStamp | formatDate}}</label>
  16. <label style="width: 28%" class="tank_form_label">{{r.ClearedTimeStamp | formatDate}}</label>
  17. </div>
  18. </form>
  19. <div class="config-right-navigation" :style="panelStyle">
  20. <div class="config-topright-tab">筛选查询</div>
  21. <div class="config-topright-settingselect">起始日期:</div>
  22. <input class="config-form-input" type="text" v-model="startDate" />
  23. @*<input class="config-form-date" type="date" v-model="startDate" />*@
  24. <div class="config-topright-settingselect">结束日期:</div>
  25. <input class="config-form-input" type="text" v-model="endDate" />
  26. @*<input class="config-form-date" type="date" v-model="endDate" />*@
  27. <div class="config-topright-settingselect">油罐选择:</div>
  28. <select class="config-form-select" v-model="tankNumber">
  29. <option v-for="(item, i) in tankArray" :key="i" :value="item.TankNumber">{{item.TankNumber}}号罐 {{item.Product.ProductLabel}}</option>
  30. </select>
  31. <div class="config-topright-settingselect">查询条件:</div>
  32. <div :class="currentTab == 'active' ? 'config-topright-rnav-image' : 'config-topright-rnav'" @@click="search('active')">活跃报警</div>
  33. <div :class="currentTab == 'history' ? 'config-topright-rnav-image' : 'config-topright-rnav'" @@click="search('history')">历史记录</div>
  34. </div>
  35. <div class="tank_filter_div" v-if="!showFilter" @@click="clickFilter()">
  36. </div>
  37. </div>
  38. <script type="text/javascript">
  39. var vm = new Vue({
  40. el: '#AlarmHistoryDiv',
  41. data: {
  42. tankAlarm: [],
  43. tankArray: [],
  44. showFilter: false,
  45. startDate: null,
  46. endDate: null,
  47. tankNumber: 1,
  48. tankAlarmFilter: [],
  49. currentTab: 'active',
  50. panelStyle: 'visibility: hidden;'
  51. },
  52. mounted() {
  53. let path = '/sys/VeederRoot_ATG_Console_Tcp/VeederRoot_ATG_Console.Handler/thing/service/'
  54. Publish2('[1, 10, 0, null]', path + 'GetTankAlarmAsync')
  55. Publish1(path + 'GetTanksAsync')
  56. this.startDate = this.toDateString(new Date())
  57. this.endDate = this.toDateString(new Date())
  58. },
  59. watch: {
  60. tankAlarm: {
  61. handler(newValue, oldValue) {
  62. if (this.tankAlarmFilter.length <= 0) {
  63. this.tankAlarmFilter = newValue
  64. this.$forceUpdate()
  65. }
  66. },
  67. deep: true
  68. }
  69. },
  70. filters: {
  71. formatDate(value) {
  72. let realVal = ''
  73. if (value !== null && typeof (value) !== 'undefined') {
  74. realVal = value.substring(0, 16).replace('T', ' ')
  75. } else {
  76. realVal = 'N/A'
  77. }
  78. return realVal
  79. }
  80. },
  81. methods: {
  82. search(tab) {
  83. this.showFilter = false
  84. this.currentTab = tab
  85. // this.tankAlarmFilter = this.tankAlarm.filter(item => item.TankNumber === this.tankNumber)
  86. let endDateHour = this.toDateString(new Date(this.endDate + ' 24:0:0'))
  87. this.tankAlarmFilter = this.tankAlarm.filter(item => item.CreatedTimeStamp >= this.startDate && item.CreatedTimeStamp < endDateHour)
  88. this.panelStyle = 'visibility: hidden;'
  89. this.$forceUpdate()
  90. },
  91. clickFilter() {
  92. this.showFilter = true
  93. this.panelStyle = 'visibility: visible;'
  94. this.$forceUpdate()
  95. },
  96. PrefixInteger(num, length) {
  97. return ('000' + num).substr(-length)
  98. },
  99. toDateString(date) {
  100. return date.getFullYear() + '-' + this.PrefixInteger(date.getMonth() + 1, 2) + '-' + this.PrefixInteger(date.getDate(), 2)
  101. }
  102. }
  103. })
  104. function OnReply(topic, jsonObj) {
  105. let path = '/sys/VeederRoot_ATG_Console_Tcp/VeederRoot_ATG_Console.Handler/thing/service/'
  106. if (topic === path + 'GetTankAlarmAsync_reply') {
  107. vm.tankAlarm = jsonObj
  108. } else if (topic === path + 'GetTanksAsync_reply') {
  109. vm.tankArray = jsonObj
  110. }
  111. }
  112. </script>