index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="container">
  3. <save-form inline :model="search" @submit="FetchList" @reset="reset" saveKey="/main/main/abnormal">
  4. <el-form-item prop="organId">
  5. <el-select
  6. clearable
  7. filterable
  8. v-model="search.organId"
  9. placeholder="请选择分部"
  10. >
  11. <el-option v-for="(item,index) in selects.branchs"
  12. :key="index"
  13. :label="item.name"
  14. :value="item.id"></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-button native-type="submit" type="primary">搜索</el-button>
  18. <el-button native-type="reset" type="danger">重置</el-button>
  19. </save-form>
  20. <div class="tags">
  21. <el-badge
  22. :hidden="!keyNames[item].num"
  23. is-dot
  24. v-for="(item, index) in permissionTags"
  25. :key="index"
  26. >
  27. <el-tag
  28. :effect="activeKey === item ? 'dark' : 'plain'"
  29. @click="changeTag(item)"
  30. >{{keyNames[item].name}}</el-tag>
  31. </el-badge>
  32. </div>
  33. <empty desc="暂无需要处理异常" v-if="!activeList.length"/>
  34. <el-button @click="handle(item)"
  35. style="width: 100%;color: #303133;margin-left: 0;"
  36. v-else
  37. v-for="(item, index) in activeList"
  38. :key="index"
  39. :disabled="(item[0].result && !item[0].result.length) || (!item[0].num)" type="text"
  40. >
  41. <title-item
  42. :type="item[0].isError ? 'error' : 'warning'"
  43. :data="item.map(title => ({name: title.desc, num: title.num, num2: title.num2, errorType:title.errorType}))"
  44. >
  45. <span style="color: #14928A;" v-if='item[0].errorType == "NO_CLASS_MUSIC_GROUP_STUDENT_INFO"'>
  46. <template v-if="permission('/notClassStudent')">
  47. 立即处理<i class="el-icon-d-arrow-right"/>
  48. </template>
  49. </span>
  50. <span style="color: #14928A;" v-else>
  51. 立即处理<i class="el-icon-d-arrow-right"/>
  52. </span>
  53. </title-item>
  54. </el-button>
  55. <!-- <title-item
  56. v-else
  57. :type="item[0].isError ? 'error' : 'warning'"
  58. v-for="(item, index) in activeList"
  59. :key="index"
  60. :data="item.map(title => ({name: title.desc, num: title.num}))"
  61. >
  62. <el-button
  63. type="text"
  64. v-if="item[0].url && item[0].result || item[0].always"
  65. @click="$router.push({
  66. path: item[0].url,
  67. query: {
  68. ...item[0].query,
  69. tag: $route.query.tag,
  70. filter_type: item[0].errorType,
  71. [item[0].resultKey]: item[0].resultKey ? (item[0].result || []).join(',') : undefined
  72. }
  73. })" :disabled="!item[0].result.length && !item[0].always"
  74. >立即处理<i class="el-icon-d-arrow-right"/></el-button>
  75. </title-item> -->
  76. </div>
  77. </template>
  78. <script>
  79. import { Searchs } from '@/helpers'
  80. import { getIndexError } from '@/views/main/api'
  81. import { createNotification } from '@/helpers/notification'
  82. import { errorType } from '@/views/main/constant'
  83. import { permission } from '@/utils/directivePage'
  84. import title from './title'
  85. const initSearch = {
  86. organId: null
  87. }
  88. export default {
  89. components: {
  90. 'title-item': title
  91. },
  92. data() {
  93. return {
  94. search: {
  95. ...initSearch
  96. },
  97. listByType: {},
  98. infoByType: {},
  99. list: [],
  100. }
  101. },
  102. computed: {
  103. keyNames() {
  104. const { status } = this.$store.state.app
  105. return {
  106. MUSIC_PATROL: {
  107. name: '乐团巡查',
  108. num: status.musicPatrol || false,
  109. },
  110. STUDENT_INFO: {
  111. name: '学员处理',
  112. num: status.studentInfo || false,
  113. },
  114. TEACHER_INFO: {
  115. name: '日常行政',
  116. num: status.teacherInfo || false,
  117. },
  118. ATTENDANCE_SERVE:{
  119. name:'考勤及服务',
  120. num: status.attendanceServe || false,
  121. }
  122. }
  123. },
  124. permissionTags() {
  125. const url = 'getIndexErrData?errorType='
  126. const permissions = ['MUSIC_PATROL', 'STUDENT_INFO', 'TEACHER_INFO','ATTENDANCE_SERVE']
  127. return permissions.filter(item => {
  128. return this.permission(url + item)
  129. })
  130. },
  131. activeKey() {
  132. let key = ''
  133. const { tag } = this.$route.query
  134. if (tag) {
  135. key = tag
  136. } else if (this.permissionTags[0]) {
  137. key = this.permissionTags[0]
  138. }
  139. return key
  140. },
  141. tags() {
  142. const tags = this.list.map(item => ({name: item.desc, type: item.errorType, num: item.num}))
  143. return tags
  144. },
  145. activeList() {
  146. const list = this.listByType[this.activeKey] || []
  147. return list
  148. },
  149. },
  150. mounted() {
  151. this.FetchList()
  152. this.$store.dispatch('setBranchs')
  153. },
  154. methods: {
  155. permission,
  156. handle(item) {
  157. if(item[0].errorType == "NO_CLASS_MUSIC_GROUP_STUDENT_INFO" && !this.permission('/notClassStudent')) {
  158. return
  159. }
  160. // 单独对未缴费学员数
  161. if(item[0].errorType == 'STUDENT_NOT_PAYMENT') {
  162. item[0].query['result'] = item[0].result ? (item[0].result || []).join(',') : undefined
  163. }
  164. new Searchs().removeByKey(item[0].url)
  165. this.$router.push({
  166. path: item[0].url,
  167. query: {
  168. ...item[0].query,
  169. tag: this.$route.query.tag,
  170. filter_type: item[0].errorType,
  171. organId: this.search.organId || undefined,
  172. [item[0].resultKey]: item[0].resultKey ? (item[0].result || []).join(',') : undefined
  173. }
  174. })
  175. },
  176. changeTag(type) {
  177. this.$router.replace({
  178. query: {
  179. ...this.$route.query,
  180. tag: type
  181. }
  182. })
  183. this.FetchList()
  184. },
  185. formatData(data) {
  186. const list = {}
  187. for (const item of data) {
  188. const row = errorType[item.errorType] || {}
  189. const key = row.parent || item.errorType
  190. if (!list[key]) {
  191. list[key] = []
  192. }
  193. list[key].push(
  194. {
  195. ...item,
  196. ...row,
  197. }
  198. )
  199. }
  200. return Object.values(list)
  201. },
  202. async FetchList() {
  203. try {
  204. const res = await getIndexError({
  205. errorType: this.activeKey,
  206. ...this.search,
  207. })
  208. this.list = res.data.data
  209. const data = {}
  210. const info = {}
  211. for (const item of this.list) {
  212. info[item.errorType] = item
  213. data[item.errorType] = this.formatData(item?.result || [])
  214. }
  215. this.infoByType = info
  216. this.listByType = data
  217. } catch (error) {}
  218. },
  219. reset() {
  220. this.search = {...initSearch}
  221. this.FetchList()
  222. },
  223. send() {
  224. createNotification({
  225. title: '测试发送通知',
  226. body: '您有一条待处理通知,请及时处理',
  227. onClick: () => {
  228. this.$router.replace('/main/main')
  229. }
  230. })
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="less" scoped>
  236. .tags{
  237. margin-bottom: 20px;
  238. >div{
  239. margin-right: 20px;
  240. cursor: pointer;
  241. }
  242. }
  243. .container{
  244. /deep/ .is-disabled {
  245. .title{
  246. >span{
  247. color: #C0C4CC!important;
  248. }
  249. }
  250. }
  251. }
  252. </style>