mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 15:37:33 +08:00
57 lines
1.2 KiB
Vue
57 lines
1.2 KiB
Vue
<template>
|
|
<div class="btn-vertical-group d-flex flex-column">
|
|
<v-btn border :key="idx"
|
|
:color="value === button.value ? 'primary' : 'default'"
|
|
:variant="value === button.value ? 'tonal' : 'outlined'" :disabled="disabled"
|
|
v-for="(button, idx) in buttons"
|
|
@click="value = button.value">
|
|
{{ button.name }}
|
|
</v-btn>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue';
|
|
|
|
interface Button {
|
|
name: string;
|
|
value: unknown;
|
|
}
|
|
|
|
const props = defineProps<{
|
|
modelValue: unknown;
|
|
buttons: Button[];
|
|
disabled?: boolean;
|
|
}>();
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'update:modelValue', value: unknown): void
|
|
}>();
|
|
|
|
const value = computed<unknown>({
|
|
get: () => {
|
|
return props.modelValue;
|
|
},
|
|
set: value => {
|
|
if (value === props.modelValue) {
|
|
return;
|
|
}
|
|
|
|
emit('update:modelValue', value);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style>
|
|
.btn-vertical-group .v-btn:not(:first-child) {
|
|
border-top-left-radius: inherit;
|
|
border-top-right-radius: inherit;
|
|
}
|
|
|
|
.btn-vertical-group .v-btn:not(:last-child) {
|
|
border-bottom: 0;
|
|
border-bottom-left-radius: inherit;
|
|
border-bottom-right-radius: inherit;
|
|
}
|
|
</style>
|