正一味 发表于 2024-5-28 19:13:53

活字格JS代码问题,求帮助

问题:编写了一段JS代码,用javascript命令,设置单元格的html

但是在输出的时候result里没有东西
求大佬能解释一下是什么问题

豪~豪 发表于 2024-5-29 16:41:25

正一味 发表于 2024-5-29 16:38

var p = Forguncy.Page;
var size = getCellValue("TemplateSize");

var ResultCode = getCellValue("ResultCode");
var PrintTemplate = getCellValue("PrintTemplate");

if (ResultCode == 100)
{
Forguncy.Page.getCell("PrintTemplate").setValue(PrintTemplate);
if(PrintTemplate != null){
$("").html(PrintTemplate);
            Forguncy.Page.getCellByLocation('code').setValue(PrintTemplate);//创建活字格变量
}
alert("下单成功,请打印标签!");
};

if (ResultCode == 105)
{
alert(Reason);
};

if (ResultCode == 106)
{
Forguncy.Page.getCell("PrintTemplate").setValue(PrintTemplate);
if(PrintTemplate != null){
$("").html(PrintTemplate);
            Forguncy.Page.getCellByLocation('code').setValue(PrintTemplate);//创建活字格变量
}
alert("该发货通知单已成功下单,现在可以打印标签!");
};

function getCellValue(cell){
var value = Forguncy.Page.getCell(cell).getValue();
if(value == null){
value = "";
}
return value;
}
活字格弹窗赋值改成=code

吴小胖 发表于 2024-5-28 21:18:48

您定义单元格的名称为PrintTemplate了吗?

正一味 发表于 2024-5-28 21:32:08

吴小胖 发表于 2024-5-28 21:18
您定义单元格的名称为PrintTemplate了吗?

命名了,result和printTemplate都

豪~豪 发表于 2024-5-29 08:44:50

代码可以放出来看看

正一味 发表于 2024-5-29 09:08:43

豪~豪 发表于 2024-5-29 08:44
代码可以放出来看看


豪~豪 发表于 2024-5-29 09:14:29

正一味 发表于 2024-5-29 09:08


你输出的有误,可以输入
document.querySelector('').innerHTML

正一味 发表于 2024-5-29 09:31:01

豪~豪 发表于 2024-5-29 09:14
你输出的有误,可以输入

大佬,我这样修改了,但是还是测试弹出输出的result还是空的:'(

豪~豪 发表于 2024-5-29 09:33:52

正一味 发表于 2024-5-29 09:31
大佬,我这样修改了,但是还是测试弹出输出的result还是空的

我是说你输出result方法有问题,不是写入有问题,你怎么输出的你贴出来

正一味 发表于 2024-5-29 10:24:01

豪~豪 发表于 2024-5-29 09:33
我是说你输出result方法有问题,不是写入有问题,你怎么输出的你贴出来

测试的是用弹窗输出的,本来的需求是要把这个单元格的内容打印出来

但是打印导出的html页面好像是因为result是空的,所以pdf显示的是整个页面,会是这个样子的:

Lay.Li 发表于 2024-5-29 12:30:44

感谢各位大佬的支持~
正如楼上大佬所述,这儿边没有看到alert()的命令哈。您是这个alert()弹出的result么?

页: [1] 2 3
查看完整版本: 活字格JS代码问题,求帮助