泛微OA 明细行默认自增长行号字段

<script>
//序号
const xh_id = WfForm.convertFieldNameToId('xh', "detail_1");
WfForm.registerAction(WfForm.ACTION_ADDROW+"1", function(index){
    //获取当前行号
    const arr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
    //从10开始每次 + 10
    if(arr.length == 1)
    {
        WfForm.changeFieldValue(xh_id+"_"+index, {value: 10});
    }
    else
    {
        //取到上一个行号的值
        const addValue = WfForm.getFieldValue(xh_id+"_"+ (arr[arr.length - 2]));
        //自增
        WfForm.changeFieldValue(xh_id+"_"+index, {value:  parseInt(addValue, 10) + 10 });
    }
}); 

WfForm.registerAction(WfForm.ACTION_DELROW+"1", function(arg){
    
    const arr = WfForm.getDetailAllRowIndexStr("detail_1").split(",");
    let value = 10;
    //删除时重编序号
    for(var i = 0 ; i < arr.length ; i++)
    {
      WfForm.changeFieldValue(xh_id+"_"+ arr[i], {value: value});
      value += 10;
    }
});
</script>

 

posted @ 2022-11-30 18:14  微风吹过~  阅读(557)  评论(0编辑  收藏  举报