更新没有usb打印机时调用云打印机

This commit is contained in:
gyq
2024-08-02 17:54:52 +08:00
parent f8c5c9bf59
commit ac469cbc32
7 changed files with 323 additions and 178 deletions

View File

@@ -46,17 +46,25 @@ const orderInfo = ref({})
async function printEwmHandle() {
try {
printEwmLoading.value = true
printStore.printInvoice({
url: ewmInfo.value.wechat_url
})
// const res = await syjprintqrcode({
// id: ewmInfo.value.id
// })
ElMessage.success('打印成功')
showEwmDialog.value = false
setTimeout(() => {
printEwmLoading.value = false
}, 1000)
if (printStore.deviceNoteList.length) {
printStore.printInvoice({
url: ewmInfo.value.wechat_url
})
ElMessage.success('打印成功')
showEwmDialog.value = false
setTimeout(() => {
printEwmLoading.value = false
}, 1000)
} else {
const res = await syjprintqrcode({
id: ewmInfo.value.id
})
ElMessage.success('打印成功')
showEwmDialog.value = false
setTimeout(() => {
printEwmLoading.value = false
}, 1000)
}
} catch (error) {
console.log(error);
printEwmLoading.value = false

View File

@@ -142,8 +142,19 @@
(orderDetaildata.status == 'refund' ||
orderDetaildata.status == 'closed')
">开发票</el-button>
<el-button :loading="normalPrintLoading" @click="print('normal')" style="flex: 1">重打小票</el-button>
<el-button :loading="labelPrintLoading" @click="print('label')" style="flex: 1">重打标签</el-button>
<el-button :loading="normalPrintLoading" @click="print('normal')" style="flex: 1" v-if="
orderDetaildata.orderType != 'return' &&
orderDetaildata.status == 'closed'
">重打小票</el-button>
<el-button :loading="labelPrintLoading" @click="print('label')" style="flex: 1" v-if="
orderDetaildata.orderType != 'return' &&
(orderDetaildata.status == 'refund' ||
orderDetaildata.status == 'closed')
">重打标签</el-button>
<el-button :loading="normalPrintLoading" @click="print('refund')" style="flex: 1"
v-if="orderDetaildata.status == 'refund'">
重打小票
</el-button>
</div>
</div>
</div>
@@ -445,47 +456,94 @@ const print = lodash.throttle(
setTimeout(() => {
labelPrintLoading.value = false
}, 1000)
} else {
normalPrintLoading.value = true
const data = {
shop_name: store.userInfo.shopName,
loginAccount: store.userInfo.loginAccount,
carts: [],
amount: printLabelOrder.value.orderAmount,
remark: printLabelOrder.value.remark,
orderInfo: printLabelOrder.value,
outNumber: printLabelOrder.value.outNumber,
createdAt: dayjs(printLabelOrder.value.createdAt).format(
"YYYY-MM-DD HH:mm:ss"
),
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
} else if (e == 'normal') {
if (printStore.deviceNoteList.length) {
normalPrintLoading.value = true
const data = {
shop_name: store.userInfo.shopName,
loginAccount: store.userInfo.loginAccount,
carts: [],
amount: printLabelOrder.value.orderAmount,
remark: printLabelOrder.value.remark,
orderInfo: printLabelOrder.value,
outNumber: printLabelOrder.value.outNumber,
createdAt: dayjs(printLabelOrder.value.createdAt).format(
"YYYY-MM-DD HH:mm:ss"
),
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
}
printLabelOrder.value.skuInfos.map(item => {
data.carts.push(
{
categoryId: item.categoryId,
name: item.productName,
number: item.num,
skuName: item.productSkuName,
salePrice: formatDecimal(item.priceAmount / item.num),
totalAmount: formatDecimal(item.priceAmount)
}
)
})
printStore.pushReceiptData(data);
setTimeout(() => {
normalPrintLoading.value = false
}, 1000)
} else {
// 云打票
await cloudPrinterprint({
type: e,
orderId: orderDetaildata.value.id,
ispre: false,
});
ElMessage({
message: "成功打票",
type: "success",
});
}
} else if (e == 'refund') {
if (printStore.deviceNoteList.length) {
normalPrintLoading.value = true
const data = {
shop_name: store.userInfo.shopName,
loginAccount: store.userInfo.loginAccount,
carts: [],
amount: printLabelOrder.value.orderAmount,
remark: printLabelOrder.value.remark,
orderInfo: printLabelOrder.value,
outNumber: printLabelOrder.value.outNumber,
createdAt: dayjs(printLabelOrder.value.createdAt).format(
"YYYY-MM-DD HH:mm:ss"
),
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
}
printLabelOrder.value.skuInfos.map(item => {
data.carts.push(
{
categoryId: item.categoryId,
name: item.productName,
number: item.num,
skuName: item.productSkuName,
salePrice: formatDecimal(item.priceAmount / item.num),
totalAmount: formatDecimal(item.priceAmount)
}
)
})
printStore.printRefund(data);
setTimeout(() => {
normalPrintLoading.value = false
}, 1000)
} else {
// 云打票
await cloudPrinterprint({
type: 'normal',
orderId: orderDetaildata.value.id,
ispre: false,
});
ElMessage({
message: "成功打票",
type: "success",
});
}
printLabelOrder.value.skuInfos.map(item => {
data.carts.push(
{
categoryId: item.categoryId,
name: item.productName,
number: item.num,
skuName: item.productSkuName,
salePrice: formatDecimal(item.priceAmount / item.num),
totalAmount: formatDecimal(item.priceAmount)
}
)
})
printStore.pushReceiptData(data);
setTimeout(() => {
normalPrintLoading.value = false
}, 1000)
// // 云打票
// await cloudPrinterprint({
// type: e,
// orderId: orderDetaildata.value.id,
// ispre: false,
// });
// ElMessage({
// message: "成功打票",
// type: "success",
// });
}
} catch (error) {
console.log(error);