index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="header">
  3. <div class="nav">
  4. <slot name="nav" v-if="$slots.nav" />
  5. <span v-else class="nav-back">
  6. <span class="back operate" v-if="!noBack">
  7. <Icon name="back" @click="router.back()" />
  8. </span>
  9. <span class="title">{{ title }}</span>
  10. </span>
  11. </div>
  12. <div class="draw-operate">
  13. <div v-for="group in actionGroups">
  14. <template v-for="action in group">
  15. <span
  16. v-if="!action.children"
  17. class="operate"
  18. @click="action.handler && action.handler(draw)"
  19. :class="{ disabled: action.disabled }"
  20. >
  21. <Icon :name="action.icon" :tip="action.text" />
  22. </span>
  23. <el-dropdown class="operate-dropdown" v-else>
  24. <span class="operate" :class="{ disabled: action.disabled }">
  25. <Icon :name="action.icon" />
  26. </span>
  27. <template #dropdown>
  28. <el-dropdown-menu>
  29. <el-dropdown-item
  30. v-for="cAction in action.children"
  31. @click="cAction.handler"
  32. >
  33. {{ cAction.text }}
  34. </el-dropdown-item>
  35. </el-dropdown-menu>
  36. </template>
  37. </el-dropdown>
  38. </template>
  39. </div>
  40. </div>
  41. <div class="saves">
  42. <slot name="saves" />
  43. </div>
  44. </div>
  45. </template>
  46. <script lang="ts" setup>
  47. import { router } from "@/example/fuse/router";
  48. import { ActionGroups } from "./actions";
  49. import { ElDropdown, ElDropdownItem, ElDropdownMenu } from "element-plus";
  50. import { Draw } from "../container/use-draw";
  51. defineProps<{
  52. actionGroups: ActionGroups;
  53. draw: Draw;
  54. title?: string;
  55. noBack?: boolean;
  56. }>();
  57. </script>
  58. <style lang="scss" scoped>
  59. @use 'element-plus/theme-chalk/src/common/var';
  60. @use '../../styles/global';
  61. .header {
  62. background-color: #fff;
  63. display: flex;
  64. align-items: center;
  65. padding: 10px;
  66. justify-content: space-between;
  67. color: rgba(0, 0, 0, 0.85);
  68. border-bottom: 1px solid #e6e6e6;
  69. margin-top: var(--top);
  70. transition: margin-top 0.3s ease;
  71. height: global.$headerSize;
  72. flex: 0 0 auto;
  73. }
  74. .draw-operate {
  75. text-align: center;
  76. display: flex;
  77. align-items: center;
  78. font-size: 20px;
  79. > div:not(:last-child) {
  80. padding-right: 15px;
  81. margin-right: 15px;
  82. position: relative;
  83. &::after {
  84. content: "";
  85. right: 0;
  86. top: 50%;
  87. transform: translateY(-50%);
  88. position: absolute;
  89. height: 0.7em;
  90. width: 1px;
  91. background: rgba(0, 0, 0, 0.3);
  92. }
  93. }
  94. i {
  95. width: auto;
  96. }
  97. .operate {
  98. margin: 0 11px;
  99. display: inline-flex;
  100. align-items: center;
  101. padding: 4px;
  102. flex-direction: row-reverse;
  103. border-radius: 4px;
  104. justify-content: center;
  105. }
  106. }
  107. .operate-dropdown {
  108. height: 100%;
  109. display: flex;
  110. outline: none !important;
  111. font-size: inherit;
  112. }
  113. .nav-back {
  114. display: flex;
  115. align-items: center;
  116. .back {
  117. padding: 2px;
  118. }
  119. .title {
  120. margin-left: 6px;
  121. font-size: 16px;
  122. }
  123. }
  124. </style>