hiprint 设计
This commit is contained in:
1 parent
209e88a905
commit
1c83bf5672
16 files changed
+943
-111
No files matched your search
@@ -1,99 +1,200 @@
|
||||
<div id="app">
|
||||
<a-button @@click="handleClick">
|
||||
@* <template #icon>
|
||||
<icon-plus />
|
||||
</template> *@
|
||||
{{ message }}
|
||||
</a-button>
|
||||
{{ result }}
|
||||
<script src="/Area/Configs/Print.js"></script>
|
||||
|
||||
<link href="/hiprint/content/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<wt:row>
|
||||
<!-- 列表 -->
|
||||
<div class="layui-col-xs1 layui-col-md1" style="padding-right:0px;">
|
||||
<div class="rect-printElement-types hiprintEpContainer">
|
||||
<ul class="hiprint-printElement-type">
|
||||
<li>
|
||||
<span class="title"><code>拖拽列表</code></span>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.text" style="">
|
||||
<span class="glyphicon glyphicon-text-width"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">文本</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.image" style="">
|
||||
<span class="glyphicon glyphicon-picture"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">图片</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.longText">
|
||||
<span class="glyphicon glyphicon-subscript"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">长文</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.tableCustom" style="">
|
||||
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">表格</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.html">
|
||||
<span class="glyphicon glyphicon-header"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">html</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<span class="title">辅助</span>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.hline" style="">
|
||||
<span class="glyphicon glyphicon-resize-horizontal"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">横线</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.vline" style="">
|
||||
<span class="glyphicon glyphicon-resize-vertical"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">竖线</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.rect">
|
||||
<span class="glyphicon glyphicon-unchecked"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">矩形</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="ep-draggable-item" tid="testModule.oval">
|
||||
<span class="glyphicon glyphicon-record"
|
||||
aria-hidden="true"></span>
|
||||
<span class="glyphicon-class">椭圆</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容 -->
|
||||
<div class="layui-col-xs8 layui-col-md8">
|
||||
<div class="hiprint-toolbar" style="margin-top:15px;">
|
||||
<ul>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A3')">A3</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A4')">A4</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('A5')">A5</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B3')">B3</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B4')">B4</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="setPaper('B5')">B5</a></li>
|
||||
|
||||
<li><a class="hiprint-toolbar-item"><input type="text" id="customWidth"
|
||||
style="width: 50px;height: 19px;border: 0px;"
|
||||
placeholder="宽/mm" /></a></li>
|
||||
<li><a class="hiprint-toolbar-item"><input type="text" id="customHeight"
|
||||
style="width: 50px;height: 19px;border: 0px;"
|
||||
placeholder="高/mm" /></a></li>
|
||||
|
||||
<li><a class="hiprint-toolbar-item"
|
||||
onclick="setPaper($('#customWidth').val(),$('#customHeight').val())">自定义</a>
|
||||
</li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="rotatePaper()">旋转</a></li>
|
||||
<li><a class="hiprint-toolbar-item" onclick="clearTemplate()">清空</a></li>
|
||||
|
||||
<li>
|
||||
<a id="A4_directPrint" class="btn hiprint-toolbar-item " style="color: #fff;
|
||||
background-color: #d9534f;
|
||||
border-color: #d43f3a;">
|
||||
打印
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div style="clear:both;"></div>
|
||||
</div>
|
||||
|
||||
<div id="hiprint-printTemplate" class="hiprint-printTemplate" style="margin-top:20px;">
|
||||
|
||||
</div>
|
||||
<div style="padding-top:15px;">
|
||||
<button type="button" class="btn btn-primary"
|
||||
id="A4_getJson_toTextarea">生成json到textarea</button>
|
||||
</div>
|
||||
<textarea class="layui-textarea" id="A4_textarea_json"></textarea>
|
||||
</div>
|
||||
|
||||
<!-- 属性 -->
|
||||
<div class="layui-col-xs3 layui-col-md3">
|
||||
<div id="PrintElementOptionSetting" style="margin-top:10px;"></div>
|
||||
</div>
|
||||
</wt:row>
|
||||
|
||||
|
||||
|
||||
<!-- 单独使用无需引入 -->
|
||||
<script src="/hiprint/custom/custom-etype-provider.js"></script>
|
||||
|
||||
|
||||
<a-table :columns="columns" :data="datat" />
|
||||
</div>
|
||||
<script src="/front/signalr.min.js"></script>
|
||||
<script>
|
||||
const { createApp, reactive } = Vue
|
||||
var hiprintTemplate;
|
||||
$(document).ready(function () {
|
||||
|
||||
const app = createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello Vue!',
|
||||
result: 'Hello Vue!',
|
||||
columns: [
|
||||
{
|
||||
title: '地址',
|
||||
dataIndex: 'Key',
|
||||
},
|
||||
{
|
||||
title: '值',
|
||||
dataIndex: 'Value',
|
||||
}
|
||||
],
|
||||
datat: reactive([])
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
var _this = this;
|
||||
_this.connection = new signalR.HubConnectionBuilder()
|
||||
.withAutomaticReconnect()
|
||||
.withUrl("/stocks")
|
||||
.build();
|
||||
_this.connection.start().then(function () {
|
||||
_this.connection.invoke("GetAllStocks").then(function (stocks) {
|
||||
for (let i = 0; i < stocks.length; i++) {
|
||||
_this.datat.push({
|
||||
Key: stocks[i].dbName,
|
||||
Value: stocks[i].dbValue
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_this.connection.invoke("OpenMarket").then(() => {
|
||||
_this.startStreaming();
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
var _this = this;
|
||||
axios.post("/configs/Print/Test", {})
|
||||
.then(function (json) {
|
||||
_this.result = json.data.Data;
|
||||
_this.datat = [];
|
||||
_this.result.forEach((item) => {
|
||||
_this.datat.push(item);
|
||||
})
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
|
||||
handleSubmit(data) {
|
||||
console.log(data);
|
||||
this.$message.info('This is an info message')
|
||||
},
|
||||
|
||||
startStreaming() {
|
||||
this.connection.stream("StreamStocks").subscribe({
|
||||
close: false,
|
||||
next: this.displayStock,
|
||||
error: function (err) {
|
||||
logger.log(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
displayStock(stock) {
|
||||
this.datat.forEach((item, index) => {
|
||||
if (item.Key == stock.dbName) {
|
||||
this.datat[index].Value = stock.dbValue;
|
||||
}
|
||||
})
|
||||
}
|
||||
// 默认值
|
||||
var customPrintJson = {
|
||||
"panels": [{
|
||||
"index": 0,
|
||||
"height": 60,
|
||||
"width": 100,
|
||||
"printElements": [],
|
||||
"paperNumberDisabled": true
|
||||
}]
|
||||
}
|
||||
});
|
||||
app.use(ArcoVue)
|
||||
.use(ArcoVueIcon)
|
||||
.mount('#app');
|
||||
|
||||
var printData = {}
|
||||
|
||||
//初始化打印插件
|
||||
hiprint.init({
|
||||
providers: [new customElementTypeProvider()]
|
||||
});
|
||||
|
||||
</script>
|
||||
//hiprint.PrintElementTypeManager.build('.hiprintEpContainer', 'testModule');
|
||||
//设置左侧拖拽事件
|
||||
hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
|
||||
|
||||
hiprintTemplate = new hiprint.PrintTemplate({
|
||||
template: customPrintJson,
|
||||
settingContainer: '#PrintElementOptionSetting',
|
||||
paginationContainer: '.hiprint-printPagination'
|
||||
});
|
||||
//打印设计
|
||||
hiprintTemplate.design('#hiprint-printTemplate');
|
||||
|
||||
$('#A4_directPrint').click(function () {
|
||||
hiprintTemplate.print(printData);
|
||||
});
|
||||
|
||||
$('#A4_getJson_toTextarea').click(function () {
|
||||
$('#A4_textarea_json').html(JSON.stringify(hiprintTemplate.getJson()))
|
||||
})
|
||||
});
|
||||
|
||||
//调整纸张
|
||||
var setPaper = function (paperTypeOrWidth, height) {
|
||||
hiprintTemplate.setPaper(paperTypeOrWidth, height);
|
||||
}
|
||||
|
||||
//旋转
|
||||
var rotatePaper = function () {
|
||||
hiprintTemplate.rotatePaper();
|
||||
}
|
||||
var clearTemplate = function () {
|
||||
hiprintTemplate.clear();
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,99 @@
|
||||
<div id="app">
|
||||
<a-button @@click="handleClick">
|
||||
@* <template #icon>
|
||||
<icon-plus />
|
||||
</template> *@
|
||||
{{ message }}
|
||||
</a-button>
|
||||
{{ result }}
|
||||
|
||||
<a-table :columns="columns" :data="datat" />
|
||||
</div>
|
||||
<script src="/front/signalr.min.js"></script>
|
||||
<script>
|
||||
const { createApp, reactive } = Vue
|
||||
|
||||
const app = createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello Vue!',
|
||||
result: 'Hello Vue!',
|
||||
columns: [
|
||||
{
|
||||
title: '地址',
|
||||
dataIndex: 'Key',
|
||||
},
|
||||
{
|
||||
title: '值',
|
||||
dataIndex: 'Value',
|
||||
}
|
||||
],
|
||||
datat: reactive([])
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
var _this = this;
|
||||
_this.connection = new signalR.HubConnectionBuilder()
|
||||
.withAutomaticReconnect()
|
||||
.withUrl("/stocks")
|
||||
.build();
|
||||
_this.connection.start().then(function () {
|
||||
_this.connection.invoke("GetAllStocks").then(function (stocks) {
|
||||
for (let i = 0; i < stocks.length; i++) {
|
||||
_this.datat.push({
|
||||
Key: stocks[i].dbName,
|
||||
Value: stocks[i].dbValue
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_this.connection.invoke("OpenMarket").then(() => {
|
||||
_this.startStreaming();
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
var _this = this;
|
||||
axios.post("/configs/Print/Test", {})
|
||||
.then(function (json) {
|
||||
_this.result = json.data.Data;
|
||||
_this.datat = [];
|
||||
_this.result.forEach((item) => {
|
||||
_this.datat.push(item);
|
||||
})
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
|
||||
handleSubmit(data) {
|
||||
console.log(data);
|
||||
this.$message.info('This is an info message')
|
||||
},
|
||||
|
||||
startStreaming() {
|
||||
this.connection.stream("StreamStocks").subscribe({
|
||||
close: false,
|
||||
next: this.displayStock,
|
||||
error: function (err) {
|
||||
logger.log(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
displayStock(stock) {
|
||||
this.datat.forEach((item, index) => {
|
||||
if (item.Key == stock.dbName) {
|
||||
this.datat[index].Value = stock.dbValue;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
app.use(ArcoVue)
|
||||
.use(ArcoVueIcon)
|
||||
.mount('#app');
|
||||
|
||||
</script>
|
||||
Reference in new issue
Block a user