index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="page-layout-info manager-page-padding" v-loading="loading" :class="{'page-layout-info--border': border}" :style="{ width }">
  3. <div class="page-layout-info__header" v-if="!cHideHeader">
  4. <div >
  5. <slot name="back">
  6. <cip-button-text @click="backPrePage" icon="el-icon-arrow-left">返回</cip-button-text>
  7. </slot>
  8. <span class="page-layout-info__title" v-if="title">
  9. {{title}}
  10. </span>
  11. </div>
  12. <div>
  13. <slot name="handle"></slot>
  14. </div>
  15. </div>
  16. <div class="page-layout-info__main">
  17. <slot></slot>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import { computed } from 'vue'
  23. import { useRouter } from 'vue-router'
  24. import { useMain } from '@cip/hooks/use-main'
  25. import { ElLoading } from 'element-plus'
  26. import { useCipConfig } from '@cip/components/hooks/use-cip-config'
  27. import CipButtonText from "@cip/components/cip-button-text";
  28. export default {
  29. name: 'PageLayoutInfo',
  30. components: { CipButtonText },
  31. props: {
  32. border: { // handle-bar 是否有边框
  33. type: Boolean,
  34. default: true
  35. },
  36. title: { // 页面title
  37. type: String
  38. },
  39. width: {
  40. type: String, // eg: 1px
  41. default: '100%'
  42. },
  43. loading: Boolean,
  44. hideHeader: {}
  45. },
  46. directives: {
  47. loading: ElLoading.directive
  48. },
  49. emits: ['back'],
  50. setup (props, { emit }) {
  51. const { closeTab } = useMain()
  52. const cipConfig = useCipConfig()
  53. const cHideHeader = computed(() => {
  54. if (props.hideHeader !== undefined) {
  55. return props.hideHeader
  56. } else {
  57. return cipConfig.layout.hideHeader === true
  58. }
  59. })
  60. const router = useRouter()
  61. const backPrePage = () => {
  62. // TODO: 可进一步处理
  63. router.go(-1)
  64. closeTab() // 返回时会关闭tab
  65. }
  66. return {
  67. cHideHeader,
  68. backPrePage
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="less">
  74. .page-layout-info{
  75. //&::-webkit-scrollbar { width: 0 !important }
  76. box-sizing: border-box;
  77. margin: 0 auto;
  78. &.page-layout-info--border{
  79. .page-layout-info__header{
  80. box-sizing: border-box;
  81. border: 1px solid #ddd;
  82. }
  83. }
  84. height: 100%;
  85. @handleBarHeight: 40px;
  86. background: @background;
  87. &__header{
  88. height: @handleBarHeight;
  89. background: #fff;
  90. margin-bottom: 8px;
  91. padding: 0 12px;
  92. display: flex;
  93. justify-content: space-between;
  94. align-items: center;
  95. }
  96. &__title{
  97. font-weight: bold;
  98. &:before{
  99. content: " ";
  100. margin: 8px;
  101. border-left: 2px solid #bbb;
  102. line-height: 0.8em;
  103. }
  104. }
  105. &__main{
  106. height: calc(100% - @handleBarHeight - 8px);
  107. }
  108. }
  109. </style>