diff --git a/src/components/print/Print.vue b/src/components/print/Print.vue
index 0761b1a..5a0b7e2 100644
--- a/src/components/print/Print.vue
+++ b/src/components/print/Print.vue
@@ -68,7 +68,7 @@
文字素材
-
EVATOST CONSULTING LTD
+
EVATOST CONSULTING LTD
@@ -279,6 +279,8 @@
this.buildLeftElement()
this.buildDesigner()
}
+
+ this.getConfig()
},
methods: {
@@ -287,6 +289,12 @@
this.isShowDynamicForm = true
},
+ getConfig() {
+ this.$http.post(`/api/material/getPage`).then(res => {
+
+ })
+ },
+
addImage(src) {
this.panel.addPrintImage({
options: {
@@ -303,12 +311,12 @@
el.design(void 0, designPaper)
},
- addText(text) {
+ addText(text, isSetField = true) {
this.panel.addPrintText({
options: {
- field: text || '',
- testData: text || '',
- title: '',
+ field: isSetField ? text : '',
+ testData: isSetField ? text : '',
+ title: isSetField ? '' : text,
left: 70.5,
top: 58.5,
width: 140,
@@ -435,11 +443,26 @@
})
},
- getHtml() {
+ save() {
+ const html = this.elementToString(this.hiprintTemplate.getHtml(this.printData))
+ const json = this.hiprintTemplate.getJson()
+
+ return {
+ html,
+ json,
+ params: JSON.stringify(this.dynamicFromList)
+ }
+ },
+
+ preview() {
this.html = this.elementToString(this.hiprintTemplate.getHtml(this.printData))
this.isShowPreview = true
},
+ getHtml() {
+ return this.elementToString(this.hiprintTemplate.getHtml(this.printData))
+ },
+
clearPaper() {
this.hiprintTemplate.clear()
},
diff --git a/src/view/lables/AddTemplate.vue b/src/view/lables/AddTemplate.vue
index a0cb3a9..8620bb6 100644
--- a/src/view/lables/AddTemplate.vue
+++ b/src/view/lables/AddTemplate.vue
@@ -11,7 +11,7 @@
下载pdf
打印
清空纸张
- 保存
+ 保存
@@ -40,7 +40,9 @@
return {
name: '',
template: template,
- printData: {}
+ printData: {},
+ id: '',
+ isLoading: false
}
},
@@ -59,7 +61,7 @@
},
preview () {
- this.$refs.printRef.getHtml()
+ this.$refs.printRef.preview()
},
savePdf () {
@@ -75,8 +77,22 @@
return this.$message.error('模板名称不能为空')
}
- const json = this.$refs.printRef.exportJson()
- console.log(json)
+ const data = this.$refs.printRef.save()
+ console.log(data)
+
+ this.isLoading = true
+ this.$http.post('/api/template/addTemplate', {
+ name: this.name,
+ codes: data.html,
+ content: JSON.stringify(data.json),
+ params: data.params
+ }).then(res => {
+ if (res.code === 0) {
+ this.isLoading = false
+ }
+ }).catch(() => {
+ this.isLoading = false
+ })
},
print() {
diff --git a/src/view/lables/Template.vue b/src/view/lables/Template.vue
index 8bdfd8b..21f6b60 100644
--- a/src/view/lables/Template.vue
+++ b/src/view/lables/Template.vue
@@ -61,7 +61,7 @@
},
created () {
- // this.getList()
+ this.getList()
},
methods: {
@@ -74,15 +74,14 @@
},
getList () {
- console.log(this.tableData)
- this.$http.post('/api/learning/pluginPage', null, {
+ this.$http.post('/api/template/getPage', null, {
params: {
...this.search
}
}).then(res => {
if (res.code === 0) {
- // this.tableData = res.data.records
- // this.total = res.data.total
+ this.tableData = res.data.records
+ this.total = res.data.total
}
})
},