PageHeader.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="page-header">
  3. <div class="page-header-index-wide">
  4. <a-breadcrumb class="breadcrumb">
  5. <a-breadcrumb-item v-for="(item, index) in breadList" :key="index">
  6. <router-link v-if="item.name != name" :to="{ path: item.path }">
  7. {{ item.meta.title }}
  8. </router-link>
  9. <span v-else>{{ item.meta.title }}</span>
  10. </a-breadcrumb-item>
  11. </a-breadcrumb>
  12. <div class="detail">
  13. <div class="main" v-if="!$route.meta.hiddenHeaderContent">
  14. <div class="row">
  15. <img v-if="logo" :src="logo" class="logo"/>
  16. <h1 v-if="title" class="title">{{ title }}</h1>
  17. <div class="action">
  18. <slot name="action"></slot>
  19. </div>
  20. </div>
  21. <div class="row">
  22. <div v-if="avatar" class="avatar">
  23. <a-avatar :src="avatar"/>
  24. </div>
  25. <div v-if="this.$slots.content" class="headerContent">
  26. <slot name="content"></slot>
  27. </div>
  28. <div v-if="this.$slots.extra" class="extra">
  29. <slot name="extra"></slot>
  30. </div>
  31. </div>
  32. <div>
  33. <slot name="pageMenu"></slot>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import Breadcrumb from '@/components/tools/Breadcrumb'
  42. export default {
  43. name: "PageHeader",
  44. components: {
  45. "s-breadcrumb": Breadcrumb
  46. },
  47. props: {
  48. title: {
  49. type: String,
  50. default: '',
  51. required: false
  52. },
  53. breadcrumb: {
  54. type: Array,
  55. default: null,
  56. required: false
  57. },
  58. logo: {
  59. type: String,
  60. default: '',
  61. required: false
  62. },
  63. avatar: {
  64. type: String,
  65. default: '',
  66. required: false
  67. }
  68. },
  69. data() {
  70. return {
  71. name: '',
  72. breadList: [],
  73. }
  74. },
  75. created() {
  76. this.getBreadcrumb()
  77. },
  78. methods: {
  79. getBreadcrumb() {
  80. this.breadList = []
  81. // this.breadList.push({name: 'index', path: '/dashboard/', meta: {title: '首页'}})
  82. this.name = this.$route.name
  83. this.$route.matched.forEach((item) => {
  84. // item.name !== 'index' && this.breadList.push(item)
  85. this.breadList.push(item)
  86. })
  87. }
  88. },
  89. watch: {
  90. $route() {
  91. this.getBreadcrumb()
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .page-header {
  98. background: #fff;
  99. padding: 16px 32px 0;
  100. border-bottom: 1px solid #e8e8e8;
  101. .breadcrumb {
  102. margin-bottom: 16px;
  103. }
  104. .detail {
  105. display: flex;
  106. /*margin-bottom: 16px;*/
  107. .avatar {
  108. flex: 0 1 72px;
  109. margin: 0 24px 8px 0;
  110. & > span {
  111. border-radius: 72px;
  112. display: block;
  113. width: 72px;
  114. height: 72px;
  115. }
  116. }
  117. .main {
  118. width: 100%;
  119. flex: 0 1 auto;
  120. .row {
  121. display: flex;
  122. width: 100%;
  123. .avatar {
  124. margin-bottom: 16px;
  125. }
  126. }
  127. .title {
  128. font-size: 20px;
  129. font-weight: 500;
  130. font-size: 20px;
  131. line-height: 28px;
  132. font-weight: 500;
  133. color: rgba(0,0,0,.85);
  134. margin-bottom: 16px;
  135. flex: auto;
  136. }
  137. .logo {
  138. width: 28px;
  139. height: 28px;
  140. border-radius: 4px;
  141. margin-right: 16px;
  142. }
  143. .content, .headerContent {
  144. flex: auto;
  145. color: rgba(0,0,0,.45);
  146. line-height: 22px;
  147. .link {
  148. margin-top: 16px;
  149. line-height: 24px;
  150. a {
  151. font-size: 14px;
  152. margin-right: 32px;
  153. }
  154. }
  155. }
  156. .extra {
  157. flex: 0 1 auto;
  158. margin-left: 88px;
  159. min-width: 242px;
  160. text-align: right;
  161. }
  162. .action {
  163. margin-left: 56px;
  164. min-width: 266px;
  165. flex: 0 1 auto;
  166. text-align: right;
  167. &:empty {
  168. display: none;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. .mobile .page-header {
  175. .main {
  176. .row {
  177. flex-wrap: wrap;
  178. .avatar {
  179. flex: 0 1 25%;
  180. margin: 0 2% 8px 0;
  181. }
  182. .content, .headerContent {
  183. flex: 0 1 70%;
  184. .link {
  185. margin-top: 16px;
  186. line-height: 24px;
  187. a {
  188. font-size: 14px;
  189. margin-right: 10px;
  190. }
  191. }
  192. }
  193. .extra {
  194. flex: 1 1 auto;
  195. margin-left: 0;
  196. min-width: 0;
  197. text-align: right;
  198. }
  199. }
  200. }
  201. }
  202. </style>