打印机

This commit is contained in:
duan 2024-09-26 10:53:38 +08:00
parent 0420158601
commit a7083b85ab
4 changed files with 202 additions and 22 deletions

View File

@ -1,7 +1,7 @@
import request from '@/utils/request'
/**
* 增加打印机
* @returns
*/
export function tbPrintMachine(data, method = 'post') {
@ -21,12 +21,34 @@ export function tbPrintMachine(data, method = 'post') {
*/
export function tbPrintMachineGet(params) {
return request({
url: '/api/tbPrintMachine',
url: '/api/shop-config/printer/list',
method: 'get',
params: {
shopId: localStorage.getItem('shopId'),
sort: '',
...params
}
})
}
}
// 删除
export function delTableHandle(id) {
return request({
url: '/api/shop-config/printer/' + id,
method: 'DELETE',
})
}
// * 打印机详情
export function printerd(id) {
return request({
url: '/api/shop-config/printer/' + id,
method: 'get',
})
}
// 编辑 新增打印机
export function configprinter(data, method = "post") {
return request({
url: `/api/shop-config/printer`,
method: method,
data
});
}

View File

@ -0,0 +1,144 @@
<template>
<div class="app-container">
<el-form :model="forms">
<el-form-item label="打印机品牌">
<el-select v-model="forms.contentType" placeholder="请选择打印机品牌">
<el-option label="云想印" value="yxyPrinter"></el-option>
<el-option label="飞鹅" value="fePrinter"></el-option>
<!-- <el-option label="本地" value="local"></el-option> -->
<!-- <el-option label="USB" value="printer"></el-option> -->
</el-select>
</el-form-item>
<el-form-item label="小票打印">
<el-select v-model="forms.subType" placeholder="请选择小票打印">
<el-option label="标签" value="label"></el-option>
<el-option label="出品" value="kitchen"></el-option>
<el-option label="小票" value="cash"></el-option>
</el-select>
</el-form-item>
<el-form-item label="打印机名称">
<el-input v-model="forms.name" style="width: 280px;" placeholder="请输入打印机名称"></el-input>
</el-form-item>
<!-- <template v-if="forms.contentType == 'network'"> -->
<el-form-item label="打印机编号">
<el-input v-model="forms.address" style="width: 280px;" placeholder="请输入打印机编号"></el-input>
</el-form-item>
<el-form-item label="打印机秘钥">
<el-input v-model="forms.port" style="width: 280px;" placeholder="请输入打印机秘钥"></el-input><br />
<div style="margin-left: 80px;color: #FF4D4F;">* 可在打印机设备底部查看打印机编号和秘钥(key)</div>
</el-form-item>
<!-- </template> -->
<!-- <template v-if="forms.contentType == 'local'"> <el-form-item label="IP地址">
<el-input v-model="forms.address" style="width: 280px;" placeholder="请输入打印机编号"></el-input>
</el-form-item>
<el-form-item label="端口">
<el-input v-model="forms.port" style="width: 280px;" placeholder="请输入打印机秘钥"></el-input><br />
<div style="margin-left: 80px;color: #FF4D4F;">* 可在打印机设备底部查看打印机编号和秘钥(key)</div>
</el-form-item>
</template> -->
<el-form-item label="小票尺寸">
<el-radio-group v-model="forms.receiptSize">
<el-radio label="58mm"></el-radio>
<el-radio label="80mm"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="分类打印">
<el-radio-group v-model="forms.classifyPrint">
<el-radio label="0">打印所有</el-radio>
<el-radio label="1">部分分类</el-radio>
<el-radio label="2">部分商品</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="桌台打印">
<el-radio-group v-model="forms.tablePrint">
<el-radio label="0">打印所有</el-radio>
<el-radio label="1">打印部分桌台</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="打印数量">
<el-radio-group v-model="forms.printQty">
<el-radio label="c1m1^2">顾客联+商家联2</el-radio>
<el-radio label="m1^1">只打印商家联1</el-radio>
<el-radio label="c1^1">只打印顾客联1</el-radio>
<el-radio label="c2m1^3">2张顾客联+1张商家联3</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="打印方式">
<el-radio-group v-model="forms.printMethod">
<el-radio label="1">普通</el-radio>
<el-radio label="2">单个菜</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="打印类型">
<el-checkbox-group v-model="forms.printType">
<el-checkbox label="1">确认退款单</el-checkbox>
<el-checkbox label="2">交班单</el-checkbox>
<el-checkbox label="3">排队取号</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="打印单据">
<el-radio-group v-model="forms.printReceipt">
<el-radio label="0">全部打印</el-radio>
<el-radio label="1">仅厨房</el-radio>
<el-radio label="2">仅前台</el-radio>
</el-radio-group>
<div style="margin-left: 80px;color: #FF4D4F;">如果你的店只使用一台小票机建议选择全部打印</div>
</el-form-item>
<el-form-item label="打印机状态">
<el-switch v-model="forms.status" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item label-width="80px">
<el-button type="primary" @click="$router.go(-1)">返回</el-button>
<el-button type="primary" @click="onSubmit">保存</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import { configprinter, printerd } from '@/api/devices'
export default {
components: {
},
data() {
return {
forms: {
sort: "0",
status: "0",
connectionType: "network", printType: []
}
}
},
filters: {
},
mounted() {
if (this.$route.query.id) {
this.getList(this.$route.query.id)
}
},
methods: {
async onSubmit() {
//
if( this.$route.query.id ){
delete this.forms.createdAt
delete this.forms.updatedAt
}
const res = await configprinter({
shopId: localStorage.getItem('shopId'),
...this.forms,
},
this.$route.query.id ? 'put' : 'post'
)
this.$router.go(-1)
},
async getList(id) {
const res = await printerd(id)
this.forms = res
this.forms.printType = JSON.parse(res.printType)
}
}
}
</script>

View File

@ -1,15 +1,15 @@
export const devices = [
{
value: 'printer',
value: 'local',
name: '本地'
},
{
value: 'yxyPrinter',
value: 'network',
name: '云想印'
},
{
value: 'fePrinter',
name: '飞鹅'
value: 'USB',
name: 'USB打印机'
}
]

View File

@ -17,7 +17,7 @@
</el-form>
</div>
<div class="head-container">
<el-button type="primary" icon="el-icon-plus" @click="$refs.addDevice.show()">
<el-button type="primary" icon="el-icon-plus" @click="toUrl">
添加云打印机
</el-button>
</div>
@ -30,11 +30,11 @@
{{ scope.row.contentType | devicesName }}
</template>
</el-table-column>
<el-table-column label="出品模式" prop="config.model">
<!-- <el-table-column label="出品模式" prop="config.model">
<template v-slot="scope">
{{ scope.row.config.model | modelsName }}
</template>
</el-table-column>
</el-table-column> -->
<el-table-column label="打印类型" prop="subType">
<template v-slot="scope">
{{ scope.row.subType | subTypesName }}
@ -45,7 +45,7 @@
{{ scope.row.createdAt | timeFilter }}
</template>
</el-table-column>
<el-table-column label="排序" sortable prop="sort"></el-table-column>
<!-- <el-table-column label="排序" sortable prop="sort"></el-table-column> -->
<el-table-column label="状态" prop="status">
<template v-slot="scope">
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0"
@ -55,7 +55,7 @@
<el-table-column label="操作" width="200">
<template v-slot="scope">
<el-button type="text" icon="el-icon-edit"
@click="$refs.addDevice.show(scope.row)">编辑</el-button>
@click="toUrl(scope.row)">编辑</el-button>
<el-popconfirm title="确定删除吗?" @confirm="delTableHandle([scope.row.id])">
<el-button type="text" icon="el-icon-delete" style="margin-left: 20px !important;"
slot="reference">删除</el-button>
@ -75,7 +75,7 @@
<script>
import { devices, models, subTypes } from './devices'
import addDevice from './components/addDevice'
import { tbPrintMachineGet, tbPrintMachine } from '@/api/devices'
import { tbPrintMachineGet, tbPrintMachine, delTableHandle } from '@/api/devices'
import dayjs from 'dayjs'
export default {
components: {
@ -99,16 +99,20 @@ export default {
},
filters: {
devicesName(value) {
const item=devices.find(item => item.value == value)
return item?item.name:''
if (value == 'yxyPrinter') {
return '云想印'
} else if (value == 'fePrinter') '飞鹅'
// const item=devices.find(item => item.value == value)
// return item?item.name:''
},
modelsName(value) {
const item=models.find(item => item.value == value)
return item?item.name:''
const item = models.find(item => item.value == value)
return item ? item.name : ''
},
subTypesName(value) {
const item=subTypes.find(item => item.value == value)
return item?item.name:''
if (value == "label") return '标签'
else if (value == 'kitchen') return '出品'
else if (value == 'cash') return '小票'
},
timeFilter(s) {
return dayjs(s).format('YYYY-MM-DD HH:mm:ss')
@ -118,6 +122,9 @@ export default {
this.getTableData()
},
methods: {
toUrl(item) {
this.$router.push({ path: '/shop/devices/details', query:{id:item.id}})
},
//
async statusChange(e, row) {
try {
@ -142,13 +149,20 @@ export default {
this.tableData.page = e - 1
this.getTableData()
},
//
async delTableHandle(item) {
const res = await delTableHandle(item)
this.getTableData()
},
//
async getTableData() {
this.tableData.loading = true
try {
const res = await tbPrintMachineGet({
name: this.query.name,
contentType: this.query.type
shopId: localStorage.getItem('shopId'),
contentType: this.query.type,
sort: '',
})
this.tableData.loading = false
this.tableData.data = res