SaveBar.vue 1.26 KB
<!-- 底部「有未保存的修改」条:表单改动后出现,保存 / 撤销。 -->
<script setup lang="ts">
defineProps<{ show: boolean; saving?: boolean; text?: string }>()
defineEmits<{ save: []; reset: [] }>()
</script>

<template>
  <transition name="bar">
    <div v-if="show" class="savebar">
      <span class="dot" />
      <span class="txt">{{ text || '有未保存的修改' }}</span>
      <el-button @click="$emit('reset')">撤销</el-button>
      <el-button type="primary" :loading="saving" @click="$emit('save')">保存</el-button>
    </div>
  </transition>
</template>

<style scoped>
.savebar { position: sticky; bottom: 16px; z-index: 20; margin: 20px auto 0; width: fit-content; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; background: #1a1e27; color: #fff;
  border-radius: 12px; box-shadow: var(--shadow-lg); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #f5b13d; }
.txt { font-size: 13px; margin-right: 6px; }
.savebar :deep(.el-button:not(.el-button--primary)) { background: transparent; color: #d6d9e0; border-color: #3a4050; }
.bar-enter-active, .bar-leave-active { transition: all 0.18s ease; }
.bar-enter-from, .bar-leave-to { opacity: 0; transform: translateY(8px); }
</style>