HistoryTable.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <div class="history-table">
  3. <div class="my-box">
  4. <i-Table stripe :columns="columns1" :data="historyTableData" size="large" @on-sort-change="onSortChange"></i-Table>
  5. <div style="margin: 10px;overflow: hidden" v-if="historyTableData.length>0">
  6. <div style="float: right;margin-right:100px;">
  7. <Page :total="total" :current="current" :pageSize='pageSize' @on-page-size-change="_nowPageSize"
  8. @on-change="changePage">
  9. </Page>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="mask-bg"></div>
  14. <div id="messageBox" v-if="itemsData">
  15. <pomp-box :itemsData="itemsData" :detailData='detailData' :emailName='emailName' :messageName='messageName' @onClose="close"></pomp-box>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import pompBox from './PompBox'
  21. // import { formatTime, toHourMinute} from '../../tools/formatTime.js'
  22. import axios from 'axios'
  23. export default {
  24. components: {
  25. pompBox
  26. },
  27. mixins: [],
  28. props: ['historyTableData', 'total', 'current', 'pageSize'],
  29. data () {
  30. return {
  31. itemsData: {},
  32. emailName: [],
  33. messageName: [],
  34. detailData: {},
  35. columns1: [
  36. {
  37. title: "重要级别",
  38. key: "level",
  39. sortable: 'custom',
  40. render: (h, params) => {
  41. const text = params.row.level + '级'
  42. if (params.row.level == 'S') {
  43. return h('div', [
  44. h('img', {
  45. attrs: {
  46. src: '/static/img/ernomal.png'
  47. },
  48. style: {
  49. marginRight: '5px',
  50. verticalAlign: 'middle',
  51. marginTop: '-3px'
  52. }
  53. }),
  54. h('span', {
  55. style: {
  56. color: '#F08378'
  57. }
  58. }, '' + text)
  59. ])
  60. } else if (params.row.level == 'A') {
  61. return h('div', [
  62. h('span', {
  63. style: {
  64. color: '#F08378',
  65. marginLeft: '10px'
  66. }
  67. }, '' + text)
  68. ])
  69. } else if (params.row.level == 'B') {
  70. return h('div', [
  71. h('span', {
  72. style: {
  73. color: '#F3B767',
  74. marginLeft: '10px'
  75. }
  76. }, '' + text)
  77. ])
  78. } else {
  79. return h('div', [
  80. h('span', {
  81. style: {
  82. marginLeft: '10px'
  83. }
  84. }, '' + text)
  85. ])
  86. }
  87. }
  88. },
  89. {
  90. title: "报警类型",
  91. key: "type"
  92. },
  93. {
  94. title: "报警内容",
  95. key: "content",
  96. width: 400,
  97. className: "description-td",
  98. render: (h, params) => {
  99. const content = params.row.content ? params.row.content : ""
  100. if (content) {
  101. const text1 = content.split("/")[0]
  102. const text2 = content.split("/")[1]
  103. return h('div', [
  104. h('span', {
  105. style: {
  106. marginRight: '18px'
  107. }
  108. }, text1),
  109. h('span', {
  110. style: {
  111. color: "#A6ADB5"
  112. }
  113. }, text2)
  114. ])
  115. }
  116. }
  117. },
  118. {
  119. title: "报警开始时间",
  120. key: "cTime",
  121. sortable: 'custom'
  122. },
  123. {
  124. title: "报警持续时间",
  125. key: "durationT",
  126. sortable: 'custom',
  127. align: 'right'
  128. },
  129. {
  130. title: "报警状态",
  131. key: "status",
  132. align: 'center',
  133. render: (h, params) => {
  134. const status = params.row.status
  135. if (status == 'alarm') {
  136. return h('div', [
  137. h('Button', {
  138. props: {
  139. type: 'text',
  140. size: 'small'
  141. },
  142. style: {
  143. color: '#F08378'
  144. }
  145. }, '未恢复')
  146. ])
  147. } else {
  148. return h('div', [
  149. h('Button', {
  150. props: {
  151. type: 'text',
  152. size: 'small'
  153. },
  154. style: {
  155. color: '#3BC6A1'
  156. }
  157. }, '已恢复')
  158. ])
  159. }
  160. }
  161. },
  162. {
  163. title: "处理情况",
  164. key: "deal",
  165. align: 'center',
  166. render: (h, params) => {
  167. const deal = params.row.deal
  168. const status = params.row.event ? params.row.event.status : ""
  169. const id = params.row.event ? params.row.event.id : ""
  170. if (deal == 0) {
  171. return h('div', [
  172. h('Button', {
  173. props: {
  174. size: 'small'
  175. },
  176. style: {
  177. marginRight: '5px',
  178. color: '#728DEE',
  179. border: '1px solid #728DEE'
  180. },
  181. on: {
  182. click: () => {
  183. this.handleClick(params.row)
  184. }
  185. }
  186. }, '需手动处理')
  187. ])
  188. }
  189. if (deal == 1) {
  190. const text = '工单状态:' + status + '工单编号:' + id
  191. return h('div', [
  192. h('img', {
  193. attrs: {
  194. src: '/static/img/bill.png'
  195. },
  196. style: {
  197. marginRight: '5px',
  198. verticalAlign: 'middle'
  199. }
  200. }),
  201. h('span', {
  202. style: {
  203. marginRight: '5px',
  204. color: '#6D747C',
  205. cursor: 'pointer'
  206. },
  207. on: {
  208. click: () => {
  209. this.handleClick(params.row)
  210. }
  211. }
  212. }, text)
  213. ])
  214. }
  215. if (deal == 2) {
  216. const text = '事件状态:' + status + '事件编号:' + id
  217. return h('div', [
  218. h('img', {
  219. attrs: {
  220. src: '/static/img/event.png'
  221. },
  222. style: {
  223. marginRight: '5px',
  224. verticalAlign: 'middle'
  225. }
  226. }),
  227. h('span', {
  228. style: {
  229. marginRight: '5px',
  230. color: '#6D747C',
  231. cursor: 'pointer'
  232. },
  233. on: {
  234. click: () => {
  235. this.handleClick(params.row)
  236. }
  237. }
  238. }, text)
  239. ])
  240. }
  241. if (deal == 3) {
  242. const text = '上级线路已断,此条自动隐藏'
  243. return h('div', [
  244. h('span', {
  245. style: {
  246. marginRight: '5px',
  247. color: '#6D747C',
  248. cursor: 'pointer'
  249. },
  250. on: {
  251. click: () => {
  252. this.handleClick(params.row)
  253. }
  254. }
  255. }, text)
  256. ])
  257. }
  258. }
  259. }
  260. ]
  261. }
  262. },
  263. computed: {
  264. },
  265. mounted () {
  266. },
  267. methods: {
  268. // iview的排序
  269. onSortChange (col) {
  270. this.$emit('setSort', col)
  271. },
  272. // 每页显示的数据条数
  273. _nowPageSize (index) {
  274. // 实时获取当前需要显示的条数
  275. this.pageSize = index
  276. },
  277. changePage (index) {
  278. this.$emit('changeCurrentPage', index)
  279. },
  280. handleClick (row) {
  281. document.querySelector('.mask-bg').style.display = 'block'
  282. document.querySelector('#messageBox').style.display = 'block'
  283. this.itemsData = row
  284. this.getEamilInfo(row)
  285. },
  286. getEamilInfo (row) {
  287. let params = {
  288. id: row.id
  289. }
  290. axios.post(`/dp-auxiliary/alarm-system/alarm/detail/query?projectId=${this.$store.state.projId}&secret=${this.$store.state.secret}`, params).then(res => {
  291. let data = res.data
  292. if (data.Result == 'success') {
  293. this.detailData = data.Content
  294. if (data.Content && data.Content.notification) {
  295. let emailName = data.Content.notification.mail ? data.Content.notification.mail : []
  296. let messageName = data.Content.notification.message ? data.Content.notification.message : []
  297. this.emailName = []
  298. if (emailName.length > 0) {
  299. emailName.forEach(el => {
  300. this.emailName.push(el.name)
  301. })
  302. }
  303. this.messageName = []
  304. if (messageName.length > 0) {
  305. messageName.forEach(el => {
  306. this.messageName.push(el.name)
  307. })
  308. } else {
  309. this.messageName = []
  310. this.emailName = []
  311. }
  312. }
  313. }
  314. })
  315. },
  316. close () {
  317. document.querySelector('.mask-bg').style.display = 'none'
  318. document.querySelector('#messageBox').style.display = 'none'
  319. }
  320. }
  321. }
  322. </script>
  323. <style scoped lang="less" >
  324. .history-table {
  325. .my-box{
  326. padding: 0 20px 20px 24px;
  327. background: #fff;
  328. }
  329. .mask-bg {
  330. position: fixed;
  331. top: 0;
  332. bottom: 0;
  333. left: 0;
  334. right: 0;
  335. z-index: 99;
  336. background:rgba(0, 0, 0, .6);
  337. display: none;
  338. }
  339. #messageBox{
  340. width: 747px;
  341. height: 630px;
  342. background: #fff;
  343. box-shadow: 0 2px 8px 0 rgba(0,0,0,0.12);
  344. border-radius: 4px;
  345. z-index: 999;
  346. position: fixed;
  347. top: 70px;
  348. left: 50%;
  349. margin-left: -360px;
  350. display: none;
  351. }
  352. }
  353. </style>
  354. <style lang="less">
  355. .history-table{
  356. .ivu-table-wrapper {
  357. border: none;
  358. }
  359. .ivu-table td,
  360. .ivu-table th {
  361. border: none;
  362. }
  363. .ivu-table:before{
  364. height: 0;
  365. }
  366. .ivu-table:after{
  367. width:0;
  368. }
  369. .ivu-table-row .description-td>.ivu-table-cell>span{
  370. // overflow: hidden;
  371. // text-overflow: ellipsis;
  372. // white-space: nowrap;
  373. max-height: 100px;
  374. display: inline-block;
  375. }
  376. }
  377. </style>