changes
This commit is contained in:
@@ -17,25 +17,29 @@ const shipping_address = computed(() => {
|
||||
async function createOrder() {
|
||||
try {
|
||||
isPending.value = true;
|
||||
|
||||
const invoicePayload = {
|
||||
customer: activeCart.value.customer,
|
||||
customer_name: activeCart.value.customer__fullname,
|
||||
customer_phone: activeCart.value.customer__phone,
|
||||
customer_email: activeCart.value.customer__email,
|
||||
shipping_address: shipping_address.value,
|
||||
product_amount: activeCartItems.value.length,
|
||||
shipping_fee: 0,
|
||||
total_amount: subtotal.value,
|
||||
discount_amount: 0,
|
||||
final_amount: subtotal.value,
|
||||
order_type: "pos",
|
||||
status: "pending",
|
||||
payment_status: 1,
|
||||
staff: 1,
|
||||
ordered_at: new Date(),
|
||||
paid_at: null,
|
||||
delivery_method: orderInfo.value.deliveryMethod.id,
|
||||
};
|
||||
|
||||
const invoice = await $insertapi("Invoice", {
|
||||
data: {
|
||||
customer: activeCart.value.customer,
|
||||
customer_name: activeCart.value.customer__fullname,
|
||||
customer_phone: activeCart.value.customer__phone,
|
||||
customer_email: activeCart.value.customer__email,
|
||||
shipping_address: shipping_address.value,
|
||||
product_amount: activeCartItems.value.length,
|
||||
shipping_fee: 0,
|
||||
total_amount: subtotal.value,
|
||||
discount_amount: 0,
|
||||
final_amount: subtotal.value,
|
||||
order_type: "pos",
|
||||
status: "pending",
|
||||
staff: 1,
|
||||
ordered_at: new Date(),
|
||||
paid_at: null,
|
||||
delivery_method: orderInfo.value.deliveryMethod.id,
|
||||
},
|
||||
data: invoicePayload,
|
||||
notify: false,
|
||||
});
|
||||
|
||||
@@ -68,8 +72,8 @@ async function createOrder() {
|
||||
if (orderInfo.value.deliveryMethod.code === "HOME_DELIVERY") {
|
||||
const deliveryInfoPayload = {
|
||||
invoice: invoice.id,
|
||||
receiver_name: invoice.customer_name,
|
||||
receiver_phone: invoice.customer_phone,
|
||||
receiver_name: orderInfo.value.receiver_name,
|
||||
receiver_phone: orderInfo.value.receiver_phone,
|
||||
city: orderInfo.value.address.city,
|
||||
district: orderInfo.value.address.district,
|
||||
ward: orderInfo.value.address.ward,
|
||||
@@ -171,9 +175,9 @@ async function createOrder() {
|
||||
<div v-else>
|
||||
<p class="font-medium fs-16 mb-0.5">{{ shipping_address }}</p>
|
||||
<p class="has-text-grey">
|
||||
<span>{{ activeCart.customer__fullname }}</span>
|
||||
<span>{{ orderInfo.receiver_name }}</span>
|
||||
<span> • </span>
|
||||
<span>{{ activeCart.customer__phone }}</span>
|
||||
<span>{{ orderInfo.receiver_phone }}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -215,10 +215,9 @@ provide("pos", {
|
||||
<p class="control">
|
||||
<input
|
||||
class="input is-small"
|
||||
type="email"
|
||||
:value="activeCart.customer__fullname"
|
||||
placeholder="Name"
|
||||
disabled
|
||||
type="text"
|
||||
v-model="orderInfo.receiver_name"
|
||||
placeholder="Tên"
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
@@ -227,10 +226,9 @@ provide("pos", {
|
||||
<p class="control">
|
||||
<input
|
||||
class="input is-small"
|
||||
type="email"
|
||||
:value="activeCart.customer__phone"
|
||||
placeholder="Phone"
|
||||
disabled
|
||||
type="text"
|
||||
v-model="orderInfo.receiver_phone"
|
||||
placeholder="SĐT"
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export default function useOrderInfo({ activeCartId, activeCart, activeCartItems, addresses, getAddresses }) {
|
||||
const orderInfo = ref({
|
||||
address: null,
|
||||
receiver_name: null,
|
||||
receiver_phone: null,
|
||||
deliveryMethod: null,
|
||||
paymentMethod: null,
|
||||
});
|
||||
@@ -18,10 +20,14 @@ export default function useOrderInfo({ activeCartId, activeCart, activeCartItems
|
||||
if (!oldVal || !oldVal.customer || oldVal.customer !== newVal.customer) {
|
||||
const defaultAddress = addresses.value.find((add) => add.is_default);
|
||||
orderInfo.value.address = defaultAddress;
|
||||
orderInfo.value.receiver_name = newVal.customer__fullname;
|
||||
orderInfo.value.receiver_phone = newVal.customer__phone;
|
||||
}
|
||||
} else {
|
||||
addresses.value = null;
|
||||
orderInfo.value.address = null;
|
||||
orderInfo.value.receiver_name = null;
|
||||
orderInfo.value.receiver_phone = null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user