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