title.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="title" :class="{error: type === 'error', warning: type === 'warning'}">
  3. <div>
  4. <span v-for="(item, index) in data" :key="index">
  5. <span v-html=titleFilter(item)></span>
  6. <el-tooltip
  7. v-if="descs[item.errorType]"
  8. :content="descs[item.errorType]"
  9. :open-delay="0.3"
  10. placement="top"
  11. >
  12. <!-- color: #f56c6c -->
  13. <i
  14. class="el-icon-warning-outline"
  15. style="font-size: 14px; "
  16. />
  17. </el-tooltip>
  18. <b v-if="!(ignore.includes(item.errorType))">{{item.num}}</b>
  19. </span>
  20. </div>
  21. <slot/>
  22. </div>
  23. </template>
  24. <script>
  25. import { descs } from '../constant'
  26. export default {
  27. props: {
  28. type: {
  29. type: String,
  30. default: 'warning'
  31. },
  32. data: {
  33. type: Array,
  34. default: []
  35. }
  36. },
  37. data(){
  38. return{
  39. descs,
  40. ignore: ['NO_CLASS_MUSIC_GROUP_STUDENT_INFO'] // // 忽略类型
  41. }
  42. },
  43. mounted(){
  44. },
  45. methods: {
  46. titleFilter(item) {
  47. if(this.ignore.includes(item.errorType)) {
  48. let tempName = item.name
  49. tempName = tempName.replace('{0}', `<b>${item.num}</b>`)
  50. tempName = tempName.replace('{1}', `<b>${item.num2}</b>`)
  51. return tempName
  52. } else {
  53. return item.name
  54. }
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="less" scoped>
  60. .title{
  61. height: 48px;
  62. line-height: 48px;
  63. background-color: rgba(0, 0, 0, .02);
  64. overflow: hidden;
  65. display: flex;
  66. justify-content: space-between;
  67. padding-right: 10px;
  68. font-weight: bold;
  69. transition: all .3s;
  70. width: 100%;
  71. /deep/b {
  72. font-size: 18px;
  73. }
  74. &:hover{
  75. background-color: rgba(0, 0, 0, .06);
  76. }
  77. &.error {
  78. /deep/b{
  79. color: #ED6F62;
  80. }
  81. &:before{
  82. background-color: #ED6F62;
  83. }
  84. }
  85. &.warning {
  86. /deep/b{
  87. color: #F2A24A;
  88. }
  89. &:before{
  90. background-color: #F2A24A;
  91. }
  92. }
  93. &:before{
  94. content: '';
  95. display: block;
  96. position: absolute;
  97. width: 7px;
  98. height: 48px;
  99. left: 0;
  100. }
  101. >div{
  102. position: relative;
  103. padding-left: 20px;
  104. font-size: 14px;
  105. >span{
  106. margin-right: 10px;
  107. display: inline-block;
  108. }
  109. }
  110. }
  111. </style>