泛微OA E9前端开发常用函数及方法
1、获取单个字段值
//获取主表值
var fieldvalue = WfForm.getFieldValue("field110");
//获取明细表:字段_+行号(从0开始算)
var field19112Value = WfForm.getFieldValue("field19112_"+rowIndex);
2、修改单个字段值
//主表:修改文本框、多行文本、选择框等字段类型
WfForm.changeFieldValue("field123", {value:"1.234"});
//明细表:字段_行号
WfForm.changeFieldValue("field19113_"+rowIndex, {value:"值"});
//延时修改值
window.setTimeout(function(){
WfForm.changeFieldValue("field19637_"+rowMax, {value:newVal});
}, 100);
3、明细字段值变化触发事件:支持删除行时也触发
//可多个拼接逗号隔开,例如:field110,field111
//参数1:字段标示(field27583),参数2:行标示,参数3:修改后的值
<script>
jQuery(document).ready(function(){
WfForm.bindDetailFieldChangeEvent("field19112",function(id,rowIndex,value){
var rowArr = WfForm.getDetailAllRowIndexStr("detail_3").split(",");
var map = {};
for(var i = 0; i < rowArr.length; i++){
var rowNumber = rowArr[i];
var field19112Value = WfForm.getFieldValue("field19112_"+rowNumber);
if(map.hasOwnProperty(field19112Value)){
map[field19112Value] = ++map[field19112Value];
}else{
map[field19112Value] = 1;
}
var val = map[field19112Value];
WfForm.changeFieldValue("field19113_"+rowNumber, {value:val});
}
});
});
</script>
4、T100项次等于行号:新增删除行时行号自动赋值给项次(行号从0开始,项次从1开始)
<script>
jQuery(document).ready(function(){
WfForm.changeFieldValue("field19110_" + 0, {value: 1});
WfForm.registerAction(WfForm.ACTION_ADDROW+"1", function(index){
let key = WfForm.getDetailRowSerailNum("detail_1", index);
//修改文本框、多行文本、选择框等字段类型
WfForm.changeFieldValue("field19110_" + index, {value: key});
});
WfForm.registerAction(WfForm.ACTION_DELROW+"1", function(arg){
var rowArr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
for(var i=0; i<rowArr.length; i++){
var rowNumber = rowArr[i];
if(rowNumber !== ""){
let key = WfForm.getDetailRowSerailNum("detail_1", rowNumber);
WfForm.changeFieldValue("field19110_" + rowNumber, {value: key});
}
}
});
});
</script>
5、JSON返回null值时转换
field19675:{value:(dataArray[j].xmdd025 !== null ? "" : dataArray[j].xmdd025)}