panel.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div class="com-panel" :class="{ 'no-title': !hasTitle, line: showLine }">
  3. <div v-if="hasTitle" class="panel-header">
  4. <div class="panel-title">
  5. <i v-if="hasIcon" class="panel-icon" :class="icon"></i>
  6. {{ title }}
  7. </div>
  8. <div class="panel-tools">{{ subTitle }}</div>
  9. </div>
  10. <div class="panel-body" :class="{ blur: bgBlur }">
  11. <slot></slot>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: "com-panel",
  18. componentName: "com-panel",
  19. props: {
  20. // 标题
  21. title: String,
  22. // 图标
  23. icon: String,
  24. // 副标题
  25. subTitle: String,
  26. showLine: {
  27. type: Boolean,
  28. default: true,
  29. },
  30. bgBlur: {
  31. type: Boolean,
  32. default: false,
  33. },
  34. },
  35. computed: {
  36. // 是否存在标题
  37. // 标题为空时 不显示标题框
  38. hasTitle() {
  39. if (this.title) return true;
  40. return false;
  41. },
  42. // 是否存在图标
  43. hasIcon() {
  44. if (this.icon) return true;
  45. return false;
  46. },
  47. },
  48. };
  49. </script>
  50. <style lang="less">
  51. .com-panel {
  52. &.line {
  53. border-left: 1px solid gray;
  54. }
  55. &.line:before {
  56. content: " ";
  57. width: 3px;
  58. height: 3px;
  59. float: left;
  60. background: #c9c9c9;
  61. margin: 0.185vh 0.556vh 0vh 0.185vh;
  62. }
  63. &.no-title {
  64. border-left: 0vh;
  65. }
  66. &.no-title::before {
  67. display: none;
  68. }
  69. .panel-header {
  70. display: flex;
  71. font-size: 14px;
  72. padding-left: 1.185vh;
  73. background: rgba(255, 255, 255, 10%);
  74. line-height: 27px;
  75. margin-bottom: 0.7407vh;
  76. height: 27px;
  77. .panel-title {
  78. color: fade(#fff, 75);
  79. flex: 1 1 auto;
  80. .panel-icon {
  81. margin-right: 10px;
  82. }
  83. }
  84. .panel-tools {
  85. flex: 0 0 auto;
  86. color: #ffffff4d;
  87. padding: 0 10px;
  88. font-size: 12px;
  89. letter-spacing: 0.093vh;
  90. }
  91. }
  92. .panel-body {
  93. position: relative;
  94. }
  95. &.line .panel-body {
  96. padding-left: 1.185vh;
  97. }
  98. &.no-title .panel-body {
  99. padding-left: 0vh;
  100. }
  101. }
  102. </style>