diff --git a/src/demo/design/index.vue b/src/demo/design/index.vue index afa8ffb67d9ffd431d332cc67363fe3678361bd9..f3dfdc6ac04a6f0bef17c8713f8c5c2cfa4ae633 100644 --- a/src/demo/design/index.vue +++ b/src/demo/design/index.vue @@ -198,6 +198,17 @@ export default { hiprint.init({ providers: [new defaultElementTypeProvider()] }); + //手动连接socket + // hiprint.init({ + // providers: [new defaultElementTypeProvider()] + // },true); + // hiprint.connectSocket.start(function(){ + // //成功回调 + // //获取打印机列表 直接打印等操作需在成功回调内执行 + // },function(){ + // //失败回调 + // //若无失败回调则默认执行成功回调 + // }) // 还原配置 hiprint.setConfig() // 替换配置 diff --git a/src/hiprint/hiprint.bundle.js b/src/hiprint/hiprint.bundle.js index 0843028832af39cfcf59199cb43f4f61c0b09378..012a9254d812545679901a6c0e44de6dd66841f2 100644 --- a/src/hiprint/hiprint.bundle.js +++ b/src/hiprint/hiprint.bundle.js @@ -4439,6 +4439,12 @@ var hiprint = function (t) { g.a.instance.draging = !1; var i = parseFloat(e.dragingGrip.target.css("left").replace("px", "")), o = r.a.px.toPt(i - e.dragingGrip.left); + //表格列宽限制 最小宽度为10pt + if(s.cell.width + o < 10){ + o = 10 - s.cell.width + }else if(s.nextGrip.cell.width - o < 10){ + o = s.nextGrip.cell.width - 10 + } s.cell.width = s.cell.width + o, s.nextGrip.cell.width = s.nextGrip.cell.width - o, t.resizeTableCellWidth(), s.target.removeClass("columngripDraging"), e.updateColumnGrips(); } }); @@ -5628,23 +5634,46 @@ var hiprint = function (t) { this.stop() this.start() }, - start: function start() { - var _this = this; - - var t = this; - window.WebSocket ? this.socket || (this.socket = io(this.host, { - reconnectionAttempts: 5 - }), this.socket.on("connect", function (e) { - t.opened = !0, console.log("Websocket opened."), _this.socket.on("successs", function (t) { - hinnn.event.trigger("printSuccess_" + t.templateId, t); - }), _this.socket.on("error", function (t) { - hinnn.event.trigger("printError_" + t.templateId, t); - }), _this.socket.on("printerList", function (e) { - t.printerList = e; - }), t.state = n; - }), this.socket.on("disconnect", function () { - t.opened = !1; - })) : console.log("WebSocket start fail"); + start: function start(success,error) { + var _this = this; + var t = this; + if(window.WebSocket){ + if(!this.socket){ + this.socket = io(this.host, { + reconnectionAttempts: 5 + }); + this.socket.on("connect", function (e) { + t.opened = !0, console.log("Websocket opened."); + _this.socket.on("successs", function (t) { + hinnn.event.trigger("printSuccess_" + t.templateId, t); + }); + _this.socket.on("error", function (t) { + hinnn.event.trigger("printError_" + t.templateId, t); + }) + _this.socket.on("printerList", function (e) { + t.printerList = e; + + success&&success(); + }); + t.state = n; + }); + this.socket.on("disconnect", function () { + t.opened = !1; + }) + //客户端未开启或未安装执行回调触发错误 + setTimeout(() => { + if(!t.opened){ + console.log("WebSocket connect error"); + error?(error()):(success&&success()) + } + },1500) + }else{ + success&&success(); + } + }else{ + console.log("WebSocket start fail"); + } + }, reconnect: function reconnect() { this.state !== n && this.state !== i || (this.stop(), this.ensureReconnectingState() && (console.log("Websocket reconnecting."), this.start())); @@ -6661,14 +6690,22 @@ var hiprint = function (t) { try { if (n) { - var l = parseInt(o.a.pt.toPx(this.options.getWidth() || 20)), - u = parseInt(o.a.pt.toPx(this.options.getHeight() || 20)); - new QRCode(a[0], { - width: l, - height: u, - colorDark: this.options.color || "#000000", - useSVG: !0 + //去除行高对高度的影响 + t.css('line-height',0) + //默认二维码永远居中 + a.css('text-align','center') + // var l = parseInt(o.a.pt.toPx(this.options.getWidth() || 20)), + // u = parseInt(o.a.pt.toPx(this.options.getHeight() || 20)), + var lpt = this.options.getWidth() || 20, + upt = this.options.getHeight() || 20 + var box = $('
').css({"width":(lpt>upt?upt:lpt)+'pt',"height":(lpt>upt?upt:lpt)+'pt','display':'inline-block'}) + new QRCode(box[0], { + width: "100%", + height: "100%", + colorDark: this.options.color || "#000000", + useSVG: !0 }).makeCode(n); + a.html(box) } } catch (t) { console.log(t), a.html("二维码生成失败"); @@ -7891,7 +7928,7 @@ var hiprint = function (t) { }, t; }(), ct = function () { - function t(t) { + function t(t,startcb) { var e = this; this.tempimageBase64 = {}, this.id = s.a.instance.guid(), s.a.instance.setPrintTemplateById(this.id, this); var n = t || {}; @@ -7900,6 +7937,7 @@ var hiprint = function (t) { n.template && i.panels.forEach(function (t) { e.printPanels.push(new pt(t, e.id)); }), n.fields && (this.fields = n.fields), n.settingContainer && new ut(this, n.settingContainer), n.paginationContainer && (this.printPaginationCreator = new dt(n.paginationContainer, this), this.printPaginationCreator.buildPagination()), this.initAutoSave(); + startcb&&startcb(); } return t.prototype.design = function (t, e) { @@ -8194,10 +8232,18 @@ var hiprint = function (t) { }), e; } - function mt(t) { - p.a.instance.init(t), p.a.instance.providers.forEach(function (t) { - t.addElementTypes(a.instance); - }); + + function mt(t,cb) { + //清空历史初始化记录 + a.instance.allElementTypes = [] + p.a.instance.init(t), p.a.instance.providers.forEach(function (t) { + t.addElementTypes(a.instance); + }); + //status true: 手动请求 false:自动请求 function:自动请求时 直接打印回调(打印操作放入回调正常打印) + if(hiwebSocket.hasIo()){ + hiwebSocket.start(cb); + } + } function cig(t) { @@ -8225,6 +8271,8 @@ var hiprint = function (t) { return mt; }), n.d(e, "setConfig", function () { return cig; + }), n.d(e, "connectSocket", function () { + return hiwebSocket }), n.d(e, "PrintElementTypeManager", function () { return it; }), n.d(e, "PrintElementTypeGroup", function () { @@ -8238,7 +8286,9 @@ var hiprint = function (t) { }), n.d(e, "getHtml", function () { return gt; }), $(document).ready(function () { - hiwebSocket.hasIo() && hiwebSocket.start(); + // if(hiwebSocket.hasIo()&&!window.disSocketRequest){ + // hiwebSocket.start(); + // } }); }]); @@ -8246,8 +8296,8 @@ var hiprint = function (t) { import defaultTypeProvider from './etypes/default-etyps-provider' var defaultElementTypeProvider = defaultTypeProvider(hiprint) - +var connectSocket = hiwebSocket.start export { hiprint, - defaultElementTypeProvider + defaultElementTypeProvider, }