PolicyConfigManage.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div class="content-main">
  3. <div class="content-body-wrap">
  4. <div class="content-body">
  5. <Tabs :value="currentTabs" @on-click="tabsClick" class="common-tabs">
  6. <TabPane v-for="tab in tabsData" :key="tab.label" :label="tab.label" :name="tab.label"></TabPane>
  7. </Tabs>
  8. <alarm-level-config v-if="currentTabs == '告警等级配置'" ref="alarmLevel" class="content-body-manage"></alarm-level-config>
  9. <Row :gutter="8" style="width:100%;height: calc(100% - 50px)" v-else>
  10. <i-col span="5" style="height:100%">
  11. <div class="station-tree">
  12. <div class="station-tree-body">
  13. <div class="station-tree-top">
  14. <Input suffix="ios-search" placeholder="请输入关键字查询" clearable search v-model="currentStation" class="common-search" @on-search="iconChange" @on-clear="clearChange"/>
  15. </div>
  16. <div class="station-tree-center">
  17. <div class="station-tree-left common-scroll" v-show="showTree">
  18. <tree-list :defaultData="stationData" :currentStaData="currentStaData" :clickAllNode="true" v-if="stationData && stationData.length>0" @treeChange="treeChange" ref="tree"></tree-list>
  19. </div>
  20. <div class="station-tree-left-notree" v-show="!showTree">
  21. 站点输入错误!
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </i-col>
  27. <i-col span="19" style="height:100%">
  28. <div class="right-main">
  29. <level-deter-config ref="levelDeter" class="content-body-manage" v-if="currentTabs == '等级判定策略配置'"></level-deter-config>
  30. <alarm-filter-config ref="alarmFilter" class="content-body-manage" v-if="currentTabs == '告警过滤策略配置'"></alarm-filter-config>
  31. <alarm-acknowledg-config ref="alarmAcknowledg" class="content-body-manage" v-if="currentTabs == '告警自动确认策略'"></alarm-acknowledg-config>
  32. <continuity-monitor-config ref="continuityMonitor" class="content-body-manage" v-if="currentTabs == '连续性监测策略'"></continuity-monitor-config>
  33. </div>
  34. </i-col>
  35. </Row>
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import AlarmLevelConfig from './AlarmLevelConfig.vue'
  42. import LevelDeterConfig from './LevelDeterConfig.vue'
  43. import AlarmFilterConfig from './AlarmFilterConfig.vue'
  44. import AlarmAcknowledgConfig from './AlarmAcknowledgConfig.vue'
  45. import ContinuityMonitorConfig from './ContinuityMonitorConfig.vue'
  46. export default {
  47. name: "PolicyConfigManage",
  48. components:{
  49. AlarmLevelConfig,LevelDeterConfig,AlarmFilterConfig,AlarmAcknowledgConfig,ContinuityMonitorConfig
  50. },
  51. data() {
  52. return {
  53. currentStation: '',
  54. currentStaData: [], // 当前搜索框搜索的站台数组对象,传给子组件,用来判断单选站台名当前选中状态
  55. showTree: true,// 是否显示树形组件
  56. stationData: [],
  57. tabsData: [{label:'告警等级配置'},{label:'等级判定策略配置'},{label:'告警过滤策略配置'},{label:'告警自动确认策略'},{label:'连续性监测策略'}],
  58. currentTabs: '告警等级配置',
  59. };
  60. },
  61. mounted() {
  62. // console.log(sessionStorage.getItem('currentTabs'))
  63. this.getCurrentTab (sessionStorage.getItem('currentTabs'))
  64. this.getMetroLevel()
  65. },
  66. // 离开当前路由之前的钩子函数
  67. beforeRouteLeave(to, form, next) {
  68. sessionStorage.removeItem('currentTabs')
  69. next()
  70. },
  71. methods: {
  72. // 获取树形数据
  73. getMetroLevel () {
  74. this.$get('metroapi/application/appEquipmentTypeTree').then(res => {
  75. if (res.httpCode == 1) {
  76. this.stationData = res.data
  77. }
  78. })
  79. },
  80. // 递归函数 每层数组的第一个对象里的属性expand 全展开(true)
  81. getTree(arr) {
  82. return arr.map((v,index) => {
  83. if (index==0) {
  84. v.expand = true
  85. }
  86. if (v.children) v.children = this.getTree(v.children);
  87. return v;
  88. });
  89. },
  90. iconChange: _.throttle(function() {
  91. this.currentStaData = []
  92. this.treeName = []
  93. this.$nextTick(()=> {
  94. this.getCurrentTab(this.currentTabs,this.currentStation)
  95. })
  96. if(this.currentStation != ''){
  97. this.showTree = false
  98. document.querySelector(".common-scroll").scrollTo(0, 0); // 滚动条回到顶部
  99. } else {
  100. document.querySelector(".common-scroll").scrollTo(0, 0); // 滚动条回到顶部
  101. this.showTree = true
  102. this.stationData = this.getTree(this.stationData)
  103. return
  104. }
  105. this.getSelectedItem()
  106. }, 500),
  107. clearChange () {
  108. this.getSelectedItem()
  109. this.getCurrentTab(this.currentTabs,this.currentStation)
  110. },
  111. getSelectedItem () {
  112. this.stationData.forEach((item, index,itemArr) => {
  113. item.expand = false;
  114. item.disabled = false;
  115. item.selected = false;
  116. if (item.title == this.currentStation) {
  117. item.selected = true;
  118. item.disabled = true; // disabled 是否禁止选中
  119. item.expand = true;
  120. this.currentStaData.push(item)
  121. this.showTree = true
  122. }
  123. if (this.currentStation == '' && index == 0) {
  124. item.expand = true
  125. }
  126. if (item.children) {
  127. item.children.forEach((val, i,valArr) => {
  128. val.expand = false; //expand 是否展开直子节点
  129. val.disabled = false; // disabled 是否禁止选中
  130. val.selected = false;
  131. if (val.title == this.currentStation) {
  132. val.selected = true;
  133. val.disabled = true; // disabled 是否禁止选中
  134. val.expand = true;
  135. item.expand = true;
  136. this.currentStaData.push(val)
  137. this.showTree = true
  138. }
  139. if (this.currentStation == '' && i==0) {
  140. val.expand = true
  141. }
  142. if (val.children) {
  143. val.children.forEach ((lastVal,lastIndex) => {
  144. lastVal.selected = false; //expand 是否展开直子节点
  145. lastVal.disabled = false;
  146. lastVal.expand = false;
  147. if (lastVal.title == this.currentStation) {
  148. lastVal.selected = true;
  149. lastVal.disabled = true; // disabled 是否禁止选中
  150. lastVal.expand = true;
  151. val.expand = true
  152. item.expand = true
  153. this.currentStaData.push(lastVal)
  154. this.showTree = true
  155. }
  156. })
  157. }
  158. });
  159. }
  160. });
  161. },
  162. treeChange(val,arr,level) {
  163. this.currentStation = val
  164. this.getCurrentTab(this.currentTabs,this.currentStation,arr,level)
  165. // if (this.currentTabs == '设备管理') {
  166. // this.$refs.device.getTableData(this.currentStation,arr,level)
  167. // } else if(this.currentTabs == '设备类型管理'){
  168. // this.$nextTick(()=> {
  169. // this.$refs.deviceType.getTableData(this.currentStation,arr,level)
  170. // })
  171. // }
  172. },
  173. tabsClick (name) {
  174. this.stationData = this.getElseTree(this.stationData) // 切换tab页时,清除tree选中情况
  175. this.currentStation = ''
  176. sessionStorage.setItem("currentTabs",name)
  177. this.getCurrentTab (name)
  178. if (document.querySelector(".station-tree-left")) {
  179. document.querySelector(".station-tree-left").scrollTo(0, 0)
  180. }
  181. },
  182. getCurrentTab (currentTabs,currentStation,arr,level) {
  183. this.currentTabs = currentTabs || '告警等级配置'
  184. if (currentTabs == '告警等级配置' || !currentTabs) {
  185. this.$nextTick(()=> {
  186. })
  187. } else if(currentTabs == '等级判定策略配置'){
  188. this.$nextTick(()=> {
  189. this.$refs.levelDeter.getTableData(currentStation,arr,level)
  190. })
  191. } else if(currentTabs == '告警过滤策略配置'){
  192. this.$nextTick(()=> {
  193. this.$refs.alarmFilter.getTableData(currentStation,arr,level)
  194. })
  195. } else if(currentTabs == '告警自动确认策略'){
  196. this.$nextTick(()=> {
  197. this.$refs.alarmAcknowledg.getTableData(currentStation,arr,level)
  198. })
  199. } else if(currentTabs == '连续性监测策略'){
  200. this.$nextTick(()=> {
  201. this.$refs.continuityMonitor.getTableData(currentStation,arr,level)
  202. })
  203. }
  204. },
  205. // 递归函数 每层数组的第一个对象里的属性expand 全展开(true)
  206. getElseTree(arr) {
  207. return arr.map((v,index) => {
  208. if (v.title==this.currentStation) {
  209. v.selected = false
  210. v.disabled = false
  211. }
  212. if (index == 0) {
  213. v.expand = true
  214. } else {
  215. v.expand = false
  216. }
  217. if (v.children) v.children = this.getElseTree(v.children);
  218. return v;
  219. });
  220. },
  221. }
  222. };
  223. </script>
  224. <style scoped lang="stylus">
  225. .content-main {
  226. width: 100%;
  227. height: calc(100% - 50px);
  228. overflow: hidden;
  229. }
  230. .content-body-wrap {
  231. width: 100%;
  232. height: 100%;
  233. background: #06214D;
  234. }
  235. .content-body {
  236. width: 100%;
  237. height: 100%;
  238. background: #06214D;
  239. padding: 10px;
  240. }
  241. .common-search {
  242. width: 100%;
  243. }
  244. >>> .common-search .ivu-input {
  245. background-color: #06214D;
  246. border: 1px solid #2355A6;
  247. border-radius: 15px;
  248. color: #fff;
  249. height: 32px;
  250. }
  251. >>> .common-search .ivu-input:focus {
  252. border-color: #0185ea;
  253. }
  254. .station-tree {
  255. height: 100%;
  256. padding: 10px;
  257. }
  258. .station-tree-body {
  259. border: 1px solid #204384;
  260. height: 100%;
  261. padding: 10px;
  262. }
  263. .station-tree-center {
  264. height: calc(100% - 32px);
  265. padding-top: 10px;
  266. }
  267. .station-tree-left {
  268. height: 100%;
  269. overflow: auto;
  270. }
  271. .station-tree-left-notree {
  272. height: 100%;
  273. display: flex;
  274. align-items: center;
  275. justify-content: center;
  276. color: #fff;
  277. fon-size: 14px;
  278. }
  279. .right-main {
  280. height: 100%;
  281. padding: 10px 0;
  282. }
  283. </style>