【新增】模板接口对接

This commit is contained in:
yanran200730
2024-10-26 22:49:11 +08:00
parent 4f4f303867
commit 8900853066
3 changed files with 54 additions and 16 deletions

View File

@@ -11,7 +11,7 @@
<el-button @click="savePdf" size="small" type="primary">下载pdf</el-button>
<el-button @click="print" size="small">打印</el-button>
<el-button @click="clearPaper" size="small" type="danger">清空纸张</el-button>
<el-button @click="saveTemplate" size="small" type="primary">保存</el-button>
<el-button @click="saveTemplate" size="small" type="primary" :loading="isLoading">保存</el-button>
</template>
</ai-title>
</template>
@@ -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() {