Compare commits

...

4 Commits

Author SHA1 Message Date
zhaoyf
4902c0e9a1 Merge remote-tracking branch 'origin/master' 2026-05-29 15:24:21 +08:00
zhaoyf
c3b58b1d0d opt:大屏打印功能-新增打印机管理页面支持多打印机 2026-05-09 14:22:25 +08:00
zhaoyf
5427d7c414 add:大屏新增打印功能-调整为zpl指令网络打印方式 2026-05-06 14:29:00 +08:00
zhaoyf
f9bf40b415 add:大屏新增打印功能 2026-04-24 10:13:17 +08:00
17 changed files with 829 additions and 13 deletions

View File

@@ -0,0 +1,71 @@
package org.nl.system.controller.printer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.system.service.param.dao.Param;
import org.nl.system.service.printer.ISysPrinterService;
import org.nl.system.service.printer.dao.SysPrinter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @author zhaoyf
* @date 2026-05-07
**/
@Slf4j
@RestController
@RequestMapping("/api/printer")
@Api("打印机管理")
public class SysPrinterController {
@Autowired
private ISysPrinterService iSysPrinterService;
@GetMapping
@Log("查询所有打印机")
@ApiOperation("查询打印机")
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
return new ResponseEntity<>(TableDataInfo.build(iSysPrinterService.queryAll(whereJson, page)), HttpStatus.OK);
}
@GetMapping("/all")
public ResponseEntity<Object> all(){
return new ResponseEntity<>(iSysPrinterService.list(),HttpStatus.OK);
}
@PostMapping
@Log("新增打印机")
@ApiOperation("新增")
public ResponseEntity<Object> create(@Validated @RequestBody SysPrinter param){
iSysPrinterService.create(param);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改打印机参数")
@ApiOperation("修改打印机参数")
public ResponseEntity<Object> update(@Validated @RequestBody SysPrinter param){
iSysPrinterService.update(param);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除打印机")
@ApiOperation("删除打印机")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
List<String> Ids = Arrays.asList(ids);
iSysPrinterService.deleteAll(Ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,44 @@
package org.nl.system.service.printer;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.common.domain.query.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.system.service.printer.dao.SysPrinter;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @description 服务接口
* @author zhaoyf
* @date 2026-05-07
**/
public interface ISysPrinterService extends IService<SysPrinter> {
/**
* 查询数据分页
* @param whereJson 条件
* @param pageable 分页参数
* @return IPage<SysPrinter>
*/
IPage<SysPrinter> queryAll(Map whereJson, PageQuery pageable);
/**
* 创建
* @param entity /
*/
void create(SysPrinter entity);
/**
* 编辑
* @param entity /
*/
void update(SysPrinter entity);
/**
* 多选删除
* @param ids /
*/
void deleteAll(List<String> ids);
}

View File

@@ -0,0 +1,77 @@
package org.nl.system.service.printer.dao;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @description /
* @author zhaoyf
* @date 2026-05-07
**/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_printer")
public class SysPrinter implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String name;
private String ip;
private Integer port;
/**
* 备注
*/
private String remark;
/**
* 是否启用
*/
private Boolean is_active;
/**
* 是否删除
*/
private Boolean is_delete;
/**
* 创建者ID
*/
private String create_id;
/**
* 创建者
*/
private String create_name;
/**
* 创建时间
*/
private String create_time;
/**
* 修改者ID
*/
private String update_id;
/**
* 修改者
*/
private String update_name;
/**
* 修改时间
*/
private String update_time;
}

View File

@@ -0,0 +1,12 @@
package org.nl.system.service.printer.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.nl.system.service.printer.dao.SysPrinter;
/**
* @author zhaoyf
* @date 2026-05-07
**/
public interface SysPrinterMapper extends BaseMapper<SysPrinter> {
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.system.service.printer.dao.mapper.SysPrinterMapper">
</mapper>

View File

@@ -0,0 +1,14 @@
package org.nl.system.service.printer.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @description /
* @author zhaoyf
* @date 2026-05-07
**/
@Data
public class SysPrinterDto implements Serializable {
}

View File

@@ -0,0 +1,12 @@
package org.nl.system.service.printer.dto;
import org.nl.common.domain.query.BaseQuery;
import org.nl.system.service.printer.dao.SysPrinter;
/**
* @author zhaoyf
* @date 2026-05-07
**/
public class SysPrinterQuery extends BaseQuery<SysPrinter> {
}

View File

@@ -0,0 +1,80 @@
package org.nl.system.service.printer.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.SecurityUtils;
import org.nl.system.service.printer.ISysPrinterService;
import org.nl.system.service.printer.dao.SysPrinter;
import org.nl.system.service.printer.dao.mapper.SysPrinterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @description 服务实现
* @author zhaoyf
* @date 2026-05-07
**/
@Slf4j
@Service
public class SysPrinterServiceImpl extends ServiceImpl<SysPrinterMapper, SysPrinter> implements ISysPrinterService {
@Autowired
private SysPrinterMapper sysPrinterMapper;
@Override
public IPage<SysPrinter> queryAll(Map whereJson, PageQuery page){
LambdaQueryWrapper<SysPrinter> lam = new LambdaQueryWrapper<>();
IPage<SysPrinter> pages = new Page<>(page.getPage() + 1, page.getSize());
sysPrinterMapper.selectPage(pages, lam);
return pages;
}
@Override
public void create(SysPrinter entity) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
entity.setCreate_id(currentUserId);
entity.setCreate_name(nickName);
entity.setCreate_time(now);
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
sysPrinterMapper.insert(entity);
}
@Override
public void update(SysPrinter entity) {
SysPrinter dto = sysPrinterMapper.selectById(entity.getId());
if (dto == null) throw new BadRequestException("被删除或无权限,操作失败!");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
entity.setUpdate_id(currentUserId);
entity.setUpdate_name(nickName);
entity.setUpdate_time(now);
sysPrinterMapper.updateById(entity);
}
@Override
public void deleteAll(List<String> ids) {
// 真删除
sysPrinterMapper.deleteBatchIds(ids);
}
}

View File

@@ -13,6 +13,7 @@ import org.nl.common.logging.annotation.Log;
import org.nl.wms.ext.fab.service.dto.CallEmpVo;
import org.nl.wms.ext.fab.service.impl.FabServiceImpl;
import org.nl.wms.ext.handheld.dto.EmptyVehicleWarehousingDto;
import org.nl.wms.ext.handheld.dto.PrintEntityDto;
import org.nl.wms.ext.handheld.service.HandheldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -262,4 +263,15 @@ public class HandheldController {
fabService.createAgvTask(toJSON, "cnt");
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK);
}
/**
* 大屏打印订单
* @return
*/
@Log("大屏打印订单标签")
@PostMapping("/print")
public ResponseEntity<Object> print(@RequestBody PrintEntityDto printEntityDto) {
handheldService.print(printEntityDto);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,22 @@
package org.nl.wms.ext.handheld.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class PrintEntityDto {
@JsonProperty("order_code")
private String orderCode;
@JsonProperty("create_time")
private String createTime;
@JsonProperty("material_qty")
private String materialQty;
@JsonProperty("material_id")
private String materialId;
@JsonProperty("material_code")
private String MaterialCode;
@JsonProperty("username")
private String username;
private String ip;
private Integer port;
}

View File

@@ -3,6 +3,7 @@ package org.nl.wms.ext.handheld.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.ext.handheld.dto.EmptyVehicleWarehousingDto;
import org.nl.wms.ext.handheld.dto.PrintEntityDto;
import org.nl.wms.sch.group_delete_log.service.dto.SD01GroupLogRespondDto;
import java.util.List;
@@ -207,4 +208,9 @@ public interface HandheldService {
*/
JSONObject queryVehicleTaskStatus(String vehicleCode);
/**
* 大屏打印订单标签
* @param printEntityDto 打印内容实体
*/
void print(PrintEntityDto printEntityDto);
}

View File

@@ -1,21 +1,16 @@
package org.nl.wms.ext.handheld.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Synchronized;
import nl.basjes.shaded.org.springframework.util.Assert;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.enums.GoodsEnum;
@@ -24,13 +19,13 @@ import org.nl.common.enums.region.RegionEnum;
import org.nl.system.service.dict.ISysDictService;
import org.nl.system.service.dict.dao.Dict;
import org.nl.wms.ext.handheld.dto.EmptyVehicleWarehousingDto;
import org.nl.wms.ext.handheld.dto.PrintEntityDto;
import org.nl.wms.ext.handheld.dto.VehicleDto;
import org.nl.wms.sch.group_delete_log.service.dao.SchBaseVehiclematerialgroupDeleteLog;
import org.nl.wms.sch.group_delete_log.service.ISchBaseVehiclematerialgroupDeleteLogService;
import org.nl.wms.sch.group_delete_log.service.dto.LogMaterialDto;
import org.nl.wms.sch.group_delete_log.service.dto.SD01GroupLogRespondDto;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.RedisUtils;
import org.nl.common.utils.SecurityUtils;
@@ -59,17 +54,20 @@ import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.task.TaskFactory;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.core.TaskType;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
@@ -117,6 +115,9 @@ public class HandheldServiceImpl implements HandheldService {
// 线程池,用于异步执行任务
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
@Autowired
private SysParamServiceImpl sysParamServiceImpl;
@Override
@@ -1042,7 +1043,9 @@ public class HandheldServiceImpl implements HandheldService {
List<Map> maps = iSchBaseVehiclematerialgroupService.selectOrdersByVehicleCode(list);
HashSet<Map> keys = new HashSet<>();
maps.stream().forEach(item -> {
keys.add(MapOf.of("material_id", item.get("material_id"), "material_path", item.get("material_path")));
keys.add(MapOf.of("material_id", item.get("material_id"), "material_path", item.get("material_path"),
"order_code",item.get("order_code"),"material_code", item.get("material_code"),
"create_time", item.get("create_time"),"material_qty", item.get("material_qty")));
});
JSONObject json = new JSONObject();
Map<String, String> map = new HashMap<>();
@@ -1718,4 +1721,50 @@ public class HandheldServiceImpl implements HandheldService {
}
}
@Override
public void print(PrintEntityDto printEntityDto) {
if (printEntityDto.getIp() == null || StringUtils.isBlank(printEntityDto.getIp())) {
throw new BadRequestException("打印出错未配置打印机IP(printerIP)");
}
if (printEntityDto.getPort() == null) {
throw new BadRequestException("打印出错:未配置打印机端口(printerPort)");
}
try (Socket client = new Socket()) {
// 3. 设置超时时间,防止网络不通时线程卡死 (单位:毫秒)
client.connect(new InetSocketAddress(printEntityDto.getIp(), printEntityDto.getPort()), 3000); // 连接超时 3秒
client.setSoTimeout(10000); // 读取超时 10秒
try (OutputStream outputStream = client.getOutputStream()) {
StringBuilder zplStr = new StringBuilder();
// TODO: 在此拼接 ZPL 指令
zplStr.append("^XA");//开始
zplStr.append("^CI28");// 启用UTF-8字符集支持中文显示部分老机型若乱码请改用 ^CI13
zplStr.append("^CW1,E:SIMSUN.FNT");//设置中文字体
zplStr.append("^FO50,75^A1,55,55^FD订单号^FS");
zplStr.append("^FO250,50^BC,50,50^FD"+printEntityDto.getOrderCode()+"^FS");//订单号条码
zplStr.append("^FO250,100^A1,50,50^FD"+printEntityDto.getOrderCode()+"^FS");//订单号
zplStr.append("^FO50,175^A1,55,55^FD物料号^FS");
zplStr.append("^FO250,150^BC,50,50^FD"+printEntityDto.getOrderCode()+"^FS");//物料号条码
zplStr.append("^FO250,200^A1,50,50^FD"+printEntityDto.getOrderCode()+"^FS");//物料号
zplStr.append("^FO50,275^A1,55,55^FD数量^FS");
zplStr.append("^FO250,275^A1,50,50^FD"+printEntityDto.getMaterialQty()+"^FS");//数量
zplStr.append("^FO50,350^A1,55,55^FD日期^FS");
zplStr.append("^FO250,350^A1,50,50^FD"+printEntityDto.getCreateTime()+"^FS");//日期
zplStr.append("^FO50,425^A1,55,55^FD人员^FS");
zplStr.append("^FO250,425^A1,50,50^FD"+printEntityDto.getUsername()+"^FS");//人员
zplStr.append("^XZ");//结束
// 4. 将 ZPL 指令写入输出流并发送
if (zplStr.length() > 0) {
outputStream.write(zplStr.toString().getBytes(StandardCharsets.UTF_8));
outputStream.flush(); // 必须 flush确保数据发送到打印机
}
}
} catch (IOException e) {
// 5. 异常处理:不要仅仅抛出 e.getMessage(),有时候它为空
throw new BadRequestException("打印出错,连接打印机失败: " + e.getMessage());
}
}
}

View File

@@ -146,8 +146,12 @@
sbv.vehicle_path,
sbv.material_path,
sbv.material_qty,
sbv.due_date
sbv.due_date,
sbv.create_time,
m.material_code
FROM sch_base_vehiclematerialgroup sbv
LEFT JOIN md_base_material m ON sbv.material_id = m.material_id
WHERE sbv.vehicle_code IN
<foreach item="code" collection="list" open="(" separator="," close=")">
#{code}

View File

@@ -0,0 +1,128 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
:before-close="crud.cancelCU"
:visible.sync="crud.status.cu > 0"
:title="crud.status.title"
width="550px"
>
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="100px">
<el-form-item label="打印机名称" prop="name">
<el-input v-model="form.name" style="width: 370px;" />
</el-form-item>
<el-form-item label="IP地址" prop="ip">
<el-input v-model="form.ip" style="width: 370px;" />
</el-form-item>
<el-form-item label="端口" prop="port">
<el-input v-model="form.port" style="width: 370px;" />
</el-form-item>
<el-form-item label="备注" prop="description">
<el-input v-model="form.remark" style="width: 380px;" rows="5" type="textarea" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
size="mini"
style="width: 100%;"
@selection-change="crud.selectionChangeHandler"
>
<el-table-column type="selection" width="55" />
<el-table-column v-if="false" prop="id" label="id" />
<el-table-column prop="name" label="打印机名称" min-width="130" show-overflow-tooltip />
<el-table-column prop="ip" label="IP地址" min-width="120" show-overflow-tooltip />
<el-table-column prop="port" label="端口" min-width="270" show-overflow-tooltip />
<el-table-column prop="remark" label="备注" />
<el-table-column v-permission="['admin','param:edit','param:del']" label="操作" width="150px" align="center">
<template slot-scope="scope">
<udOperation
:data="scope.row"
:permission="permission"
/>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>
<script>
import crudPrinter from '@/views/system/printer/printer'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
const defaultForm = {
ip: null,
name: null,
port: null,
remark: null
}
export default {
name: 'Printer',
components: { pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({ title: '打印机管理', url: 'api/printer', idField: 'id', sort: 'id,desc', crudMethod: { ...crudPrinter },
optShow: {
add: true,
edit: true,
del: true,
download: false,
reset: true
}
})
},
data() {
return {
permission: {
add: ['admin', 'printer:add'],
edit: ['admin', 'printer:edit'],
del: ['admin', 'printer:del']
},
rules: {
ip: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
name: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
port: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}
}
},
created() {
// this.webSocket()
},
methods: {
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
},
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,34 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'api/printer',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'api/printer/',
method: 'delete',
data: ids
})
}
export function edit(data) {
return request({
url: 'api/printer',
method: 'put',
data
})
}
export function getValueByCode(code) {
return request({
url: 'api/printer/getValueByCode/' + code,
method: 'post'
})
}
export default { add, edit, del, getValueByCode }

View File

@@ -314,6 +314,11 @@
prop="material_id"
label="图纸查看"
/>
<el-table-column>
<template slot-scope="scope">
<button v-if="scope.row.material_id != undefined" class="call-button" @click="doPrint(scope.row)">打印</button>
</template>
</el-table-column>
</el-table>
</div>
</div>
@@ -324,6 +329,9 @@
<el-col :span="4">
<button class="login_button" @click="toSure">确定</button>
</el-col>
<el-col :span="4">
<button class="login_button" @click="customPrint">自定义打印</button>
</el-col>
</el-row>
</div>
<div v-show="type === 'CACHE'" class="pop-wraper" :class="{'popshow': show, 'pophide': !show}">
@@ -391,13 +399,142 @@
</el-row>
</div>
<div v-show="errorShow" class="modal" style="z-index: 22;" />
<!-- 打印确认弹窗-->
<div v-show="printShow" class="pop-wraper pop-wraper-1" :class="{'popshow': printShow, 'pophide': !printShow}" style="z-index: 23;">
<div class="pop-h1">确认打印内容</div>
<div class="filter-items">
<div class="info-list" style="color: #F0F3F4">
<div class="info-item">
<div class="info-label">打印机</div>
<div class="info-value">
<el-row class="filter-wraper" style="margin-bottom: 0" type="flex" justify="space-between">
<el-col style="width: 100%;" class="select-wraper">
<el-select v-model="printer" :popper-append-to-body="false" placeholder="请选择">
<el-option
v-for="item in printers"
:key="item.name"
:label="item.name"
:value="item.name"
class="option-wraper"
/>
</el-select>
</el-col>
</el-row>
</div>
</div>
<!-- 订单号 竖向行 -->
<div class="info-item">
<div class="info-label">订单号</div>
<div class="info-value">{{printData.order_code}}</div>
</div>
<!-- 物料号 竖向行 -->
<div class="info-item">
<div class="info-label">物料号</div>
<div class="info-value">{{printData.material_code}}</div>
</div>
<!-- 数量 竖向行 -->
<div class="info-item">
<div class="info-label">数量</div>
<div class="info-value amount">{{printData.material_qty}}</div>
</div>
<!-- 日期 竖向行 -->
<div class="info-item">
<div class="info-label">日期</div>
<div class="info-value date">{{printData.create_time}}</div>
</div>
<!-- 人员 竖向行 -->
<div class="info-item">
<div class="info-label">人员</div>
<div class="info-value">{{printData.username}}</div>
</div>
</div>
</div>
<el-row type="flex" justify="space-around">
<el-col :span="6">
<button class="login_button login_button_dis" @click="printShow = false">取消</button>
</el-col>
<el-col :span="6">
<button class="login_button" @click="confirmPrint">确认打印</button>
</el-col>
</el-row>
</div>
<!-- 自定义打印弹窗-->
<div v-show="customPrintShow" class="pop-wraper pop-wraper-1" :class="{'popshow': customPrintShow, 'pophide': !customPrintShow}" style="z-index: 23;">
<div class="pop-h1">自定义打印</div>
<div class="filter-items">
<div class="info-list" style="color: #F0F3F4">
<!-- 订单号 竖向行 -->
<div class="info-item">
<div class="info-label">打印机</div>
<div class="info-value">
<el-row class="filter-wraper" style="margin-bottom: 0" type="flex" justify="space-between">
<el-col style="width: 100%;" class="select-wraper">
<el-select v-model="printer" :popper-append-to-body="false" placeholder="请选择">
<el-option
v-for="item in printers"
:key="item.name"
:label="item.name"
:value="item.name"
class="option-wraper"
/>
</el-select>
</el-col>
</el-row>
</div>
</div>
<!-- 订单号 竖向行 -->
<div class="info-item">
<div class="info-label">订单号</div>
<div class="info-value"><input v-model="customPrintData.order_code" type="text" class="set-input"></div>
</div>
<!-- 物料号 竖向行 -->
<div class="info-item">
<div class="info-label">物料号</div>
<div class="info-value"><input v-model="customPrintData.material_code" type="text" class="set-input"></div>
</div>
<!-- 数量 竖向行 -->
<div class="info-item">
<div class="info-label">数量</div>
<div class="info-value amount"><input v-model="customPrintData.material_qty" type="text" class="set-input"></div>
</div>
<!-- 日期 竖向行 -->
<div class="info-item">
<div class="info-label">日期</div>
<div class="info-value date"><input v-model="customPrintData.create_time" type="text" class="set-input"></div>
</div>
<!-- 人员 竖向行 -->
<div class="info-item">
<div class="info-label">人员</div>
<div class="info-value"><input v-model="customPrintData.username" type="text" class="set-input"></div>
</div>
</div>
</div>
<el-row type="flex" justify="space-around">
<el-col :span="6">
<button class="login_button login_button_dis" @click="customPrintShow = false">取消</button>
</el-col>
<el-col :span="6">
<button class="login_button" @click="confirmCustomPrint">确认打印</button>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
import crudProduceScreen from './produceScreen'
import crudProduceScreen, {getAllPrinter, sendPrint} from './produceScreen'
import {getAgvStatus} from '@/api/agv_alarm'
// import crudProduceScreen from './mork'
export default {
data() {
return {
@@ -424,7 +561,20 @@ export default {
// 异常信息相关属性
hasError: false,
errorDetails: [],
errorShow: false
errorShow: false,
printShow: false,
customPrintShow: false,
printData: {},
printers: [],
printer: '',
customPrintData: {
order_code: '',
create_time: new Date().toLocaleString() || '',
material_qty: '',
material_id: '',
material_code: '',
username: JSON.parse(localStorage.getItem('screenData')).username
}
}
},
computed: {
@@ -525,6 +675,45 @@ export default {
this.show = true
}
},
doPrint(row) {
console.log(row)
this.getAllPrinter()
this.printShow = true
this.printData = row
this.printData.username = JSON.parse(localStorage.getItem('screenData')).username || ''
},
confirmCustomPrint() {
console.log(this.customPrintData)
this.sendPrint(this.customPrintData)
this.customPrintShow = false
},
confirmPrint() {
console.log(this.printData)
this.sendPrint(this.printData)
this.printShow = false
this.printData = {}
},
customPrint() {
this.getAllPrinter()
this.customPrintData.create_time = new Date().toLocaleString()
this.customPrintShow = true
},
sendPrint(data) {
console.log(this.printer)
const printer = this.printers.filter(item => item.name === this.printer)
console.log(printer)
data.ip = printer[0].ip
data.port = printer[0].port
sendPrint(data).then(res => {
console.log(res)
})
},
getAllPrinter() {
getAllPrinter().then(res => {
console.log(res)
this.printers = res
})
},
handleCurrentChange(val) {
if (val) {
if (val.is_lock === '1') { // 如果点击的是占用状态的行,重置相关数据
@@ -1024,4 +1213,46 @@ export default {
.text-large .search_button {
font-size: 16px;
}
/*确认打印内容样式*/
/* 竖向信息列表 - 干净利落 */
.info-list {
display: flex;
flex-direction: column;
gap: 1rem;
}
.info-item {
display: flex;
align-items: flex-start;
gap: 12px;
align-items: center;
}
/* 左侧标签区 - 固定宽度,整洁 */
.info-label {
min-width: 68px;
font-size: 0.85rem;
font-weight: 500;
letter-spacing: 0.3px;
padding-top: 2px;
}
/* 右侧内容区 - 可换行,竖向自然 */
.info-value {
flex: 1;
font-size: 0.95rem;
font-weight: 500;
word-break: break-word;
line-height: 1.4;
}
/* 针对不同字段轻微风格微调 */
.info-value.amount {
font-weight: 600;
}
.info-value.date {
font-family: monospace;
letter-spacing: 0.3px;
}
</style>

View File

@@ -143,6 +143,21 @@ export function getExceptionMessage(deviceCode) {
method: 'get'
})
}
//17.打印标签
export function sendPrint(data) {
return request({
url: 'api/handheld/print',
method: 'post',
data
})
}
//18.获取所有打印机
export function getAllPrinter() {
return request({
url: 'api/printer/all',
method: 'get'
})
}
export default {
authLogin, getUserOrDevice, deviceInLogin, regionOrder, fabMaterial, callMater, callEmp, fabOrders, sendMater, sendVehicle, getPointVehicle, loginOut, selectMaterialAndJpg, selectCacheTask, deletevehiclemessage, getExceptionMessage