对接支付优惠

This commit is contained in:
gyq
2025-03-11 09:10:49 +08:00
parent 5cf2355d28
commit 3df0cce9ec
31 changed files with 1527 additions and 846 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);
}