PageView.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div :style="!$route.meta.hiddenHeaderContent ? 'margin: -24px -24px 0px;' : null">
  3. <!-- pageHeader , route meta :true on hide -->
  4. <page-header v-if="!$route.meta.hiddenHeaderContent" :title="pageTitle" :logo="logo" :avatar="avatar">
  5. <slot slot="action" name="action"/>
  6. <slot slot="content" name="headerContent"/>
  7. <div slot="content" v-if="!this.$slots.headerContent && description">
  8. <p style="font-size: 14px;color: rgba(0,0,0,.65)">{{ description }}</p>
  9. <div class="link">
  10. <template v-for="(link, index) in linkList">
  11. <a :key="index" @click="() => { link.callback && link.callback() }">
  12. <a-icon :type="link.icon" />
  13. <span>{{ link.title }}</span>
  14. </a>
  15. </template>
  16. </div>
  17. </div>
  18. <slot slot="extra" name="extra">
  19. <div class="extra-img">
  20. <img v-if="typeof extraImage !== 'undefined'" :src="extraImage"/>
  21. </div>
  22. </slot>
  23. <div slot="pageMenu">
  24. <div class="page-menu-search" v-if="search">
  25. <a-input-search
  26. style="width: 80%; max-width: 522px;"
  27. placeholder="请输入..."
  28. size="large"
  29. enterButton="搜索"
  30. />
  31. </div>
  32. <div class="page-menu-tabs" v-if="tabs && tabs.items">
  33. <!-- @change="callback" :activeKey="activeKey" -->
  34. <a-tabs :tabBarStyle="{margin: 0}" :activeKey="tabs.active()" @change="tabs.callback">
  35. <a-tab-pane v-for="item in tabs.items" :tab="item.title" :key="item.key"/>
  36. </a-tabs>
  37. </div>
  38. </div>
  39. </page-header>
  40. <div class="content">
  41. <div class="page-header-index-wide">
  42. <slot>
  43. <!-- keep-alive -->
  44. <keep-alive v-if="multiTab">
  45. <router-view ref="content" />
  46. </keep-alive>
  47. <router-view v-else ref="content" />
  48. </slot>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import { mapState } from 'vuex'
  55. import PageHeader from '@/components/PageHeader'
  56. export default {
  57. name: 'PageView',
  58. components: {
  59. PageHeader
  60. },
  61. props: {
  62. avatar: {
  63. type: String,
  64. default: null
  65. },
  66. title: {
  67. type: [String, Boolean],
  68. default: true
  69. },
  70. logo: {
  71. type: String,
  72. default: null
  73. },
  74. directTabs: {
  75. type: Object,
  76. default: null
  77. }
  78. },
  79. data () {
  80. return {
  81. pageTitle: null,
  82. description: null,
  83. linkList: [],
  84. extraImage: '',
  85. search: false,
  86. tabs: {}
  87. }
  88. },
  89. computed: {
  90. ...mapState({
  91. multiTab: state => state.app.multiTab
  92. })
  93. },
  94. mounted () {
  95. this.tabs = this.directTabs
  96. this.getPageMeta()
  97. },
  98. updated () {
  99. this.getPageMeta()
  100. },
  101. methods: {
  102. getPageMeta () {
  103. // eslint-disable-next-line
  104. this.pageTitle = (typeof(this.title) === 'string' || !this.title) ? this.title : this.$route.meta.title
  105. const content = this.$refs.content
  106. if (content) {
  107. if (content.pageMeta) {
  108. Object.assign(this, content.pageMeta)
  109. } else {
  110. this.description = content.description
  111. this.linkList = content.linkList
  112. this.extraImage = content.extraImage
  113. this.search = content.search === true
  114. this.tabs = content.tabs
  115. }
  116. }
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="less" scoped>
  122. .content {
  123. margin: 24px 24px 0;
  124. .link {
  125. margin-top: 16px;
  126. &:not(:empty) {
  127. margin-bottom: 16px;
  128. }
  129. a {
  130. margin-right: 32px;
  131. height: 24px;
  132. line-height: 24px;
  133. display: inline-block;
  134. i {
  135. font-size: 24px;
  136. margin-right: 8px;
  137. vertical-align: middle;
  138. }
  139. span {
  140. height: 24px;
  141. line-height: 24px;
  142. display: inline-block;
  143. vertical-align: middle;
  144. }
  145. }
  146. }
  147. }
  148. .page-menu-search {
  149. text-align: center;
  150. margin-bottom: 16px;
  151. }
  152. .page-menu-tabs {
  153. margin-top: 48px;
  154. }
  155. .extra-img {
  156. margin-top: -60px;
  157. text-align: center;
  158. width: 195px;
  159. img {
  160. width: 100%;
  161. }
  162. }
  163. .mobile {
  164. .extra-img{
  165. margin-top: 0;
  166. text-align: center;
  167. width: 96px;
  168. img{
  169. width: 100%;
  170. }
  171. }
  172. }
  173. </style>