title.vue 2.2 KB

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