index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div>
  3. <save-form inline :model="search" @submit="FetchList" @reset="FetchList">
  4. <el-form-item prop="organIds">
  5. <el-select
  6. multiple
  7. clearable
  8. filterable
  9. collapse-tags
  10. v-model="search.organIds"
  11. >
  12. <el-option v-for="(item,index) in selects.branchs"
  13. :key="index"
  14. :label="item.name"
  15. :value="item.id"></el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-button native-type="submit" type="primary">搜索</el-button>
  19. <el-button native-type="reset" type="danger">重置</el-button>
  20. </save-form>
  21. <div class="tags">
  22. <el-badge
  23. :hidden="listByType[item.type].length === 0"
  24. :value="listByType[item.type].length"
  25. :max="99"
  26. v-for="(item, index) in tags"
  27. :key="index"
  28. >
  29. <el-tag
  30. :effect="activeKey === item.type ? 'dark' : 'plain'"
  31. @click="activeKey = item.type"
  32. >{{item.name}}</el-tag>
  33. </el-badge>
  34. </div>
  35. <empty desc="暂无需要处理异常" v-if="!activeList.length"/>
  36. <title-item
  37. v-else
  38. :type="item[0].isError ? 'error' : 'warning'"
  39. v-for="(item, index) in activeList"
  40. :key="index"
  41. :data="item.map(title => ({name: title.desc, num: title.num}))"
  42. >
  43. <el-button type="text">立即处理<i class="el-icon-d-arrow-right"/></el-button>
  44. </title-item>
  45. </div>
  46. </template>
  47. <script>
  48. import { getIndexError } from '@/views/main/api'
  49. import { createNotification } from '@/helpers/notification'
  50. import { errorType } from '@/views/main/constant'
  51. import title from './title'
  52. export default {
  53. components: {
  54. 'title-item': title
  55. },
  56. data() {
  57. return {
  58. activeKey: '',
  59. search: {
  60. organIds: []
  61. },
  62. listByType: {},
  63. list: [],
  64. }
  65. },
  66. computed: {
  67. tags() {
  68. const tags = this.list.map(item => ({name: item.desc, type: item.errorType}))
  69. if (tags.length && !this.activeKey) {
  70. this.activeKey = tags[0].type
  71. }
  72. return tags
  73. },
  74. activeList() {
  75. const list = this.listByType[this.activeKey] || []
  76. return list
  77. },
  78. },
  79. mounted() {
  80. this.FetchList()
  81. this.$store.dispatch('setBranchs')
  82. },
  83. methods: {
  84. formatData(data) {
  85. const list = {}
  86. for (const item of data) {
  87. const row = errorType[item.errorType] || {}
  88. const key = row.parent || item.errorType
  89. if (!list[key]) {
  90. list[key] = []
  91. }
  92. list[key].push(
  93. {
  94. ...item,
  95. isError: row.isError
  96. }
  97. )
  98. }
  99. return Object.values(list)
  100. },
  101. async FetchList() {
  102. try {
  103. const res = await getIndexError({
  104. ...this.search,
  105. organIds: this.search.organIds.join(',')
  106. })
  107. this.list = res.data.data
  108. const data = {}
  109. for (const item of this.list) {
  110. data[item.errorType] = this.formatData(item?.result || [])
  111. }
  112. this.listByType = data
  113. } catch (error) {}
  114. },
  115. send() {
  116. createNotification({
  117. title: '测试发送通知',
  118. body: '您有一条待处理通知,请及时处理',
  119. onClick: () => {
  120. this.$router.replace('/main/main')
  121. }
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="less" scoped>
  128. .tags{
  129. margin-bottom: 20px;
  130. >div{
  131. margin-right: 20px;
  132. cursor: pointer;
  133. }
  134. }
  135. </style>