123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <template>
- <div class="head-layer">
- <el-tabs
- :modelValue="modelValue"
- @update:modelValue="(str: any) => updateModelValue(str)"
- >
- <el-tab-pane
- v-for="item in options"
- :key="item.value"
- :label="item.name"
- :name="item.value"
- >
- </el-tab-pane>
- </el-tabs>
- <div class="head-content-layer" :class="{ show: show }" v-if="!notContent">
- <div class="head-content">
- <slot />
- </div>
- <div class="display" @click="show = !show" v-if="showCtrl">
- <template v-if="show">
- <span>收起</span>
- <el-icon><ArrowUp /></el-icon>
- </template>
- <template v-else>
- <span>展开</span>
- <el-icon><ArrowDown /></el-icon>
- </template>
- </div>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { ref } from "vue";
- import { Options } from "./head";
- const props = withDefaults(
- defineProps<{
- options: Options;
- modelValue?: any;
- showCtrl?: boolean;
- notContent?: boolean;
- }>(),
- {
- notContent: false,
- showCtrl: false,
- }
- );
- const activeValue = ref(props.modelValue || props.options[0].value);
- const emit = defineEmits<{
- (e: "update:modelValue", modelValue: string): void;
- }>();
- const updateModelValue = (modelValue: string) => {
- if ("modelValue" in props) {
- console.log(modelValue, props);
- emit("update:modelValue", modelValue);
- } else {
- activeValue.value = modelValue;
- }
- };
- const show = ref(true);
- </script>
- <style lang="scss" scoped>
- .head-layer {
- background-color: #fff;
- border-radius: 4px;
- }
- .head-content-layer {
- padding: 16px 154px 16px 16px;
- position: relative;
- .head-content {
- overflow: hidden;
- height: 42px;
- }
- &.show {
- padding-bottom: 16px;
- .head-content {
- height: auto;
- }
- }
- .display {
- position: absolute;
- top: 16px;
- right: 16px;
- color: var(--primaryColor);
- font-size: 0.85rem;
- cursor: pointer;
- i {
- color: currentColor;
- font-size: 1em;
- margin-left: 5px;
- }
- }
- }
- </style>
- <style>
- .head-layer .el-tabs__nav-wrap {
- padding: 0 16px;
- }
- .head-layer .el-tabs__header {
- margin-bottom: 0;
- }
- .head-layer .el-form-item {
- margin-bottom: 0;
- }
- </style>
|