代码拉取完成,页面将自动刷新
同步操作将从 CcSimple/vue-plugin-hiprint 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
hiprint.hiwebSocket.setHost('http://localhost:17521',(connected, e) => {
console.log('connected', connected);
console.log('e', e);
})
let hiprintTemplate = new hiprint.PrintTemplate({
template: {},
settingContainer: '#PrintElementOptionSetting',
paginationContainer: '.hiprint-printPagination',
defaultPanelName: '默认面板名称', // 默认面板名称(当面板没有 name 属性时)
onPanelAddClick: (panel, createPanel) => {
// 修改名称, 可以弹出输入框, 也可以直接修改
panel.name = '新面板' + (panel.index+1);
// 记得 调用 createPanel 创建面板
createPanel(panel);
},
});
hiprint.setConfig({
adsorbMin: 3, //吸附最小距离pt
showAdsorbLine: true, //显示吸附线
adsorbLineMin: 6, //吸附线显示最小距离pt
})
{
options: {
// 分组统计字段
groupFieldsFormatter: function(groupData,options) {
return ["name"];
}
// 分组表头
groupFormatter: function(groupData,options) {
return '<td></td>';
}
// 分组表脚
groupFooterFormatter: function(groupData,options) {
return '<td></td>';
}
}
}
let hiprintTemplate = new hiprint.PrintTemplate({
template: {},
settingContainer: '#PrintElementOptionSetting',
});
hiprintTemplate.design('#id',{ grid: true });
hinnn.toUpperCase('0',10.8) // 十点八
hinnn.toUpperCase('5',10.8) // 人民币壹拾元捌角
hinnn.toUpperCase('7',10.8) // 壹拾元捌角零分
// eg: 自定义渲染进度条样式
function(value,row,index,options) {
return `<progress value='${value}' max="1000"></progress>`;
}
1.fix toPdf options isDownload bug (toPdf 传3个参数时未正常导出pdf问题)
2.fix size-box font-family bug
3.fix 多行表头编辑bug
4.fix table 卡死问题(模板内"多表格"分页问题)
5.fix table tableSummaryTitle(底部聚合标题) 参数bug
<head>
<!-- 打印样式是必须的,你可以调整成自由链接, 注意名称 print-lock.css -->
<link rel="stylesheet" type="text/css" media="print" href="https://unpkg.com/vue-plugin-hiprint@0.0.36/dist/print-lock.css" />
<!-- 下列使用的都是 unpkg提供的 稳定性未知, 建议下载自行处理 -->
<!-- jquery 必须 -->
<script src="https://unpkg.com/jquery@3.6.1/dist/jquery.js"></script>
<!-- 条形码 -->
<script src="https://unpkg.com/jsbarcode@3.11.5/dist/JsBarcode.all.min.js"></script>
<!-- 颜色选择器 -->
<script src="https://unpkg.com/@claviska/jquery-minicolors@2.3.6/jquery.minicolors.min.js"></script>
<!-- 直接打印(print2)需要 -->
<script src="https://unpkg.com/socket.io-client@4.5.1/dist/socket.io.min.js"></script>
<!-- toPdf需要 -->
<script src="https://unpkg.com/canvg@3.0.10/lib/umd.js"></script>
<script src="https://unpkg.com/jspdf@2.5.1/dist/jspdf.umd.min.js"></script>
<script src="https://unpkg.com/html2canvas@1.4.1/dist/html2canvas.js"></script>
<!-- vue-plugin-hiprint 😃 -->
<script src="https://unpkg.com/vue-plugin-hiprint@0.0.36/dist/vue-plugin-hiprint.js"></script>
</head>
<body>
<!-- 注意 defer -->
<script defer>
console.log('vue-plugin-hiprint')
console.log(window['vue-plugin-hiprint'])
console.log('hiprint')
// hiprint 以注入 全局
console.log(hiprint)
var autoConnect = window['vue-plugin-hiprint'].autoConnect,
disAutoConnect = window['vue-plugin-hiprint'].disAutoConnect,
defaultElementTypeProvider = window['vue-plugin-hiprint'].defaultElementTypeProvider;
</script>
</body>
<head>
<!-- 打印样式是必须的,你可以调整成自由链接, 注意名称 print-lock.css -->
<link rel="stylesheet" type="text/css" media="print" href="https://unpkg.com/vue-plugin-hiprint@0.0.34/dist/print-lock.css" />
<!-- 下列使用的都是 unpkg提供的 稳定性未知, 建议下载自行处理 -->
<!-- jquery 必须 -->
<script src="https://unpkg.com/jquery@3.6.1/dist/jquery.js"></script>
<!-- 条形码 -->
<script src="https://unpkg.com/jsbarcode@3.11.5/dist/JsBarcode.all.min.js"></script>
<!-- 颜色选择器 -->
<script src="https://unpkg.com/@claviska/jquery-minicolors@2.3.6/jquery.minicolors.min.js"></script>
<!-- 直接打印(print2)需要 -->
<script src="https://unpkg.com/socket.io-client@4.5.1/dist/socket.io.min.js"></script>
<!-- toPdf需要 -->
<script src="https://unpkg.com/browse/canvg@4.0.1/dist/index.cjs"></script>
<script src="https://unpkg.com/jspdf@2.5.1/dist/jspdf.umd.min.js"></script>
<script src="https://unpkg.com/html2canvas@1.4.1/dist/html2canvas.js"></script>
<!-- vue-plugin-hiprint 😃 -->
<script src="https://unpkg.com/vue-plugin-hiprint@0.0.34/dist/vue-plugin-hiprint.js"></script>
</head>
hiprintTemplate = new hiprint.PrintTemplate({
onImageChooseClick: (target) => {
// 测试 3秒后修改图片地址值
setTimeout(() => {
// target.refresh(url,options,callback)
// 自定义处理
// target.refresh(url,false,(el,width,height)=>{
// el.options.width = width;
// el.designTarget.css('width', width + "pt");
// el.designTarget.children('.resize-panel').trigger($.Event('click'));
// })
target.refresh("https://portrait.gitee.com/uploads/avatars/user/1800/5400665_CcSimple_1591166830.png!avatar200", {
// auto: true, // 根据图片宽高自动等比(宽>高?width:height)
// width: true, // 按宽调整高
// height: true, // 按高调整宽
real: true // 根据图片实际尺寸调整(转pt)
})
}, 3000)
}
})
hiprint.setConfig({
text: {
tabs: [
// 隐藏部分 (根据已有分组顺序来)
{
name: '测试', options: [
{
name: 'title',
hidden: false
},
{
name: 'field',
hidden: true
},
]
},
],
},
image: {
tabs: [
{
// 整体替换 及当前选项卡 按新参数设定
replace: true,
name: '基本', options: [
{
name: 'field',
hidden: false
},
{
name: 'src',
hidden: false
},
{
name: 'fit',
hidden: false
}
]
},
],
}
});
// 单选时 返回 [e]
let els = hiprintTemplate.getSelectEls();
console.log(els)
// 更新当前选中元素字体为 12pt
hiprintTemplate.updateOption('fontSize', 12);
// 更新当前选中元素字体粗细为 bolder
hiprintTemplate.updateOption('fontWeight', 'bolder');
/**
* 通过IPP 可以调用打印机所提供的功能
* 如:创建打印任务,取消打印任务,通过uri打印文档等等 (需要打印机支持)
* 详见 IPP: https://github.com/williamkapke/ipp
*/
// 不知道打印机 ipp 情况, 可通过 '客户端' 获取一下
const printerList = hiprintTemplate.getPrinterList();
console.log(printerList)
if (!printerList.length) return;
let p = printerList[0];
console.log(p)
// 系统不同, 参数可能不同
let url = p.options['printer-uri-supported'];
// 测试 打印文本
hiprint.ippPrint({
url: url,
// 打印机参数: {version,uri,charset,language}
opt: {},
action: 'Print-Job',
// ipp参数
message: {
"operation-attributes-tag": {
"requesting-user-name": "hiPrint", // 用户名
"job-name": "ipp Test Job", // 任务名
"document-format": "text/plain" // 文档类型
},
// data 需为 Buffer (客户端简单处理了string 转 Buffer), 支持设置 encoding
// data 需为 Buffer (客户端简单处理了string 转 Buffer), 支持设置 encoding
// data 需为 Buffer (客户端简单处理了string 转 Buffer), 支持设置 encoding
// 其他 Uint8Array/ArrayBuffer 默认仅 使用 Buffer.from(data)
// 其他 Uint8Array/ArrayBuffer 默认仅 使用 Buffer.from(data)
// 其他 Uint8Array/ArrayBuffer 默认仅 使用 Buffer.from(data)
// 其他 Uint8Array/ArrayBuffer 默认仅 使用 Buffer.from(data)
data: 'test test test test test test test',
encoding: 'utf-8' // 默认可不传
}
}, (res) => {
// 执行的ipp 任务回调 / 错误回调
console.log(res)
}, (printer) => {
// ipp连接成功 回调 打印机信息
console.log(printer)
})
hiprint.setConfig({
optionItems: [
// 自定义添加一个scale参数 (重写及定义一个已存在的name)
function () {
function t() {
// json模板 options 对应键值
this.name = "scale";
}
return t.prototype.css = function (t, e) { // t: 元素对象, e 参数值
if (t && t.length) {
if (e) return t.css('transform', 'scale(' + e + ')');
}
return null;
}, t.prototype.createTarget = function (t,i,e) { // t: 元素对象,i: 元素options, e: 元素printElementType
return this.target = $('<div class="hiprint-option-item">\n <div class="hiprint-option-item-label">\n 缩放\n </div>\n <div class="hiprint-option-item-field">\n <input type="number" class="auto-submit"/>\n </div>\n </div>'), this.target;
}, t.prototype.getValue = function () {
var t = this.target.find("input").val();
if (t) return parseFloat(t.toString());
}, t.prototype.setValue = function (t) { // t: options 对应键的值
this.target.find("input").val(t);
}, t.prototype.destroy = function () {
this.target.remove();
}, t;
}(),
],
// 添加到 样式 tab 下的 transform 后面
text: {
tabs: [
{
name: '基础', options: []
},
{
name: '样式', options: [
{
name: 'scale',
after: 'transform', // 自定义参数,插入在 transform 之后
hidden: false
},
]
}
]
}
})
// json模板中配置
options: {
qrcodeLevel: 1 // {L:1, M:0, Q:3, H:2}
}
1. fix 不显示表头时,样式问题
2. fix 元素参数(字体、字间距)对宽高大小框的影响
3. fix printerList、address 回调越来越多的问题
4. fix printSuccess、printError 回调越来越多的问题
5. fix 多选元素 拖拽 辅助线 问题
6. 调整优化 宽高大小/坐标位置 样式 (居中)
7. fix 表格列排序样式问题
8. fix 部分参数设置未及时生效问题(左/右/下边框;上/下/右内边距)
hiprintTemplate = new hiprint.PrintTemplate({
...,
// 自定义可选字体(本机已安装字体)
// 或者使用 hiprintTemplate.setFontList([])
// 或元素中 options.fontList: []
fontList: [
{title:'微软雅黑',value:'Microsoft YaHei'},
{title:'黑体',value:'STHeitiSC-Light'},
{title:'思源黑体',value:'SourceHanSansCN-Normal'},
{title:'王羲之书法体',value:'王羲之书法体'},
{title:'宋体',value:'SimSun'},
{title:'华为楷体',value:'STKaiti'},
{title:'cursive',value:'cursive'},
],
详见参数配置
元素多卡顿问题(hinnn.event导致)
始终隐藏元素 重写 .alwaysHide css
position/size-box的样式(层级及元素行高影响问题)
/* 拖拽时元素辅助线 */
.toplineOfPosition, .bottomlineOfPosition {
border: 0;
border-top: 1px dashed rgb(169, 169, 169);
}
.leftlineOfPosition, .rightlineOfPosition {
border: 0;
border-left: 1px dashed rgb(169, 169, 169);
}
hiprint.setConfig({
movingDistance: 2.5,
panel: {
supportOptions: [
{
name: 'firstPaperFooter', // 隐藏 首页页尾
hidden: true
},
{
name: 'evenPaperFooter', // 隐藏 偶数页页尾
hidden: true
},
]
}
})
设置元素 options.showInPage: 'none' 打印时不打印
或在右侧参数 '显示规则' 下列选择 '始终隐藏'
// 连接上客户端时 获取最新打印机列表
hiprint.refreshPrinterList((list)=>{
console.log(list)
})
// 连接上客户端时 获取MAC地址等
/**
* 参数格式:
* 1. 类型(ip、ipv6、mac、dns、all、interface、vboxnet)
* 2. 回调 data => {addr, e} addr: 返回的数据 e:错误信息
* 3. 其他参数 ...args
*/
hiprint.getAddress('mac',(data)=>{
console.log('mac')
console.log(data)
})
options.zIndex: 10 调整元素层级
或在右侧参数 '元素层级' 中输入 10
(原无法返回此fields列表,且需设置在元素的printElementType中)
设置元素字段名 options.fields: [{"text":'id',"field":'id']
字段名将变成下列选择样式, getJson() 将返回此列表
hiprintTemplate = new hiprint.PrintTemplate({
template: panel,
// 图片选择功能
onImageChooseClick: (target) => {
// target.getValue()
// 测试 3秒后修改图片地址值
setTimeout(()=>{
target.refresh("url")
},3000)
},
settingContainer: '#PrintElementOptionSetting',
});
图片元素设置 options.bject-fix: fill|contain|cover|none
或右侧参数 '图片缩放' 下拉选择
text元素修改为barcode/qrcode时调整控制按钮
右下控制点拖动时等比缩放, 按住shift时可自由缩放
从右侧参数栏快速从右往左选择时鼠标移动到design内时框选框的大小问题
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。