Files
web/app/components/imports/addons/AddExternalStorage.vue
2026-05-11 13:34:53 +07:00

61 lines
1.5 KiB
Vue

<script setup>
const { $empty, $insertapi } = useNuxtApp();
const isLoading = ref(false);
const body = ref({
code: null,
max_capacity: null,
});
async function submit() {
isLoading.value = true;
await $insertapi("External_Storage", body.value);
isLoading.value = false;
}
</script>
<template>
<form class="fixed-grid has-12-cols">
<div class="grid">
<div class="cell is-col-span-6">
<div class="field">
<label class="label"></label>
<div class="control">
<input
type="text"
class="input"
v-model.trim="body.code"
placeholder="Mã"
/>
</div>
</div>
</div>
<div class="cell is-col-span-6">
<div class="field">
<label class="label">Dung lượng max</label>
<div class="control">
<InputNumber
v-bind="{
record: body,
attr: 'max_capacity',
placeholder: 'Dung lượng max',
unit: 'GB',
}"
@number="(num) => (body.max_capacity = num)"
/>
</div>
</div>
</div>
<div class="cell is-col-span-12">
<button
@click.prevent="submit"
:disabled="Object.values(body).every($empty)"
:class="['button is-primary', { 'is-loading': isLoading }]"
>
Thêm
</button>
</div>
</div>
</form>
</template>