优化打印机设置
This commit is contained in:
@@ -5,10 +5,10 @@ ENV = development
|
||||
# VITE_API_WSS = 'wss://sockets.sxczgkj.com/wss'
|
||||
|
||||
# 正式ws
|
||||
# VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
||||
VITE_API_WSS = 'wss://czgeatws.sxczgkj.com/wss'
|
||||
|
||||
# 本地ws
|
||||
VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||
# VITE_API_WSS = 'ws://192.168.1.42:2348'
|
||||
|
||||
# 正式 php
|
||||
VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
@@ -23,7 +23,7 @@ VITE_API_PHP_URL = 'https://newblockwlx.sxczgkj.cn/index.php/api'
|
||||
# VITE_API_URL = 'https://tapi.cashier.sxczgkj.cn'
|
||||
|
||||
# 线上正式
|
||||
# VITE_API_URL = 'https://cashier.sxczgkj.com'
|
||||
VITE_API_URL = 'https://cashier.sxczgkj.com'
|
||||
|
||||
# 本地调试连接
|
||||
VITE_API_URL = 'http://192.168.1.42/'
|
||||
# VITE_API_URL = 'http://192.168.1.42/'
|
||||
29862
dist-electron/main.js
29862
dist-electron/main.js
File diff suppressed because one or more lines are too long
12
package-lock.json
generated
12
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.25",
|
||||
"version": "2.0.28",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "vite-electron",
|
||||
"version": "2.0.25",
|
||||
"version": "2.0.28",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
@@ -30,7 +30,7 @@
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"win32-api": "^26.1.2",
|
||||
"ysk-utils": "^1.0.85"
|
||||
"ysk-utils": "^1.0.91"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
@@ -6730,9 +6730,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ysk-utils": {
|
||||
"version": "1.0.85",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.85.tgz",
|
||||
"integrity": "sha512-HkbV4Jidi3G6DAuGAN972tClUYtC2zVoxo4crrxexfn0rZa8HjXatUfEbawHOeEzyl6G1CdC+160I2bKfxEBlA==",
|
||||
"version": "1.0.91",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.91.tgz",
|
||||
"integrity": "sha512-zM0846gmFvo7QIMNeqAKa8e7wnGOGpy7cDwwQdbJzHs4m/UaAC2hgU9MfLfK3U+f4W2TbxsMsZ0ekP4EbSJVUw==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.3.1",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "2.0.27",
|
||||
"version": "2.0.29",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
@@ -33,7 +33,7 @@
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"win32-api": "^26.1.2",
|
||||
"ysk-utils": "^1.0.85"
|
||||
"ysk-utils": "^1.0.91"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
|
||||
@@ -108,7 +108,8 @@ onMounted(() => {
|
||||
|
||||
<style scoped lang="scss">
|
||||
.list {
|
||||
min-height: 200px;
|
||||
height: 55vh;
|
||||
overflow-y: auto;
|
||||
|
||||
.row {
|
||||
padding-bottom: 20px;
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
</div>
|
||||
<div class="d_content">
|
||||
<div class="d_list">
|
||||
<el-form :model="form" label-position="left" label-width="60%">
|
||||
<el-form-item label="设备名称">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-position="left" label-width="60%">
|
||||
<el-form-item label="设备名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型">
|
||||
<el-radio-group v-model="form.connectionType" @change="form.address = ''">
|
||||
<el-radio-group v-model="form.connectionType" @change="connectionTypeChange">
|
||||
<el-radio-button label="USB" value="USB"></el-radio-button>
|
||||
<el-radio-button label="局域网" value="局域网"></el-radio-button>
|
||||
</el-radio-group>
|
||||
@@ -23,35 +23,34 @@
|
||||
</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-option label="58mm" value="58mm" v-if="form.connectionType === 'USB'"></el-option>
|
||||
<el-option label="80mm" value="80mm" v-if="form.connectionType === '局域网'"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择设备" v-if="form.connectionType === 'USB'">
|
||||
<el-form-item label="选择设备" prop="address" v-if="form.connectionType === 'USB'">
|
||||
<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="设备IP" v-if="form.connectionType === '局域网'">
|
||||
<el-form-item label="设备IP" prop="address" v-if="form.connectionType === '局域网'">
|
||||
<el-input v-model="form.address" placeholder="请输入设备IP地址"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类">
|
||||
<el-form-item label="商品分类" prop="classifyPrint" v-if="form.connectionType === '局域网'">
|
||||
<div class="column">
|
||||
<el-radio-group v-model="form.classifyPrint" @change="form.categoryList = []; form.categoryIds = ''">
|
||||
<el-radio-button label="全部" value="0"></el-radio-button>
|
||||
<el-radio-button label="部分" value="1" v-show="printTypeList[1].values.length > 0"></el-radio-button>
|
||||
<el-radio-button label="部分(仅后厨)" value="1"
|
||||
:disabled="printTypeList[1].values.length == 0"></el-radio-button>
|
||||
</el-radio-group>
|
||||
<div style="cursor: pointer" @click="classifyRef.show()" v-if="form.classifyPrint == '1'">
|
||||
<span style="color: #409eff" v-if="form.categoryList.length">
|
||||
{{form.categoryList.map(item => item.name).join(',')}}
|
||||
</span>
|
||||
<span style="color: #e65d6e" v-else>
|
||||
请选择分类
|
||||
</span>
|
||||
<el-button type="primary" v-else style="margin-top: 10px;">选择商品分类</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="打印类型">
|
||||
<el-form-item label="打印类型" v-if="form.connectionType === '局域网'">
|
||||
<div class="row" v-for="(item, index) in printTypeList" :key="index">
|
||||
<div class="title">{{ item.label }}</div>
|
||||
<div class="cont">
|
||||
@@ -159,7 +158,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<classify ref="classifyRef" @success="(e) => (form.categoryList = e)" />
|
||||
<classify ref="classifyRef" @success="classifyChange" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -226,6 +225,23 @@ const printTypeList = ref([
|
||||
}
|
||||
])
|
||||
|
||||
// 切换打印机类型
|
||||
function connectionTypeChange(e) {
|
||||
form.value.address = ''
|
||||
form.value.receiptSize = ''
|
||||
form.value.classifyPrint = '0'
|
||||
if (e == 'USB') {
|
||||
form.value.receiptSize = '58mm'
|
||||
} else {
|
||||
form.value.printContentType = ''
|
||||
form.value.receiptSize = '80mm'
|
||||
form.value.printContentType = ''
|
||||
printTypeList.value.forEach(el => {
|
||||
el.values = []
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const categoryIdsType = ref('all') // all=全部 custom=部分
|
||||
|
||||
const form = ref({
|
||||
@@ -239,15 +255,55 @@ const form = ref({
|
||||
categoryIds: '', // 打印分类Id
|
||||
categoryList: [], // 分类
|
||||
sort: '',
|
||||
receiptSize: '58mm', // 小票尺寸 58mm 80mm
|
||||
receiptSize: '', // 小票尺寸 58mm 80mm
|
||||
classifyPrint: '0', // 分类打印 0-所有 1-部分分类 2-部分商品
|
||||
printNum: '', // 打印数量 c1m1^2 = 顾客+商家[2张] m1^1 = 商家[1张] c1^1顾客[1张] c2m1^3顾客2+商家1[3张]
|
||||
kitchenPrintMode: 'all', // 打印方式 all-全部打印 normal-仅打印结账单「前台」one-仅打印制作单「厨房」queue-仅打印排队取号
|
||||
printContentType: [],
|
||||
printContentType: '',
|
||||
status: 1,
|
||||
handoverSwitch: 0, // 交班单开关 0-关闭 1-开启
|
||||
});
|
||||
|
||||
const rules = ref({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
address: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (form.value.connectionType == 'USB') {
|
||||
if (form.value.address == '') {
|
||||
callback(new Error('请选择设备'))
|
||||
}
|
||||
callback()
|
||||
} else {
|
||||
if (form.value.address == '') {
|
||||
callback(new Error('请输入设备IP'))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
classifyPrint: [
|
||||
{
|
||||
required: false,
|
||||
validator: (rule, value, callback) => {
|
||||
if (form.value.classifyPrint == '1' && form.value.categoryList.length == '0') {
|
||||
callback(new Error('请选择商品分类'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
})
|
||||
const printDataLoading = ref(false);
|
||||
const printData = reactive({
|
||||
shop_name: '',
|
||||
@@ -291,33 +347,30 @@ function getPrintList() {
|
||||
}
|
||||
|
||||
// 测试打印
|
||||
function printHandle() {
|
||||
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||
ElMessage.error("请输入设备IP地址");
|
||||
return;
|
||||
}
|
||||
const formRef = ref(null)
|
||||
async function printHandle() {
|
||||
try {
|
||||
await formRef.value.validateField(['address'])
|
||||
printDataLoading.value = true;
|
||||
printData.shop_name = store.shopInfo.shopName
|
||||
printData.loginAccount = store.userInfo.name
|
||||
printData.deviceName = form.value.name;
|
||||
printData.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
printDataLoading.value = true;
|
||||
printData.shop_name = store.shopInfo.shopName
|
||||
printData.loginAccount = store.userInfo.name
|
||||
printData.deviceName = form.value.name;
|
||||
printData.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
if (form.value.connectionType === 'USB') {
|
||||
receiptPrint(printData,)
|
||||
} else if (form.value.connectionType === '局域网') {
|
||||
ipcRenderer.send('ORDER', JSON.stringify({
|
||||
printerIp: form.value.address,
|
||||
orderData: printData
|
||||
}))
|
||||
if (form.value.connectionType === 'USB') {
|
||||
receiptPrint(printData,)
|
||||
} else if (form.value.connectionType === '局域网') {
|
||||
ipcRenderer.send('ORDER', JSON.stringify({
|
||||
printerIp: form.value.address,
|
||||
orderData: printData
|
||||
}))
|
||||
}
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false;
|
||||
}, 2500);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false;
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
// 打印类型切换
|
||||
@@ -325,49 +378,48 @@ function printTypeChange(e, index) {
|
||||
if (index == 1 && printTypeList.value[index].values.length == 0) {
|
||||
form.value.categoryList = []
|
||||
form.value.classifyPrint = '0'
|
||||
} else {
|
||||
formRef.value?.clearValidate('classifyPrint')
|
||||
}
|
||||
if (index == 1 && printTypeList.value[index].values.length > 0) {
|
||||
form.value.classifyPrint = '1'
|
||||
}
|
||||
}
|
||||
|
||||
// 选择分类以后的回调
|
||||
function classifyChange(e) {
|
||||
form.value.categoryList = e
|
||||
formRef.value.validateField(['classifyPrint'])
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
async function submitHandle() {
|
||||
try {
|
||||
if (!form.value.name) {
|
||||
ElMessage.error("请输入设备名称");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||
ElMessage.error("请输入设备IP地址");
|
||||
return;
|
||||
}
|
||||
function submitHandle() {
|
||||
formRef.value.validate(async valid => {
|
||||
try {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
form.value.categoryIds = form.value.categoryList.map(item => item.id).join(',')
|
||||
|
||||
if (form.value.classifyPrint == '1' && !form.value.categoryList.length) {
|
||||
ElMessage.error("请选择商品分类");
|
||||
return;
|
||||
if (form.value.connectionType == 'USB') {
|
||||
form.value.receiptSize = '58mm'
|
||||
form.value.printContentType = 'GUEST_ORDER,PRE_ORDER,ORDER,REFUND_ORDER'
|
||||
} else {
|
||||
form.value.receiptSize = '80mm'
|
||||
let arr = []
|
||||
printTypeList.value.forEach(item => {
|
||||
arr.push(...item.values)
|
||||
})
|
||||
form.value.printContentType = arr.join(',')
|
||||
}
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
printStore.init();
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
form.value.categoryIds = form.value.categoryList.map(item => item.id).join(',')
|
||||
|
||||
let arr = []
|
||||
printTypeList.value.forEach(item => {
|
||||
arr.push(...item.values)
|
||||
})
|
||||
|
||||
form.value.printContentType = arr.join(',')
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
printStore.init();
|
||||
router.back();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
loading.value = false;
|
||||
loading.value = false;
|
||||
})
|
||||
}
|
||||
|
||||
// 查询打印机详情
|
||||
|
||||
Reference in New Issue
Block a user