优化问题
This commit is contained in:
parent
f3dfd4a121
commit
b5356d8370
|
|
@ -1 +1,171 @@
|
|||
"use strict";const i=require("path"),e=require("electron");let o;e.app.whenReady().then(()=>{o=new e.BrowserWindow({title:"银收客",width:1024,height:768,fullscreenable:!0,fullscreen:!process.env.VITE_DEV_SERVER_URL,simpleFullscreen:!0,frame:!!process.env.VITE_DEV_SERVER_URL,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}),process.env.VITE_DEV_SERVER_URL?o.loadURL(process.env.VITE_DEV_SERVER_URL):o.loadFile(i.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(t,n)=>{e.app.quit()}),e.ipcMain.on("getPrintList",()=>{o.webContents.getPrintersAsync().then(t=>{o.webContents.send("printList",t)})});const a=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?a.loadFile(i.join(__dirname,"../public/print.html")):a.loadFile(i.resolve(__dirname,"../dist/print.html")),e.ipcMain.on("printerInfoSync",(t,n)=>{a.webContents.send("getParams",n)}),e.ipcMain.on("printStart",(t,n)=>{console.log(n);let r=JSON.parse(n).deviceName;a.webContents.print({silent:!0,deviceName:r,pageSize:{width:58e3,height:216e3},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})});const s=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?s.loadFile(i.join(__dirname,"../public/work_print.html")):s.loadFile(i.resolve(__dirname,"../dist/work_print.html")),e.ipcMain.on("printerWorkSync",(t,n)=>{s.webContents.send("getParams",n)}),e.ipcMain.on("printWorkStart",(t,n)=>{let r=JSON.parse(n).deviceName;s.webContents.print({silent:!0,deviceName:r,pageSize:{width:58e3,height:216e3},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})});const l=new e.BrowserWindow({show:!1,width:320,height:240,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?l.loadFile(i.join(__dirname,"../public/tag_print.html")):l.loadFile(i.resolve(__dirname,"../dist/tag_print.html")),e.ipcMain.on("printerTagSync",(t,n)=>{console.log(n),l.webContents.send("getParams",n)}),e.ipcMain.on("printTagStart",(t,n)=>{console.log(n);let r=JSON.parse(n).deviceName;l.webContents.print({silent:!0,deviceName:r,pageSize:{width:4e4,height:3e4},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});
|
||||
"use strict";
|
||||
const path = require("path");
|
||||
const electron = require("electron");
|
||||
let win;
|
||||
electron.app.whenReady().then(() => {
|
||||
win = new electron.BrowserWindow({
|
||||
title: "银收客",
|
||||
width: 1024,
|
||||
height: 768,
|
||||
fullscreenable: true,
|
||||
fullscreen: process.env.VITE_DEV_SERVER_URL ? false : true,
|
||||
simpleFullscreen: true,
|
||||
frame: process.env.VITE_DEV_SERVER_URL ? true : false,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
win.loadURL(process.env.VITE_DEV_SERVER_URL);
|
||||
} else {
|
||||
win.loadFile(path.resolve(__dirname, "../dist/index.html"));
|
||||
}
|
||||
electron.app.on("activate", () => {
|
||||
if (electron.BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
electron.ipcMain.on("quitHandler", (_, msg) => {
|
||||
electron.app.quit();
|
||||
});
|
||||
electron.ipcMain.on("getPrintList", () => {
|
||||
win.webContents.getPrintersAsync().then((res) => {
|
||||
win.webContents.send("printList", res);
|
||||
});
|
||||
});
|
||||
const printWin = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 464,
|
||||
height: 1726,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
printWin.loadFile(path.join(__dirname, "../public/print.html"));
|
||||
} else {
|
||||
printWin.loadFile(path.resolve(__dirname, "../dist/print.html"));
|
||||
}
|
||||
electron.ipcMain.on("printerInfoSync", (event, arg) => {
|
||||
printWin.webContents.send("getParams", arg);
|
||||
});
|
||||
electron.ipcMain.on("printStart", (event, arg) => {
|
||||
console.log(arg);
|
||||
const _parmas = JSON.parse(arg);
|
||||
let name = _parmas.deviceName;
|
||||
printWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 58e3,
|
||||
height: 216e3
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203
|
||||
}
|
||||
});
|
||||
});
|
||||
const workPrintWin = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 464,
|
||||
height: 1726,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
workPrintWin.loadFile(path.join(__dirname, "../public/work_print.html"));
|
||||
} else {
|
||||
workPrintWin.loadFile(path.resolve(__dirname, "../dist/work_print.html"));
|
||||
}
|
||||
electron.ipcMain.on("printerWorkSync", (event, arg) => {
|
||||
workPrintWin.webContents.send("getParams", arg);
|
||||
});
|
||||
electron.ipcMain.on("printWorkStart", (event, arg) => {
|
||||
const _parmas = JSON.parse(arg);
|
||||
let name = _parmas.deviceName;
|
||||
workPrintWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 58e3,
|
||||
height: 216e3
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203
|
||||
}
|
||||
});
|
||||
});
|
||||
const tagPrintWin = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 320,
|
||||
height: 240,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
tagPrintWin.loadFile(path.join(__dirname, "../public/tag_print.html"));
|
||||
} else {
|
||||
tagPrintWin.loadFile(path.resolve(__dirname, "../dist/tag_print.html"));
|
||||
}
|
||||
electron.ipcMain.on("printerTagSync", (event, arg) => {
|
||||
console.log(arg);
|
||||
tagPrintWin.webContents.send("getParams", arg);
|
||||
});
|
||||
electron.ipcMain.on("printTagStart", (event, arg) => {
|
||||
const _parmas = JSON.parse(arg);
|
||||
let name = _parmas.deviceName;
|
||||
tagPrintWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 4e4,
|
||||
height: 3e4
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
electron.app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin")
|
||||
electron.app.quit();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ app.whenReady().then(() => {
|
|||
|
||||
// 执行标签小票的打印操作
|
||||
ipcMain.on("printTagStart", (event, arg) => {
|
||||
console.log(arg);
|
||||
// console.log(arg);
|
||||
const _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas)
|
||||
let name = _parmas.deviceName;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ async function tbShopCategoryGetAjax() {
|
|||
page: 0,
|
||||
pageSize: 200,
|
||||
});
|
||||
console.log(res);
|
||||
// console.log(res);
|
||||
res.list.map((item) => {
|
||||
item.active = false;
|
||||
item.childrenList.map((item) => {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ export const usePrint = defineStore({
|
|||
contentType: "local",
|
||||
subType: "label",
|
||||
});
|
||||
console.log("打印队列初始化成功");
|
||||
},
|
||||
// 检查本地打印机是否能正常使用
|
||||
checkLocalPrint(deviceName) {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ const form = ref({
|
|||
|
||||
const canvasRef = ref(null)
|
||||
const printData = ref({
|
||||
deviceName: form.value.config.deviceName,
|
||||
deviceName: '',
|
||||
outNumber: '123',
|
||||
name: '甜橙马黛茶',
|
||||
skuName: '加奶、加珍珠',
|
||||
|
|
@ -173,7 +173,7 @@ function getPrintList() {
|
|||
// 测试打印
|
||||
const printHandle = _.throttle(function () {
|
||||
if (!form.value.config.deviceName) {
|
||||
ElMessage.warning("请选择打印设备");
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
ipcRenderer.send(
|
||||
|
|
@ -204,6 +204,7 @@ async function tbPrintMachineDetailAjax() {
|
|||
try {
|
||||
const res = await tbPrintMachineDetail(route.query.id);
|
||||
form.value = res;
|
||||
printData.value.deviceName = res.config.deviceName
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
|
@ -217,7 +218,7 @@ onMounted(() => {
|
|||
|
||||
QRCode.toCanvas(canvasRef.value, printData.value.outNumber, function (error) {
|
||||
if (error) console.error(error)
|
||||
console.log('success!');
|
||||
// console.log('success!');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
<script setup>
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import { ref } from 'vue'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import _ from 'lodash'
|
||||
import useStorage from "@/utils/useStorage";
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ async function productqueryCommodityInfoAjax() {
|
|||
// clearInterval(loopTimer.value)
|
||||
// loopTimer.value = null
|
||||
// }
|
||||
return res.list
|
||||
return res
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
console.log(error)
|
||||
|
|
@ -271,51 +271,51 @@ function loopGetGoods() {
|
|||
loopTimer.value = setInterval(async () => {
|
||||
goodsPage.value++
|
||||
const res = await productqueryCommodityInfoAjax()
|
||||
goodsList.value.push(res)
|
||||
goodsList.value.push(res.list)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
// 更新商品数据
|
||||
async function updateData() {
|
||||
localUpdateShopListType()
|
||||
await updateCategoryActive()
|
||||
await queryCategoryAjax()
|
||||
updataGoods()
|
||||
}
|
||||
|
||||
// 更新商品数据
|
||||
async function updataGoods() {
|
||||
if (!goodsList.value.length) {
|
||||
const res = await productqueryCommodityInfoAjax()
|
||||
goodsList.value.push(res)
|
||||
goodsList.value.push(res.list)
|
||||
|
||||
if (res.length >= goodsPageSize.value) {
|
||||
if (!res.isLastPage) {
|
||||
goodsPage.value++
|
||||
const res2 = await productqueryCommodityInfoAjax()
|
||||
goodsList.value.push(res2)
|
||||
goodsList.value.push(res2.list)
|
||||
}
|
||||
searchLoading.value = false
|
||||
} else {
|
||||
goodsPage.value = currentGoodsIndex.value + 1
|
||||
goodsList.value[currentGoodsIndex.value] = await productqueryCommodityInfoAjax()
|
||||
// console.log('更新第二页数据', goodsPage.value);
|
||||
const res = await productqueryCommodityInfoAjax()
|
||||
goodsList.value[currentGoodsIndex.value] = res.list
|
||||
searchLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 轮播图开始滑动
|
||||
const onSlideChange = _.debounce(async function (e) {
|
||||
if (e.activeIndex == e.previousIndex || finish.value) return
|
||||
if (e.activeIndex == e.previousIndex) return
|
||||
if (e.activeIndex > e.previousIndex) {
|
||||
// console.log('向下滑动');
|
||||
{
|
||||
goodsPage.value++
|
||||
const res = await productqueryCommodityInfoAjax()
|
||||
goodsList.value.push(res)
|
||||
res.list.length && goodsList.value.push(res.list)
|
||||
}
|
||||
|
||||
{
|
||||
goodsPage.value++
|
||||
const res = await productqueryCommodityInfoAjax()
|
||||
goodsList.value.push(res)
|
||||
res.list.length && goodsList.value.push(res.list)
|
||||
}
|
||||
// goodsList.value.shift()
|
||||
} else {
|
||||
|
|
@ -331,6 +331,12 @@ const onSlideChange = _.debounce(async function (e) {
|
|||
defineExpose({
|
||||
updateData
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
localUpdateShopListType()
|
||||
await updateCategoryActive()
|
||||
await queryCategoryAjax()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ import { onMounted, ref } from "vue";
|
|||
import { useUser } from "@/store/user.js";
|
||||
import payCard from "@/components/payCard/payCard.vue";
|
||||
import { print } from "@/api/pay";
|
||||
import { orderfindOrder } from '@/api/order/index.js'
|
||||
import { ElMessage } from "element-plus";
|
||||
import dayjs from "dayjs";
|
||||
import useStorage from '@/utils/useStorage'
|
||||
|
|
@ -116,7 +117,7 @@ const props = defineProps({
|
|||
|
||||
const isPrint = ref(true);
|
||||
|
||||
// 打印操作
|
||||
// 预打印操作
|
||||
const printHandle = _.throttle(async function () {
|
||||
try {
|
||||
if (!isPrint.value) return;
|
||||
|
|
@ -151,16 +152,57 @@ const printHandle = _.throttle(async function () {
|
|||
}
|
||||
}, 1500, { leading: true, trailing: false })
|
||||
|
||||
// 打印订单标签
|
||||
async function printOrderLable() {
|
||||
try {
|
||||
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.merchantName,
|
||||
carts: [],
|
||||
orderInfo: printLabelOrder,
|
||||
outNumber: printLabelOrder.outNumber,
|
||||
createdAt: dayjs(printLabelOrder.createdAt).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
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
// console.log('重打标签小票', data);
|
||||
printStore.labelPrint(data)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 订单已支付
|
||||
function paySuccess() {
|
||||
useStorage.del('memberInfo')
|
||||
dialogVisible.value = false;
|
||||
printHandle();
|
||||
printOrderLable()
|
||||
emit("paySuccess");
|
||||
}
|
||||
|
||||
function show() {
|
||||
dialogVisible.value = true;
|
||||
getLocalMemberInfo()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
|
|
|||
Loading…
Reference in New Issue