Files
web/app/components/parameter/DeleteCart.vue
2026-03-02 09:45:33 +07:00

53 lines
1.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="content-delete-cart">
<div class="container is-fluid px-4">
<div v-if="productRes.length">
<p>
Không thể thực hiện thao tác giỏ hàng vẫn còn sản phẩm. Vui lòng xóa toàn bộ sản phẩm trong giỏ hàng trước
khi tiếp tục.
</p>
</div>
<div v-else>
<p>
Bạn chắc chắn muốn xóa giỏ hàng [{{ props.row.code.toUpperCase() }} {{ props.row.name.toUpperCase() }}]
không?
</p>
<div class="action mt-3">
<button class="button is-light" @click="handleCancel">Hủy</button>
<button class="button is-primary" @click="handleDeleteCart">Đồng ý</button>
</div>
</div>
</div>
</div>
</template>
<script setup>
const { $snackbar, $getdata, $deleteapi, $copy } = useNuxtApp();
const emit = defineEmits(["close"]);
const props = defineProps({
row: Object,
});
const productRes = await $getdata("product", { cart: props.row.id });
const cartRes = await $getdata("cart");
$copy("cart", cartRes);
const handleDeleteCart = async () => {
const res = await $deleteapi("cart", props.row.id);
if (res) {
emit("close");
$snackbar("Xóa giỏ hàng thành công");
}
};
const handleCancel = () => {
emit("close");
};
</script>
<style>
.content-delete-cart .action .button + .button {
margin-left: 20px;
}
</style>