|
@@ -8,6 +8,7 @@
|
|
|
<script lang="ts">
|
|
|
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
|
|
|
import {query,add,update,del} from '@/api/printTemplate'
|
|
|
+import {preview} from '@/api/print'
|
|
|
@Component({components:{}})
|
|
|
export default class PrintTemplate extends Vue {
|
|
|
load=false;
|
|
@@ -63,7 +64,8 @@ export default class PrintTemplate extends Vue {
|
|
|
table:{
|
|
|
attr:{
|
|
|
size:'mini',
|
|
|
- seq:true
|
|
|
+ seq:true,
|
|
|
+ checkbox:true
|
|
|
},
|
|
|
columns:[{
|
|
|
title:'模板名称',
|
|
@@ -100,7 +102,16 @@ export default class PrintTemplate extends Vue {
|
|
|
tools:{
|
|
|
return:true,
|
|
|
add:true
|
|
|
- }
|
|
|
+ },
|
|
|
+ customTools:[{
|
|
|
+ name: '预览',
|
|
|
+ icon: 'el-icon-view',
|
|
|
+ event:{
|
|
|
+ click:() => {
|
|
|
+ this.preView()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }]
|
|
|
},
|
|
|
form:{
|
|
|
attr:{
|
|
@@ -185,7 +196,8 @@ export default class PrintTemplate extends Vue {
|
|
|
compConfig:{
|
|
|
attr:{
|
|
|
defaultValue:'{}',
|
|
|
- type:'textarea'
|
|
|
+ type:'textarea',
|
|
|
+ rows:3
|
|
|
}
|
|
|
}
|
|
|
}]
|
|
@@ -198,9 +210,37 @@ export default class PrintTemplate extends Vue {
|
|
|
this.getList()
|
|
|
})
|
|
|
}
|
|
|
+ //预览
|
|
|
+ preView(){
|
|
|
+ let data = (this.$refs.view as any).getFormValue();
|
|
|
+ if(!data.templateEngine){
|
|
|
+ this.$message('模版引擎不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!data.templateHtml){
|
|
|
+ this.$message('模版内容不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!data.dataExample){
|
|
|
+ this.$message('示例数据不能为空!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.load=true;
|
|
|
+ preview({
|
|
|
+ templateEngine:data.templateEngine,
|
|
|
+ templateHtml:data.templateHtml,
|
|
|
+ templateData:data.dataExample,
|
|
|
+ outType:'PDF'
|
|
|
+ }).then((res:any) => {
|
|
|
+ this.load=false;
|
|
|
+
|
|
|
+ }).catch((err:any)=>{
|
|
|
+ this.load=false;
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //单个删除
|
|
|
singleDel(item:any){
|
|
|
let data=[item.id];
|
|
|
- console.log(data);
|
|
|
this.$confirm('此操作将永久删除“'+item.templateName+'”, 是否继续?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
@@ -209,6 +249,7 @@ export default class PrintTemplate extends Vue {
|
|
|
this.del(data);
|
|
|
}).catch(() => {});
|
|
|
}
|
|
|
+ //多个删除
|
|
|
multipleDel(){
|
|
|
let data = (this.$refs.view as any).getSelectData();
|
|
|
if(data.length == 0){
|
|
@@ -269,6 +310,7 @@ export default class PrintTemplate extends Vue {
|
|
|
}
|
|
|
this.isSearch = false;
|
|
|
let data = (this.$refs.view as any).getPage();
|
|
|
+ delete data.total;
|
|
|
this.requestList(data);
|
|
|
}
|
|
|
//列表请求(包含分页和搜素条件)
|
|
@@ -303,6 +345,7 @@ export default class PrintTemplate extends Vue {
|
|
|
(this.$refs.view as any).getFormValidate(this.onSave)
|
|
|
}
|
|
|
}
|
|
|
+ //新增
|
|
|
onAdd(){
|
|
|
let value = (this.$refs.view as any).getFormValue();
|
|
|
if(value){
|
|
@@ -320,6 +363,7 @@ export default class PrintTemplate extends Vue {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ //保存
|
|
|
onSave(){
|
|
|
let data = (this.$refs.view as any).getFormValue();
|
|
|
this.load = true;
|