新增添加网口打印机
This commit is contained in:
@@ -321,7 +321,7 @@ export function printerList(subType = "") {
|
||||
params: {
|
||||
name: "",
|
||||
subType: subType,
|
||||
connectionType: "USB",
|
||||
connectionType: "",
|
||||
page: 1,
|
||||
size: 100,
|
||||
},
|
||||
|
||||
@@ -5,9 +5,9 @@ import test from "@/views/home/test.vue";
|
||||
const routes = [
|
||||
{
|
||||
path: "/",
|
||||
name: "home",
|
||||
// component: test,
|
||||
component: home,
|
||||
// name: "home",
|
||||
component: test,
|
||||
// component: home,
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
<el-form-item label="设备名称">
|
||||
<el-input v-model="form.name" placeholder="请输入设备名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型">
|
||||
<el-radio-group v-model="form.connectionType">
|
||||
<el-radio-button label="USB" value="USB"></el-radio-button>
|
||||
<el-radio-button label="局域网" value="局域网"></el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="打印机品牌">
|
||||
<el-input v-model="form.contentType" placeholder="请输入打印机品牌"></el-input>
|
||||
</el-form-item> -->
|
||||
@@ -21,17 +27,24 @@
|
||||
<el-option label="80mm" value="80mm"></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-form-item label="选择设备" 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-input v-model="form.address" placeholder="请输入设备IP地址"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类">
|
||||
<div style="cursor: pointer" @click="classifyRef.show()">
|
||||
<span style="color: #409eff" v-if="form.categoryList.length">
|
||||
{{form.categoryList.map(item => item.name).join(',')}}
|
||||
</span>
|
||||
<span style="color: #e65d6e" v-else>
|
||||
请选择分类
|
||||
</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- <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>
|
||||
@@ -125,6 +138,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<classify ref="classifyRef" @success="(e) => (form.categoryList = e)" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -136,6 +150,11 @@ import { ElMessage } from "element-plus";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { usePrint } from "@/store/print.js";
|
||||
import { printerAdd, printerDetail } from "@/api/account.js";
|
||||
import classify from "@/components/classify/index.vue";
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const classifyRef = ref(null);
|
||||
|
||||
const printStore = usePrint();
|
||||
const store = useUser();
|
||||
@@ -150,7 +169,7 @@ const requestLoading = ref(false);
|
||||
const form = ref({
|
||||
id: "",
|
||||
name: '', // 设备名称
|
||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙
|
||||
connectionType: 'USB', // 现在打印机支持USB 和 网络、蓝牙、局域网
|
||||
address: '', // 打印机名称
|
||||
port: '', // 端口
|
||||
subType: 'cash', // 打印类型(分类)label标签cash小票kitchen出品
|
||||
@@ -210,16 +229,29 @@ function getPrintList() {
|
||||
|
||||
// 测试打印
|
||||
function printHandle() {
|
||||
if (!form.value.address) {
|
||||
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||
ElMessage.error("请输入设备IP地址");
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (form.value.connectionType === 'USB') {
|
||||
printStore.pushReceiptData(printData, false);
|
||||
} else if (form.value.connectionType === '局域网') {
|
||||
ipcRenderer.send('networkPrint', JSON.stringify({
|
||||
printerIp: form.value.address,
|
||||
orderData: printData
|
||||
}))
|
||||
}
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false;
|
||||
}, 2500);
|
||||
@@ -232,11 +264,16 @@ async function submitHandle() {
|
||||
ElMessage.error("请输入设备名称");
|
||||
return;
|
||||
}
|
||||
if (!form.value.address) {
|
||||
if (form.value.connectionType === 'USB' && !form.value.address) {
|
||||
ElMessage.error("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
if (form.value.connectionType === '局域网' && !form.value.address) {
|
||||
ElMessage.error("请输入设备IP地址");
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
form.value.categoryIds = form.value.categoryList.map(item => item.id)
|
||||
await printerAdd(form.value, form.value.id ? "put" : "post");
|
||||
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
|
||||
printStore.init();
|
||||
@@ -253,6 +290,19 @@ async function tbPrintMachineDetailAjax(id) {
|
||||
requestLoading.value = true;
|
||||
const res = await printerDetail({ id: id });
|
||||
form.value = res;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog> -->
|
||||
<el-input v-model="authCode" placeholder="请扫描支付码"></el-input>
|
||||
<el-button type="primary" @click="microPayAjax">反扫支付</el-button>
|
||||
<!-- <el-input v-model="authCode" placeholder="请扫描支付码"></el-input>
|
||||
<el-button type="primary" @click="microPayAjax">反扫支付</el-button> -->
|
||||
<el-button type="primary" @click="printReceipt">调用本地网络打印机</el-button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -47,6 +48,26 @@ const tempFilePath = ref('')
|
||||
|
||||
const authCode = ref('')
|
||||
|
||||
function printReceipt() {
|
||||
let data = {
|
||||
printerIp: '192.168.1.53',
|
||||
orderData: {
|
||||
orderNo: '20260327008',
|
||||
shopName: '川味小馆',
|
||||
createTime: new Date().toLocaleString(),
|
||||
products: [
|
||||
{ name: '回锅肉', price: '32.00', num: 1 },
|
||||
{ name: '米饭', price: '2.00', num: 2 },
|
||||
{ name: '紫菜蛋花汤', price: '8.00', num: 1 }
|
||||
],
|
||||
total: '42.00',
|
||||
payType: '支付宝',
|
||||
remark: '微辣'
|
||||
}
|
||||
}
|
||||
ipcRenderer.send('portPrint', JSON.stringify(data))
|
||||
}
|
||||
|
||||
// 检查版本更新
|
||||
async function findVersionAjax() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user