<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<jsp:useBean id="strUtil" class="weaver.common.StringUtil" scope="page" />
<jsp:useBean id="dateUtil" class="weaver.common.DateUtil" scope="page" />
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="attProcSetManager" class="com.engine.kq.wfset.attendance.manager.HrmAttProcSetManager" scope="page" />
<%

%>

<script >

  jQuery(document).ready(function(){
    try{


        WfForm.bindDetailFieldChangeEvent(WfForm.convertFieldNameToId("bdkrq", "detail_1"),function(id,rowIndex,value){
            console.log("WfForm.bindDetailFieldChangeEvent--",id,rowIndex,value);
            let bdkry = WfForm.getFieldValue(WfForm.convertFieldNameToId('bdkry'));
            $.ajax({
                url:'/api/operate/common/queryCommon',
                data:{
                    action:'query_common',
                    mark:'query_attendance_result',
                    condition:'ygid:'+bdkry+',rq:'+value
                },
                type:'GET',
                dataType:'json',
                success:function(res){
                    console.log(res)
                    if(res.data.data.length > 0){
                        let data = res.data.data[0]
                        //班次信息
                        WfForm.changeFieldValue(WfForm.convertFieldNameToId("bcbdxx", "detail_1")+"_"+rowIndex, {value:data.bcbdxx});
                        //出勤结果
                        WfForm.changeFieldValue(WfForm.convertFieldNameToId("cqjg", "detail_1")+"_"+rowIndex, {value:data.cqzt});

                        let dkxx='';
                        for(let i=1;i<9;i++){
                            let j = "j"+i;
                            let c = "c"+i;
                            let jvalue="";
                            let cvalue="";
                            for (let key in data){
                                if(key == j){
                                    jvalue = data[key];
                                }else if (key == c){
                                    cvalue = data[key];
                                }
                            }
                            if (jvalue != "" || cvalue != ""){
                                dkxx = dkxx +jvalue+"-"+cvalue+",";
                            }
                        }
                        if (dkxx.length >0){
                            dkxx.substring(0,dkxx.length-1);
                        }
                        //打卡信息
                        WfForm.changeFieldValue(WfForm.convertFieldNameToId("dkxx", "detail_1")+"_"+rowIndex, {value:dkxx});
                    }
                }
            })
        });

    }catch (e) {
    }
  });


</script>
