This commit is contained in:
weipengfei 2024-04-05 17:45:32 +08:00
parent 6d21ce159a
commit 8b34814a90
1 changed files with 54 additions and 49 deletions

View File

@ -26,9 +26,10 @@ const open = () => {
const changeActive = (e) => { const changeActive = (e) => {
active.value = e; active.value = e;
if (active.value == 2) { // if (active.value == 2) {
document.addEventListener('keydown', keyboard); //
}else document.removeEventListener('keydown', keyboard); document.addEventListener("keydown", keyboard);
} else document.removeEventListener("keydown", keyboard);
}; };
const form = ref({}); const form = ref({});
@ -191,6 +192,8 @@ const beforeClose = () => {
reLoad.value = false; reLoad.value = false;
loading.value = false; loading.value = false;
input.value = ""; input.value = "";
collection.value = "";
collectionArray.value = [];
codeRef.value?.blur(); codeRef.value?.blur();
emit("paySuccess"); emit("paySuccess");
drawer.value = false; drawer.value = false;
@ -206,12 +209,13 @@ defineExpose({
const collectionArray = ref([]); const collectionArray = ref([]);
const collection = ref(""); // const collection = ref(""); //
const changePrice = computed(()=>{ // const changePrice = computed(() => {
//
if (+collection.value > 0) { if (+collection.value > 0) {
return (collection.value - form.value.order_price).toFixed(2); return (collection.value - form.value.order_price).toFixed(2);
} }
return -1; return -1;
}) });
const defaultcalc = ref(false); const defaultcalc = ref(false);
// //
@ -246,8 +250,7 @@ const numTap = (item) => {
}; };
// //
const cashBnt = () => { const cashBnt = () => {
console.log("结算"); if(changePrice.value!=''&&changePrice.value>=0) orderCreateApi({
orderCreateApi({
address_id: "", address_id: "",
key: form.value.key, key: form.value.key,
cart_id: cart_id.value, cart_id: cart_id.value,
@ -266,6 +269,8 @@ const cashBnt = () => {
} else { } else {
if (!res.data.group_order_sn) { if (!res.data.group_order_sn) {
order_id.value = res.data.result.order_id; order_id.value = res.data.result.order_id;
collection.value = "";
collectionArray.value = [];
loading.value = false; loading.value = false;
return ElMessage({ return ElMessage({
message: res.message, message: res.message,
@ -281,9 +286,6 @@ const cashBnt = () => {
}) })
.catch((err) => { .catch((err) => {
loading.value = false; loading.value = false;
nextTick(() => {
codeRef.value?.focus();
});
}); });
}; };
@ -345,6 +347,9 @@ const keyboard = (event) => {
case 8: case 8:
delNum(); delNum();
break; break;
case 13:
cashBnt();
break;
} }
}; };
</script> </script>
@ -403,7 +408,9 @@ const keyboard = (event) => {
<div class="counter"> <div class="counter">
<div class="received"> <div class="received">
<span v-if="collection">{{ collection }}</span> <span v-if="collection">{{ collection }}</span>
<span v-else style="font-size: 1rem;color: #999;">按下键盘输入客户支付金额</span> <span v-else style="font-size: 1rem; color: #999"
>按下键盘输入客户支付金额</span
>
</div> </div>
<div class="balance" v-if="changePrice >= 0"> <div class="balance" v-if="changePrice >= 0">
需找零()<span class="money">{{ changePrice }}</span> 需找零()<span class="money">{{ changePrice }}</span>
@ -433,9 +440,7 @@ const keyboard = (event) => {
</template> </template>
<template #footer> <template #footer>
<div style="width: 100%; display: flex; justify-content: center"> <div style="width: 100%; display: flex; justify-content: center">
<el-button class="cancel-btn" @click="cancelClick" <el-button class="cancel-btn" @click="cancelClick">取消收款</el-button>
>取消收款</el-button
>
</div> </div>
</template> </template>
</el-drawer> </el-drawer>