优化打印机
This commit is contained in:
parent
51fe3266ce
commit
5bb73cb3b3
|
|
@ -1 +1,86 @@
|
|||
"use strict";const r=require("path"),e=require("electron");let t;e.app.whenReady().then(()=>{t=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?t.loadURL(process.env.VITE_DEV_SERVER_URL):t.loadFile(r.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(o,n)=>{e.app.quit()}),e.ipcMain.on("getPrintList",()=>{t.webContents.getPrintersAsync().then(o=>{t.webContents.send("printList",o)})});const i=new e.BrowserWindow({show:!1,width:464,height:2206,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?i.loadFile(r.join(__dirname,"../public/print.html")):i.loadFile(r.resolve(__dirname,"../dist/print.html")),e.ipcMain.on("printerInfoSync",(o,n)=>{i.webContents.send("getParams",n)}),e.ipcMain.on("printStart",(o,n)=>{console.log(n);const s=JSON.parse(n);console.log(s);let a=s.deviceName;i.webContents.print({silent:!0,deviceName:a,pageSize:{width:58e3,height:276e3},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
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
electron.app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin")
|
||||
electron.app.quit();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ app.whenReady().then(() => {
|
|||
const printWin = new BrowserWindow({
|
||||
show: false,
|
||||
width: 464,
|
||||
height: 2206,
|
||||
height: 1726,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
|
|
@ -74,14 +74,14 @@ app.whenReady().then(() => {
|
|||
ipcMain.on('printStart', (event, arg) => {
|
||||
console.log(arg);
|
||||
const _parmas = JSON.parse(arg)
|
||||
console.log(_parmas)
|
||||
// console.log(_parmas)
|
||||
let name = _parmas.deviceName
|
||||
printWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 58000,
|
||||
height: 276000
|
||||
height: 216000
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "1.0.20",
|
||||
"version": "1.0.25",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
|
|
|
|||
53
src/App.vue
53
src/App.vue
|
|
@ -23,22 +23,22 @@
|
|||
|
||||
<script setup>
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import leftMenu from '@/components/leftMenu.vue'
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import leftMenu from "@/components/leftMenu.vue";
|
||||
|
||||
const route = useRoute()
|
||||
const route = useRoute();
|
||||
|
||||
const includeList = reactive([]);
|
||||
const hideLeftMenu = ref(false)
|
||||
const hideLeftMenu = ref(false);
|
||||
watch(route, (to) => {
|
||||
if (to.meta.keepAlive) {
|
||||
includeList.push(to.name);
|
||||
}
|
||||
let arr = ['/login', '/device_list', '/add_device']
|
||||
let arr = ["/login", "/device_list", "/add_device", "/add_label"];
|
||||
if (arr.includes(to.path)) {
|
||||
hideLeftMenu.value = true
|
||||
hideLeftMenu.value = true;
|
||||
} else {
|
||||
hideLeftMenu.value = false
|
||||
hideLeftMenu.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -87,12 +87,28 @@ router.beforeEach((to, from) => {
|
|||
--b-darker: calc(var(--b) * 0.8);
|
||||
|
||||
--primary-color: rgb(var(--r), var(--g), var(--b));
|
||||
--primary-color-hover: rgb(var(--r-lighter3), var(--g-lighter3), var(--b-lighter3));
|
||||
--primary-color-hover: rgb(
|
||||
var(--r-lighter3),
|
||||
var(--g-lighter3),
|
||||
var(--b-lighter3)
|
||||
);
|
||||
--el-color-primary: var(--primary-color) !important;
|
||||
--el-button-hover-bg-color: var(--primary-color) !important;
|
||||
--el-color-primary-light-3: rgb(var(--r-lighter), var(--g-lighter), var(--b-lighter)) !important;
|
||||
--el-color-primary-dark-2: rgb(var(--r-darker), var(--g-darker), var(--b-darker)) !important;
|
||||
--el-color-primary-light-5: rgb(var(--r-lighter2), var(--g-lighter2), var(--b-lighter2)) !important;
|
||||
--el-color-primary-light-3: rgb(
|
||||
var(--r-lighter),
|
||||
var(--g-lighter),
|
||||
var(--b-lighter)
|
||||
) !important;
|
||||
--el-color-primary-dark-2: rgb(
|
||||
var(--r-darker),
|
||||
var(--g-darker),
|
||||
var(--b-darker)
|
||||
) !important;
|
||||
--el-color-primary-light-5: rgb(
|
||||
var(--r-lighter2),
|
||||
var(--g-lighter2),
|
||||
var(--b-lighter2)
|
||||
) !important;
|
||||
|
||||
--el-font-size-base: 16px !important;
|
||||
--el-message-close-size: var(--el-font-size-base) !important;
|
||||
|
|
@ -101,8 +117,8 @@ router.beforeEach((to, from) => {
|
|||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'num';
|
||||
src: url('@/assets/font/Ignotum-Regular.ttf');
|
||||
font-family: "num";
|
||||
src: url("@/assets/font/Ignotum-Regular.ttf");
|
||||
}
|
||||
|
||||
html {
|
||||
|
|
@ -133,7 +149,6 @@ html {
|
|||
|
||||
.el-drawer__body {
|
||||
padding: 0 var(--el-drawer-padding-primary) !important;
|
||||
|
||||
}
|
||||
|
||||
.el-textarea {
|
||||
|
|
@ -148,7 +163,8 @@ html {
|
|||
background-color: #555;
|
||||
margin-right: 0 !important;
|
||||
padding-bottom: 20px !important;
|
||||
border-radius: var(--el-dialog-border-radius) var(--el-dialog-border-radius) 0 0;
|
||||
border-radius: var(--el-dialog-border-radius) var(--el-dialog-border-radius) 0
|
||||
0;
|
||||
}
|
||||
|
||||
.el-dialog__title {
|
||||
|
|
@ -169,7 +185,8 @@ html {
|
|||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: calc(var(--el-dialog-padding-primary) + 10px) var(--el-dialog-padding-primary);
|
||||
padding: calc(var(--el-dialog-padding-primary) + 10px)
|
||||
var(--el-dialog-padding-primary);
|
||||
}
|
||||
|
||||
.el-dialog__header {
|
||||
|
|
@ -198,7 +215,7 @@ html {
|
|||
/*定义滚动条轨道
|
||||
内阴影+圆角*/
|
||||
::-webkit-scrollbar-track {
|
||||
background-color: #F5F5F5;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
/*定义滑块
|
||||
|
|
@ -257,7 +274,7 @@ html {
|
|||
display: flex;
|
||||
width: 200%;
|
||||
|
||||
&>div {
|
||||
& > div {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,4 +62,16 @@ export function bySubType(params) {
|
|||
url: "/tbPrintMachine/bySubType",
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品分类列表
|
||||
* @returns
|
||||
*/
|
||||
export function tbShopCategoryGet(params) {
|
||||
return request({
|
||||
url: `/tbShopCategory`,
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
<template>
|
||||
<el-dialog title="选择分类" v-model="dialogVisible">
|
||||
<div class="list" v-loading="loading">
|
||||
<div class="row" v-for="(item, index) in categorys" :key="item.id">
|
||||
<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
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span slot="footer" style="display: flex; justify-content: flex-end">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { tbShopCategoryGet } from "@/api/device";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useUser } from "@/store/user.js";
|
||||
|
||||
const store = useUser();
|
||||
const emit = defineEmits(["success"]);
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const loading = ref(false);
|
||||
const categorys = ref([]);
|
||||
|
||||
function onSubmitHandle() {
|
||||
let categorysArr = [];
|
||||
for (let item of categorys.value) {
|
||||
if (item.active) {
|
||||
categorysArr.push({
|
||||
name: `${item.name}`,
|
||||
id: item.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;
|
||||
}
|
||||
|
||||
// 选择分类
|
||||
function selectHandle(item, index = -1) {
|
||||
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,
|
||||
size: 500,
|
||||
});
|
||||
res.map((item) => {
|
||||
item.active = false;
|
||||
item.childrenList.map((item) => {
|
||||
item.active = false;
|
||||
});
|
||||
});
|
||||
categorys.value = res;
|
||||
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 300);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function show() {
|
||||
dialogVisible.value = true;
|
||||
tbShopCategoryGetAjax();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
tbShopCategoryGetAjax();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.list {
|
||||
min-height: 200px;
|
||||
|
||||
.row {
|
||||
padding-bottom: 20px;
|
||||
|
||||
.list_title {
|
||||
color: #999;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.item_wrap {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -73,6 +73,11 @@ const routes = [
|
|||
path: "/add_device",
|
||||
name: "add_device",
|
||||
component: () => import("@/views/device/add.vue"),
|
||||
},
|
||||
{
|
||||
path: "/add_label",
|
||||
name: "add_label",
|
||||
component: () => import("@/views/device/add_label.vue"),
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,344 @@
|
|||
<template>
|
||||
<div class="device_container">
|
||||
<div class="header" @click="router.back()">
|
||||
<el-icon
|
||||
style="position: relative; top: 2px; margin-right: 4px"
|
||||
size="22"
|
||||
>
|
||||
<ArrowLeft />
|
||||
</el-icon>
|
||||
<el-text>{{ form.id ? "编辑便签打印机" : "添加便签打印机" }}</el-text>
|
||||
</div>
|
||||
<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-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="设备类型">
|
||||
<el-select v-model="form.connectionType">
|
||||
<el-option label="USB" value="USB"></el-option>
|
||||
<el-option label="网络" value="network"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择设备">
|
||||
<el-select v-model="form.config.deviceName">
|
||||
<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>
|
||||
<span
|
||||
style="color: #e65d6e"
|
||||
v-if="!form.config.categoryList.length"
|
||||
>
|
||||
请选择分类
|
||||
</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="打印子订单">
|
||||
<el-select v-model="form.config.printSub">
|
||||
<el-option label="是" :value="0"></el-option>
|
||||
<el-option label="否" :value="1"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="自动切刀">
|
||||
<el-select v-model="form.config.autoCut">
|
||||
<el-option label="是" :value="1"></el-option>
|
||||
<el-option label="否" :value="0"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="尾部留空">
|
||||
<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>
|
||||
</div>
|
||||
<div class="menu_wrap">
|
||||
<div class="print_view">
|
||||
<div class="title t1 blod">#A9 #A9</div>
|
||||
<div class="row blod">
|
||||
<span>甜橙马黛茶</span>
|
||||
<span style="margin-left: 30px">1</span>
|
||||
</div>
|
||||
<div class="row blod">加奶、加珍珠</div>
|
||||
<div class="row blod" style="margin-top: 10px">
|
||||
<span>03-08 16:58</span>
|
||||
<span style="margin-left: 30px">¥28</span>
|
||||
</div>
|
||||
<div class="btn_wrap">
|
||||
<div class="btn">
|
||||
<el-button plain style="width: 100%" @click="printHandle">
|
||||
打印测试小票
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<el-button
|
||||
type="primary"
|
||||
style="width: 100%"
|
||||
:loading="loading"
|
||||
@click="submitHandle"
|
||||
>
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<classify
|
||||
ref="classifyRef"
|
||||
@success="(e) => (form.config.categoryList = e)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ipcRenderer } from "electron";
|
||||
import { onMounted, 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 classify from "@/components/classify/index.vue";
|
||||
|
||||
const store = useUser();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const classifyRef = ref(null);
|
||||
const printList = ref([]);
|
||||
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,
|
||||
});
|
||||
|
||||
// 获取打印机列表
|
||||
function getPrintList() {
|
||||
ipcRenderer.send("getPrintList");
|
||||
ipcRenderer.on("printList", (event, arg) => {
|
||||
printList.value = arg;
|
||||
});
|
||||
}
|
||||
|
||||
// 测试打印
|
||||
function printHandle() {
|
||||
if (!form.value.config.deviceName) {
|
||||
ElMessage.warning("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
ipcRenderer.send(
|
||||
"printStart",
|
||||
JSON.stringify({ deviceName: form.value.config.deviceName })
|
||||
);
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
async function submitHandle() {
|
||||
try {
|
||||
if (!form.value.config.deviceName) {
|
||||
ElMessage.warning("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
Loading.value = true;
|
||||
await tbPrintMachinePost(form.value, form.value.id ? "put" : "post");
|
||||
Loading.value = false;
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 查询打印机详情
|
||||
async function tbPrintMachineDetailAjax() {
|
||||
try {
|
||||
const res = await tbPrintMachineDetail(route.query.id);
|
||||
form.value = res;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getPrintList();
|
||||
if (route.query.id) {
|
||||
tbPrintMachineDetailAjax(route.query.id);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.device_container {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
padding: 15px;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.header {
|
||||
height: 50px;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.d_content {
|
||||
padding-top: 15px;
|
||||
display: flex;
|
||||
height: calc(100vh - 15px * 2 - 50px);
|
||||
|
||||
.d_list {
|
||||
flex: 2;
|
||||
border-radius: 10px;
|
||||
background-color: #fff;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.menu_wrap {
|
||||
flex: 1.5;
|
||||
margin-left: 15px;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
padding: 0 15px;
|
||||
|
||||
.print_view {
|
||||
padding: 20px 0;
|
||||
.blod {
|
||||
font-weight: 600;
|
||||
}
|
||||
.title {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 4px;
|
||||
|
||||
&.t1 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
&.t2 {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-top: 2px;
|
||||
|
||||
&.between {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
.btn_wrap {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
padding: 20px 0;
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
margin: 10px 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
|
||||
tr {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
td {
|
||||
flex: 1;
|
||||
|
||||
&:nth-child(1) {
|
||||
flex: 2;
|
||||
}
|
||||
|
||||
&:not(:first-child) {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.sku {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -43,7 +43,10 @@
|
|||
<el-text
|
||||
type="primary"
|
||||
@click="
|
||||
router.push({ name: 'add_device', query: { id: item.id } })
|
||||
router.push({
|
||||
name: deviceRoute[item.subType],
|
||||
query: { id: item.id },
|
||||
})
|
||||
"
|
||||
>
|
||||
编辑
|
||||
|
|
@ -84,10 +87,7 @@
|
|||
</div> -->
|
||||
</div>
|
||||
<div class="menu_wrap">
|
||||
<div
|
||||
class="row"
|
||||
@click="router.push({ name: 'add_device', query: { type: 1 } })"
|
||||
>
|
||||
<div class="row" @click="router.push({ name: 'add_device' })">
|
||||
<div class="icon" style="background-color: var(--primary-color)">
|
||||
<el-image
|
||||
:src="icons.cash"
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
<div class="intro">用来打印客户(收银)小票的打印机。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row" @click="router.push({ name: 'add_label' })">
|
||||
<div class="icon" style="background-color: #79c3d5">
|
||||
<el-image
|
||||
:src="icons.label"
|
||||
|
|
@ -161,6 +161,11 @@ const list = ref([]);
|
|||
const dialogVisible = ref(false);
|
||||
const deleteId = ref("");
|
||||
const delLoading = ref(false);
|
||||
const deviceRoute = ref({
|
||||
cash: "add_device",
|
||||
label: "add_label",
|
||||
kitchen: "add_kitchen",
|
||||
});
|
||||
|
||||
async function statusChange(e, item) {
|
||||
console.log(e, item);
|
||||
|
|
|
|||
|
|
@ -151,47 +151,47 @@ async function bySubTypeAjax() {
|
|||
}
|
||||
|
||||
async function printHandle() {
|
||||
// try {
|
||||
// if (!isPrint.value) return;
|
||||
// if (printList.value.length) {
|
||||
// const data = {
|
||||
// shop_name: store.userInfo.merchantName,
|
||||
// carts: props.cart,
|
||||
// amount: props.amount,
|
||||
// remark: props.remark,
|
||||
// orderInfo: props.orderInfo,
|
||||
// deviceName: printList.value[0].config.deviceName,
|
||||
// createdAt: dayjs(props.orderInfo.createdAt).format(
|
||||
// "YYYY-MM-DD HH:mm:ss"
|
||||
// ),
|
||||
// printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
// };
|
||||
// ipcRenderer.send("printerInfoSync", JSON.stringify(data));
|
||||
// } else {
|
||||
// ElMessage.error("您还没有添加打印设备");
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
try {
|
||||
printLoading.value = true;
|
||||
await print({
|
||||
type: "normal",
|
||||
ispre: true,
|
||||
orderId: props.orderInfo.id,
|
||||
});
|
||||
printLoading.value = false;
|
||||
ElMessage.success("打印成功");
|
||||
if (!isPrint.value) return;
|
||||
if (printList.value.length) {
|
||||
const data = {
|
||||
shop_name: store.userInfo.merchantName,
|
||||
carts: props.cart,
|
||||
amount: props.amount,
|
||||
remark: props.remark,
|
||||
orderInfo: props.orderInfo,
|
||||
deviceName: printList.value[0].config.deviceName,
|
||||
createdAt: dayjs(props.orderInfo.createdAt).format(
|
||||
"YYYY-MM-DD HH:mm:ss"
|
||||
),
|
||||
printTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
ipcRenderer.send("printerInfoSync", JSON.stringify(data));
|
||||
} else {
|
||||
ElMessage.error("您还没有添加打印设备");
|
||||
}
|
||||
} catch (error) {
|
||||
printLoading.value = false;
|
||||
console.log(error);
|
||||
}
|
||||
// try {
|
||||
// printLoading.value = true;
|
||||
// await print({
|
||||
// type: "normal",
|
||||
// ispre: true,
|
||||
// orderId: props.orderInfo.id,
|
||||
// });
|
||||
// printLoading.value = false;
|
||||
// ElMessage.success("打印成功");
|
||||
// } catch (error) {
|
||||
// printLoading.value = false;
|
||||
// console.log(error);
|
||||
// }
|
||||
}
|
||||
|
||||
// 订单已支付
|
||||
function paySuccess() {
|
||||
dialogVisible.value = false;
|
||||
// printHandle();
|
||||
printHandle();
|
||||
emit("paySuccess");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export default defineConfig({
|
|||
'/api': {
|
||||
target: 'https://cashierclient.sxczgkj.cn/cashier-client', // 线上
|
||||
// target: 'http://192.168.2.27:10587/cashier-client', // 国成
|
||||
// target: 'http://192.168.2.128:10587/cashier-client',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue