对接支付优惠
This commit is contained in:
@@ -11,7 +11,7 @@ VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
||||
# VITE_API_WSS = 'ws://192.168.2.17:9998/client'
|
||||
|
||||
# 正式 php
|
||||
VITE_API_PHP_URL = 'https://czgdoumei.sxczgkj.com/index.php/api'
|
||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
|
||||
# 测试 php 开票
|
||||
# VITE_API_KP_URL = 'http://192.168.1.13:8888/api'
|
||||
@@ -34,9 +34,12 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||
# 张松本地
|
||||
# VITE_API_URL = 'https://36z1017t45.goho.co/cashier-client'
|
||||
|
||||
# 谭凯凯
|
||||
VITE_API_URL = 'http://192.168.1.35/'
|
||||
|
||||
# 正式
|
||||
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
|
||||
|
||||
# 正式
|
||||
VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
||||
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ ENV = production
|
||||
VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||
|
||||
# 正式 php
|
||||
VITE_API_PHP_URL = 'https://czgdoumei.sxczgkj.com/index.php/api'
|
||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
|
||||
# 正式 php 开票
|
||||
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||
|
||||
@@ -36,15 +36,10 @@ import { ipcRenderer } from 'electron';
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const socket = useSocket();
|
||||
|
||||
const global = useGlobal();
|
||||
|
||||
const leftMenuRef = ref(null);
|
||||
|
||||
const store = useUser();
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const includeList = reactive([]);
|
||||
@@ -177,6 +172,7 @@ onMounted(() => {
|
||||
// 防止刷新页面长连接丢失
|
||||
if (store.userInfo && store.userInfo.id) {
|
||||
goodsStore.initGoods()
|
||||
store.getShopInfo()
|
||||
}
|
||||
|
||||
ipcRenderer.on('showCloseDialog', (event, arg) => {
|
||||
|
||||
@@ -13,6 +13,19 @@ export function login(data) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function logout(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/account/admin/auth/logout",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码获取
|
||||
* @param {*} params
|
||||
@@ -39,6 +52,19 @@ export function shopInfo_detail(params) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前店铺拓展通过key
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function shopExtendDetail(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/shopExtend/detail",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺用户列表
|
||||
* @param {*} params
|
||||
@@ -232,3 +258,127 @@ export function callTableCallState(data) {
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 收银机-交班数据统计
|
||||
*/
|
||||
export function handoverTotal(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/handover-record/total",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 收银机-交班
|
||||
*/
|
||||
export function handover(isPrint) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/account/admin/handover-record/handover?isPrint=" + isPrint,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 收银机-交班记录-详情
|
||||
*/
|
||||
export function handoverData(id) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: `/account/admin/handover-record/detail/${id}`,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 交班记录-分页
|
||||
*/
|
||||
export function handoverRecordPage(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: `/account/admin/handover-record/page`,
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 收银机-交班/关班-网络打印机打印交班小票
|
||||
*/
|
||||
export function handoverNetworkPrint(id) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: `/account/admin/handover-record/network/print/${id}`,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机列表
|
||||
*/
|
||||
export function printerList(subType = "") {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/printer",
|
||||
params: {
|
||||
name: "",
|
||||
subType: subType,
|
||||
connectionType: "USB",
|
||||
page: 1,
|
||||
size: 100,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机详情
|
||||
*/
|
||||
export function printerDetail(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/printer/detail",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增打印机
|
||||
*/
|
||||
export function printerAdd(data, method = "post") {
|
||||
return request({
|
||||
method: method,
|
||||
url: "/account/admin/printer",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找优惠券 生成订单后使用
|
||||
*/
|
||||
export function findCoupon(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/coupon/findCoupon",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||
*/
|
||||
export function calcUsablePoints(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/points/memberPoints/calcUsablePoints",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 003-根据积分计算可抵扣金额
|
||||
*/
|
||||
export function calcDeductionAmount(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/points/memberPoints/calcDeductionAmount",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export function refundOrder(data) {
|
||||
export function getOrderById(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/order/admin/order/getOrderById",
|
||||
url: "/order/admin/order/getOrderByIdPrint",
|
||||
params,
|
||||
});
|
||||
}
|
||||
@@ -155,3 +155,42 @@ export function refundVip(data) {
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂账人 - 分页
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function buyerPage(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/order/admin/order/credit/buyer/page",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂账人 - 付款
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function creditPay(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/order/pay/creditPay",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂账人 - 会员支付订单
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function vipPay(data) {
|
||||
return request({
|
||||
method: "post",
|
||||
url: "/order/pay/vipPay",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<div class="list_title">{{ item.name }}</div>
|
||||
<div class="item_wrap">
|
||||
<el-button :type="item.active ? 'primary' : ''" @click="selectHandle(item)">全部</el-button>
|
||||
<el-button :type="val.active ? 'primary' : ''" v-for="val in item.childrenList" :key="val.id"
|
||||
@click="selectHandle(val, index)">{{ val.name }}</el-button>
|
||||
<!-- <el-button :type="val.active ? 'primary' : ''" v-for="val in item.childrenList" :key="val.id"
|
||||
@click="selectHandle(val, index)">{{ val.name }}</el-button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -18,9 +18,11 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { tbShopCategoryGet } from "@/api/device";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const store = useUser();
|
||||
const emit = defineEmits(["success"]);
|
||||
@@ -29,6 +31,7 @@ const dialogVisible = ref(false);
|
||||
const loading = ref(false);
|
||||
const categorys = ref([]);
|
||||
|
||||
// 确定
|
||||
function onSubmitHandle() {
|
||||
let categorysArr = [];
|
||||
for (let item of categorys.value) {
|
||||
@@ -38,16 +41,16 @@ function onSubmitHandle() {
|
||||
id: item.id,
|
||||
});
|
||||
}
|
||||
if (item.childrenList.length) {
|
||||
for (let val of item.childrenList) {
|
||||
if (val.active) {
|
||||
categorysArr.push({
|
||||
name: `${val.name}`,
|
||||
id: val.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (item.childrenList.length) {
|
||||
// for (let val of item.childrenList) {
|
||||
// if (val.active) {
|
||||
// categorysArr.push({
|
||||
// name: `${val.name}`,
|
||||
// id: val.id,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
emit("success", categorysArr);
|
||||
dialogVisible.value = false;
|
||||
@@ -55,38 +58,34 @@ function onSubmitHandle() {
|
||||
|
||||
// 选择分类
|
||||
function selectHandle(item, index = -1) {
|
||||
if (index != -1) {
|
||||
categorys.value[index].active = false;
|
||||
} else {
|
||||
item.childrenList.map((item) => {
|
||||
item.active = false;
|
||||
});
|
||||
}
|
||||
// if (index != -1) {
|
||||
// categorys.value[index].active = false;
|
||||
// } else {
|
||||
// item.childrenList.map((item) => {
|
||||
// item.active = false;
|
||||
// });
|
||||
// }
|
||||
item.active = !item.active;
|
||||
}
|
||||
|
||||
// 获取分类
|
||||
async function tbShopCategoryGetAjax() {
|
||||
try {
|
||||
loading.value = true;
|
||||
const res = await tbShopCategoryGet({
|
||||
shopId: store.userInfo.shopId,
|
||||
sort: "sort,desc",
|
||||
page: 0,
|
||||
pageSize: 200,
|
||||
// loading.value = true;
|
||||
// const res = await categoryList();
|
||||
// res.list.map((item) => {
|
||||
// item.active = false;
|
||||
// item.childrenList.map((item) => {
|
||||
// item.active = false;
|
||||
// });
|
||||
// });
|
||||
categorys.value = goodsStore.originCategoryList.map(item => {
|
||||
item.active = false
|
||||
return item
|
||||
});
|
||||
// console.log(res);
|
||||
res.list.map((item) => {
|
||||
item.active = false;
|
||||
item.childrenList.map((item) => {
|
||||
item.active = false;
|
||||
});
|
||||
});
|
||||
categorys.value = res.list;
|
||||
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 300);
|
||||
// setTimeout(() => {
|
||||
// loading.value = false;
|
||||
// }, 300);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
loading.value = false;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<!-- 更多 -->
|
||||
<more ref="moreref" @openCall="openCall"></more>
|
||||
<!-- 叫号 -->
|
||||
<callNumber ref="callNumberRef" />
|
||||
<!-- <callNumber ref="callNumberRef" /> -->
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
@@ -13,52 +13,67 @@ export default (data) => {
|
||||
// 文字内容
|
||||
let html = `
|
||||
<div style="font-size: 30px;display:flex;justify-content:center;">
|
||||
${data.merchantName}
|
||||
${data.shopName}
|
||||
</div>
|
||||
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
|
||||
交班小票
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top:50px;">
|
||||
当班时间:${data.startTime}
|
||||
当班时间:${data.loginTime}
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
交班时间:${data.endTime}
|
||||
交班时间:${data.handoverTime}
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
收银员:${data.staff}
|
||||
收银员:${data.staffName}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
当班收入:${data.totalAmount}
|
||||
当班总收入:${data.handAmount}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
现金收入:${data.cashAmount}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
微信收入:${data.wechatAmount}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
支付宝收入:${data.alipayAmount}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
会员支付:${data.vipPay}
|
||||
</div>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
会员充值:${data.vipRecharge}
|
||||
</div>
|
||||
`;
|
||||
|
||||
let payInfos = "";
|
||||
if (data.payInfos && data.payInfos.length) {
|
||||
for (let item of data.payInfos) {
|
||||
payInfos += `
|
||||
<div style="font-size: 12px;padding-left:20px;">
|
||||
${item.payType}:${item.amount}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
// let payInfos = "";
|
||||
// if (data.payInfos && data.payInfos.length) {
|
||||
// for (let item of data.payInfos) {
|
||||
// payInfos += `
|
||||
// <div style="font-size: 12px;padding-left:20px;">
|
||||
// ${item.payType}:${item.amount}
|
||||
// </div>
|
||||
// `;
|
||||
// }
|
||||
// }
|
||||
|
||||
let memberTitle = `
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
会员数据
|
||||
</div>
|
||||
`;
|
||||
// let memberTitle = `
|
||||
// <div style="font-size: 12px;margin-top: 4px;">
|
||||
// 会员数据
|
||||
// </div>
|
||||
// `;
|
||||
|
||||
let memberData = "";
|
||||
if (data.memberData && data.memberData.length) {
|
||||
for (let item of data.memberData) {
|
||||
memberData += `
|
||||
<div style="font-size: 12px;padding-left:20px;">
|
||||
${item.deposit}:${item.amount}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
// let memberData = "";
|
||||
// if (data.memberData && data.memberData.length) {
|
||||
// for (let item of data.memberData) {
|
||||
// memberData += `
|
||||
// <div style="font-size: 12px;padding-left:20px;">
|
||||
// ${item.deposit}:${item.amount}
|
||||
// </div>
|
||||
// `;
|
||||
// }
|
||||
// }
|
||||
|
||||
let productCategoriesTabHead = `
|
||||
<div style="font-size: 12px;margin-top: 4px;">分类数据</div>
|
||||
@@ -71,8 +86,8 @@ export default (data) => {
|
||||
`;
|
||||
|
||||
let productCategoriesTableBody = "";
|
||||
if (data.productCategories && data.productCategories.length) {
|
||||
for (let item of data.productCategories) {
|
||||
if (data.categoryDataList && data.categoryDataList.length) {
|
||||
for (let item of data.categoryDataList) {
|
||||
productCategoriesTableBody += `
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:50%;">
|
||||
@@ -98,8 +113,8 @@ export default (data) => {
|
||||
`;
|
||||
|
||||
let tableBody = "";
|
||||
if (data.productInfos && data.productInfos.length) {
|
||||
for (let item of data.productInfos) {
|
||||
if (data.productDatalist && data.productDatalist.length) {
|
||||
for (let item of data.productDatalist) {
|
||||
tableBody += `
|
||||
<tr>
|
||||
<td style="font-size: 12px;width:75%;">
|
||||
@@ -120,27 +135,23 @@ export default (data) => {
|
||||
</table>
|
||||
<div style="font-size: 12px;margin-top: 4px;">
|
||||
<span>快捷收款金额:</span>
|
||||
<span>${data.quickAmount}</span>
|
||||
<span>${data.quickInAmount}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>退款金额:</span>
|
||||
<span>${data.returnAmount}</span>
|
||||
<span>${data.refundAmount}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>总收入:</span>
|
||||
<span>${data.totalAmount}</span>
|
||||
<span>${data.handAmount}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>备用金:</span>
|
||||
<span>${data.imprest}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
<span>应交金额:</span>
|
||||
<span>${data.payable}</span>
|
||||
<span>挂账金额:</span>
|
||||
<span>${data.creditAmount}</span>
|
||||
</div>
|
||||
<div style="margin-top: 20px; font-size: 12px;">
|
||||
<span>总订单数:</span>
|
||||
<span>${data.orderNum}</span>
|
||||
<span>${data.orderCount}</span>
|
||||
</div>
|
||||
<div style="font-size: 12px;">
|
||||
打印时间:${data.printTime}
|
||||
@@ -151,7 +162,9 @@ export default (data) => {
|
||||
<div>.</div>
|
||||
`;
|
||||
|
||||
let lastHtml = `${html}${payInfos}${memberTitle}${memberData}${productCategoriesTabHead}${productCategoriesTableBody}${tabHead}${tableBody}${str}`;
|
||||
// let lastHtml = `${html}${payInfos}${memberTitle}${memberData}${productCategoriesTabHead}${productCategoriesTableBody}${tabHead}${tableBody}${str}`;
|
||||
|
||||
let lastHtml = `${html}${productCategoriesTabHead}${productCategoriesTableBody}${tabHead}${tableBody}${str}`;
|
||||
|
||||
setTimeout(() => {
|
||||
LODOP.ADD_PRINT_HTM("9mm", "0mm", "RightMargin:0mm", 20, lastHtml);
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
<div class="drawerbox_bo_top">
|
||||
<div class="drawerbox_bo_top_left" @click="computeExpired">
|
||||
<div class="drawerbox_bo_top_left_one" style="font-size: 24px;">
|
||||
{{ store.userInfo.shopName }}
|
||||
{{ store.shopInfo.shopName }}
|
||||
</div>
|
||||
<div class="tips" style="margin-top: 4px; color: var(--el-color-warning);" v-if="!showTips">注意:您的账号将于{{
|
||||
store.userInfo.expireDate }}后过期,请尽快续期!</div>
|
||||
store.shopInfo.expireTime }}后过期,请尽快续期!</div>
|
||||
<div class="drawerbox_bo_top_left_tow" style="margin-top: 10px">
|
||||
收银员:{{ store.userInfo.loginAccount }}
|
||||
收银员:{{ store.userInfo.name }}
|
||||
</div>
|
||||
<div>
|
||||
<span style="color: #666">{{ dayjs(store.userInfo.loginTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
|
||||
@@ -50,14 +50,14 @@
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">设备管理</div>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_itembox" @click="openCallHandle">
|
||||
<!-- <div class="drawerbox_bo_box_itembox" @click="openCallHandle">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
<Bell />
|
||||
</el-icon>
|
||||
</div>
|
||||
<div class="drawerbox_bo_box_icontext">叫号</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="drawerbox_bo_box_itembox" @click="screenref.shows()">
|
||||
<div class="drawerbox_bo_box_icon">
|
||||
<el-icon size="40">
|
||||
@@ -123,7 +123,7 @@ function computeExpired() {
|
||||
// 当前日期
|
||||
let now = dayjs()
|
||||
// 到期时间
|
||||
let expired = dayjs(store.userInfo.expireDate).subtract(30, 'day')
|
||||
let expired = dayjs(store.userInfo.expireTime).subtract(30, 'day')
|
||||
// 判断当前时间是否大于到期时间30天
|
||||
showTips.value = now.isBefore(expired)
|
||||
}
|
||||
|
||||
216
src/components/payCard/couponModal.vue
Normal file
216
src/components/payCard/couponModal.vue
Normal file
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<el-dialog v-model="showDialog" title="选择优惠券" top="12vh" width="80%" @closed="resetHandle">
|
||||
<el-radio-group v-model="query.type" @change="typeChange">
|
||||
<el-radio-button label="优惠券" :value="1"></el-radio-button>
|
||||
<el-radio-button label="商品券" :value="2"></el-radio-button>
|
||||
</el-radio-group>
|
||||
<div class="table">
|
||||
<el-table ref="tableRef1" :data="tableData.list" border stripe v-loading="tableData.loading"
|
||||
v-show="query.type == 1" height="300px">
|
||||
<el-table-column label="名称" prop="name"></el-table-column>
|
||||
<el-table-column label="抵扣" prop="discountAmount"></el-table-column>
|
||||
<el-table-column label="限制" prop="fullAmount">
|
||||
<template v-slot="scope">
|
||||
满{{ scope.row.fullAmount }}减{{ scope.row.discountAmount }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="描述" prop="useRestrictions">
|
||||
<template v-slot="scope">
|
||||
<div v-html="scope.row.useRestrictions"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template v-slot="scope">
|
||||
<el-button type="primary" @click="selectCoupon(scope.row)">选择</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-table ref="tableRef2" :data="tableData.list" border stripe row-key="id" v-loading="tableData.loading"
|
||||
v-show="query.type == 2" height="300px">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column label="名称" prop="name"></el-table-column>
|
||||
<el-table-column label="商品信息">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.productName }} ¥{{ scope.row.lowPrice }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="描述" prop="useRestrictions">
|
||||
<template v-slot="scope">
|
||||
<div v-html="scope.row.useRestrictions"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="dialog_footer" v-if="query.type == 2">
|
||||
<el-button @click="showDialog = false">取消</el-button>
|
||||
<el-button type="primary" @click="selectCoupon()">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
import { findCoupon } from '@/api/account.js'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
orderList: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
const emits = defineEmits(['success'])
|
||||
|
||||
const goodsStore = useGoods()
|
||||
const tableRef1 = ref(null)
|
||||
const tableRef2 = ref(null)
|
||||
const showDialog = ref(false)
|
||||
const query = ref({
|
||||
type: 1,
|
||||
userId: ''
|
||||
})
|
||||
const tableData = reactive({
|
||||
loading: false,
|
||||
list: []
|
||||
})
|
||||
|
||||
// 关闭初始化
|
||||
function resetHandle() {
|
||||
query.value.type = 1
|
||||
tableData.loading = false
|
||||
tableData.list = []
|
||||
}
|
||||
|
||||
function typeChange() {
|
||||
tableData.loading = false
|
||||
tableData.list = []
|
||||
findCouponAjax()
|
||||
if (query.type == 2) {
|
||||
tableRef2.value.clearSelection()
|
||||
}
|
||||
}
|
||||
|
||||
function groupByPropertyAndCount(arr, property) {
|
||||
// 创建一个空对象来存储每个属性值对应的数量
|
||||
const propertyMap = {};
|
||||
|
||||
// 遍历原始数组
|
||||
arr.forEach(item => {
|
||||
const key = item[property];
|
||||
const num = item.number || 1;
|
||||
if (!propertyMap[key]) {
|
||||
// 如果该属性值还没有在 propertyMap 中,初始化一个对象
|
||||
propertyMap[key] = {
|
||||
value: item[property],
|
||||
count: num
|
||||
};
|
||||
} else {
|
||||
// 如果该属性值已经存在,增加数量
|
||||
propertyMap[key].count += num;
|
||||
}
|
||||
});
|
||||
|
||||
// 将 propertyMap 中的结果转换为数组
|
||||
return Object.values(propertyMap);
|
||||
}
|
||||
|
||||
// 选择优惠券
|
||||
function selectCoupon(row) {
|
||||
if (query.value.type == 1) {
|
||||
emits('success', { type: query.value.type, couponList: [{ ...row }] })
|
||||
} else {
|
||||
|
||||
let goods = [
|
||||
...goodsStore.cartList,
|
||||
...goodsStore.orderList.map(item => item.goods).flat()
|
||||
]
|
||||
|
||||
let arr = tableRef2.value.getSelectionRows()
|
||||
|
||||
|
||||
if (!arr.length) {
|
||||
ElMessage.error('请选择优惠券')
|
||||
return
|
||||
}
|
||||
|
||||
let obj = groupByPropertyAndCount(arr, 'proId')
|
||||
let goodsObj = groupByPropertyAndCount(goods, 'product_id')
|
||||
|
||||
console.log(obj);
|
||||
console.log(goodsObj);
|
||||
|
||||
for (let val of goodsObj) {
|
||||
for (let item of obj) {
|
||||
if (val.value == item.value) {
|
||||
if (item.count > val.count) {
|
||||
ElMessage.error('超出订单数量,请重新选择')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emits('success', { type: query.value.type, couponList: arr })
|
||||
}
|
||||
showDialog.value = false
|
||||
}
|
||||
|
||||
// 获取用户可用de优惠券
|
||||
async function findCouponAjax() {
|
||||
try {
|
||||
tableData.loading = true
|
||||
const res = await findCoupon({
|
||||
shopUserId: query.value.userId,
|
||||
type: query.value.type
|
||||
})
|
||||
|
||||
if (query.value.type == 1) {
|
||||
tableData.list = res
|
||||
} else {
|
||||
let arr = []
|
||||
let ids = props.orderList.map(item => item.productId)
|
||||
res.map(item => {
|
||||
if (ids.includes(item.proId)) {
|
||||
let pro = props.orderList.find(val => val.productId == item.proId)
|
||||
arr.push({
|
||||
...item,
|
||||
productName: pro.productName,
|
||||
lowPrice: pro.lowPrice
|
||||
})
|
||||
}
|
||||
})
|
||||
tableData.list = arr
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
tableData.loading = false
|
||||
}
|
||||
|
||||
function show(userId) {
|
||||
showDialog.value = true
|
||||
query.value.userId = userId
|
||||
findCouponAjax()
|
||||
|
||||
console.log('couponModal.orderList===', props.orderList);
|
||||
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.table {
|
||||
padding-top: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.dialog_footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-top: var(--el-font-size-base);
|
||||
}
|
||||
</style>
|
||||
@@ -7,10 +7,11 @@
|
||||
<span class="num">{{ money }}</span>
|
||||
</div>
|
||||
<div class="t2">
|
||||
<span>原价:¥{{ formatDecimal(props.amount) }}</span>
|
||||
<span>原价:¥{{ formatDecimal(props.amount - goodsStore.tableInfo.tableFee) }}</span>
|
||||
<span style="margin-left: 20px">餐位费:¥{{ formatDecimal(goodsStore.tableInfo.tableFee) }}</span>
|
||||
<span style="margin-left: 20px">优惠:¥{{ formatDecimal(props.amount - money) }}</span>
|
||||
<span style="margin-left: 20px" v-if="props.discount" @click="cancelDiscount">折扣:{{
|
||||
formatDecimal(props.discount * 10, 1, true) }}折
|
||||
<span style="margin-left: 20px" v-if="discountRateVlaue" @click="cancelDiscount">
|
||||
折扣:{{ discountRateVlaue }}折
|
||||
<el-icon style="margin-left: 6px">
|
||||
<CircleClose />
|
||||
</el-icon>
|
||||
@@ -27,7 +28,7 @@
|
||||
</div>
|
||||
<span class="title">{{ item.payName }}</span>
|
||||
</div>
|
||||
<!-- <div class="item" :class="{ active: payActive == 'buyer' }"
|
||||
<div class="item" :class="{ active: payActive == 'buyer' }"
|
||||
@click="payTypeChange('buyer', { payType: 'buyer' })">
|
||||
<div class="icon">
|
||||
<div class="img"
|
||||
@@ -36,10 +37,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<span class="title">挂账</span>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="input_wrap">
|
||||
<div class="input" style="flex: 1">储值:¥{{ money }}</div>
|
||||
<div class="input" style="flex: 1">付款:¥{{ money }}</div>
|
||||
<el-button type="primary" style="width: 120px;border-radius: 6px; height: 60px;"
|
||||
@click="showCouponHandle">添加优惠</el-button>
|
||||
</div>
|
||||
@@ -99,7 +100,7 @@
|
||||
:total="Number(tableData.total)" v-model:current-page="tableData.page" @current-change="getMemberList" />
|
||||
</el-dialog>
|
||||
<!-- 选择挂账人员 -->
|
||||
<el-dialog title="挂账" top="3vh" v-model="showBuyer" width="90%" @closed="resetBuyerTable">
|
||||
<el-dialog title="挂账" top="1vh" v-model="showBuyer" width="90%" @closed="resetBuyerTable">
|
||||
<el-form inline>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入挂账人或手机号搜索" v-model="buyerTable.keywords" />
|
||||
@@ -110,7 +111,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="buyerTable.list" height="440px" border stripe v-loading="buyerTable.loading">
|
||||
<el-table-column prop="debtor" label="挂账人" />
|
||||
<el-table-column prop="debtor" label="挂账人" width="100px" />
|
||||
<el-table-column prop="mobile" label="手机" width="150px" />
|
||||
<el-table-column prop="position" label="职位" width="120px" />
|
||||
<el-table-column prop="repaymentMethod" label="还款方式" width="160px">
|
||||
@@ -143,49 +144,128 @@
|
||||
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
|
||||
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
||||
</el-dialog>
|
||||
<el-dialog v-model="showCoupon" title="添加优惠">
|
||||
<el-form ref="couponFormRef" :model="couponForm">
|
||||
<el-form-item label="会员">
|
||||
<el-select>
|
||||
<el-option label="会员1" value="1"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-dialog v-model="showCoupon" title="添加优惠" @open="couponDialogOpen" @closed="resetCouponFormHandle" top="5vh"
|
||||
width="80%">
|
||||
<div class="coupom_dialog">
|
||||
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
||||
<el-form-item label="整单折扣">
|
||||
<el-input v-model="couponForm.discountRatio" placeholder="请输入折扣" style="width: 180px;"
|
||||
@input="discountInput">
|
||||
<template #append>折</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择会员">
|
||||
<div class="flex">
|
||||
<div class="select_wrap">
|
||||
<el-select placeholder="请选择会员" readonly v-model="couponFormUser.userId"
|
||||
@click="SelectVipUserRef.show()" style="width: 100%;">
|
||||
<el-option :label="item.nickName" :value="item.id" v-for="item in couponFormUserList"
|
||||
:key="item.id"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
<el-button type="danger" @click="clearCouponUser">清除</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券">
|
||||
<div style="width: 100%;">
|
||||
<el-button type="primary" :disabled="!couponFormUser.id"
|
||||
@click="showCounponModalHandle">选择优惠券</el-button>
|
||||
<div>
|
||||
<div class="title">优惠券</div>
|
||||
<el-table :data="couponResList1" border stripe>
|
||||
<el-table-column label="名称" prop="name"></el-table-column>
|
||||
<el-table-column label="抵扣" prop="discountAmount"></el-table-column>
|
||||
<el-table-column label="限制" prop="fullAmount">
|
||||
<template v-slot="scope">
|
||||
满{{ scope.row.fullAmount }}减{{ scope.row.discountAmount }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="描述" prop="useRestrictions">
|
||||
<template v-slot="scope">
|
||||
<div v-html="scope.row.useRestrictions"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="110" align="center">
|
||||
<template v-slot="scope">
|
||||
<el-button type="danger" @click="delCoupon(scope.$index, 1)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div>
|
||||
<div class="title">商品券</div>
|
||||
<el-table :data="couponResList2" border stripe>
|
||||
<el-table-column label="名称" prop="name"></el-table-column>
|
||||
<el-table-column label="商品信息">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.productName }} ¥{{ scope.row.lowPrice }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="描述" prop="useRestrictions">
|
||||
<template v-slot="scope">
|
||||
<div v-html="scope.row.useRestrictions"></div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="110" align="center">
|
||||
<template v-slot="scope">
|
||||
<el-button type="danger" @click="delCoupon(scope.$index, 2)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="积分抵扣">
|
||||
<el-input v-model="couponForm.pointsNum"
|
||||
:disabled="!couponFormUser.id || !pointOptions.usable || couponForm.amount < pointOptions.minPaymentAmount"
|
||||
:placeholder="pointOptions.usable ? '请输入需要抵扣的积分' : pointOptions.unusableReason"
|
||||
v-loading="pointOptions.loading" @input="pointInput">
|
||||
<template #prepend>现有积分:{{ couponFormUser.accountPoints || 0 }}</template>
|
||||
<template #append>可抵扣金额:¥{{ pointOptions.amount || 0 }}</template>
|
||||
</el-input>
|
||||
<div class="point_tips err"
|
||||
v-if="couponFormUser.id && couponForm.amount < pointOptions.minPaymentAmount">注意:订单金额不足¥{{
|
||||
formatDecimal(+pointOptions.minPaymentAmount) }},无法使用积分抵扣
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠完">
|
||||
<div class="res">
|
||||
<span class="i">¥</span> <span class="n">{{ formatDecimal(+couponForm.amount) }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="dialog_footer" style="display: flex;justify-content: flex-end;">
|
||||
<el-button @click="showCoupon = false">取消</el-button>
|
||||
<el-button type="primary" @click="discountConfirm">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!-- 选择会员 -->
|
||||
<SelectVipUser ref="SelectVipUserRef" @success="selectUserHandle" />
|
||||
<!-- 选择优惠券 -->
|
||||
<CouponModal ref="CouponModalRef" :orderList="props.orderList" @success="CouponModalSuccess" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref, computed, watch, reactive } from "vue";
|
||||
import {
|
||||
queryPayType,
|
||||
accountPay,
|
||||
vipPay,
|
||||
buyerPage,
|
||||
payCreditPay,
|
||||
} from "@/api/pay";
|
||||
import {
|
||||
queryMembermember,
|
||||
createMembermember,
|
||||
membermemberScanPay,
|
||||
accountPaymember,
|
||||
} from "@/api/member/index.js";
|
||||
import _ from 'lodash'
|
||||
import { onMounted, ref, reactive, watch } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { clearNoNum, formatDecimal } from "@/utils";
|
||||
|
||||
import { clearNoNum, formatDecimal, inputFilterInt, inputFilterFloat } from "@/utils";
|
||||
import { getPayType } from "@/api/account.js";
|
||||
|
||||
import scanModal from "@/components/payCard/scanModal.vue";
|
||||
import SelectVipUser from '@/components/selectVipUser.vue'
|
||||
import CouponModal from '@/components/payCard/couponModal.vue'
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useGlobal } from "@/store/global.js";
|
||||
import { staffPermission } from "@/api/user.js";
|
||||
import { cashPay } from "@/api/order.js";
|
||||
|
||||
import { cashPay, buyerPage, creditPay, vipPay } from "@/api/order.js";
|
||||
import { calcUsablePoints, calcDeductionAmount } from '@/api/account.js'
|
||||
import { useGoods } from "@/store/goods.js";
|
||||
|
||||
const SelectVipUserRef = ref(null)
|
||||
const CouponModalRef = ref(null)
|
||||
const goodsStore = useGoods();
|
||||
|
||||
const global = useGlobal();
|
||||
|
||||
const store = useUser();
|
||||
|
||||
const props = defineProps({
|
||||
@@ -198,32 +278,24 @@ const props = defineProps({
|
||||
default: 0,
|
||||
},
|
||||
orderId: {
|
||||
type: [String, Number],
|
||||
default: "",
|
||||
},
|
||||
discount: {
|
||||
type: [String, Number],
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["paySuccess", "cancelDiscount"]);
|
||||
|
||||
const money = ref("0");
|
||||
const scanModalRef = ref(null);
|
||||
|
||||
watch(props, (value) => {
|
||||
money.value = `${formatDecimal(props.amount)}`;
|
||||
if (props.discount > 0) {
|
||||
money.value = `${formatDecimal(props.amount * props.discount)}`;
|
||||
orderList: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
});
|
||||
|
||||
// const waitPayMoney = computed(() => {
|
||||
// let num = JSON.stringify(props.amount - money.value)
|
||||
// num = Math.floor(num * 100) / 100
|
||||
// return num
|
||||
// })
|
||||
watch(props, () => {
|
||||
money.value = formatDecimal(props.amount)
|
||||
})
|
||||
|
||||
const emit = defineEmits(["paySuccess"]);
|
||||
|
||||
const money = ref("0");
|
||||
const discountRateVlaue = ref(0)
|
||||
const scanModalRef = ref(null);
|
||||
|
||||
const payActive = ref(0);
|
||||
const payType = ref("");
|
||||
@@ -231,6 +303,8 @@ const payList = ref([]);
|
||||
const payLoading = ref(false);
|
||||
const payData = ref({});
|
||||
|
||||
const roundAmount = ref(0) // 抹零金额
|
||||
|
||||
// 挂账人 start
|
||||
const showBuyer = ref(false);
|
||||
const buyerTable = reactive({
|
||||
@@ -248,7 +322,7 @@ function showBuyerHandle() {
|
||||
getBuyerList();
|
||||
}
|
||||
|
||||
//
|
||||
// 重置
|
||||
function resetBuyerTable() {
|
||||
buyerTable.keywords = "";
|
||||
buyerTable.page = 1;
|
||||
@@ -262,19 +336,17 @@ async function getBuyerList() {
|
||||
const res = await buyerPage({
|
||||
page: buyerTable.page,
|
||||
size: buyerTable.size,
|
||||
shopId: store.userInfo.shopId,
|
||||
keywords: buyerTable.keywords,
|
||||
status: 1,
|
||||
responsiblePerson: "",
|
||||
repaymentStatus: "",
|
||||
});
|
||||
buyerTable.loading = false;
|
||||
buyerTable.list = res.list;
|
||||
buyerTable.total = res.total;
|
||||
buyerTable.list = res.records;
|
||||
buyerTable.total = res.totalRow;
|
||||
} catch (error) {
|
||||
buyerTable.loading = false;
|
||||
console.log(error);
|
||||
}
|
||||
buyerTable.loading = false;
|
||||
}
|
||||
|
||||
// 选择挂账人支付
|
||||
@@ -282,17 +354,12 @@ async function payCreditPayHandle(row) {
|
||||
try {
|
||||
payLoading.value = true;
|
||||
buyerTable.loading = true;
|
||||
const res = await payCreditPay({
|
||||
creditBuyerId: row.id,
|
||||
orderId: props.orderId,
|
||||
payAmount: props.discount > 0 ? money.value : "",
|
||||
discountAmount:
|
||||
props.discount > 0 ? formatDecimal(props.amount - money.value) : "",
|
||||
});
|
||||
|
||||
payData.value.creditBuyerId = row.id
|
||||
await creditPay(payData.value);
|
||||
showBuyer.value = false;
|
||||
payLoading.value = false;
|
||||
buyerTable.loading = false;
|
||||
ElMessage.success("支付成功");
|
||||
emit("paySuccess");
|
||||
} catch (error) {
|
||||
buyerTable.loading = false;
|
||||
@@ -338,17 +405,13 @@ async function payTypeChange(index, item) {
|
||||
async function confirmOrder() {
|
||||
try {
|
||||
payLoading.value = true;
|
||||
// 暂时使用现金支付
|
||||
|
||||
payData.value.checkOrderPay.orderAmount = formatDecimal(+money.value);
|
||||
payData.value.checkOrderPay.roundAmount = formatDecimal(props.amount - money.value);
|
||||
payData.value.checkOrderPay.userId = goodsStore.vipUserInfo.userId ? goodsStore.vipUserInfo.userId : "";
|
||||
payData.value.checkOrderPay.roundAmount = roundAmount.value;
|
||||
payData.value.checkOrderPay.vipPrice = goodsStore.vipUserInfo.userId ? 1 : 0;
|
||||
await cashPay(payData.value);
|
||||
payLoading.value = false;
|
||||
emit("paySuccess");
|
||||
return;
|
||||
await staffPermission("yun_xu_shou_kuan");
|
||||
if (payLoading.value) return;
|
||||
payData.value.checkOrderPay.couponList = [...couponResList1.value.map(item => item.id), ...couponResList2.value.map(item => item.id)];
|
||||
|
||||
// await staffPermission("yun_xu_shou_kuan");
|
||||
if (payActive.value == "buyer") {
|
||||
showBuyerHandle();
|
||||
} else if (payList.value[payActive.value].payType == "scanCode") {
|
||||
@@ -357,40 +420,16 @@ async function confirmOrder() {
|
||||
// if (money.value < props.amount) return
|
||||
payLoading.value = true;
|
||||
switch (payList.value[payActive.value].payType) {
|
||||
case "deposit": //储值卡
|
||||
// if (props.selecttype == 1) {
|
||||
|
||||
// } else {
|
||||
|
||||
// }
|
||||
if (global.orderMemberInfo.id) {
|
||||
await accountPay({
|
||||
orderId: props.orderId,
|
||||
memberId: global.orderMemberInfo.id,
|
||||
memberAccount: "",
|
||||
});
|
||||
} else {
|
||||
payLoading.value = false;
|
||||
scanModalRef.value.show();
|
||||
return;
|
||||
}
|
||||
case "deposit":
|
||||
// 会员码支付
|
||||
payLoading.value = false;
|
||||
scanModalRef.value.show();
|
||||
break;
|
||||
case "cash": //现金
|
||||
if (props.selecttype == 1) {
|
||||
await accountPaymember({
|
||||
shopId: store.userInfo.shopId,
|
||||
memberId: props.orderId,
|
||||
amount: props.amount,
|
||||
});
|
||||
case "cash":
|
||||
//现金
|
||||
if (props.selecttype == 0) {
|
||||
await cashPay(payData.value);
|
||||
} else {
|
||||
await cashPay({
|
||||
orderId: props.orderId,
|
||||
payAmount: props.discount > 0 ? money.value : "",
|
||||
discountAmount:
|
||||
props.discount > 0
|
||||
? formatDecimal(props.amount - money.value)
|
||||
: "",
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "vipPay":
|
||||
@@ -404,7 +443,6 @@ async function confirmOrder() {
|
||||
break;
|
||||
}
|
||||
payLoading.value = false;
|
||||
ElMessage.success("支付成功");
|
||||
emit("paySuccess");
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -417,10 +455,13 @@ async function confirmOrder() {
|
||||
// 输入
|
||||
function amountInput(num) {
|
||||
if (money.value + num <= props.amount) {
|
||||
money.value = clearNoNum({ value: (money.value += num) });
|
||||
money.value = clearNoNum({ value: (money.value += num) })
|
||||
} else {
|
||||
money.value = clearNoNum({ value: `${props.amount}` });
|
||||
money.value = formatDecimal(+props.amount);
|
||||
}
|
||||
|
||||
roundAmount.value = formatDecimal(props.amount - money.value)
|
||||
console.log('roundAmount.value', roundAmount.value);
|
||||
}
|
||||
|
||||
// 删除
|
||||
@@ -430,6 +471,9 @@ function delHandle() {
|
||||
if (!money.value) {
|
||||
money.value = "0";
|
||||
}
|
||||
|
||||
roundAmount.value = formatDecimal(props.amount - money.value)
|
||||
console.log('roundAmount.value', roundAmount.value);
|
||||
}
|
||||
|
||||
// 获取支付方式
|
||||
@@ -445,10 +489,10 @@ async function queryPayTypeAjax() {
|
||||
}
|
||||
});
|
||||
|
||||
payList.value = res;
|
||||
if (res[0].payType == "scanCode" && !res[0].disabled) {
|
||||
payList.value = res.filter(item => item.isDisplay);
|
||||
if (payList.value[0].payType == "scanCode" && !payList.value[0].disabled) {
|
||||
scanModalRef.value.show();
|
||||
payType.value = res[0].payType;
|
||||
payType.value = payList.value[0].payType;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
@@ -517,56 +561,337 @@ async function toHomeMember(row) {
|
||||
|
||||
// 取消折扣
|
||||
function cancelDiscount() {
|
||||
emit("cancelDiscount");
|
||||
discountRateVlaue.value = 0
|
||||
money.value = formatDecimal(props.amount)
|
||||
}
|
||||
|
||||
/** 添加优惠 start */
|
||||
const showCoupon = ref(false)
|
||||
const couponFormRef = ref(null)
|
||||
const couponForm = ref({
|
||||
userId: '',
|
||||
discountRatio: '',
|
||||
const couponFormUser = ref('')
|
||||
const couponFormUserList = ref([])
|
||||
const couponFormDiscountRate = ref(10)
|
||||
const couponResType = ref('')
|
||||
const couponResList1 = ref([])
|
||||
const couponResList2 = ref([])
|
||||
|
||||
const pointOptions = ref({
|
||||
min: 0,
|
||||
max: 0,
|
||||
minPaymentAmount: 0,
|
||||
usable: true,
|
||||
unusableReason: '',
|
||||
amount: 0,
|
||||
loading: false
|
||||
})
|
||||
|
||||
const couponForm = ref({
|
||||
originAmount: 0,
|
||||
discountRatio: "",
|
||||
pointsNum: '',
|
||||
amount: '',
|
||||
coupon: '',
|
||||
productCouponDiscountAmount: 0,
|
||||
fullCouponDiscountAmount: 0,
|
||||
couponList: []
|
||||
})
|
||||
|
||||
const resetCouponForm = ref('')
|
||||
|
||||
// 清除已选择的用户
|
||||
function clearCouponUser() {
|
||||
couponFormUser.value = ''
|
||||
couponFormUserList.value = []
|
||||
resetCouponFormHandle()
|
||||
}
|
||||
|
||||
// 折扣格式化
|
||||
function discountInput(e) {
|
||||
couponForm.value.amount = couponForm.value.originAmount
|
||||
setTimeout(() => {
|
||||
couponForm.value.discountRatio = inputFilterFloat(e)
|
||||
if (couponForm.value.discountRatio > 9.9) {
|
||||
couponForm.value.discountRatio = 9.9
|
||||
}
|
||||
if (couponForm.value.discountRatio < 0.1) {
|
||||
couponForm.value.discountRatio = 0.1
|
||||
}
|
||||
|
||||
if (couponForm.value.discountRatio) {
|
||||
couponForm.value.amount = formatDecimal(couponForm.value.amount * (couponForm.value.discountRatio / couponFormDiscountRate.value))
|
||||
} else {
|
||||
couponForm.value.amount = formatDecimal(+couponForm.value.originAmount)
|
||||
}
|
||||
|
||||
// 将优惠券/积分所有设置初始化
|
||||
couponResList1.value = []
|
||||
couponResList2.value = []
|
||||
|
||||
couponForm.value.pointsNum = ''
|
||||
pointOptions.value.amount = 0
|
||||
}, 50)
|
||||
}
|
||||
|
||||
// 积分输入格式化
|
||||
function pointInput(e) {
|
||||
setTimeout(() => {
|
||||
couponForm.value.pointsNum = inputFilterInt(e)
|
||||
// 若如果大于最大值
|
||||
if (couponForm.value.pointsNum > pointOptions.value.max) {
|
||||
couponForm.value.pointsNum = pointOptions.value.max
|
||||
}
|
||||
// 如果小于最大值
|
||||
if (couponForm.value.pointsNum < pointOptions.value.min) {
|
||||
couponForm.value.pointsNum = pointOptions.value.min
|
||||
}
|
||||
|
||||
if (!e) {
|
||||
couponForm.value.pointsNum = 0
|
||||
couponForm.value.amount = +couponForm.value.amount + +pointOptions.value.amount
|
||||
pointOptions.value.amount = 0
|
||||
}
|
||||
|
||||
// 满足条件式开始计算抵扣金额,由后端返回
|
||||
if (couponForm.value.pointsNum >= pointOptions.value.min && couponForm.value.pointsNum <= pointOptions.value.max) {
|
||||
pointOptions.value.loading = true
|
||||
calcPointMoney()
|
||||
}
|
||||
}, 50)
|
||||
}
|
||||
|
||||
// 003-根据积分计算可抵扣金额
|
||||
const calcPointMoney = _.debounce(async function () {
|
||||
try {
|
||||
const res = await calcDeductionAmount({
|
||||
userId: couponFormUser.value.id,
|
||||
orderAmount: couponForm.value.amount,
|
||||
points: couponForm.value.pointsNum
|
||||
})
|
||||
pointOptions.value.amount = formatDecimal(+res)
|
||||
couponForm.value.amount = couponForm.value.amount - res
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
pointOptions.value.loading = false
|
||||
}, 500)
|
||||
|
||||
// 当dialog打开时
|
||||
function couponDialogOpen() {
|
||||
couponForm.value.amount = formatDecimal(money.value - goodsStore.tableInfo.tableFee)
|
||||
couponForm.value.originAmount = couponForm.value.amount
|
||||
resetCouponForm.value = { ...couponForm.value }
|
||||
|
||||
couponResList1.value = []
|
||||
couponResList2.value = []
|
||||
|
||||
// 当购物车已存在用户时
|
||||
if (goodsStore.vipUserInfo.id && goodsStore.showVipPrice) {
|
||||
couponFormUserList.value = [
|
||||
{
|
||||
id: goodsStore.vipUserInfo.userId,
|
||||
nickName: goodsStore.vipUserInfo.nickName,
|
||||
}
|
||||
]
|
||||
couponFormUser.value = goodsStore.vipUserInfo
|
||||
pointOptions()
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭后初始化dialog
|
||||
function resetCouponFormHandle() {
|
||||
couponForm.value = { ...resetCouponForm.value }
|
||||
}
|
||||
|
||||
// 选择会员完成后
|
||||
function selectUserHandle(row) {
|
||||
couponFormUserList.value = [
|
||||
{
|
||||
id: row.userId,
|
||||
nickName: row.nickName,
|
||||
}
|
||||
]
|
||||
couponFormUser.value = row
|
||||
pointOptionsAjax()
|
||||
|
||||
// 已存在选择的用户,并且切换了不通用户
|
||||
if (couponFormUser.id && row.userId != couponFormUser.value.userId) {
|
||||
resetCoupon()
|
||||
}
|
||||
}
|
||||
|
||||
// 重选用户后重置优惠券和积分,并重新计算价格
|
||||
function resetCoupon() {
|
||||
couponResList1.value = []
|
||||
couponResList2.value = []
|
||||
couponForm.value.amount = formatDecimal(couponForm.value.amount * (couponForm.value.discountRatio / couponFormDiscountRate.value))
|
||||
}
|
||||
|
||||
// 选择完用户后开始获取积分使用配置
|
||||
async function pointOptionsAjax() {
|
||||
try {
|
||||
const res = await calcUsablePoints({
|
||||
userId: couponFormUser.value.id,
|
||||
orderAmount: couponForm.value.amount
|
||||
})
|
||||
|
||||
pointOptions.value.min = res.minDeductionPoints // 最少使用积分
|
||||
pointOptions.value.max = res.maxUsablePoints // 最大使用积分
|
||||
pointOptions.value.usable = res.usable // 是否可用
|
||||
pointOptions.value.unusableReason = res.unusableReason // 不可用的原因
|
||||
pointOptions.value.minPaymentAmount = res.minPaymentAmount // 最少使用的金额
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示添加优惠
|
||||
function showCouponHandle() {
|
||||
showCoupon.value = true
|
||||
}
|
||||
|
||||
// 显示选择优惠券
|
||||
function showCounponModalHandle() {
|
||||
CouponModalRef.value.show(couponFormUser.value.id)
|
||||
}
|
||||
|
||||
// 选择完优惠券的回调事件
|
||||
function CouponModalSuccess(res) {
|
||||
console.log(res);
|
||||
couponResType.value = res.type
|
||||
if (res.type == 1) {
|
||||
if (couponForm.value.amount < res.couponList[0].fullAmount) {
|
||||
ElMessage.error(`订单金额不足¥${formatDecimal(res.couponList[0].fullAmount, 2, true)},无法使用优惠券`)
|
||||
return
|
||||
} else {
|
||||
couponResList1.value = res.couponList
|
||||
couponForm.value.amount = formatDecimal(couponForm.value.amount - res.couponList[0].discountAmount)
|
||||
couponForm.value.fullCouponDiscountAmount = res.couponList[0].discountAmount
|
||||
}
|
||||
} else {
|
||||
couponResList2.value = res.couponList
|
||||
const discountOrders = applyCoupons([...props.orderList], couponResList2.value)
|
||||
console.log('discountOrder===', discountOrders);
|
||||
|
||||
// 计算所有的优惠金额
|
||||
let amount = 0
|
||||
discountOrders.forEach(item => {
|
||||
if (item.isCoupon) {
|
||||
amount += item.price
|
||||
}
|
||||
})
|
||||
couponForm.value.productCouponDiscountAmount = amount
|
||||
couponForm.value.amount = formatDecimal(couponForm.value.amount - amount)
|
||||
}
|
||||
}
|
||||
|
||||
// 多个优惠券抵扣多个商品,优先已价格最低的抵扣
|
||||
const applyCoupons = (orders, coupons) => {
|
||||
// 遍历每张优惠券
|
||||
coupons.forEach(coupon => {
|
||||
// 筛选出订单列表中与当前优惠券 product_id 相同的商品
|
||||
const eligibleProducts = orders.filter(order => order.product_id == coupon.proId);
|
||||
// 对筛选出的商品按价格从小到大排序
|
||||
eligibleProducts.sort((a, b) => a.price - b.price);
|
||||
|
||||
let couponUsed = false; // 用于标记优惠券是否已使用
|
||||
|
||||
// 依次使用优惠券抵扣价格最低的商品
|
||||
eligibleProducts.forEach(product => {
|
||||
if (!couponUsed && !product.isCoupon) {
|
||||
product.isCoupon = true;
|
||||
couponUsed = true; // 标记优惠券已使用
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return orders;
|
||||
};
|
||||
|
||||
|
||||
// 删除优惠券
|
||||
function delCoupon(index, t) {
|
||||
if (t == 1) {
|
||||
couponForm.value.amount = +couponForm.value.amount + +couponResList1.value[index].discountAmount
|
||||
couponResList1.value.splice(index, 1)
|
||||
} else {
|
||||
// 恢复这个券的价格
|
||||
const price = props.orderList.find(item => item.product_id == couponResList2.value[index].proId).price
|
||||
couponForm.value.amount = +couponForm.value.amount + +price
|
||||
couponResList2.value.splice(index, 1)
|
||||
}
|
||||
console.log(couponForm.value.amount);
|
||||
}
|
||||
|
||||
// 确认优惠
|
||||
function discountConfirm() {
|
||||
// 确认折扣
|
||||
discountRateVlaue.value = couponForm.value.discountRatio || ''
|
||||
payData.value.checkOrderPay.discountAmount = couponForm.value.discountRatio ? formatDecimal(couponForm.value.originAmount - (couponForm.value.originAmount * (couponForm.value.discountRatio / couponFormDiscountRate.value))) : 0
|
||||
|
||||
if (couponFormUser.value.id) {
|
||||
payData.value.checkOrderPay.userId = couponFormUser.value.userId
|
||||
|
||||
// 确认积分
|
||||
payData.value.checkOrderPay.pointsNum = couponForm.value.pointsNum
|
||||
payData.value.checkOrderPay.pointsDiscountAmount = pointOptions.value.amount
|
||||
payData.value.checkOrderPay.productCouponDiscountAmount = couponForm.value.productCouponDiscountAmount
|
||||
}
|
||||
|
||||
payData.value.checkOrderPay.orderAmount = couponForm.value.amount
|
||||
|
||||
// 优惠完之后加上餐位费
|
||||
money.value = formatDecimal(+couponForm.value.amount + +goodsStore.tableInfo.tableFee)
|
||||
|
||||
payData.value.checkOrderPay.fullCouponDiscountAmount = couponForm.value.fullCouponDiscountAmount
|
||||
|
||||
showCoupon.value = false
|
||||
}
|
||||
/** 添加优惠 end */
|
||||
|
||||
onMounted(() => {
|
||||
// 初始化
|
||||
function reset() {
|
||||
roundAmount.value = 0
|
||||
discountRateVlaue.value = 0
|
||||
money.value = `${formatDecimal(props.amount)}`;
|
||||
payData.value = {
|
||||
shopId: store.shopInfo.id,
|
||||
buyerRemark: "", // 订单备注
|
||||
checkOrderPay: {
|
||||
orderId: goodsStore.orderListInfo.id,
|
||||
vipPrice: 0, // 是否使用会员价
|
||||
allPack: 0, // 是否整单打包
|
||||
vipPrice: store.shopInfo.isMemberPrice || goodsStore.showVipPrice, // 是否使用会员价
|
||||
allPack: goodsStore.allSelected, // 是否整单打包
|
||||
userId: goodsStore.vipUserInfo.id,
|
||||
seatNum: goodsStore.tableInfo.num, // 用餐人数
|
||||
originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
|
||||
discountRatio: '', // 折扣比例(计算时 向上取整保留 两位小数)
|
||||
discountAmount: 0, // 手动优惠金额
|
||||
productCouponDiscountAmount: 0, // 商品优惠券抵扣金额
|
||||
fullCouponDiscountAmount: 0, // 满减优惠券抵扣金额
|
||||
couponList: [], // 用户使用的卡券
|
||||
orderAmount: formatDecimal(
|
||||
+goodsStore.cartInfo.totalAmount - goodsStore.cartInfo.packFee
|
||||
), // 订单金额
|
||||
orderAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单金额
|
||||
roundAmount: 0, // 抹零金额 减免多少钱
|
||||
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: 0, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
queryPayTypeAjax();
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
reset
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.point_tips {
|
||||
&.err {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: var(--el-font-size-base);
|
||||
height: 100%;
|
||||
@@ -718,4 +1043,39 @@ onMounted(() => {
|
||||
font-size: calc(var(--el-font-size-base) + 10px);
|
||||
}
|
||||
}
|
||||
|
||||
.coupom_dialog {
|
||||
.title {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
gap: 10px;
|
||||
|
||||
.select_wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.res {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.i {
|
||||
font-size: 14px;
|
||||
position: relative;
|
||||
top: 4px;
|
||||
}
|
||||
|
||||
.n {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -58,7 +58,7 @@ import { scanpay, queryOrder, quickPay, queryQuickPayStatus, accountPay, querySc
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { formatDecimal } from '@/utils'
|
||||
import { microPay, queryOrderStatus, microPayVip } from '@/api/order.js'
|
||||
import { microPay, queryOrderStatus, microPayVip, vipPay } from '@/api/order.js'
|
||||
|
||||
const store = useUser();
|
||||
const global = useGlobal()
|
||||
@@ -89,6 +89,7 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
// 支付类型
|
||||
payType: {
|
||||
type: [Number, String],
|
||||
default: "",
|
||||
@@ -119,11 +120,20 @@ async function submitHandle() {
|
||||
if (!scanCode.value) return;
|
||||
loading.value = true;
|
||||
if (props.selecttype == 0) {
|
||||
// 正常下单扫码支付
|
||||
await microPay({
|
||||
...props.payData,
|
||||
authCode: scanCode.value
|
||||
});
|
||||
// 下单扫码支付
|
||||
if (props.payType == 'payType') {
|
||||
|
||||
await microPay({
|
||||
...props.payData,
|
||||
authCode: scanCode.value
|
||||
});
|
||||
} else if (props.payType == 'deposit') {
|
||||
await vipPay({
|
||||
...props.payData,
|
||||
payType: 'scanCode',
|
||||
authCode: scanCode.value
|
||||
});
|
||||
}
|
||||
} else if (props.selecttype == 1) {
|
||||
// 会员扫码充值
|
||||
await microPayVip({
|
||||
@@ -133,6 +143,7 @@ async function submitHandle() {
|
||||
authCode: scanCode.value
|
||||
})
|
||||
} else {
|
||||
// 快捷收银
|
||||
if (props.fast) {
|
||||
await quickPay({
|
||||
amount: props.amount,
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
<template>
|
||||
<el-dialog :title="`选择会员`" top="3vh" v-model="showDialog" width="80%">
|
||||
<el-dialog :title="`选择会员`" top="2vh" v-model="showDialog" width="80%">
|
||||
<el-form inline>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入手机号搜索会员" v-model="tableData.phone" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-select v-model="tableData.isVips" placeholder="是否为会员" style="width: 150px;" @change="resetTable">
|
||||
<el-option label="全部" value=""></el-option>
|
||||
<el-option label="是" :value="1"></el-option>
|
||||
<el-option label="否" :value="0"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getMemberList">搜索</el-button>
|
||||
<el-button @click="resetTable">重置</el-button>
|
||||
@@ -15,7 +22,7 @@
|
||||
<el-table-column prop="code" label="编号" width="120px" />
|
||||
<el-table-column prop="level" label="等级" />
|
||||
<el-table-column prop="accountPoints" label="积分" />
|
||||
<el-table-column prop="amount" label="余额" width="100px">
|
||||
<el-table-column prop="amount" label="余额" width="120px">
|
||||
<template v-slot="scope">
|
||||
¥{{ formatDecimal(scope.row.amount) }}
|
||||
</template>
|
||||
@@ -35,14 +42,12 @@
|
||||
import { ref, reactive } from 'vue'
|
||||
import { shopUserList } from "@/api/account.js";
|
||||
import { formatDecimal } from '@/utils/index.js'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
import { useUser } from '@/store/user.js'
|
||||
|
||||
const useStore = useUser()
|
||||
const goodsStore = useGoods()
|
||||
const emits = defineEmits(['success'])
|
||||
const showDialog = ref(false)
|
||||
const tableData = reactive({
|
||||
phone: '',
|
||||
isVips: "",
|
||||
loading: false,
|
||||
list: [],
|
||||
page: 1,
|
||||
@@ -50,15 +55,10 @@ const tableData = reactive({
|
||||
total: 0
|
||||
})
|
||||
|
||||
|
||||
// 选择会员去下单
|
||||
async function toHomeMember(row) {
|
||||
try {
|
||||
goodsStore.vipUserInfo = { ...row }
|
||||
if (useStore.shopInfo.isMemberPrice) {
|
||||
goodsStore.showVipPrice = true
|
||||
goodsStore.calcCartInfo()
|
||||
}
|
||||
emits('success', { ...row })
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ async function getMemberList() {
|
||||
tableData.loading = true
|
||||
const res = await shopUserList({
|
||||
key: tableData.phone,
|
||||
isVips: 1,
|
||||
isVips: tableData.isVips,
|
||||
page: tableData.page,
|
||||
size: tableData.size
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _, { update } from "lodash";
|
||||
import _ from "lodash";
|
||||
import { defineStore } from "pinia";
|
||||
import { productPage, categoryList } from "@/api/product_new.js";
|
||||
import { historyOrder } from "@/api/order.js";
|
||||
@@ -6,12 +6,12 @@ import { useUser } from "@/store/user.js";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
import useStorage from "@/utils/useStorage.js";
|
||||
import { formatDecimal } from "@/utils/index.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
// 商品store + 购物车store
|
||||
export const useGoods = defineStore("goods", {
|
||||
state: () => ({
|
||||
showVipPrice: false,
|
||||
allSelected: 0, // 是否整单打包
|
||||
vipUserInfo: {}, // 会员信息
|
||||
tableInfo: {
|
||||
name: "A1",
|
||||
@@ -331,6 +331,7 @@ export const useGoods = defineStore("goods", {
|
||||
.join("、");
|
||||
}
|
||||
|
||||
item.product_id = item.productId;
|
||||
item.lowPrice = val.lowPrice;
|
||||
item.sku_name = sku && sku.specInfo;
|
||||
item.group_type = val.groupType;
|
||||
@@ -385,13 +386,11 @@ export const useGoods = defineStore("goods", {
|
||||
this.operateCart({ table_code: tableCode }, "cleanup");
|
||||
},
|
||||
// 清空购物车回执操作
|
||||
successClearCart(clearOrder = false) {
|
||||
successClearCart() {
|
||||
this.cartList = [];
|
||||
this.cartInfo = {};
|
||||
if (clearOrder) {
|
||||
this.orderList = [];
|
||||
this.orderListInfo = "";
|
||||
}
|
||||
this.orderList = [];
|
||||
this.orderListInfo = "";
|
||||
this.calcCartInfo();
|
||||
},
|
||||
// 下单成功清除购物车,重新加载订单
|
||||
@@ -504,7 +503,9 @@ export const useGoods = defineStore("goods", {
|
||||
this.tableInfo.tableFee = tableFee;
|
||||
}
|
||||
|
||||
this.cartInfo.totalAmount = totalAmount + packFee;
|
||||
console.log("this.tableInfo.tableFee===", tableFee);
|
||||
|
||||
this.cartInfo.totalAmount = totalAmount + packFee + tableFee;
|
||||
|
||||
console.log("this.cartInfo===", this.cartInfo);
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { bySubType } from "@/api/device";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useShop } from "@/store/shop.js";
|
||||
import dayjs from "dayjs";
|
||||
import receiptPrint from "@/components/lodop/receiptPrint.js";
|
||||
import lodopPrintWork from "@/components/lodop/lodopPrintWork.js";
|
||||
import invoicePrint from "@/components/lodop/invoicePrint.js";
|
||||
import refundPrint from "@/components/lodop/refundPrint.js";
|
||||
import { printerList } from "@/api/account.js";
|
||||
|
||||
export const usePrint = defineStore("print", {
|
||||
state: () => ({
|
||||
@@ -22,8 +21,6 @@ export const usePrint = defineStore("print", {
|
||||
actions: {
|
||||
// 获取本地打印机和已添加的可以用打印机列表
|
||||
async init() {
|
||||
const store = useUser();
|
||||
|
||||
// 获取本地打印机
|
||||
ipcRenderer.send("getPrintList");
|
||||
ipcRenderer.on("printList", (event, arg) => {
|
||||
@@ -32,26 +29,24 @@ export const usePrint = defineStore("print", {
|
||||
this.localDevices = arg;
|
||||
});
|
||||
|
||||
// // 获取已添加的小票打印机
|
||||
// this.deviceNoteList = await bySubType({
|
||||
// shopId: store.userInfo.shopId,
|
||||
// contentType: "local",
|
||||
// subType: "cash",
|
||||
// });
|
||||
|
||||
// // 获取已添加的标签打印机
|
||||
// this.deviceLableList = await bySubType({
|
||||
// shopId: store.userInfo.shopId,
|
||||
// contentType: "local",
|
||||
// subType: "label",
|
||||
// });
|
||||
console.log("打印队列初始化成功");
|
||||
// 获取已添加的打印机
|
||||
const res = await printerList();
|
||||
this.deviceNoteList = res.records.filter(
|
||||
(item) => item.status && item.subType == "cash"
|
||||
);
|
||||
this.deviceLableList = res.records.filter(
|
||||
(item) => item.status && item.subType == "label"
|
||||
);
|
||||
console.log("打印队列初始化成功", {
|
||||
deviceNoteList: this.deviceNoteList,
|
||||
deviceLableList: this.deviceLableList,
|
||||
});
|
||||
},
|
||||
// 检查本地打印机是否能正常使用
|
||||
checkLocalPrint(deviceName) {
|
||||
checkLocalPrint(address) {
|
||||
let print = "";
|
||||
for (let item of this.localDevices) {
|
||||
if (item.name == deviceName) {
|
||||
if (item.name == address) {
|
||||
print = item;
|
||||
}
|
||||
}
|
||||
@@ -64,16 +59,13 @@ export const usePrint = defineStore("print", {
|
||||
},
|
||||
// 打印标签小票
|
||||
labelPrint(props) {
|
||||
const shopInfo = useShop();
|
||||
const store = useUser();
|
||||
|
||||
if (
|
||||
this.deviceLableList.length &&
|
||||
this.checkLocalPrint(this.deviceLableList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceLableList[0].address)
|
||||
) {
|
||||
let pids = this.deviceLableList[0].config.categoryList.map(
|
||||
(item) => item.id
|
||||
);
|
||||
|
||||
let pids = this.deviceLableList[0].categoryList;
|
||||
let count = 0;
|
||||
let sum = 0;
|
||||
|
||||
@@ -94,16 +86,19 @@ export const usePrint = defineStore("print", {
|
||||
name: item.name,
|
||||
skuName: item.skuName,
|
||||
masterId: props.orderInfo.tableName,
|
||||
deviceName: this.deviceLableList[0].config.deviceName,
|
||||
// deviceName: "Xprinter XP-T202UA",
|
||||
deviceName: this.deviceLableList[0].address,
|
||||
createdAt: dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss"),
|
||||
isPrint: false,
|
||||
count: `${count}/${sum}`,
|
||||
ticketLogo: shopInfo.info.ticketLogo,
|
||||
ticketLogo: store.shopInfo.ticketLogo,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log("this.labelList===", this.labelList);
|
||||
// return;
|
||||
|
||||
// 执行打印操作
|
||||
this.startLabelPrint();
|
||||
} else {
|
||||
@@ -133,38 +128,17 @@ export const usePrint = defineStore("print", {
|
||||
// console.log("pushReceiptData===", props);
|
||||
if (!isDevice) {
|
||||
// 测试打印,无需校验本地打印机
|
||||
const store = useUser();
|
||||
props.shop_name = store.userInfo.shopName;
|
||||
props.loginAccount = store.userInfo.loginAccount;
|
||||
props.createdAt = dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss");
|
||||
props.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
if (!props.orderInfo.masterId) {
|
||||
props.orderInfo.masterId = props.orderInfo.tableName;
|
||||
}
|
||||
props.orderInfo.outNumber = props.outNumber;
|
||||
|
||||
this.receiptList.push(props);
|
||||
this.startReceiptPrint();
|
||||
} else {
|
||||
props.deviceName = "MHT-POS58 2";
|
||||
if (!props.orderInfo.masterId) {
|
||||
props.orderInfo.masterId = props.orderInfo.tableName;
|
||||
}
|
||||
props.orderInfo.outNumber = props.outNumber;
|
||||
if (!props.discountAmount) {
|
||||
props.discountAmount = props.amount;
|
||||
}
|
||||
this.receiptList.push(props);
|
||||
this.startReceiptPrint();
|
||||
return;
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
const store = useUser();
|
||||
props.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
props.shop_name = store.userInfo.shopName;
|
||||
props.loginAccount = store.userInfo.loginAccount;
|
||||
props.deviceName = this.deviceNoteList[0].address;
|
||||
props.shop_name = store.shopInfo.shopName;
|
||||
props.loginAccount = store.userInfo.name;
|
||||
props.createdAt = dayjs(props.createdAt).format(
|
||||
"YYYY-MM-DD HH:mm:ss"
|
||||
);
|
||||
@@ -201,9 +175,9 @@ export const usePrint = defineStore("print", {
|
||||
printWork(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
data.address = this.deviceNoteList[0].address;
|
||||
lodopPrintWork(data);
|
||||
} else {
|
||||
console.log("交班小票:没有小票打印机");
|
||||
@@ -213,9 +187,9 @@ export const usePrint = defineStore("print", {
|
||||
printInvoice(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
data.address = this.deviceNoteList[0].address;
|
||||
invoicePrint(data);
|
||||
} else {
|
||||
console.log("订单发票:没有小票打印机");
|
||||
@@ -225,9 +199,9 @@ export const usePrint = defineStore("print", {
|
||||
printRefund(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
this.checkLocalPrint(this.deviceNoteList[0].address)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
data.address = this.deviceNoteList[0].address;
|
||||
refundPrint(data);
|
||||
} else {
|
||||
console.log("退单小票:没有小票打印机");
|
||||
|
||||
@@ -35,16 +35,18 @@ export const useSocket = defineStore("socket", {
|
||||
2000,
|
||||
{ leading: true, trailing: false }
|
||||
),
|
||||
cartInit(tableCode = "") {
|
||||
cartInit() {
|
||||
const store = useUser();
|
||||
const goodsStore = useGoods();
|
||||
|
||||
this.ws.send(
|
||||
JSON.stringify({
|
||||
type: "cashier",
|
||||
account: `cashier_${store.shopInfo.id}`,
|
||||
operate_type: "init",
|
||||
shop_id: store.shopInfo.id,
|
||||
table_code: goodsStore.tableInfo.tableCode,
|
||||
table_code:
|
||||
goodsStore.tableInfo.tableCode || useStorage.get("tableCode"),
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -84,9 +86,12 @@ export const useSocket = defineStore("socket", {
|
||||
let data = JSON.parse(e.data);
|
||||
if (data.operate_type == "init") {
|
||||
// console.log("接收消息", data);
|
||||
if (!goodsStore.tableInfo.tableCode) {
|
||||
useStorage.set("tableCode", data.table_code);
|
||||
}
|
||||
goodsStore.getCartList(data.data);
|
||||
}
|
||||
|
||||
|
||||
this.ws.send(
|
||||
JSON.stringify({
|
||||
type: "receipt",
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { login, shopStaffInfo, shopInfo_detail } from "@/api/account.js";
|
||||
import {
|
||||
login,
|
||||
shopStaffInfo,
|
||||
shopInfo_detail,
|
||||
logout,
|
||||
shopExtendDetail,
|
||||
} from "@/api/account.js";
|
||||
import useStorage from "@/utils/useStorage";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
|
||||
export const useUser = defineStore("user", {
|
||||
state: () => ({
|
||||
@@ -14,7 +21,9 @@ export const useUser = defineStore("user", {
|
||||
return login(param).then(async (res) => {
|
||||
this.token = res.tokenInfo.tokenValue;
|
||||
useStorage.set("token", this.token);
|
||||
useStorage.set("shopInfo", res.shopInfo);
|
||||
|
||||
const logo = await shopExtendDetail({ autoKey: "ticket_logo" });
|
||||
useStorage.set("shopInfo", { ...res.shopInfo, ticketLogo: logo.value });
|
||||
this.shopInfo = useStorage.get("shopInfo");
|
||||
return await this.shopStaffInfo();
|
||||
});
|
||||
@@ -33,11 +42,37 @@ export const useUser = defineStore("user", {
|
||||
async getShopInfo() {
|
||||
try {
|
||||
const res = await shopInfo_detail();
|
||||
useStorage.set("shopInfo", res);
|
||||
// 获取标签小票的logo
|
||||
const logo = await shopExtendDetail({ autoKey: "ticket_logo" });
|
||||
useStorage.set("shopInfo", { ...res, ticketLogo: logo.value });
|
||||
this.shopInfo = useStorage.get("shopInfo");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// 退出登录
|
||||
async logout() {
|
||||
try {
|
||||
const socket = useSocket();
|
||||
|
||||
await logout();
|
||||
useStorage.del("userInfo");
|
||||
useStorage.del("shopInfo");
|
||||
useStorage.del("token");
|
||||
useStorage.del("douyin");
|
||||
|
||||
this.userInfo = {};
|
||||
this.shopInfo = {};
|
||||
this.token = "";
|
||||
|
||||
socket.close();
|
||||
|
||||
setTimeout(() => {
|
||||
window.onload();
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -19,20 +19,29 @@ export function RandomNumBoth(Max, Min = 0) {
|
||||
* @param {Object} obj
|
||||
*/
|
||||
export function clearNoNum(obj) {
|
||||
//如果用户第一位输入的是小数点,则重置输入框内容
|
||||
// 如果用户第一位输入的是小数点,则重置输入框内容
|
||||
if (obj.value != "" && obj.value.substr(0, 1) == ".") {
|
||||
obj.value = "";
|
||||
}
|
||||
obj.value = obj.value.replace(/^0*(0\.|[1-9])/, "$1"); //粘贴不生效
|
||||
obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
|
||||
obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
|
||||
|
||||
// 去除数字前面多余的 0,但保留 0. 这种情况
|
||||
obj.value = obj.value.replace(/^0*(0\.|[1-9])/, "$1");
|
||||
|
||||
// 清除“数字”和“.”以外的字符
|
||||
obj.value = obj.value.replace(/[^\d.]/g, "");
|
||||
|
||||
// 只保留第一个. 清除多余的
|
||||
obj.value = obj.value.replace(/\.{2,}/g, ".");
|
||||
obj.value = obj.value
|
||||
.replace(".", "$#$")
|
||||
.replace(/\./g, "")
|
||||
.replace("$#$", ".");
|
||||
obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数
|
||||
|
||||
// 只能输入两个小数
|
||||
obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3");
|
||||
|
||||
if (obj.value.indexOf(".") < 0 && obj.value != "") {
|
||||
//以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
|
||||
// 以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02 的金额
|
||||
if (obj.value.substr(0, 1) == "0" && obj.value.length == 2) {
|
||||
obj.value = obj.value.substr(1, obj.value.length);
|
||||
}
|
||||
@@ -149,6 +158,7 @@ export async function getOrderByIdAjax(orderId) {
|
||||
export function commOrderPrintData(orderInfo) {
|
||||
const userStore = useUser();
|
||||
let data = {
|
||||
isBefore: orderInfo.isBefore || false,
|
||||
shop_name: userStore.shopInfo.shopName,
|
||||
loginAccount: userStore.userInfo.name,
|
||||
carts: [],
|
||||
@@ -160,7 +170,7 @@ export function commOrderPrintData(orderInfo) {
|
||||
remark: orderInfo.remark,
|
||||
orderInfo: orderInfo,
|
||||
outNumber: orderInfo.tableCode,
|
||||
createdAt: orderInfo.paidTime,
|
||||
createdAt: orderInfo.createTime,
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
|
||||
@@ -9,18 +9,18 @@ const service = axios.create({
|
||||
? "/api/"
|
||||
: import.meta.env.VITE_API_URL,
|
||||
// withCredentials: true, // 跨域请求时发送 cookies
|
||||
timeout: 10000, // 请求超时
|
||||
timeout: 20000, // 请求超时
|
||||
});
|
||||
|
||||
// 请求拦截器
|
||||
service.interceptors.request.use(
|
||||
(config) => {
|
||||
// 在发送请求之前做些什么 token
|
||||
config.headers["platformType"] = "PC";
|
||||
if (useStorage.get("token")) {
|
||||
// 让每个请求携带 token
|
||||
// ['X-Token'] 是自定义标题键
|
||||
// 请根据实际情况修改
|
||||
config.headers["platformType"] = 'PC';
|
||||
config.headers["token"] = useStorage.get("token");
|
||||
if (useStorage.get("shopInfo") && useStorage.get("shopInfo").id) {
|
||||
config.headers["shopId"] = useStorage.get("shopInfo").id;
|
||||
|
||||
@@ -9,10 +9,16 @@
|
||||
<div class="d_content">
|
||||
<div class="d_list">
|
||||
<el-form :model="form" label-position="left" label-width="60%">
|
||||
<el-form-item label="设备名称">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="打印机品牌">
|
||||
<el-input v-model="form.contentType" placeholder="请输入打印机品牌"></el-input>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="设备尺寸">
|
||||
<el-select v-model="form.config.width">
|
||||
<el-option label="58mm" value="58"></el-option>
|
||||
<el-option label="80mm" value="80"></el-option>
|
||||
<el-select v-model="form.receiptSize">
|
||||
<el-option label="58mm" value="58mm"></el-option>
|
||||
<el-option label="80mm" value="80mm"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型">
|
||||
@@ -22,15 +28,12 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择设备">
|
||||
<el-select v-model="form.config.deviceName">
|
||||
<el-select v-model="form.address">
|
||||
<el-option :label="item.name" :value="item.name" v-for="item in printList" :key="item.name"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="打印份数">
|
||||
<el-select v-model="form.config.printerNum">
|
||||
<!-- <el-form-item label="打印份数">
|
||||
<el-select v-model="form.printQty">
|
||||
<el-option :label="item" :value="item" v-for="item in 4" :key="item"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -56,13 +59,15 @@
|
||||
<el-select v-model="form.config.feet">
|
||||
<el-option :label="`${item}行`" :value="`${item}`" v-for="item in feets" :key="item"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="menu_wrap">
|
||||
<div class="print_view">
|
||||
<div class="title t1">{{ printData.shop_name }}</div>
|
||||
<div class="title t2">预结算单【{{ printData.orderInfo.masterId }}】</div>
|
||||
<div class="title t2">
|
||||
预结算单【{{ printData.orderInfo.masterId }}】
|
||||
</div>
|
||||
<div class="row">订单号:{{ printData.orderInfo.orderNo }}</div>
|
||||
<div class="row">交易时间:{{ printData.createdAt }}</div>
|
||||
<div class="row">收银员:{{ printData.loginAccount }}</div>
|
||||
@@ -96,17 +101,17 @@
|
||||
<div class="line"></div>
|
||||
<div class="row">备注:{{ printData.remark }}</div>
|
||||
<div class="row">打印时间:{{ printData.printTime }}</div>
|
||||
<div class="btn_wrap">
|
||||
<div class="btn">
|
||||
<el-button plain style="width: 100%" :loading="printDataLoading" @click="printHandle">
|
||||
打印测试小票
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%" :loading="loading" @click="submitHandle">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn_wrap">
|
||||
<div class="btn">
|
||||
<el-button plain style="width: 100%" :loading="printDataLoading" @click="printHandle">
|
||||
打印测试小票
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button type="primary" style="width: 100%" :loading="loading" @click="submitHandle">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,15 +120,15 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import dayjs from 'dayjs'
|
||||
import dayjs from "dayjs";
|
||||
import { ipcRenderer } from "electron";
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { tbPrintMachinePost, tbPrintMachineDetail } from "@/api/device";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { Loading } from "element-plus/es/components/loading/src/service";
|
||||
import { usePrint } from "@/store/print.js";
|
||||
import { printerAdd, printerDetail } from "@/api/account.js";
|
||||
|
||||
const printStore = usePrint();
|
||||
const store = useUser();
|
||||
@@ -136,59 +141,57 @@ const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
||||
const loading = ref(false);
|
||||
const form = ref({
|
||||
id: "",
|
||||
contentType: "",
|
||||
connectionType: "USB",
|
||||
config: {
|
||||
deviceName: "",
|
||||
width: "58", // 设备尺寸毫米mm
|
||||
printerNum: 1, //打印份数
|
||||
categoryList: [], // 商品分类
|
||||
model: "normal", // 出品模式,
|
||||
feet: "2",
|
||||
autoCut: 0,
|
||||
printSub: 1,
|
||||
},
|
||||
name: "小票打印机",
|
||||
subType: "cash", // 打印类型
|
||||
status: 1,
|
||||
sort: "",
|
||||
shopId: store.userInfo.shopId,
|
||||
name: '', // 设备名称
|
||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙
|
||||
address: '', // 打印机名称
|
||||
port: '', // 端口
|
||||
subType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
||||
contentType: '', // 打印机品牌
|
||||
categoryIds: [], // 打印分类Id
|
||||
categoryList: [], // 分类
|
||||
sort: '',
|
||||
receiptSize: '58mm', // 小票尺寸 58mm 80mm
|
||||
classifyPrint: 1, // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||
printQty: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||
printMethod: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||
printType: [], // 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
||||
status: 1
|
||||
});
|
||||
|
||||
const printDataLoading = ref(false)
|
||||
const printDataLoading = ref(false);
|
||||
const printData = reactive({
|
||||
shop_name: store.userInfo.shopName,
|
||||
loginAccount: store.userInfo.loginAccount,
|
||||
shop_name: '',
|
||||
loginAccount: '',
|
||||
isBefore: true,
|
||||
carts: [
|
||||
{
|
||||
id: 1,
|
||||
name: '【测试】娃哈哈矿泉水',
|
||||
skuName: '500ml',
|
||||
salePrice: '1.0',
|
||||
number: '10',
|
||||
totalAmount: '10'
|
||||
name: "【测试】娃哈哈矿泉水",
|
||||
skuName: "500ml",
|
||||
salePrice: "1.0",
|
||||
number: "10",
|
||||
totalAmount: "10",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '【测试】柠檬奶茶',
|
||||
skuName: '加冰、加珍珠',
|
||||
salePrice: '10',
|
||||
number: '2',
|
||||
totalAmount: '20'
|
||||
}
|
||||
name: "【测试】柠檬奶茶",
|
||||
skuName: "加冰、加珍珠",
|
||||
salePrice: "10",
|
||||
number: "2",
|
||||
totalAmount: "20",
|
||||
},
|
||||
],
|
||||
amount: '30.00',
|
||||
discountAmount: '30.00',
|
||||
amount: "30.00",
|
||||
discountAmount: "30.00",
|
||||
discount: 0,
|
||||
remark: '给我多放点辣椒,谢谢老板',
|
||||
remark: "给我多放点辣椒,谢谢老板",
|
||||
orderInfo: {
|
||||
masterId: '#002',
|
||||
orderNo: '202404021023542223445'
|
||||
masterId: "#002",
|
||||
orderNo: "202404021023542223445",
|
||||
},
|
||||
deviceName: '',
|
||||
createdAt: '2024-04-02 10:15',
|
||||
printTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
deviceName: "",
|
||||
createdAt: "2024-04-02 10:15",
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
});
|
||||
|
||||
// 获取打印机列表
|
||||
@@ -201,33 +204,33 @@ function getPrintList() {
|
||||
|
||||
// 测试打印
|
||||
function printHandle() {
|
||||
if (!form.value.config.deviceName) {
|
||||
if (!form.value.address) {
|
||||
ElMessage.warning("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
printDataLoading.value = true
|
||||
printData.deviceName = form.value.config.deviceName
|
||||
printData.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
printStore.pushReceiptData(printData, false)
|
||||
printDataLoading.value = true;
|
||||
printData.shop_name = store.shopInfo.shopName
|
||||
printData.loginAccount = store.userInfo.name
|
||||
printData.deviceName = form.value.address;
|
||||
printData.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
printStore.pushReceiptData(printData, false);
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false
|
||||
}, 1500)
|
||||
printDataLoading.value = false;
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
async function submitHandle() {
|
||||
try {
|
||||
if (!form.value.config.deviceName) {
|
||||
if (!form.value.address) {
|
||||
ElMessage.warning("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
Loading.value = true;
|
||||
await tbPrintMachinePost(form.value, form.value.id ? "put" : "post");
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
Loading.value = false;
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
|
||||
printStore.init();
|
||||
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
@@ -235,9 +238,9 @@ async function submitHandle() {
|
||||
}
|
||||
|
||||
// 查询打印机详情
|
||||
async function tbPrintMachineDetailAjax() {
|
||||
async function tbPrintMachineDetailAjax(id) {
|
||||
try {
|
||||
const res = await tbPrintMachineDetail(route.query.id);
|
||||
const res = await printerDetail({ id: id });
|
||||
form.value = res;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
@@ -245,6 +248,9 @@ async function tbPrintMachineDetailAjax() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
printData.shop_name = store.shopInfo.shopName
|
||||
printData.loginAccount = store.userInfo.name
|
||||
|
||||
getPrintList();
|
||||
if (route.query.id) {
|
||||
tbPrintMachineDetailAjax(route.query.id);
|
||||
@@ -282,13 +288,26 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.menu_wrap {
|
||||
flex: 1.5;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
margin-left: 15px;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
padding: 0 15px;
|
||||
|
||||
.btn_wrap {
|
||||
display: flex;
|
||||
gap: var(--el-font-size-base);
|
||||
padding: var(--el-font-size-base) 0;
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.print_view {
|
||||
flex: 1;
|
||||
padding: 20px 0;
|
||||
|
||||
.title {
|
||||
@@ -314,15 +333,6 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.btn_wrap {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
padding: 20px 0;
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
margin: 10px 0;
|
||||
|
||||
@@ -9,12 +9,15 @@
|
||||
<div class="d_content">
|
||||
<div class="d_list">
|
||||
<el-form :model="form" label-position="left" label-width="60%">
|
||||
<!-- <el-form-item label="设备尺寸">
|
||||
<el-select v-model="form.config.width">
|
||||
<el-option label="58mm" value="58"></el-option>
|
||||
<el-option label="80mm" value="80"></el-option>
|
||||
<el-form-item label="设备名称">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备尺寸">
|
||||
<el-select v-model="form.receiptSize">
|
||||
<el-option label="58mm" value="58mm"></el-option>
|
||||
<el-option label="80mm" value="80mm"></el-option>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型">
|
||||
<el-select v-model="form.connectionType">
|
||||
<el-option label="USB" value="USB"></el-option>
|
||||
@@ -22,30 +25,16 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择设备">
|
||||
<el-select v-model="form.config.deviceName">
|
||||
<el-select v-model="form.address">
|
||||
<el-option :label="item.name" :value="item.name" v-for="item in printList" :key="item.name"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备名称">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="打印份数">
|
||||
<el-select v-model="form.config.printerNum">
|
||||
<el-option :label="item" :value="item" v-for="item in 4" :key="item"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品模式">
|
||||
<el-select v-model="form.config.model">
|
||||
<el-option label="普通出单" value="normal"></el-option>
|
||||
<el-option label="分类出单" value="category"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类">
|
||||
<div style="cursor: pointer" @click="classifyRef.show()">
|
||||
<span style="color: #409eff" v-for="item in form.config.categoryList">
|
||||
{{ item.name }},
|
||||
<span style="color: #409eff" v-if="form.categoryList.length">
|
||||
{{form.categoryList.map(item => item.name).join(',')}}
|
||||
</span>
|
||||
<span style="color: #e65d6e" v-if="!form.config.categoryList.length">
|
||||
<span style="color: #e65d6e" v-else>
|
||||
请选择分类
|
||||
</span>
|
||||
</div>
|
||||
@@ -78,7 +67,7 @@
|
||||
<div class="print_view">
|
||||
<canvas class="ewm" ref="canvasRef"></canvas>
|
||||
<div class="header">
|
||||
<img class="logo" :src="shopInfo.info.ticketLogo" />
|
||||
<img class="logo" :src="printData.ticketLogo" />
|
||||
<!-- <span class="title">双屿Pisces</span> -->
|
||||
</div>
|
||||
<div class="number_wrap">
|
||||
@@ -107,7 +96,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<classify ref="classifyRef" @success="(e) => (form.config.categoryList = e)" />
|
||||
<classify ref="classifyRef" @success="(e) => (form.categoryList = e)" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -116,21 +105,19 @@ import { ipcRenderer } from "electron";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { ElMessage, dayjs } from "element-plus";
|
||||
import { tbPrintMachinePost, tbPrintMachineDetail } from "@/api/device";
|
||||
import { printerAdd, printerDetail } from "@/api/account.js";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { Loading } from "element-plus/es/components/loading/src/service";
|
||||
import classify from "@/components/classify/index.vue";
|
||||
import QRCode from 'qrcode'
|
||||
import { usePrint } from "@/store/print.js";
|
||||
import { useShop } from "@/store/shop.js";
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
const printStore = usePrint();
|
||||
|
||||
const store = useUser();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const shopInfo = useShop();
|
||||
|
||||
const classifyRef = ref(null);
|
||||
const printList = ref([]);
|
||||
@@ -138,23 +125,21 @@ const feets = ref([0, 1, 2, 3, 4, 5, 8]);
|
||||
const loading = ref(false);
|
||||
const form = ref({
|
||||
id: "",
|
||||
contentType: "",
|
||||
connectionType: "USB",
|
||||
config: {
|
||||
deviceName: "",
|
||||
width: "40", // 设备尺寸毫米mm
|
||||
printerNum: 1, //打印份数
|
||||
categoryList: [], // 商品分类
|
||||
model: "normal", // 出品模式,
|
||||
feet: "2",
|
||||
autoCut: 0,
|
||||
printSub: 1,
|
||||
},
|
||||
name: "标签打印机",
|
||||
subType: "label", // 打印类型
|
||||
status: 1,
|
||||
sort: "",
|
||||
shopId: store.userInfo.shopId,
|
||||
name: '', // 设备名称
|
||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙
|
||||
address: '', // 打印机名称
|
||||
port: '', // 端口
|
||||
subType: 'label', // 打印类型(分类)label标签cash小票kitchen出品
|
||||
contentType: '', // 打印机品牌
|
||||
categoryIds: [], // 打印分类Id
|
||||
categoryList: [], // 分类
|
||||
sort: '',
|
||||
receiptSize: '58mm', // 小票尺寸 58mm 80mm
|
||||
classifyPrint: 1, // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||
printQty: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||
printMethod: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||
printType: [], // 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
||||
status: 1
|
||||
});
|
||||
|
||||
const canvasRef = ref(null)
|
||||
@@ -165,7 +150,7 @@ const printData = ref({
|
||||
skuName: '测试、加珍珠',
|
||||
masterId: '#A9',
|
||||
createdAt: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
ticketLogo: shopInfo.info.ticketLogo,
|
||||
ticketLogo: store.shopInfo.ticketLogo,
|
||||
})
|
||||
|
||||
// 获取打印机列表
|
||||
@@ -178,11 +163,11 @@ function getPrintList() {
|
||||
|
||||
// 测试打印
|
||||
const printHandle = _.throttle(function () {
|
||||
if (!form.value.config.deviceName) {
|
||||
if (!form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
printData.value.deviceName = form.value.config.deviceName
|
||||
printData.value.deviceName = form.value.address
|
||||
ipcRenderer.send(
|
||||
"printerTagSync",
|
||||
JSON.stringify(printData.value)
|
||||
@@ -192,12 +177,13 @@ const printHandle = _.throttle(function () {
|
||||
// 提交打印机
|
||||
async function submitHandle() {
|
||||
try {
|
||||
if (!form.value.config.deviceName) {
|
||||
if (!form.value.address) {
|
||||
ElMessage.warning("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
Loading.value = true;
|
||||
await tbPrintMachinePost(form.value, form.value.id ? "put" : "post");
|
||||
form.value.categoryIds = form.value.categoryList.map(item => item.id)
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
Loading.value = false;
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
printStore.init();
|
||||
@@ -210,9 +196,21 @@ async function submitHandle() {
|
||||
// 查询打印机详情
|
||||
async function tbPrintMachineDetailAjax() {
|
||||
try {
|
||||
const res = await tbPrintMachineDetail(route.query.id);
|
||||
const res = await printerDetail({ id: route.query.id });
|
||||
form.value = res;
|
||||
printData.value.deviceName = res.config.deviceName
|
||||
|
||||
let arr = []
|
||||
goodsStore.originCategoryList.map(item => {
|
||||
res.categoryList.map(val => {
|
||||
if (item.id == val) {
|
||||
arr.push({
|
||||
id: item.id,
|
||||
name: item.name
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
form.value.categoryList = arr
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="name">{{ item.name }}</div>
|
||||
<div class="xh">{{ item.config.deviceName }}</div>
|
||||
<div class="xh">{{ item.address }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
@@ -114,20 +114,14 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
tbPrintMachineGet,
|
||||
tbPrintMachineDelete,
|
||||
tbPrintMachinePost,
|
||||
} from "@/api/device";
|
||||
import { printerList, printerAdd } from '@/api/account.js'
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
import icons from "./icons";
|
||||
import { usePrint } from "@/store/print.js";
|
||||
|
||||
const printStore = usePrint();
|
||||
const store = useUser();
|
||||
|
||||
const router = useRouter();
|
||||
const list = ref([]);
|
||||
@@ -142,7 +136,7 @@ const deviceRoute = ref({
|
||||
|
||||
async function statusChange(e, item) {
|
||||
try {
|
||||
await tbPrintMachinePost(item, "put");
|
||||
await printerAdd(item, "put");
|
||||
tbPrintMachineGetAjax();
|
||||
printStore.init();
|
||||
} catch (error) {
|
||||
@@ -160,7 +154,7 @@ function showDelete(item) {
|
||||
async function tbPrintMachineDeleteAjax() {
|
||||
try {
|
||||
delLoading.value = true;
|
||||
await tbPrintMachineDelete({ id: deleteId.value });
|
||||
await printerAdd({ id: deleteId.value }, 'delete');
|
||||
delLoading.value = false;
|
||||
dialogVisible.value = false;
|
||||
ElMessage.success("删除成功");
|
||||
@@ -174,12 +168,8 @@ async function tbPrintMachineDeleteAjax() {
|
||||
// 获取打印机列表
|
||||
async function tbPrintMachineGetAjax() {
|
||||
try {
|
||||
const res = await tbPrintMachineGet({
|
||||
shopId: store.userInfo.shopId,
|
||||
page: 0,
|
||||
pageSize: 100,
|
||||
});
|
||||
list.value = res.list;
|
||||
const res = await printerList();
|
||||
list.value = res.records;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted } from 'vue'
|
||||
import { formatDecimal } from '@/utils/index.js'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -91,10 +90,6 @@ const props = defineProps({
|
||||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
console.log('SettleItem===', props.list);
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -88,6 +88,9 @@
|
||||
v-if="goodsStore.orderList.length">
|
||||
历史下单
|
||||
</div>
|
||||
<CartItem
|
||||
:item="{ product_name: '客座费', number: goodsStore.tableInfo.num, lowPrice: store.shopInfo.tableFee, memberPrice: store.shopInfo.tableFee }"
|
||||
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.name && (goodsStore.cartList.length || goodsStore.orderList.length)" />
|
||||
<div class="order_list_item" v-for="(arr, index) in goodsStore.orderList" :key="index">
|
||||
<div class="order_num">{{ `第${arr.orderNum}次下单` }}</div>
|
||||
<CartItem type="order" :border="false" :item="item" :index="index" :i="i" :key="item.id"
|
||||
@@ -105,7 +108,7 @@
|
||||
<div class="num_wrap_top">
|
||||
<div class="left" @click="allSelectedHandle" v-if="store.shopInfo.eatModel.includes('take-out')">
|
||||
<div class="selected">
|
||||
<div class="selected_round" v-if="!allSelected"></div>
|
||||
<div class="selected_round" v-if="!goodsStore.allSelected"></div>
|
||||
<el-icon class="icon" v-else>
|
||||
<CircleCheckFilled />
|
||||
</el-icon>
|
||||
@@ -168,19 +171,12 @@
|
||||
<!-- 检查版本升级 -->
|
||||
<updateDialog />
|
||||
<!-- 选择会员 -->
|
||||
<SelectVipUser ref="SelectVipUserRef" />
|
||||
<SelectVipUser ref="SelectVipUserRef" @success="selectUser" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "home",
|
||||
};
|
||||
</script>
|
||||
<script setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { ref } from "vue";
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
|
||||
import SelectVipUser from "@/components/selectVipUser.vue";
|
||||
import updateDialog from '@/components/updateDialog.vue'
|
||||
import remarkModal from "@/components/remarkModal.vue";
|
||||
@@ -191,23 +187,18 @@ import fastCashier from "@/views/home/components/fastCashier.vue";
|
||||
import pendingCartModal from "@/views/home/components/pendingCartModal.vue";
|
||||
import tableMerging from '@/views/home/components/tableMerging.vue'
|
||||
import CartItem from './components/cartItem.vue'
|
||||
import useStorage from '@/utils/useStorage'
|
||||
import { formatDecimal, formatPhoneNumber } from '@/utils/index.js'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
|
||||
import { queryShopInfo, staffPermission } from '@/api/user.js'
|
||||
import { staffPermission } from '@/api/user.js'
|
||||
import { createOrder } from '@/api/order.js'
|
||||
|
||||
// 商品列表
|
||||
import goods from "@/views/home/components/goods.vue";
|
||||
import member from "@/views/member/index.vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useUser } from '@/store/user.js'
|
||||
|
||||
const SelectVipUserRef = ref(null)
|
||||
|
||||
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const global = useGlobal()
|
||||
|
||||
|
||||
@@ -220,9 +211,6 @@ const pendingCartModalRef = ref(null);
|
||||
const settleAccountRef = ref(null);
|
||||
const fastCashierRef = ref(null);
|
||||
const tableMergingRef = ref(null)
|
||||
|
||||
const allSelected = ref(false);
|
||||
|
||||
const remark = ref("");
|
||||
const cartListActive = ref(0);
|
||||
const cartListActiveItem = ref({})
|
||||
@@ -234,6 +222,14 @@ const orderInfo = ref({});
|
||||
const createOrderLoading = ref(false);
|
||||
|
||||
|
||||
function selectUser(row) {
|
||||
goodsStore.vipUserInfo = { ...row }
|
||||
if (store.shopInfo.isMemberPrice && row.isVip) {
|
||||
goodsStore.showVipPrice = true
|
||||
goodsStore.calcCartInfo()
|
||||
}
|
||||
}
|
||||
|
||||
// 挂单量
|
||||
const pendingCartNum = ref(0);
|
||||
|
||||
@@ -255,19 +251,18 @@ async function createOrderHandle(t = 0) {
|
||||
orderId: goodsStore.orderListInfo.id || '', // 订单id
|
||||
shopId: store.shopInfo.id, // 店铺id
|
||||
seatNum: goodsStore.tableInfo.num || 0, // 用餐人数
|
||||
seatAmount: goodsStore.cartInfo.tableFee, // 餐位费
|
||||
packFee: goodsStore.cartInfo.packFee, // 打包费
|
||||
originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount, 2, true), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
tableCode: goodsStore.cartList[0].table_code, // 台桌号
|
||||
dineMode: allSelected.value ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0], // 用餐方式
|
||||
dineMode: goodsStore.allSelected ? store.shopInfo.eatModel.split(',')[1] : store.shopInfo.eatModel.split(',')[0], // 用餐方式
|
||||
remark: remark.value, // 备注
|
||||
placeNum: (goodsStore.orderListInfo.placeNum || 0) + 1, // 下单次数
|
||||
waitCall: 0,//是否叫号
|
||||
userId: '', // 会员用户id
|
||||
vipPrice: 0, // 会员价
|
||||
waitCall: 0, // 是否叫号
|
||||
userId: goodsStore.vipUserInfo.userId, // 会员用户id
|
||||
}
|
||||
|
||||
createOrderLoading.value = true;
|
||||
goodsStore.calcCartInfo()
|
||||
const res = await createOrder(data)
|
||||
// 设置订单信息
|
||||
goodsStore.orderListInfo = res
|
||||
@@ -279,7 +274,6 @@ async function createOrderHandle(t = 0) {
|
||||
// 清除购物车,更新历史订单
|
||||
goodsStore.updateOrderList()
|
||||
} else {
|
||||
goodsStore.calcCartInfo()
|
||||
settleAccountRef.value.show(t)
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -321,7 +315,11 @@ function giftPackHandle(key, item) {
|
||||
|
||||
// 打包全选
|
||||
const allSelectedHandle = async () => {
|
||||
allSelected.value = !allSelected.value;
|
||||
if (goodsStore.allSelected) {
|
||||
goodsStore.allSelected = 0
|
||||
} else {
|
||||
goodsStore.allSelected = 1
|
||||
}
|
||||
};
|
||||
|
||||
// 购物车选中
|
||||
|
||||
@@ -145,9 +145,7 @@ const submitHandle = () => {
|
||||
loading.value = true;
|
||||
store
|
||||
.userlogin(form)
|
||||
.then(async (res) => {
|
||||
console.log(res);
|
||||
|
||||
.then(async (res) => {
|
||||
// 登录成功后保存商户号
|
||||
// useStorage.set('merchantLoginAccount', form.username)
|
||||
ElMessage.success("登录成功");
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-form-item label="退款金额" prop="amount">
|
||||
<el-input-number v-model="form.amount" :min="0.01" :max="form.max" placeholder="请输入退款金额" />
|
||||
<el-input-number v-model="form.amount" :max="form.max" placeholder="请输入退款金额" />
|
||||
<div class="tips" v-if="refundItem.giftAmount - refundItem.giftRefundAmount > 0">
|
||||
注意:一旦退款,赠送金额{{ refundItem.giftAmount }}也将全额退还</div>
|
||||
注意:一旦退款,优先扣除赠送金额</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="退款说明">
|
||||
<el-input v-model="form.remark" placeholder="请输入退款说明" />
|
||||
|
||||
@@ -23,11 +23,7 @@
|
||||
<div class="item">小计</div>
|
||||
</div>
|
||||
<div class="table_content">
|
||||
<div
|
||||
class="table_row"
|
||||
v-for="item in orderInfo.cartList"
|
||||
:key="item.id"
|
||||
>
|
||||
<div class="table_row" v-for="item in orderInfo.cartList" :key="item.id">
|
||||
<div v-if="item.productType == 'package'">
|
||||
<div class="flex">
|
||||
<div class="item">
|
||||
@@ -37,11 +33,7 @@
|
||||
{{ formatDecimal(item.payAmount) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex"
|
||||
v-for="val in item.proGroupInfo"
|
||||
:key="val.proId"
|
||||
>
|
||||
<div class="flex" v-for="val in item.proGroupInfo" :key="val.proId">
|
||||
<div class="item">>{{ val.proName }}</div>
|
||||
<div class="item">0.00</div>
|
||||
<div class="item">{{ val.number }}</div>
|
||||
@@ -84,21 +76,12 @@
|
||||
<template #footer>
|
||||
<div class="drawer_footer">
|
||||
<div class="btn">
|
||||
<el-button
|
||||
style="width: 100%"
|
||||
:loading="printLoading"
|
||||
@click="printHandle('label')"
|
||||
>
|
||||
<el-button style="width: 100%" :loading="printLoading" @click="printHandle('label')">
|
||||
打印标签
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button
|
||||
type="primary"
|
||||
style="width: 100%"
|
||||
:loading="printLoading"
|
||||
@click="printHandle('normal')"
|
||||
>
|
||||
<el-button type="primary" style="width: 100%" :loading="printLoading" @click="printHandle('normal')">
|
||||
打印小票
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -111,13 +94,11 @@
|
||||
import { ref } from "vue";
|
||||
import { usePrint } from "@/store/print.js";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { getOrderById } from "@/api/order.js";
|
||||
import {
|
||||
formatDecimal,
|
||||
getOrderByIdAjax,
|
||||
commOrderPrintData,
|
||||
} from "@/utils/index.js";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const userStore = useUser();
|
||||
const printStore = usePrint();
|
||||
@@ -135,6 +116,10 @@ function printHandle(type) {
|
||||
// 打印订单小票
|
||||
printStore.pushReceiptData(commOrderPrintData(orderInfo.value));
|
||||
break;
|
||||
case "label":
|
||||
// 打印标签小票
|
||||
printStore.labelPrint(commOrderPrintData(orderInfo.value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -164,52 +149,66 @@ defineExpose({
|
||||
padding-top: 20px;
|
||||
padding-bottom: 50px;
|
||||
color: #333;
|
||||
|
||||
.header {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.line {
|
||||
margin: 14px 0;
|
||||
border-bottom: 1px dashed #666;
|
||||
}
|
||||
|
||||
.blod {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-top: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.between {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.table {
|
||||
--itemWidth: 45px;
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.item {
|
||||
&:nth-child(1) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
&:nth-child(2) {
|
||||
width: var(--itemWidth);
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
width: var(--itemWidth);
|
||||
}
|
||||
|
||||
&:nth-child(4) {
|
||||
width: var(--itemWidth);
|
||||
}
|
||||
}
|
||||
|
||||
.table_head {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.table_row {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
<div class="cart_list">
|
||||
<div class="item" v-for="item in cartList" :key="item.id">
|
||||
<div class="top">
|
||||
<span class="name">{{ item.name }}</span>
|
||||
<span class="n">x{{ item.number }}</span>
|
||||
<span class="p">¥{{ item.salePrice }}</span>
|
||||
<span class="name">{{ item.productName }}</span>
|
||||
<span class="n">x{{ item.num }}</span>
|
||||
<span class="p">¥{{ item.price }}</span>
|
||||
</div>
|
||||
<div class="tag_wrap" v-if="item.skuName">
|
||||
<div class="tag" v-for="item in item.skuName.split(',')">
|
||||
@@ -93,6 +93,7 @@ import settleAccount from "@/views/home/components/settleAccount.vue";
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { clearTable } from '@/api/table.js'
|
||||
import { useGoods } from "@/store/goods.js";
|
||||
import { getOrderByIdAjax } from '@/utils/index.js'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
const router = useRouter()
|
||||
@@ -173,22 +174,14 @@ async function getOrderDetail() {
|
||||
try {
|
||||
if (props.tableInfo.orderId) {
|
||||
payLoading.value = true
|
||||
const res = await orderDetail({
|
||||
shopId: store.userInfo.shopId,
|
||||
id: props.tableInfo.orderId
|
||||
})
|
||||
const res = await getOrderByIdAjax(props.tableInfo.orderId)
|
||||
|
||||
console.log(res);
|
||||
|
||||
payLoading.value = false
|
||||
orderInfo.value = res
|
||||
|
||||
cartList.value = res.detailList.map(item => {
|
||||
let obj = {
|
||||
name: item.productName,
|
||||
number: item.num,
|
||||
salePrice: item.price,
|
||||
skuName: item.productSkuName
|
||||
}
|
||||
return obj
|
||||
})
|
||||
cartList.value = res.cartList
|
||||
}
|
||||
} catch (error) {
|
||||
payLoading.value = false
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="box_content_left_top_item">
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div style="color:#ff5252; font-size: 30px;">
|
||||
{{ infoData.orderNum || 0 }}
|
||||
{{ infoData.orderCount || 0 }}
|
||||
</div>
|
||||
<div style="margin-top: 6px; color: #666;">
|
||||
总订单
|
||||
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div style="color:#ff5252; font-size: 30px;">
|
||||
¥{{ formatDecimal(infoData.amount || 0) }}
|
||||
¥{{ formatDecimal(infoData.handAmount || 0) }}
|
||||
</div>
|
||||
<div style="margin-top: 6px; color: #666;">
|
||||
营业额
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
<div class="box_content_left_top_item_botton">
|
||||
<div style=" font-size: 20px;">
|
||||
¥{{ formatDecimal(infoData.returnAmount || 0) }}
|
||||
¥{{ formatDecimal(infoData.refundAmount || 0) }}
|
||||
</div>
|
||||
<div style="margin-top: 6px;">
|
||||
退款金额
|
||||
@@ -59,7 +59,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_left_bottom">
|
||||
<el-table :data="infoData.detailList" border style="width: 100%;" height="360px">
|
||||
<el-table :data="infoData.detailList" border style="width: 100%;" height="382px">
|
||||
<el-table-column prop="productName" label="商品名称" />
|
||||
<el-table-column prop="skuName" label="规格名称" />
|
||||
<el-table-column prop="num" label="商品数量" />
|
||||
@@ -73,6 +73,14 @@
|
||||
</div>
|
||||
<div class="box_content_right">
|
||||
<div class="top">
|
||||
<div class="box_content_right_tiem">
|
||||
<div class="box_content_right_tiemleft">
|
||||
店铺:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ infoData.shopName }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_right_tiem">
|
||||
<div class="box_content_right_tiemleft">
|
||||
上岗时间:
|
||||
@@ -86,38 +94,39 @@
|
||||
交班时间:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ dayjs(infoData.loginOutTime).format("YYYY-MM-DD HH:mm:ss") }}
|
||||
{{ dayjs(infoData.handoverTime).format("YYYY-MM-DD HH:mm:ss") }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_right_tiem">
|
||||
<!-- <div class="box_content_right_tiem">
|
||||
<div class="box_content_right_tiemleft">
|
||||
终端名称:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ infoData.equipment || '无' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_right_tiem">
|
||||
</div> -->
|
||||
<!-- <div class="box_content_right_tiem">
|
||||
<div class="box_content_right_tiemleft">
|
||||
备用金:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ infoData.pettyCash || '无' }}
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="box_content_right_tiem">
|
||||
<div class="box_content_right_tiemleft">
|
||||
收营员:
|
||||
</div>
|
||||
<div class="box_content_right_tiemright">
|
||||
{{ infoData.userName || '无' }}
|
||||
{{ infoData.staffName || '无' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="is_shop">
|
||||
<div class="button">
|
||||
<el-checkbox v-model="isPrint" border label="是否打印商品销售数据" style="width: 100%" />
|
||||
<el-checkbox v-model="isPrint" :true-value="1" :false-value="0" border
|
||||
label="是否打印商品销售数据" style="width: 100%" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_right_tiembutton" :loading="loading" @click="exit">
|
||||
@@ -133,40 +142,29 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ipcRenderer } from "electron";
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage, dayjs } from 'element-plus'
|
||||
import { tglogout } from '@/api/group.js'
|
||||
import { shopInfoqueryDuty, loginlogout, handoverData, handoverprint } from '@/api/work/index.js'
|
||||
import useStorage from '@/utils/useStorage'
|
||||
import { handoverTotal, handover, handoverData, handoverNetworkPrint } from '@/api/account.js'
|
||||
import { useRouter } from "vue-router";
|
||||
import { bySubType } from "@/api/device";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
import { formatDecimal } from '@/utils/index.js'
|
||||
import { usePrint } from "@/store/print.js";
|
||||
import { staffPermission } from '@/api/user.js'
|
||||
|
||||
const printStore = usePrint();
|
||||
|
||||
const socket = useSocket();
|
||||
|
||||
const store = useUser();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const dialogVisible = ref(false) //交班
|
||||
//详情数据
|
||||
const infoData = ref({})
|
||||
const loading = ref(false);
|
||||
|
||||
const isPrint = ref(true)
|
||||
const isPrint = ref(1)
|
||||
|
||||
// 查看交班记录
|
||||
async function checkRecord() {
|
||||
try {
|
||||
const res = await staffPermission('yun_xu_cha_kan_suo_you_jiao_ban_ji_lu')
|
||||
// await staffPermission('yun_xu_cha_kan_suo_you_jiao_ban_ji_lu')
|
||||
router.push('/workrecord')
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
@@ -176,84 +174,46 @@ async function checkRecord() {
|
||||
// 开始交班
|
||||
const exit = async () => {
|
||||
try {
|
||||
await staffPermission('yun_xu_jiao_ban')
|
||||
|
||||
let data = {}
|
||||
// 获取交班打印小票数据
|
||||
data = await handoverData({
|
||||
id: infoData.value.id
|
||||
})
|
||||
|
||||
// await staffPermission('yun_xu_jiao_ban')
|
||||
const res = await handover(isPrint.value)
|
||||
const data = await handoverData(res)
|
||||
if (printStore.deviceNoteList.length) {
|
||||
loading.value = true;
|
||||
|
||||
// 使用本地打印机 打印交班数据
|
||||
data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
data.printShop = isPrint.value
|
||||
printStore.printWork(data)
|
||||
|
||||
// return
|
||||
await loginlogout({
|
||||
status: 1
|
||||
})
|
||||
|
||||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
useStorage.del('updateFlag')
|
||||
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
name: "login",
|
||||
});
|
||||
}, 1000);
|
||||
loading.value = false;
|
||||
} else {
|
||||
console.log('云打印交班数据');
|
||||
loading.value = true;
|
||||
|
||||
await tglogout()
|
||||
|
||||
// 退出登录
|
||||
await loginlogout({
|
||||
status: 1
|
||||
})
|
||||
|
||||
// 打印交班数据
|
||||
await handoverprint({
|
||||
id: infoData.value.id,
|
||||
isprintProduct: isPrint.value
|
||||
})
|
||||
|
||||
// useStorage.clear()
|
||||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
useStorage.del('updateFlag')
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
name: "login",
|
||||
});
|
||||
}, 1000);
|
||||
loading.value = false;
|
||||
// 使用云打印机 打印交班数据
|
||||
await handoverNetworkPrint(data.id)
|
||||
}
|
||||
socket.close()
|
||||
logoutHandle()
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
async function logoutHandle() {
|
||||
try {
|
||||
loading.value = true;
|
||||
await store.logout()
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
name: "login",
|
||||
});
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
console.log('退出失败');
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
// 获取交班打印数据前置
|
||||
const infoshopInfoqueryDutys = async () => {
|
||||
try {
|
||||
let res = await shopInfoqueryDuty({
|
||||
page: 1,
|
||||
pageSize: 10
|
||||
})
|
||||
let res = await handoverTotal()
|
||||
infoData.value = res
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
@@ -269,11 +229,6 @@ function show() {
|
||||
defineExpose({
|
||||
show
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// getPrintList()
|
||||
// bySubTypeAjax()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -286,7 +241,7 @@ onMounted(() => {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
padding: 6px 10px;
|
||||
padding: 10px;
|
||||
border-radius: 6px;
|
||||
color: #161718;
|
||||
text-decoration: none;
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
<template>
|
||||
<div class="box">
|
||||
<div class="box_top" @click="clickrecord">
|
||||
<div class="box_top_left" @click="router.back()">
|
||||
<el-icon size="20">
|
||||
<ArrowLeft />
|
||||
</el-icon>
|
||||
<div class="box_top_right">
|
||||
交班记录
|
||||
<div class="contenr_wrap" style="flex: 1;">
|
||||
<div class="box">
|
||||
<div class="box_top" @click="clickrecord">
|
||||
<div class="box_top_left" @click="router.back()">
|
||||
<el-icon size="20">
|
||||
<ArrowLeft />
|
||||
</el-icon>
|
||||
<div class="box_top_right">
|
||||
交班记录
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content">
|
||||
<div class="box_content_left">
|
||||
<div class="box_content_left_top">
|
||||
<div class="box_content_left_top_item">
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div>
|
||||
{{ infoData.total }}
|
||||
<div class="box_content">
|
||||
<div class="box_content_left">
|
||||
<div class="box_content_left_top">
|
||||
<div class="box_content_left_top_item">
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div>
|
||||
{{ infoData.total }}
|
||||
</div>
|
||||
<div>
|
||||
交班数
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
交班数
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div>
|
||||
{{ infoData.amount }}
|
||||
</div>
|
||||
<div>
|
||||
总收款
|
||||
<div class="box_content_left_top_item_top">
|
||||
<div>
|
||||
{{ infoData.amount }}
|
||||
</div>
|
||||
<div>
|
||||
总收款
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box_content_left_bouttom">
|
||||
<div class="box_content_left_bouttomox">
|
||||
<div class="box_content_left_bouttom_item" v-for="(item, index) in infoData.pageInfo.list"
|
||||
:key="index">
|
||||
<div class="wbox_content_left_bouttom_item_top">
|
||||
<div>
|
||||
{{ dayjs(item.loginTime).format("YYYY-MM-DD HH:mm:ss") }}
|
||||
<div class="box_content_left_bouttom">
|
||||
<div class="box_content_left_bouttomox">
|
||||
<div class="box_content_left_bouttom_item" v-for="(item, index) in infoData.list"
|
||||
:key="index">
|
||||
<div class="wbox_content_left_bouttom_item_top">
|
||||
<div>
|
||||
{{ item.loginTime }}
|
||||
</div>
|
||||
<div>
|
||||
¥{{ item.handAmount }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
¥{{ item.amount }}
|
||||
<div class="wbox_content_left_bouttom_item_topone">
|
||||
<div style="display: flex;">
|
||||
<span>收营员:</span>
|
||||
<span style="font-weight: bold;">{{ item.staffName }}</span>
|
||||
</div>
|
||||
<div style="display: flex;">
|
||||
<span>总订单数:</span>
|
||||
<span style="font-weight: bold;">{{ item.orderCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wbox_content_left_bouttom_item_topone">
|
||||
<div style="display: flex;">
|
||||
<span>收营员:</span>
|
||||
<span style="font-weight: bold;">{{ item.userName }}</span>
|
||||
</div>
|
||||
<div style="display: flex;">
|
||||
<span>总订单数:</span>
|
||||
<span style="font-weight: bold;">{{ item.orderNum }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wbox_content_left_bouttom_item_topone">
|
||||
<div style="display: flex;">
|
||||
<span>起止时间:</span>
|
||||
<span style="font-weight: bold;"> {{
|
||||
dayjs(item.loginTime).format("YYYY-MM-DD HH:mm:ss") }}</span>
|
||||
</div>
|
||||
<div style="display: flex;">
|
||||
<span>备用金:</span>
|
||||
<span style="font-weight: bold;">{{ item.pettyCash }}</span>
|
||||
<div class="wbox_content_left_bouttom_item_topone">
|
||||
<div style="display: flex;">
|
||||
<span>起止时间:</span>
|
||||
<span style="font-weight: bold;"> {{ item.loginTime }}</span>
|
||||
</div>
|
||||
<div style="display: flex;">
|
||||
<span>挂账金额</span>
|
||||
<span style="font-weight: bold;">{{ item.creditAmount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="box_content_right">
|
||||
<!-- <div class="box_content_right">
|
||||
<div class="box_content_right_tiem">
|
||||
<div class="box_content_right_tiemleft">
|
||||
上岗时间:
|
||||
@@ -114,36 +114,43 @@
|
||||
关班/退出
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { reactive, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { shopinfoqueryDutyFlow } from '@/api/work/index.js'
|
||||
import { handoverRecordPage } from '@/api/account.js'
|
||||
import { useUser } from "@/store/user.js"
|
||||
import { ElMessage, dayjs } from 'element-plus'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const store = useUser()
|
||||
const record = ref(true)//交班记录
|
||||
//详情数据
|
||||
const infoData = ref({
|
||||
pageInfo: {
|
||||
list: []
|
||||
}
|
||||
const infoData = reactive({
|
||||
list: [],
|
||||
total: 0,
|
||||
amount: 0
|
||||
})
|
||||
|
||||
// 获取交班总记录
|
||||
const infoshopInfoqueryDuty = async () => {
|
||||
let res = await shopinfoqueryDutyFlow({
|
||||
shopId: store.userInfo.shopId,
|
||||
let res = await handoverRecordPage({
|
||||
page: 1,
|
||||
pageSize: 10
|
||||
size: 99999
|
||||
})
|
||||
infoData.value = res
|
||||
console.log(infoData.value)
|
||||
infoData.list = res.records
|
||||
infoData.total = +res.totalRow
|
||||
|
||||
let amount = 0
|
||||
|
||||
res.records.map(item => {
|
||||
amount += item.handAmount
|
||||
})
|
||||
|
||||
infoData.amount = amount
|
||||
}
|
||||
onMounted(() => {
|
||||
infoshopInfoqueryDuty()
|
||||
@@ -152,7 +159,7 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
.box {
|
||||
width: 100%;
|
||||
width: 100vw;
|
||||
padding: 16px;
|
||||
height: 100vh;
|
||||
background-color: #efefef;
|
||||
@@ -162,8 +169,8 @@ onMounted(() => {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
padding: 6px 10px;
|
||||
border-radius: 6px;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
/* 取消下划线效果 */
|
||||
|
||||
.box_top_left {
|
||||
@@ -191,7 +198,7 @@ onMounted(() => {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
border-radius: 10px;
|
||||
// padding: 30px 20px;
|
||||
|
||||
.box_content_left_top {
|
||||
|
||||
Reference in New Issue
Block a user