请假流程表单怎么提取自建数据表数据
自己创建了名为jiaoqiTable的数据表,在表单的“可休年休假天数”的事件change里面写了代码,保存的时候报错。var table = new this.Table("jiaqiTable");
var name = "name";// 假设表单中获取到的 name 值
var dept = "dept";// 假设表单中获取到的 dept 值
var where = "o.name='" + name + "' AND o.dept='" + dept + "'";
table.listRowSelect(where, null, null, function(data) {
if (data.type === "success" && data.data && data.data.length > 0) {
var totalLeave = data.data.totalLeave;
console.log("Total Leave: " + totalLeave);
} else {
console.error("未找到匹配的数据");
}
}, function(xhr) {
console.error("查询错误: " + xhr);
});
您这个图里的错误是当前这个表单保存的时候出现的错误把
看错误应该是表单的别名重复了,您在检查下 代码更改成一下:但是还是获取不到数据
var table = new this.Table("jiaqitable");
var name = this.workContext.getWork().creatorPerson;// 直接获取实际的值
var dept = this.workContext.getWork().creatorUnit;// 直接获取实际的值
var where = "o.name='" + name + "' AND o.dept='" + dept + "'";
let totalLeave;// 定义在外部,以便在后续使用
table.listRowSelect(where, null, null, function(data) {
if (data.type === "success" && data.data && data.data.length > 0) {
totalLeave = data.data.totalLeave;// 直接赋值给外部定义的变量
console.log("Total Leave: " + totalLeave);
} else {
if (data.type === "error") {
console.error("查询年休假数据时发生服务器内部错误,错误信息: " + data.message);
} else {
console.error("未找到匹配的年休假数据,可能原因:表单中的人员信息不准确或无相关数据。");
}
}
}, function(xhr) {
console.error("与服务器通信发生错误: " + xhr.status + " - " + xhr.statusText);
});
this.form.get("totalLeave").setData(totalLeave);// 此时可以使用 totalLeave
pwll 发表于 2024-8-8 14:35
代码更改成一下:但是还是获取不到数据
var table = new this.Table("jiaqitable");
默认是异步调用的,您要在最外面拿到totalLeave去进行赋值的话,需要同步调用
页:
[1]