【新增】打印
This commit is contained in:
@@ -19,7 +19,13 @@
|
||||
<ai-card title="标签模板" class="card" :hideTitle="true">
|
||||
<template #content>
|
||||
<div class="add-label__wrapper">
|
||||
<Print ref="printRef" :template="template" :printData="printData" :isPrint="false"></Print>
|
||||
<Print
|
||||
ref="printRef"
|
||||
:template="template"
|
||||
:printData="printData"
|
||||
:isPrint="false"
|
||||
:params="params">
|
||||
</Print>
|
||||
</div>
|
||||
</template>
|
||||
</ai-card>
|
||||
@@ -39,9 +45,28 @@
|
||||
data () {
|
||||
return {
|
||||
name: '',
|
||||
template: template,
|
||||
template: {
|
||||
"panels": [{
|
||||
"index": 0,
|
||||
"name": 1,
|
||||
"height": 200,
|
||||
"width": 200,
|
||||
"paperHeader": 0,
|
||||
"paperFooter": 547,
|
||||
"printElements": [],
|
||||
"paperNumberLeft": 500,
|
||||
"paperNumberTop": 530,
|
||||
"paperNumberDisabled": true,
|
||||
"paperNumberContinue": true,
|
||||
"fontFamily": "Microsoft YaHei",
|
||||
"scale": 1,
|
||||
"watermarkOptions": {}
|
||||
}]
|
||||
},
|
||||
printData: {},
|
||||
id: '',
|
||||
info: {},
|
||||
params: [],
|
||||
isLoading: false
|
||||
}
|
||||
},
|
||||
@@ -53,6 +78,12 @@
|
||||
skuExtCode: 'AAA1100mWh-orange',
|
||||
skuSpecName: '8pcs'
|
||||
}
|
||||
|
||||
if (this.$route.query.id) {
|
||||
this.id = this.$route.query.id
|
||||
|
||||
this.getInfo()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -60,6 +91,20 @@
|
||||
this.$router.go(-1)
|
||||
},
|
||||
|
||||
getInfo () {
|
||||
this.$http.post(`/api/template/detail?id=${this.$route.query.id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.info = res.data
|
||||
this.name = res.data.name
|
||||
this.params = JSON.parse(res.data.params)
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.template = JSON.parse(res.data.content)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
preview () {
|
||||
this.$refs.printRef.preview()
|
||||
},
|
||||
@@ -78,20 +123,23 @@
|
||||
}
|
||||
|
||||
const data = this.$refs.printRef.save()
|
||||
console.log(data)
|
||||
|
||||
this.isLoading = true
|
||||
this.$http.post('/api/template/addTemplate', {
|
||||
|
||||
const url = this.id ? `/api/template/modify` : `/api/template/addTemplate`
|
||||
this.$http.post(url, {
|
||||
name: this.name,
|
||||
codes: data.html,
|
||||
content: JSON.stringify(data.json),
|
||||
params: data.params
|
||||
params: data.params,
|
||||
id: this.id || ''
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.isLoading = false
|
||||
this.$message.success('模板创建成功')
|
||||
this.cancel()
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
}).catch(() => {
|
||||
this.isLoading = false
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user