|
@@ -228,6 +228,8 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { SlickList, SlickItem } from "vue-slicksort";
|
|
import { SlickList, SlickItem } from "vue-slicksort";
|
|
|
|
+import axios from "axios";
|
|
|
|
+import $ from "jquery";
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
SlickList,
|
|
SlickList,
|
|
@@ -529,7 +531,6 @@ export default {
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: "房号",
|
|
title: "房号",
|
|
- key: "",
|
|
|
|
align: "center",
|
|
align: "center",
|
|
key: "number_detail",
|
|
key: "number_detail",
|
|
minWidth: 100,
|
|
minWidth: 100,
|
|
@@ -655,23 +656,21 @@ export default {
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
this.getOptions();
|
|
this.getOptions();
|
|
- const wxsoect = new WebSocket("ws://127.0.0.1:1808");
|
|
|
|
- this.wxsoect = wxsoect;
|
|
|
|
- wxsoect.onopen = function(evt) {
|
|
|
|
- console.log(`已成功打开`);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- wxsoect.onclose = function(evt) {
|
|
|
|
- console.log(`已断开socket连接`);
|
|
|
|
- };
|
|
|
|
|
|
+ // const wxsoect = new WebSocket("ws://localhost:8080");
|
|
|
|
+ // this.wxsoect = wxsoect;
|
|
|
|
+ // wxsoect.onopen = function(evt) {
|
|
|
|
+ // console.log(`已成功打开`);
|
|
|
|
+ // };
|
|
|
|
|
|
- wxsoect.onerror = function(err) {
|
|
|
|
- throw new Error(err);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- wxsoect.onmessage = function(message) {
|
|
|
|
- console.log(message);
|
|
|
|
- };
|
|
|
|
|
|
+ // wxsoect.onclose = function(evt) {
|
|
|
|
+ // console.log(`已断开socket连接`);
|
|
|
|
+ // };
|
|
|
|
+ // wxsoect.onerror = function(err) {
|
|
|
|
+ // throw new Error(err);
|
|
|
|
+ // };
|
|
|
|
+ // wxsoect.onmessage = function(message) {
|
|
|
|
+ // console.log(message);
|
|
|
|
+ // };
|
|
this.axios("/api/bp_list").then((res) => {
|
|
this.axios("/api/bp_list").then((res) => {
|
|
this.info.bps = res.data;
|
|
this.info.bps = res.data;
|
|
});
|
|
});
|
|
@@ -987,12 +986,12 @@ export default {
|
|
.catch((err) => {});
|
|
.catch((err) => {});
|
|
},
|
|
},
|
|
openShipModal(row) {
|
|
openShipModal(row) {
|
|
- if (this.wxsoect.readyState != 1) {
|
|
|
|
- return this.$Message.error("打印机未正常连接,请检查");
|
|
|
|
- }
|
|
|
|
- if (Array.isArray(row) && row.length < 1) {
|
|
|
|
- return this.$Message.warning("请先择");
|
|
|
|
- }
|
|
|
|
|
|
+ // if (this.wxsoect.readyState != 1) {
|
|
|
|
+ // return this.$Message.error("打印机未正常连接,请检查");
|
|
|
|
+ // }
|
|
|
|
+ // if (Array.isArray(row) && row.length < 1) {
|
|
|
|
+ // return this.$Message.warning("请先择");
|
|
|
|
+ // }
|
|
const result = row.map((pre) => pre.id);
|
|
const result = row.map((pre) => pre.id);
|
|
this.confirmDelete({
|
|
this.confirmDelete({
|
|
title: "批量打印芯片",
|
|
title: "批量打印芯片",
|
|
@@ -1008,14 +1007,139 @@ export default {
|
|
if (resp.code == 200) {
|
|
if (resp.code == 200) {
|
|
const result = resp.data;
|
|
const result = resp.data;
|
|
console.log(result, "多打印");
|
|
console.log(result, "多打印");
|
|
- if (result && result.length > 0) {
|
|
|
|
- result.map((ele) => this.printDemo(ele));
|
|
|
|
- }
|
|
|
|
|
|
+ this.handlePrintChips(resp.data);
|
|
|
|
+ // if (result && result.length > 0) {
|
|
|
|
+ // result.map((ele) => this.printDemo(ele));
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ handlePrintChips(contents) {
|
|
|
|
+ let data = {};
|
|
|
|
+ let url = "http://192.168.1.110:888/postek/print";
|
|
|
|
+ data.reqParam = "1";
|
|
|
|
+ let printparamsJsonArray = [];
|
|
|
|
+ let IP = "192.168.1.58";
|
|
|
|
+ let port = 9100;
|
|
|
|
+ let IP_Port = IP + "," + port;
|
|
|
|
+ printparamsJsonArray.push({ PTK_Connect_Timer: IP_Port + ",1" });
|
|
|
|
+ printparamsJsonArray.push({ PTK_ClearBuffer: "" });
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetDirection: "B" });
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetPrintSpeed: "4" });
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetDarkness: "10" });
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_SetLabelHeight: 75 + "," + 2 + ",0,false",
|
|
|
|
+ });
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetLabelWidth: 10 });
|
|
|
|
+ contents.map((content) => {
|
|
|
|
+ const printContent_l1 = `项目:${content.client_name} 图号:${content.url_number} 区域:${content.house}号楼-${content.layer}层${content.number_detail}`;
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_DrawText_TrueType:
|
|
|
|
+ "1100,250,50,0,微软雅黑,1,700,0,0,0," + printContent_l1,
|
|
|
|
+ });
|
|
|
|
+ const printContent_l2 = `产品:${content.product_title} 部件:${content.part_title} `;
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_DrawText_TrueType:
|
|
|
|
+ "1100,200,50,0,微软雅黑,1,700,0,0,0," + printContent_l2,
|
|
|
|
+ });
|
|
|
|
+ const printContent_l3 = `材料:${content.process} `;
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_DrawText_TrueType:
|
|
|
|
+ "1100,150,50,0,微软雅黑,1,700,0,0,0," + printContent_l3,
|
|
|
|
+ });
|
|
|
|
+ const printContent_l4 = `尺寸:${content.measure} 位置:${content.position} `;
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_DrawText_TrueType:
|
|
|
|
+ "10,10,50,0,微软雅黑,1,700,0,0,0," + printContent_l4,
|
|
|
|
+ });
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_RWRFIDLabel:
|
|
|
|
+ "1,0,0," + content.chip.length / 2 + ",1," + content.chip,
|
|
|
|
+ });
|
|
|
|
+ printparamsJsonArray.push({ PTK_PrintLabel: "1,1" });
|
|
|
|
+ });
|
|
|
|
+ printparamsJsonArray.push({ PTK_CloseConnect: "" });
|
|
|
|
+ data.printparams = JSON.stringify(printparamsJsonArray);
|
|
|
|
+ // $.ajax({
|
|
|
|
+ // type: "post",
|
|
|
|
+ // url,
|
|
|
|
+ // data,
|
|
|
|
+ // headers: {
|
|
|
|
+ // "Access-Control-Allow-Origin": "*",
|
|
|
|
+ // "Access-Control-Allow-Methods": "POST",
|
|
|
|
+ // "Access-Control-Allow-Headers": "x-requested-with,content-type",
|
|
|
|
+ // },
|
|
|
|
+ // dataType: "json",
|
|
|
|
+ // timeout: 5000,
|
|
|
|
+ // success: function(result) {
|
|
|
|
+ // if (result.retval == "0") {
|
|
|
|
+ // this.$Message.success("发送成功");
|
|
|
|
+ // } else {
|
|
|
|
+ // this.$Message.error("发送失败,返回结果:" + result.msg);
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
|
|
+ // });
|
|
|
|
+ axios
|
|
|
|
+ .post(url, data)
|
|
|
|
+ .then((result) => {
|
|
|
|
+ console.log(result.msg);
|
|
|
|
+ if (result.retval == "0") {
|
|
|
|
+ this.$Message.success("发送成功");
|
|
|
|
+ } else {
|
|
|
|
+ this.$Message.error("发送失败,返回结果:" + result.msg);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch((err) => {
|
|
|
|
+ this.$Message.error("请求失败,请重试" + err.msg);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ handleConnectPrinter() {
|
|
|
|
+ let data = {};
|
|
|
|
+ data.reqParam = "1";
|
|
|
|
+ let printparamsJsonArray = [];
|
|
|
|
+ //若有且仅有一台POSTEK打印机 不用去获取USB端口号 usbPort=255即可
|
|
|
|
+ printparamsJsonArray.push({ PTK_OpenUSBPort: 255 });
|
|
|
|
+ //清空缓存
|
|
|
|
+ printparamsJsonArray.push({ PTK_ClearBuffer: "" });
|
|
|
|
+ //设置打印方向 B为从底部开始打印 T为从顶部开始打印
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetDirection: "B" });
|
|
|
|
+ //设置打印速度 最高速度由打印机的型号决定
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetPrintSpeed: "4" });
|
|
|
|
+ //设置打印黑度 最大打印黑度20 树脂碳带一般设置15左右
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetDarkness: "10" });
|
|
|
|
+ //必须正确设置标签的宽高--防止内容打偏 宽高可用尺子量取也可以查看标签的规格 一般桌面型打印机的最大打印宽度为110毫米 实际有效打印宽度根据打印机的参数决定
|
|
|
|
+ // {"PTK_SetLabelHeight" : "height,gap,gapOffset,bFlag"}
|
|
|
|
+ // height:标签的高度,以点(dots)为单位。取值:0 - 65535 的正整数
|
|
|
|
+ // gap:标签间的定位间隙\黑标\穿孔的高度,以点(dots)为单位。
|
|
|
|
+ // 取值:0 – 65535 的正整数。
|
|
|
|
+ // 当 gap=0 时,设置标签为连续纸;当实际标签不是连续纸而 gap 设置为 0
|
|
|
|
+ // 时会出现打印内容偏移的现象
|
|
|
|
+ // gapOffset:标签间隙\黑线\穿孔定位偏移值,以点(dots)为单位,参数类型为正
|
|
|
|
+ // 整数
|
|
|
|
+ // bFlag:定位偏移值(gapOffset)是否有效;true - 有效,false - 无效
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_SetLabelHeight: 75 + "," + 2 + ",0,false",
|
|
|
|
+ });
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetLabelWidth: 10 });
|
|
|
|
+ //打印一行微软雅黑的文字 具体的参数函数请参考开发文档
|
|
|
|
+ printparamsJsonArray.push({ PTK_SetFontGap: "10" });
|
|
|
|
+
|
|
|
|
+ // {"PTK_DrawText" : "x,y,pdirec,pFont,pHorizontal,pVertical,pColor,pstr"}
|
|
|
|
+
|
|
|
|
+ // pColor:文本样式,参数值及说明如下 N - 白底黑字,R - 黑底白字
|
|
|
|
+ printparamsJsonArray.push({
|
|
|
|
+ PTK_DrawText_TrueType: "10,10,0,6,2,2,N," + $("#printlabel").val(),
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //执行打印 必须有PTK_PrintLabel 否则不执行打印 {"PTK_PrintLabel" : "number,cpnumber"}
|
|
|
|
+ // number:打印标签的数量。取值:1 – 65535 的正整数
|
|
|
|
+ // cpnumber:每张标签的复制份数。取值:1 – 65535 的正整数
|
|
|
|
+ printparamsJsonArray.push({ PTK_CloseConnect: "" });
|
|
|
|
+ //执行打印完关闭打印机USB端口
|
|
|
|
+ printparamsJsonArray.push({ PTK_PrintLabel: "1,1" });
|
|
|
|
+ },
|
|
printDemo(data) {
|
|
printDemo(data) {
|
|
if (!data) return 0;
|
|
if (!data) return 0;
|
|
const st = this.wxsoect;
|
|
const st = this.wxsoect;
|