对接支付优惠
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<!-- 结算订单 -->
|
||||
<template>
|
||||
<el-drawer size="100%" :with-header="false" direction="btt" v-model="dialogVisible" @closed="drawerClose">
|
||||
<el-drawer size="100%" :with-header="false" direction="btt" v-model="dialogVisible">
|
||||
<div class="drawer_wrap">
|
||||
<div class="cart_list">
|
||||
<div class="nav_wrap card">
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="master_id">
|
||||
<span>{{ goodsStore.orderListInfo.tableCode }}</span>
|
||||
<span>{{ goodsStore.orderListInfo.tableCode || store.shopInfo.shopName }}</span>
|
||||
<span class="member_info" v-if="goodsStore.vipUserInfo.id">
|
||||
会员:{{ formatPhoneNumber(goodsStore.vipUserInfo.phone) }}
|
||||
</span>
|
||||
@@ -26,8 +26,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="list_wrap card" style="margin-top: var(--el-font-size-base)">
|
||||
<SettleItem :list="cartList" />
|
||||
<!-- <SettleItem :list="cartList" /> -->
|
||||
<SettleItem :list="orderList" />
|
||||
<SettleItem
|
||||
:list="[{ id: 'tableFee', product_name: '客座费', number: goodsStore.tableInfo.num, lowPrice: store.shopInfo.tableFee }]"
|
||||
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.name && (goodsStore.cartList.length || goodsStore.orderList.length)" />
|
||||
</div>
|
||||
<div class="footer">
|
||||
<!-- <el-button icon="Edit"></el-button> -->
|
||||
@@ -43,11 +46,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="pay_wrap">
|
||||
<payCard :amount="cartInfo.totalAmount" :discount="propsDiscount" :orderId="goodsStore.orderListInfo.id"
|
||||
@paySuccess="paySuccess" @cancelDiscount="propsDiscount = 0" />
|
||||
<payCard ref="payCardRef" :orderList="orderList" :amount="cartInfo.totalAmount"
|
||||
:orderId="goodsStore.orderListInfo.id" @paySuccess="paySuccess" />
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="showStaffDiscount" title="员工折扣" @close="global.updateData(true)">
|
||||
<!-- <el-dialog v-model="showStaffDiscount" title="员工折扣" @close="global.updateData(true)">
|
||||
<el-form>
|
||||
<el-form-item label="折扣比例">
|
||||
<div>
|
||||
@@ -72,25 +75,21 @@
|
||||
<el-button type="primary" style="width: 100%;" @click="discountConfirm">确认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-dialog> -->
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { onMounted, ref } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import payCard from "@/components/payCard/payCard.vue";
|
||||
import SettleItem from './settleItem.vue'
|
||||
import { print } from "@/api/pay";
|
||||
import { orderfindOrder, getStaffDiscount } from '@/api/order/index.js'
|
||||
import { shopStaffInfo } from '@/api/account.js'
|
||||
import { ElMessage } from "element-plus";
|
||||
import dayjs from "dayjs";
|
||||
import useStorage from '@/utils/useStorage'
|
||||
import { ipcRenderer } from "electron";
|
||||
import { formatDecimal, formatPhoneNumber } from '@/utils/index.js'
|
||||
import receiptPrint from "@/components/lodop/receiptPrint.js";
|
||||
import { formatPhoneNumber, getOrderByIdAjax, commOrderPrintData } from '@/utils/index.js'
|
||||
import useStorage from '@/utils/useStorage.js'
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { usePrint } from '@/store/print.js'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
@@ -112,7 +111,6 @@ const printLoading = ref(false);
|
||||
const showStaffDiscount = ref(false)
|
||||
const staffDiscount = ref('')
|
||||
const discount = ref(0)
|
||||
const propsDiscount = ref(0)
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const props = defineProps({
|
||||
@@ -178,106 +176,25 @@ async function getStaffDiscountAjax() {
|
||||
}
|
||||
}
|
||||
|
||||
// 确认折扣
|
||||
function discountConfirm() {
|
||||
if (discount.value >= staffDiscount.value) {
|
||||
propsDiscount.value = discount.value
|
||||
}
|
||||
showStaffDiscount.value = false
|
||||
}
|
||||
|
||||
// 关闭结算弹窗
|
||||
function drawerClose() {
|
||||
propsDiscount.value = 0
|
||||
}
|
||||
|
||||
// 预打印操作
|
||||
const printHandle = _.throttle(async function () {
|
||||
try {
|
||||
if (!isPrint.value) return;
|
||||
printLoading.value = true;
|
||||
const data = {
|
||||
shop_name: store.userInfo.shopName,
|
||||
loginAccount: store.userInfo.loginAccount,
|
||||
isBefore: true,
|
||||
carts: cartList.value,
|
||||
amount: formatDecimal(props.amount),
|
||||
discountAmount: propsDiscount.value > 0 ? formatDecimal(props.amount * propsDiscount.value) : formatDecimal(props.amount),
|
||||
discount: formatDecimal(propsDiscount.value * 10, 1, true),
|
||||
remark: props.remark,
|
||||
orderInfo: props.orderInfo,
|
||||
createdAt: dayjs(props.orderInfo.createdAt).format("YYYY-MM-DD HH:mm:ss"),
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
printStore.labelPrint(data)
|
||||
setTimeout(() => {
|
||||
printLoading.value = false;
|
||||
}, 1500)
|
||||
if (printStore.deviceNoteList.length) {
|
||||
printStore.pushReceiptData(data)
|
||||
} else {
|
||||
await print({
|
||||
type: "normal",
|
||||
ispre: true,
|
||||
orderId: props.orderInfo.id,
|
||||
});
|
||||
printLoading.value = false;
|
||||
ElMessage.success("打印成功");
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
printLoading.value = true
|
||||
await printOrderLable(true)
|
||||
setTimeout(() => {
|
||||
printLoading.value = false
|
||||
}, 1000)
|
||||
}, 1500, { leading: true, trailing: false })
|
||||
|
||||
// 打印订单标签
|
||||
async function printOrderLable() {
|
||||
async function printOrderLable(isBefore = false) {
|
||||
try {
|
||||
if (!isPrint.value) return
|
||||
const res = await orderfindOrder({
|
||||
shopId: store.userInfo.shopId,
|
||||
status: '',
|
||||
size: 10,
|
||||
page: 1,
|
||||
orderNo: props.orderInfo.orderNo
|
||||
})
|
||||
|
||||
const printLabelOrder = res.list[0]
|
||||
|
||||
const data = {
|
||||
shop_name: store.userInfo.shopName,
|
||||
loginAccount: store.userInfo.loginAccount,
|
||||
carts: [],
|
||||
amount: formatDecimal(printLabelOrder.orderAmount),
|
||||
discountAmount: printLabelOrder.discountRatio > 0 ? formatDecimal(printLabelOrder.orderAmount - printLabelOrder.discountAmount) : formatDecimal(printLabelOrder.orderAmount),
|
||||
discount: formatDecimal(printLabelOrder.discountRatio * 10, 1, true) || 0,
|
||||
remark: printLabelOrder.remark,
|
||||
orderInfo: printLabelOrder,
|
||||
outNumber: printLabelOrder.outNumber,
|
||||
createdAt: dayjs(printLabelOrder.createdAt).format(
|
||||
"YYYY-MM-DD HH:mm:ss"
|
||||
),
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
}
|
||||
printLabelOrder.skuInfos.map(item => {
|
||||
data.carts.push(
|
||||
{
|
||||
categoryId: item.categoryId,
|
||||
name: item.productName,
|
||||
number: item.num,
|
||||
skuName: item.productSkuName,
|
||||
salePrice: formatDecimal(item.price),
|
||||
totalAmount: formatDecimal(item.num * item.price),
|
||||
proGroupInfo: item.proGroupInfo
|
||||
}
|
||||
)
|
||||
})
|
||||
// 打印标签
|
||||
printStore.labelPrint(data)
|
||||
|
||||
if (printStore.deviceNoteList.length) {
|
||||
// 打印小票
|
||||
printStore.pushReceiptData(data)
|
||||
// 使用本地打印机打印
|
||||
const data = await getOrderByIdAjax(goodsStore.orderListInfo.id);
|
||||
printStore.labelPrint(commOrderPrintData(data))
|
||||
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
|
||||
} else {
|
||||
// 本地没有可用打印机使用云打印机
|
||||
await print({
|
||||
type: "normal",
|
||||
ispre: true,
|
||||
@@ -293,20 +210,29 @@ async function printOrderLable() {
|
||||
|
||||
// 订单已支付
|
||||
function paySuccess() {
|
||||
propsDiscount.value = 0
|
||||
dialogVisible.value = false;
|
||||
|
||||
ElMessage.success('支付成功')
|
||||
printOrderLable()
|
||||
useStorage.del('tableCode')
|
||||
goodsStore.successClearCart(!cartList.length)
|
||||
// printOrderLable()
|
||||
// emit("paySuccess");
|
||||
}
|
||||
|
||||
|
||||
const payCardRef = ref(null)
|
||||
function show(t) {
|
||||
dialogVisible.value = true;
|
||||
cartInfo.value = { ...goodsStore.cartInfo }
|
||||
orderList.value = [...goodsStore.orderList.map(item => item.goods).flat()]
|
||||
if (t = 1) cartList.value = [...goodsStore.cartList];
|
||||
console.log(cartInfo.value);
|
||||
orderList.value = [...goodsStore.cartList, ...goodsStore.orderList.map(item => item.goods).flat()]
|
||||
|
||||
console.log('orderList===', orderList.value);
|
||||
|
||||
|
||||
// 每次初始化paycard
|
||||
setTimeout(() => {
|
||||
payCardRef.value.reset()
|
||||
}, 100)
|
||||
// if (t = 1) cartList.value = [...goodsStore.cartList];
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
||||
Reference in New Issue
Block a user