FnaSubmitRequestJsShare_e9.jsp 39 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888
<%@page import="weaver.fna.maintenance.FnaSystemSetComInfo"%>
<%@page import="weaver.general.BaseBean"%>
<%@page import="java.util.Map"%>
<%@page import="org.json.JSONObject"%>
<%@page import="weaver.fna.general.FnaCommon"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.UUID"%>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="weaver.general.Util"%>
<%@page import="weaver.workflow.field.BrowserComInfo"%>
<%@page import="weaver.fna.maintenance.FnaCostCenter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%

String guid1 = UUID.randomUUID().toString();

User user = HrmUserVarify.getUser (request , response) ;
if(user==null){
    response.sendRedirect("/notice/noright.jsp") ;
    return ;
}

RecordSet rs = new RecordSet();

FnaSystemSetComInfo fnaSystemSetComInfo = new FnaSystemSetComInfo();
boolean subjectFilter = 1==Util.getIntValue(fnaSystemSetComInfo.get_subjectFilter(), 0);
int costControlCycle = Util.getIntValue(fnaSystemSetComInfo.get_costControlCycle(), 0);//费用控制周期


int requestid = Util.getIntValue(request.getParameter("requestid"),0);
int workflowid = Util.getIntValue(request.getParameter("workflowid"),0);
int formid = 0;
int currentnodetype = 0;
boolean isNeverSubmit = false;//流程从未提交下去标志位

if(workflowid <= 0){
    rs.executeSql("select workflowid, currentnodetype from workflow_requestbase where requestid = "+requestid);
    if(rs.next()){
        workflowid = Util.getIntValue(rs.getString("workflowid"), 0);
        currentnodetype = Util.getIntValue(rs.getString("currentnodetype"), 0);
    }
}
if(requestid > 0 && currentnodetype==0){
    rs.executeSql("select count(*) cnt from workflow_requestLog a where a.logtype <> '1' and a.requestid = "+requestid);
    if(rs.next() && rs.getInt("cnt") == 0){
        isNeverSubmit = true;
    }
}else{
    isNeverSubmit = true;
}


Map<String, String> dataMap = new HashMap<String, String>();
FnaCommon.getFnaWfFieldInfo4Expense(workflowid, dataMap);

String fieldIdSubject = Util.null2String(dataMap.get("fieldIdSubject_fieldId"));
String fieldIdOrgType = Util.null2String(dataMap.get("fieldIdOrgType_fieldId"));
String fieldIdOrgId = Util.null2String(dataMap.get("fieldIdOrgId_fieldId"));
String fieldIdOccurdate = Util.null2String(dataMap.get("fieldIdOccurdate_fieldId"));
String fieldIdAmount = Util.null2String(dataMap.get("fieldIdAmount_fieldId"));
String fieldIdHrmInfo = Util.null2String(dataMap.get("fieldIdHrmInfo_fieldId"));
String fieldIdDepInfo = Util.null2String(dataMap.get("fieldIdDepInfo_fieldId"));
String fieldIdSubInfo = Util.null2String(dataMap.get("fieldIdSubInfo_fieldId"));
String fieldIdFccInfo = Util.null2String(dataMap.get("fieldIdFccInfo_fieldId"));

String fieldIdSubject2 = Util.null2String(dataMap.get("fieldIdSubject2_fieldId"));
String fieldIdOrgType2 = Util.null2String(dataMap.get("fieldIdOrgType2_fieldId"));
String fieldIdOrgId2 = Util.null2String(dataMap.get("fieldIdOrgId2_fieldId"));
String fieldIdOccurdate2 = Util.null2String(dataMap.get("fieldIdOccurdate2_fieldId"));
String fieldIdHrmInfo2 = Util.null2String(dataMap.get("fieldIdHrmInfo2_fieldId"));
String fieldIdDepInfo2 = Util.null2String(dataMap.get("fieldIdDepInfo2_fieldId"));
String fieldIdSubInfo2 = Util.null2String(dataMap.get("fieldIdSubInfo2_fieldId"));
String fieldIdFccInfo2 = Util.null2String(dataMap.get("fieldIdFccInfo2_fieldId"));

String fieldIdSubject_isDtl = Util.null2String(dataMap.get("fieldIdSubject_fieldId_isDtl"));
String fieldIdOrgType_isDtl = Util.null2String(dataMap.get("fieldIdOrgType_fieldId_isDtl"));
String fieldIdOrgId_isDtl = Util.null2String(dataMap.get("fieldIdOrgId_fieldId_isDtl"));
String fieldIdOccurdate_isDtl = Util.null2String(dataMap.get("fieldIdOccurdate_fieldId_isDtl"));
String fieldIdAmount_isDtl = Util.null2String(dataMap.get("fieldIdAmount_fieldId_isDtl"));
String fieldIdHrmInfo_isDtl = Util.null2String(dataMap.get("fieldIdHrmInfo_fieldId_isDtl"));
String fieldIdDepInfo_isDtl = Util.null2String(dataMap.get("fieldIdDepInfo_fieldId_isDtl"));
String fieldIdSubInfo_isDtl = Util.null2String(dataMap.get("fieldIdSubInfo_fieldId_isDtl"));
String fieldIdFccInfo_isDtl = Util.null2String(dataMap.get("fieldIdFccInfo_fieldId_isDtl"));

String fieldIdSubject2_isDtl = Util.null2String(dataMap.get("fieldIdSubject2_fieldId_isDtl"));
String fieldIdOrgType2_isDtl = Util.null2String(dataMap.get("fieldIdOrgType2_fieldId_isDtl"));
String fieldIdOrgId2_isDtl = Util.null2String(dataMap.get("fieldIdOrgId2_fieldId_isDtl"));
String fieldIdOccurdate2_isDtl = Util.null2String(dataMap.get("fieldIdOccurdate2_fieldId_isDtl"));
String fieldIdHrmInfo2_isDtl = Util.null2String(dataMap.get("fieldIdHrmInfo2_fieldId_isDtl"));
String fieldIdDepInfo2_isDtl = Util.null2String(dataMap.get("fieldIdDepInfo2_fieldId_isDtl"));
String fieldIdSubInfo2_isDtl = Util.null2String(dataMap.get("fieldIdSubInfo2_fieldId_isDtl"));
String fieldIdFccInfo2_isDtl = Util.null2String(dataMap.get("fieldIdFccInfo2_fieldId_isDtl"));

String fieldIdOrgId_automaticTake = Util.null2String(dataMap.get("fieldIdOrgId_automaticTake"));

String fieldIdOrgId2_automaticTake = Util.null2String(dataMap.get("fieldIdOrgId2_automaticTake"));

if(Util.getIntValue(fieldIdSubject2) <= 0){
    fieldIdSubject2 = fieldIdSubject;
    fieldIdSubject2_isDtl = fieldIdSubject_isDtl;
}
if(Util.getIntValue(fieldIdOrgType2) <= 0){
    fieldIdOrgType2 = fieldIdOrgType;
    fieldIdOrgType2_isDtl = fieldIdOrgType_isDtl;
}
if(Util.getIntValue(fieldIdOrgId2) <= 0){
    fieldIdOrgId2 = fieldIdOrgId;
    fieldIdOrgId2_isDtl = fieldIdOrgId_isDtl;
}
if(Util.getIntValue(fieldIdOccurdate2) <= 0){
    fieldIdOccurdate2 = fieldIdOccurdate;
    fieldIdOccurdate2_isDtl = fieldIdOccurdate_isDtl;
}
if(Util.getIntValue(fieldIdHrmInfo2) <= 0){
    fieldIdHrmInfo2 = fieldIdHrmInfo;
    fieldIdHrmInfo2_isDtl = fieldIdHrmInfo_isDtl;
}
if(Util.getIntValue(fieldIdDepInfo2) <= 0){
    fieldIdDepInfo2 = fieldIdDepInfo;
    fieldIdDepInfo2_isDtl = fieldIdDepInfo_isDtl;
}
if(Util.getIntValue(fieldIdSubInfo2) <= 0){
    fieldIdSubInfo2 = fieldIdSubInfo;
    fieldIdSubInfo2_isDtl = fieldIdSubInfo_isDtl;
}
if(Util.getIntValue(fieldIdFccInfo2) <= 0){
    fieldIdFccInfo2 = fieldIdFccInfo;
    fieldIdFccInfo2_isDtl = fieldIdFccInfo_isDtl;
}

%>
<script language="javascript" src="/fna/js/e8Common_wev8.js?r=20"></script>
<script language="javascript" src="/fna/js/fna_e9Common.js?r=v3"></script>
<script type="text/javascript" >
var __fna_haveNotTopDialogAlertVal = __fna_haveNotTopDialogAlert();
//费用分摊默认全明细
var _____guid1 = "<%=guid1 %>";
var _____currentnodetype = "<%=currentnodetype %>";

var dt1_subject = "<%=fieldIdSubject %>";
var dt1_organizationtype = "<%=fieldIdOrgType %>";
var dt1_organizationid = "<%=fieldIdOrgId %>";
var dt1_budgetperiod = "<%=fieldIdOccurdate %>";
var dt1_applyamount = "<%=fieldIdAmount %>";
var dt1_hrmremain = "<%=fieldIdHrmInfo %>";
var dt1_deptremain = "<%=fieldIdDepInfo %>";
var dt1_subcomremain = "<%=fieldIdSubInfo %>";
var dt1_fccremain = "<%=fieldIdFccInfo %>";

var dt1_subject2 = "<%=fieldIdSubject2 %>";
var dt1_organizationtype2 = "<%=fieldIdOrgType2 %>";
var dt1_organizationid2 = "<%=fieldIdOrgId2 %>";
var dt1_budgetperiod2 = "<%=fieldIdOccurdate2 %>";
var dt1_hrmremain2 = "<%=fieldIdHrmInfo2 %>";
var dt1_deptremain2 = "<%=fieldIdDepInfo2 %>";
var dt1_subcomremain2 = "<%=fieldIdSubInfo2 %>";
var dt1_fccremain2 = "<%=fieldIdFccInfo2 %>";


//是否是明细表字段;1:是明细表;0:是主表;-1:未配置字段;
var dt1_subject_isDtl = "<%=fieldIdSubject_isDtl %>";
var dt1_organizationtype_isDtl = "<%=fieldIdOrgType_isDtl %>";
var dt1_organizationid_isDtl = "<%=fieldIdOrgId_isDtl %>";
var dt1_budgetperiod_isDtl = "<%=fieldIdOccurdate_isDtl %>";
var dt1_applyamount_isDtl = "<%=fieldIdAmount_isDtl %>";
var dt1_hrmremain_isDtl = "<%=fieldIdHrmInfo_isDtl %>";
var dt1_deptremain_isDtl = "<%=fieldIdDepInfo_isDtl %>";
var dt1_subcomremain_isDtl = "<%=fieldIdSubInfo_isDtl %>";
var dt1_fccremain_isDtl = "<%=fieldIdFccInfo_isDtl %>";


//是否是明细表字段;1:是明细表;0:是主表;-1:未配置字段;
var dt1_subject2_isDtl = "<%=fieldIdSubject2_isDtl %>";
var dt1_organizationtype2_isDtl = "<%=fieldIdOrgType2_isDtl %>";
var dt1_organizationid2_isDtl = "<%=fieldIdOrgId2_isDtl %>";
var dt1_budgetperiod2_isDtl = "<%=fieldIdOccurdate2_isDtl %>";
var dt1_hrmremain2_isDtl = "<%=fieldIdHrmInfo2_isDtl %>";
var dt1_deptremain2_isDtl = "<%=fieldIdDepInfo2_isDtl %>";
var dt1_subcomremain2_isDtl = "<%=fieldIdSubInfo2_isDtl %>";
var dt1_fccremain2_isDtl = "<%=fieldIdFccInfo2_isDtl %>";


var __workflowid = "<%=workflowid %>";
var __requestid = "<%=requestid %>";

/**
 * 更新明细表1已有预算信息
 */
function bindfee(){
    var detailAllRowIndexStr = "";
    try{
        detailAllRowIndexStr = WfForm.getDetailAllRowIndexStr("detail_1");
    } catch (e) {}
    if(detailAllRowIndexStr != ""){
        var detailAllRowIndexStr_array = detailAllRowIndexStr.split(",");
        for(var rowIdx = 0; rowIdx < detailAllRowIndexStr_array.length; rowIdx++){
            var idx = detailAllRowIndexStr_array[rowIdx];
            getFnaInfoData(idx, "");
            getFnaInfoData(idx, "2");
        }
    }
}

/**
 * 一次性更新明细表1已有预算信息
 */
function bindfees(){
    var detailAllRowIndexStr = "";
    try{
        detailAllRowIndexStr = WfForm.getDetailAllRowIndexStr("detail_1");
    } catch (e) {}
    if(detailAllRowIndexStr != ""){
        var detailAllRowIndexStr_array = detailAllRowIndexStr.split(",");
        var idxs = '';
        for(var rowIdx = 0; rowIdx < detailAllRowIndexStr_array.length; rowIdx++){
            var idx = detailAllRowIndexStr_array[rowIdx];
            idxs += idx + ',';
        }
        idxs = idxs.substring(0,idxs.lastIndexOf(','));
        getFnaInfoDatas(idxs, "");
        getFnaInfoDatas(idxs, "2");
    }
}

//提交事件前出发函数
function doBeforeSubmit_fna(callback){
        try{
            WfForm.controlBtnDisabled(true);//把流程中的按钮置灰
            var temprequestid = __requestid;           
            var detailAllRowIndexStr1 = "";//明细表1下标id
            try{
            	detailAllRowIndexStr1 = WfForm.getDetailAllRowIndexStr("detail_1");
            } catch (e) {}
            var poststr = "";
         	try{
	            if(detailAllRowIndexStr1 != ""){
	                var detailAllRowIndexStr_array = detailAllRowIndexStr1.split(",");
	                for(var rowIdx = 0; rowIdx < detailAllRowIndexStr_array.length; rowIdx++){
	                    try{
	                        var idx = detailAllRowIndexStr_array[rowIdx];

	                        var budgetfeetype = "";
	                        var orgType = "";
	                        var orgId = "";
	                        var applyDate = "";
	                        
	                        var applyAmount = "";
	                        
	                        var budgetfeetype2 = "";
	                        var orgType2 = "";
	                        var orgId2 = "";
	                        var applyDate2 = "";

		                    try{
		                        budgetfeetype = WfForm.getFieldValue("field" + dt1_subject + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                    try{
		                        orgType = WfForm.getFieldValue("field" + dt1_organizationtype + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                    try{
		                        orgId = WfForm.getFieldValue("field" + dt1_organizationid + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                    try{
		                        applyDate = WfForm.getFieldValue("field" + dt1_budgetperiod + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                    
		                    try{
		                        applyAmount = WfForm.getFieldValue("field" + dt1_applyamount + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                        
		                    try{
		                        budgetfeetype2 = WfForm.getFieldValue("field" + dt1_subject2 + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                    try{
		                        orgType2 = WfForm.getFieldValue("field" + dt1_organizationtype2 + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                    try{
		                        orgId2 = WfForm.getFieldValue("field" + dt1_organizationid2 + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
		                    try{
		                        applyDate2 = WfForm.getFieldValue("field" + dt1_budgetperiod2 + "_" + idx);
		                    }catch(e0){
		                        //console.log("e:"+e);
		                    }
	                        
	                        if(poststr!=""){
	                            poststr += "|";
	                        }
	                        poststr += budgetfeetype+","+orgType+","+orgId+","+applyDate+","+applyAmount+","+
	                            budgetfeetype2+","+orgType2+","+orgId2+","+applyDate2+",postStrEnd";
	                        
	                    }catch(e){
	                        //console.log("e:"+e);
	                    }
	               }
	                
	            }
            }catch(ex001){
            	//alert(ex001);
            }
            
            if(poststr == ""){
                WfForm.controlBtnDisabled(false);//取消流程中的按钮置灰
                callback(); //继续提交需调用callback,不调用代表阻断
                return;
            }
            
            var _data = "poststr="+poststr+"&requestid="+temprequestid+"&workflowid="+__workflowid;
            jQuery.ajax({
                url : "/fna/budget/FnaShareifoverJsonAjax.jsp",
                type : "post",
                processData : false,
                data : _data,
                dataType : "json",
                success: function do4Success(fnainfo){
                    if(fnainfo.flag){
                        WfForm.controlBtnDisabled(false);
                        callback(); //继续提交需调用callback,不调用代表阻断
                        return;
                    }else{
                        var errorType = fnainfo.errorType;
                        var errorInfo = fnainfo.errorInfo;
                        if(errorInfo!=null){
                            errorInfo = errorInfo.replace("\n","<br>");
                        }else{
                            errorInfo="";
                        }
                        if(errorType=="alert"){
                            WfForm.controlBtnDisabled(false);
                            if(__fna_haveNotTopDialogAlertVal){
                            	alert(errorInfo._fnaReplaceAll("<br>","\n"));
                            }else{
                            	top.Dialog.alert(errorInfo);
                            }
                            return;
                        }else if(errorType=="confirm"){
                        	if(__fna_haveNotTopDialogAlertVal){
                        		if(confirm(errorInfo._fnaReplaceAll("<br>","\n"))){
                                    WfForm.controlBtnDisabled(false);
                                    callback(); //继续提交需调用callback,不调用代表阻断
                                    return;
                        		}else{
                                    WfForm.controlBtnDisabled(false);
                                    return;
                        		}
                        	}else{
                        		top.Dialog.confirm(errorInfo,
                                        function(){
                                            WfForm.controlBtnDisabled(false);
                                            callback(); //继续提交需调用callback,不调用代表阻断
                                            return;
                                        },function(){
                                            WfForm.controlBtnDisabled(false);
                                            return;
                                        }
                                    );
                        	}
                        }else{
                            WfForm.controlBtnDisabled(false);
                            if(__fna_haveNotTopDialogAlertVal){
                            	alert(errorInfo._fnaReplaceAll("<br>","\n"));
                            }else{
                            	top.Dialog.alert(errorInfo);
                            }
                            return;
                        }
                    }
                }
            });
            
        }catch(ex2){
            WfForm.controlBtnDisabled(false);
            alert(ex2.message);
            return;
        }
}
 
    
//获取预算信息  type  1  2
function getFnaInfoData(rowIndex, type){
    var budgetfeetype = "";
    var orgType = "";
    var orgId = "";
    var applyDate = "";

	try{
	    budgetfeetype = WfForm.getFieldValue("field" + dt1_subject + "_" + rowIndex);
	}catch(e0){
	    //console.log("e:"+e);
	}
	try{
	    orgType = WfForm.getFieldValue("field" + dt1_organizationtype + "_" + rowIndex);
	}catch(e0){
	    //console.log("e:"+e);
	}
	try{
	    orgId = WfForm.getFieldValue("field" + dt1_organizationid + "_" + rowIndex);
	}catch(e0){
	    //console.log("e:"+e);
	}
	try{
	    applyDate = WfForm.getFieldValue("field" + dt1_budgetperiod + "_" + rowIndex);
	}catch(e0){
	    //console.log("e:"+e);
	}

    if(type == "2"){
		try{
			budgetfeetype = "";
	        budgetfeetype = WfForm.getFieldValue("field" + dt1_subject2 + "_" + rowIndex);
		}catch(e0){
		    //console.log("e:"+e);
		}
		try{
			orgType = "";
	        orgType = WfForm.getFieldValue("field" + dt1_organizationtype2 + "_" + rowIndex);
		}catch(e0){
		    //console.log("e:"+e);
		}
		try{
			orgId = "";
	        orgId = WfForm.getFieldValue("field" + dt1_organizationid2 + "_" + rowIndex);
		}catch(e0){
		    //console.log("e:"+e);
		}
		try{
			applyDate = "";
	        applyDate = WfForm.getFieldValue("field" + dt1_budgetperiod2 + "_" + rowIndex);
		}catch(e0){
		    //console.log("e:"+e);
		}
    }
    
    var _data = "budgetfeetype="+budgetfeetype+"&orgtype="+orgType+"&orgid="+orgId+"&applydate="+applyDate;
    jQuery.ajax({
        url : "/workflow/request/FnaBudgetInfoAjax.jsp",
        type : "post",
        processData : false,
        data : _data,
        dataType : "html",
        success: function do4Success(msg){
            var fnainfos = jQuery.trim(msg).split("|");

            var have_budgetAmount_fy_ytd = false;
            var budgetAmount_fy = "";
            var budgetAmount_ytd = "";
            var budget_avail_color = "#000000";
        	if(fnainfos.length>=6){
        		try{
        			var budgetChangeInfo_str = fnainfos[5];
        			if(budgetChangeInfo_str!=null && budgetChangeInfo_str!=""){
        				var budgetChangeInfo_array = eval("["+budgetChangeInfo_str+"]");
        				if(budgetChangeInfo_array && budgetChangeInfo_array.length==1){
        					have_budgetAmount_fy_ytd = budgetChangeInfo_array[0].have_budgetAmount_fy_ytd;
        					if(have_budgetAmount_fy_ytd){
        						budgetAmount_fy = budgetChangeInfo_array[0].budgetAmount_fy;
        						budgetAmount_ytd = budgetChangeInfo_array[0].budgetAmount_ytd;
        					}
        					try{
        						if(budgetChangeInfo_array[0].budget_avail_color){
        							budget_avail_color = budgetChangeInfo_array[0].budget_avail_color;
        						}
        					}catch(exBudgetChangeInfo1){}
        				}
        			}
        		}catch(exBudgetChangeInfo){}
            }

            var _dt1_remain_array = [];
    		var orgtype1 = "";
            if(type == ""){
                _dt1_remain_array = [dt1_hrmremain, dt1_deptremain, dt1_subcomremain, dt1_fccremain];
                orgtype1 = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype_isDtl, rowIndex);
            }else if(type =="2"){
                _dt1_remain_array = [dt1_hrmremain2, dt1_deptremain2, dt1_subcomremain2, dt1_fccremain2];
                orgtype1 = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype2_isDtl, rowIndex);
            }
            var _cnt = getFnaNotEmptyCount(_dt1_remain_array);
            if(_cnt==1){
                var _dt1_remain_only = getFnaOnlyNotEmptyValue(_dt1_remain_array);
                _dt1_remain_array = [_dt1_remain_only];
            }
            var _dt1_remain_array_len = _dt1_remain_array.length;
            var _dt1_remain_only = "";
            if(getFnaNotEmptyCount(_dt1_remain_array)==1){
                _dt1_remain_only = getFnaOnlyNotEmptyValue(_dt1_remain_array);
            }
    		var _dt1_remain_exsits_array = [];
            for(var i=0;i<_dt1_remain_array_len;i++){
                var _dt1_remain = _dt1_remain_array[i];
                
                if(_dt1_remain_only!=""&&_dt1_remain_only!=_dt1_remain){
                    continue;
                }
                var values = fnainfos[i].split(",");
                if((_dt1_remain_only!=""&&_dt1_remain_only==_dt1_remain) || (getFnaSameValueCount(_dt1_remain_array, _dt1_remain)>1)){
                    //个人:orgtype==0;部门:orgtype==2;分部:orgtype==3;成本中心:orgtype==4;
                	if(_dt1_remain_array[orgType] == _dt1_remain){
                	    values = fnainfos[orgType].split(",");
                	}
                }
        		var _fontColor_values0 = "";
        		if(budget_avail_color!=null && budget_avail_color!=""){
        			_fontColor_values0 = "color:"+budget_avail_color+" !important;";
        		}
        		var tempmsg = "<font style=\"font-weight: bolder !important;"+_fontColor_values0+"\" ><%=SystemEnv.getHtmlLabelName(18768,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(values[0],2),'#,##0.00')+"</font>"+
					"<br><span style=\"color: blue !important;\"><%=SystemEnv.getHtmlLabelName(18503,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(values[1],2),'#,##0.00')+"</span>"+
					"<br><span style=\"color: green !important;\"><%=SystemEnv.getHtmlLabelName(18769,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(values[2],2),'#,##0.00')+"</span>";
			<%if(costControlCycle==1 || costControlCycle==5){ %>
				//1=按预算年度累计; 5=按预算年度合计;
				//alert("orgtype="+orgtype+";i="+i+";_dt1_remain="+_dt1_remain+"");
				if((orgtype1=="0" && i==0) || (orgtype1=="1" && i==1) || (orgtype1=="2" && i==2) || (orgtype1=="3" && i==3)){
					//alert("in 1");
					tempmsg = "<span><%=SystemEnv.getHtmlLabelName(383425,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(budgetAmount_fy,2),'#,##0.00')+"</span><br>"+
					"<span><%=SystemEnv.getHtmlLabelName(383426,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(budgetAmount_ytd,2),'#,##0.00')+"</span><br>"+
					tempmsg;
				}else{
					if(jQuery.inArray(_dt1_remain, _dt1_remain_exsits_array)>=0){
						continue;
					}
				}
				_dt1_remain_exsits_array.push(_dt1_remain);
			<%}else if(costControlCycle==6){ %>
                    //跨年度合计
                    if((orgtype1=="0" && i==0) || (orgtype1=="1" && i==1) || (orgtype1=="2" && i==2) || (orgtype1=="3" && i==3)){
                        //alert("in 1");
                        tempmsg = "<span><%=SystemEnv.getHtmlLabelName(388960,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(budgetAmount_fy,2),'#,##0.00')+"</span><br>"+
                            tempmsg;
                    }else{
                        if(jQuery.inArray(_dt1_remain, _dt1_remain_exsits_array)>=0){
                            continue;
                        }
                    }
                    _dt1_remain_exsits_array.push(_dt1_remain);
					<%}%>
                
                //WfForm.changeSingleField("field" + _dt1_remain + "_" + rowIndex, {value:tempmsg}); 
                jQuery("#field"+_dt1_remain+"_"+rowIndex+"span").html(tempmsg);
            }
        }
    }); 
}

//获取全部预算信息  type  ""  2
function getFnaInfoDatas(rowIndexs, type){
    rowIndexs = rowIndexs.split(",");
    var budgetfeetype = '';
    var orgType = '';
    var orgId = '';
    var applyDate = '';
    for(var i=0;i<rowIndexs.length;i++) {
        if(type == "") {
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_subject, dt1_subject_isDtl, rowIndexs[i])==''){
	                budgetfeetype += "0,";
	            }else{
	                budgetfeetype += getWfMainAndDetailFieldValueForPc_e9(dt1_subject, dt1_subject_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		budgetfeetype += "0,";
        	}
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype_isDtl, rowIndexs[i])==''){
	                orgType += "0,";
	            }else{
	                orgType += getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		orgType += "0,";
        	}
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid, dt1_organizationid_isDtl, rowIndexs[i])==''){
	                orgId += "0,";
	            }else{
	                orgId += getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid, dt1_organizationid_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		orgId += "0,";
        	}
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_budgetperiod, dt1_budgetperiod_isDtl, rowIndexs[i])==''){
	                applyDate += " ,";
	            }else{
	                applyDate += getWfMainAndDetailFieldValueForPc_e9(dt1_budgetperiod, dt1_budgetperiod_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		applyDate += " ,";
        	}
        }else if (type == "2") {
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_subject2, dt1_subject2_isDtl, rowIndexs[i])==''){
	                budgetfeetype += "0,";
	            }else{
	                budgetfeetype += getWfMainAndDetailFieldValueForPc_e9(dt1_subject2, dt1_subject2_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		budgetfeetype += "0,";
        	}
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype2, dt1_organizationtype2_isDtl, rowIndexs[i])==''){
	                orgType += "0,";
	            }else{
	                orgType += getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype2, dt1_organizationtype2_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		orgType += "0,";
        	}
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid2, dt1_organizationid2_isDtl, rowIndexs[i])==''){
	                orgId += "0,";
	            }else{
	                orgId += getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid2, dt1_organizationid2_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		orgId += "0,";
        	}
        	try{
	            if(getWfMainAndDetailFieldValueForPc_e9(dt1_budgetperiod2, dt1_budgetperiod2_isDtl, rowIndexs[i])==''){
	                applyDate += " ,";
	            }else{
	                applyDate += getWfMainAndDetailFieldValueForPc_e9(dt1_budgetperiod2, dt1_budgetperiod2_isDtl, rowIndexs[i])+",";
	            }
        	}catch(e0){
        		applyDate += " ,";
        	}
        }
    }
    budgetfeetype = budgetfeetype.substring(0,budgetfeetype.lastIndexOf(','));
    orgType = orgType.substring(0,orgType.lastIndexOf(','));
    orgId = orgId.substring(0,orgId.lastIndexOf(','));
    applyDate = applyDate.substring(0,applyDate.lastIndexOf(','));
    var _data = "budgetfeetype="+budgetfeetype+"&orgtype="+orgType+"&orgid="+orgId+"&applydate="+applyDate;

    jQuery.ajax({
        url : "/api/fna/workflow/budgetInfo",
        type : "post",
        processData : false,
        data : _data,
        dataType : "json",
        success: function do4Success(msg){
            orgType = orgType.split(',');
            for(var k=0;k<rowIndexs.length;k++) {
                var fnainfos = msg['detail'+k].split("|");

	            var have_budgetAmount_fy_ytd = false;
	            var budgetAmount_fy = "";
	            var budgetAmount_ytd = "";
	            var budget_avail_color = "#000000";
	        	if(fnainfos.length>=6){
	        		try{
	        			var budgetChangeInfo_str = fnainfos[5];
	        			if(budgetChangeInfo_str!=null && budgetChangeInfo_str!=""){
	        				var budgetChangeInfo_array = eval("["+budgetChangeInfo_str+"]");
	        				if(budgetChangeInfo_array && budgetChangeInfo_array.length==1){
	        					have_budgetAmount_fy_ytd = budgetChangeInfo_array[0].have_budgetAmount_fy_ytd;
	        					if(have_budgetAmount_fy_ytd){
	        						budgetAmount_fy = budgetChangeInfo_array[0].budgetAmount_fy;
	        						budgetAmount_ytd = budgetChangeInfo_array[0].budgetAmount_ytd;
	        					}
	        					try{
	        						if(budgetChangeInfo_array[0].budget_avail_color){
	        							budget_avail_color = budgetChangeInfo_array[0].budget_avail_color;
	        						}
	        					}catch(exBudgetChangeInfo1){}
	        				}
	        			}
	        		}catch(exBudgetChangeInfo){}
	            }
	
                var _dt1_remain_array = [];
        		var orgtype1 = "";
                if (type == "") {
                    _dt1_remain_array = [dt1_hrmremain, dt1_deptremain, dt1_subcomremain, dt1_fccremain];
                    orgtype1 = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype_isDtl, rowIndexs[k]);
                } else if (type == "2") {
                    _dt1_remain_array = [dt1_hrmremain2, dt1_deptremain2, dt1_subcomremain2, dt1_fccremain2];
                    orgtype1 = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype2_isDtl, rowIndexs[k]);
                }
                var _cnt = getFnaNotEmptyCount(_dt1_remain_array);
                if (_cnt == 1) {
                    var _dt1_remain_only = getFnaOnlyNotEmptyValue(_dt1_remain_array);
                    _dt1_remain_array = [_dt1_remain_only];
                }
                var _dt1_remain_array_len = _dt1_remain_array.length;
                var _dt1_remain_only = "";
                if (getFnaNotEmptyCount(_dt1_remain_array) == 1) {
                    _dt1_remain_only = getFnaOnlyNotEmptyValue(_dt1_remain_array);
                }
        		var _dt1_remain_exsits_array = [];
                for (var i = 0; i < _dt1_remain_array_len; i++) {
                    var _dt1_remain = _dt1_remain_array[i];

                    if (_dt1_remain_only != "" && _dt1_remain_only != _dt1_remain) {
                        continue;
                    }
                    var values = fnainfos[i].split(",");
                    if ((_dt1_remain_only != "" && _dt1_remain_only == _dt1_remain) || (getFnaSameValueCount(_dt1_remain_array, _dt1_remain) > 1)) {
                        //个人:orgtype==0;部门:orgtype==2;分部:orgtype==3;成本中心:orgtype==4;
                        values = fnainfos[orgType[k]].split(",");//orgType上面是拼接的需要切开
                    }
            		var _fontColor_values0 = "";
            		if(budget_avail_color!=null && budget_avail_color!=""){
            			_fontColor_values0 = "color:"+budget_avail_color+" !important;";
            		}
            		var tempmsg = "<font style=\"font-weight: bolder !important;"+_fontColor_values0+"\" ><%=SystemEnv.getHtmlLabelName(18768,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(values[0],2),'#,##0.00')+"</font>"+
						"<br><span style=\"color: blue !important;\"><%=SystemEnv.getHtmlLabelName(18503,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(values[1],2),'#,##0.00')+"</span>"+
						"<br><span style=\"color: green !important;\"><%=SystemEnv.getHtmlLabelName(18769,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(values[2],2),'#,##0.00')+"</span>";
				<%if(costControlCycle==1 || costControlCycle==5){ %>
					//1=按预算年度累计; 5=按预算年度合计;
					//alert("orgtype="+orgtype+";i="+i+";_dt1_remain="+_dt1_remain+"");
					if((orgtype1=="0" && i==0) || (orgtype1=="1" && i==1) || (orgtype1=="2" && i==2) || (orgtype1=="3" && i==3)){
						//alert("in 1");
						tempmsg = "<span><%=SystemEnv.getHtmlLabelName(383425,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(budgetAmount_fy,2),'#,##0.00')+"</span><br>"+
						"<span><%=SystemEnv.getHtmlLabelName(383426,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(budgetAmount_ytd,2),'#,##0.00')+"</span><br>"+
						tempmsg;
					}else{
						if(jQuery.inArray(_dt1_remain, _dt1_remain_exsits_array)>=0){
							continue;
						}
					}
					_dt1_remain_exsits_array.push(_dt1_remain);
				<%}else if(costControlCycle==6){ %>
                    //跨年度合计
                    if((orgtype1=="0" && i==0) || (orgtype1=="1" && i==1) || (orgtype1=="2" && i==2) || (orgtype1=="3" && i==3)){
                        //alert("in 1");
                        tempmsg = "<span><%=SystemEnv.getHtmlLabelName(388960,user.getLanguage())%>:&nbsp;&nbsp;"+formatNumber(fnaRound2(budgetAmount_fy,2),'#,##0.00')+"</span><br>"+
                            tempmsg;
                    }else{
                        if(jQuery.inArray(_dt1_remain, _dt1_remain_exsits_array)>=0){
                            continue;
                        }
                    }
                    _dt1_remain_exsits_array.push(_dt1_remain);
					<%}%>

                    jQuery("#field" + _dt1_remain + "_" + rowIndexs[k] + "span").html(tempmsg);
                }
            }
        }
    });
}

//清理科目id
function clearSubjectById(rowId,type){
    <%if(subjectFilter){ %>
        var budgetfeetype = getWfMainAndDetailFieldValueForPc_e9(dt1_subject, dt1_subject_isDtl, rowId);
        var orgtype = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype_isDtl, rowId);
        var orgid = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid, dt1_organizationid_isDtl, rowId);
        var subject_fieldId = "field"+dt1_subject;
        var subject_isDtl = dt1_subject_isDtl;
        
        if(type == "2"){
            budgetfeetype = getWfMainAndDetailFieldValueForPc_e9(dt1_subject2, dt1_subject2_isDtl, rowId);
            orgtype = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype2, dt1_organizationtype2_isDtl, rowId);
            orgid = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid2, dt1_organizationid2_isDtl, rowId);
            subject_fieldId = "field"+dt1_subject2;
            subject_isDtl = dt1_subject2_isDtl;
        }
        
        
        if(budgetfeetype != "" && orgid !=""){
            jQuery.ajax({
                url : "/fna/wfPage/getClearSubjectInfo.jsp",
                type : "post",
                processData : false,
                data : "budgetfeetype="+budgetfeetype+"&orgtype="+orgtype+"&orgid="+orgid,
                dataType : "json",
                success: function do4Success(fnainfo){
                    if(fnainfo.flag){
                        if(fnainfo.change != "1"){
                            if(subject_isDtl == 0){
                                WfForm.changeSingleField(subject_fieldId, {value:""}); 
                            }else if(subject_isDtl == 1){
                                WfForm.changeSingleField(subject_fieldId + "_" + rowId, {value:""}); 
                            }
                            getFnaInfoData(rowId,type);
                        }
                    }else{
                    	if(__fna_haveNotTopDialogAlertVal){
                    		alert(fnainfo.errorInfo._fnaReplaceAll("<br>","\n"));
                    	}else{
                    		top.Dialog.alert(fnainfo.errorInfo);
                    	}
                    }
                }
            });
        }
    <%}%>
}


//传入科目浏览按钮的过滤依据数据
function appendBrowserOtherData(idx){
    var orgType = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype, dt1_organizationtype_isDtl, idx);
    var orgId = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid, dt1_organizationid_isDtl, idx);
    var subject_fieldId = "field"+dt1_subject;
    
    var orgType2 = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationtype2, dt1_organizationtype2_isDtl, idx);
    var orgId2 = getWfMainAndDetailFieldValueForPc_e9(dt1_organizationid2, dt1_organizationid2_isDtl, idx);
    var subject_fieldId2 = "field"+dt1_subject2;
    
    if(dt1_subject == dt1_subject2){
        if(idx != null && idx.length != 0){
            WfForm.appendBrowserDataUrlParam(subject_fieldId+"_"+idx,{"orgType":orgType,"orgId":orgId,"orgType2":orgType2,"orgId2":orgId2});
        }else{
            WfForm.appendBrowserDataUrlParam(subject_fieldId,{"orgType":orgType,"orgId":orgId,"orgType2":orgType2,"orgId2":orgId2});
        }
    }else{
        if(idx != null && idx.length != 0){
            WfForm.appendBrowserDataUrlParam(subject_fieldId+"_"+idx,{"orgType":orgType,"orgId":orgId});
            WfForm.appendBrowserDataUrlParam(subject_fieldId2+"_"+idx,{"orgType":orgType2,"orgId":orgId2});
        }else{
            WfForm.appendBrowserDataUrlParam(subject_fieldId,{"orgType":orgType,"orgId":orgId});
            WfForm.appendBrowserDataUrlParam(subject_fieldId2,{"orgType":orgType2,"orgId":orgId2});
        }
    }
}

//明细1新增成功后触发事件,addIndexStr即刚新增的行标示,添加多行为(1,2,3)
function _customAddFun0(addIndexStr){  
    appendBrowserOtherData(addIndexStr);
    appendBrowserOtherData(addIndexStr);
    getFnaInfoData(addIndexStr,"");
    getFnaInfoData(addIndexStr,"2");
}


jQuery(document).ready(function(){
    
    var fieldOrgStr1 = "field" + dt1_organizationid;
    var fieldOrgStr2 = "field" + dt1_organizationid2;
    WfForm.bindDetailFieldChangeEvent(fieldOrgStr1,function(id,rowIndex,value){
        clearSubjectById(rowIndex,"");
        appendBrowserOtherData(rowIndex);
        getFnaInfoData(rowIndex, "");
    });
    
    WfForm.bindDetailFieldChangeEvent(fieldOrgStr2,function(id,rowIndex,value){
        clearSubjectById(rowIndex,"2");
        appendBrowserOtherData(rowIndex);
        getFnaInfoData(rowIndex, "2");
    }); 
    
    //费用分摊只有全明细
    var fieldStr1 = "field" + dt1_subject + ",field" + dt1_budgetperiod;
    var fieldStr2 = "field" + dt1_subject2 + ",field" + dt1_budgetperiod2;
    WfForm.bindDetailFieldChangeEvent(fieldStr1,function(id,rowIndex,value){
        getFnaInfoData(rowIndex, "");
    });
    WfForm.bindDetailFieldChangeEvent(fieldStr2,function(id,rowIndex,value){
        getFnaInfoData(rowIndex, "2");
    }); 
    
    //更新明细表1预算信息
    //bindfee();
    bindfees();//一次性设置所有值
    
    //绑定提交前事件
    WfForm.registerCheckEvent(WfForm.OPER_SUBMIT,function(callback){
        doBeforeSubmit_fna(callback);
    });

});





</script>