shre 发表于 2022-11-24 21:41:23

如何获取表单的html

本帖最后由 shre 于 2022-11-24 21:41 编辑

新手请教,应用场景是:在流程中将表单的内容转换为pdf附件。如何得到流程表单实例的html内容。如图片所示,比如要取得表单table对应的html内容。麻烦给个思路和样例。


论坛管理员 发表于 2022-11-25 10:41:04

this.form.get("table").node,就获取到了dom对象了

shre 发表于 2022-11-26 11:01:09

没有搞成功,
我是模仿使用手册的方法实现自动转换html为pdf附件。使用那一段固定html文本代码是可以成功创建附件的。想要做一个动态截取表单内容html转换pdf附件。没搞明白怎么得到那个html文本。代码入下,请管理员帮忙改一下;

var work = this.workContext.getWork();
//var html = '<style>table{border-collapse:collapse}td{border:1px solid rgb(3,3,3)}.title{font-weight:bold;height:30px;line-height:30px;width:22%;text-align:center}.content{width:30%;padding-left:10px}</style><table cellspacing="0"style="width: 700px; background-color: rgb(255, 255, 255);"><tr><td colspan="4"style="width: 100%;text-align: center;font-size: 24px; line-height: 60px; font-weight: bold; height: 60px; color: black;">教育系统国内公务考察活动审批表</td></tr><tr><td class="title">主题</td><td colspan="3"class="content">余杭小学外出考察学习审批</td></tr><tr><td class="title">经办人</td><td class="content">张安</td><td class="title">联系电话</td><td class="content">15858248111</td></tr></table>';
var data = this.data
var form = this.form
var node = this.form.get("table").node
var html = node.innerHTML
var action = this.Actions.load("x_processplatform_assemble_surface");
var fileName = work.title + '.pdf';
debugger
//html转换成pdf
action.AttachmentAction.htmlToPdf({
    "workHtml" :html,
    "title" : fileName
},function( json ){
    //上传到附件
    var url = "http://192.168.3.129/x_processplatform_assemble_surface/jaxrs/attachment/download/transfer/flag/" + json.data.id;
   
    action.AttachmentAction.uploadWithUrl({
      "workId" : work.id,
      "fileName" : fileName,
      "fileUrl" : url,
      "site" : "attachment",
      "person" : "xadmin"
    },function(){})
   
}.bind(this));

论坛管理员 发表于 2022-11-28 09:32:53

看起来没有什么问题,您F12跟踪一下,html是否有获取到?调用接口是否有成功返回?

shre 发表于 2022-11-28 21:18:36



看系统日志像是form没有获取到,get方法无效。
F12不怎么会调试,加了debugger没有跳出断点:(。

论坛管理员 发表于 2022-11-29 09:28:26

this.form.get("table").node,这是前端用法,后端取不到的,您应该前端获取到传到接口里去

shre 发表于 2022-11-29 20:22:11

可以更具体一点么?有点懵。最好帮给点示例,感谢!
页: [1]
查看完整版本: 如何获取表单的html