DocUtil_e9.js 42.7 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 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
var oDocUtil = {
    uploadPDFCanClick : true,
    uuid : null,
	onlySave: null,
    loadOdocConfig: function () {
        var docInfo = WfForm.getOdocConfig();
        //流程监控增加临时权限判断
        if(docInfo.docParam && !docInfo.docParam.authStr){
            docInfo.docParam.authStr = wfform.getGlobalStore().commonParam.authStr;
        }
        if(docInfo.docParam && !docInfo.docParam.authSignatureStr){
            docInfo.docParam.authSignatureStr = wfform.getGlobalStore().commonParam.authSignatureStr;
        }
        WfForm.changeOdocConfig(docInfo);
        var secifeldid = -1;
        if(secifeldid!=docInfo.docParam.secFieldid){
            secifeldid = "field" + docInfo.docParam.secFieldid;
        }
        //取值
        oDocUtil.loadDocInfoBySecid(secifeldid);
        var formSecifeldid = "field" + docInfo.docParam.secFieldid;
        WfForm.bindFieldChangeEvent(formSecifeldid, function (obj, id, value) {
            oDocUtil.loadDocInfoBySecid(secifeldid);
        });
        if (docInfo.docParam.secFieldid != -1) {
            //解决下拉框默认值不加载对应模板的问题
            oDocUtil.getFromFieldValue(new Array([docInfo.docParam.secFieldid]));
            WfForm.bindFieldChangeEvent(secifeldid, function (obj, id, value) {
                oDocUtil.getFromFieldValue(new Array([secifeldid]));
            });
        }
        setTimeout("setTextShowInForm()", 100);
        setTimeout("odocregisterCheckEvent()", 100);

        if (docInfo.opentextdefaultnode === true && docInfo.docParam.docid > 0) {
            setTimeout("WfForm.switchTab('odoc')",500);
        }
        oDocUtil.count = 0;
        oDocUtil.countfj = 0;
        if (docInfo.isConvertSuccess == "0") {
            oDocUtil.checkTarget(docInfo.fieldidspan, docInfo.ofdlable);
        }
        if (docInfo.fjConvertSuccess == "1") {
            oDocUtil.checkFJTarget(docInfo.fjfieldidspan, docInfo.fjlable);
        }
    },

    clickAddOdoc: function (isText,hideBtn,docid,isTrue,odocfileType) {
        if(isText){
            WfForm.switchTab("odoc");
            return true;
        }
        if(!oDocUtil.uploadPDFCanClick){
            return ;
        }
        oDocUtil.uploadPDFCanClick = false;
        docInfo = WfForm.getOdocConfig();
        if(docInfo.uploadPdf !== true && docInfo.uploadOfd !== true){
            return true;
        }
        var req_workflow_odoc = document.getElementsByClassName("req-workflow-odoc")
        if(req_workflow_odoc.length>0){
            req_workflow_odoc[0].style.width = "1px";
        }
        if(!window.weaOdoc){
            window.eventRegister && window.eventRegister.loadModule('f_odoc',
                function(){
                    renderDialog(hideBtn,docid,odocfileType);
                },
                function(){
                    window.console && console.log("公文模块加载失败");
                }
            );
        }else{
            renderDialog(hideBtn,docid,odocfileType);
        }
         

    },
    uploadDocFile: function (limitType) {
        if(!window.weaOdoc){
            window.eventRegister && window.eventRegister.loadModule('f_odoc',
                function(){
                    var uploadComponent = document.createElement("div");
                    uploadComponent.setAttribute("id","uploadDocComponent");
                    uploadComponent.setAttribute("limitType",limitType);
                    document.body.appendChild(uploadComponent);
                    var UploadFileComp = weaOdoc.components.UploadDocFile;
                    ReactDOM.render(
                        UploadFileComp,
                        document.getElementById("uploadDocComponent")
                    )
                },
                function(){
                    window.console && console.log("公文模块加载失败");
                }
            );
        }else{
            var uploadComponent = document.createElement("div");
            uploadComponent.setAttribute("id","uploadDocComponent");
            uploadComponent.setAttribute("limitType",limitType);
            document.body.appendChild(uploadComponent);
            var UploadFileComp = weaOdoc.components.UploadDocFile;
            ReactDOM.render(
                UploadFileComp,
                document.getElementById("uploadDocComponent")
            )
        }
    },
    selectTemplate: function (iseditmould) {
        var docInfo = WfForm.getOdocConfig();
        var workflowId = docInfo.docParam.workflowid;//流程id
        //选择框目录字段
        var secFieldid = docInfo.docParam.secFieldid;
        var selectvalue = -1;
        if(secFieldid == -1){
            selectvalue = -1;
        }else{
            selectvalue = WfForm.getFieldValue('field'+secFieldid)=="" ? -1 : WfForm.getFieldValue('field'+secFieldid);
        }
        var req_workflow_odoc = document.getElementsByClassName("req-workflow-odoc");
		if(docInfo.docParam.isTextInFormCanEdit&&(docInfo.docParam.isTextInForm||docInfo.docParam.isColumnShow=='1')&&docInfo.docParam.docid>0){
			if(docInfo.docParam.isColumnShow=='1'){
				req_workflow_odoc=document.getElementsByClassName("wf-req-form-odoc-iframe");
			}else{
				req_workflow_odoc=document.getElementById("requestdocInForm");
			}
		}
        if(req_workflow_odoc.length>0){
			try{
            req_workflow_odoc[0].style.width = "1px";
			}catch(e){
			req_workflow_odoc.style.width = "1px";	
			}
        }
        if(window.weaOdoc){
            var openModelDom = document.createElement("div");
            openModelDom.setAttribute("id","openModelComponent");
            openModelDom.setAttribute("workflowId",workflowId);
            openModelDom.setAttribute("selectvalue",selectvalue);
            openModelDom.setAttribute("iseditmould",iseditmould);
            document.body.appendChild(openModelDom);
            var OpenModelComp = weaOdoc.components.OpenModel;
            ReactDOM.render(
                OpenModelComp,
                document.getElementById("openModelComponent")
            )
        }else{
            parent.antd.message.error("公文模块加载失败");
        }
    },

    checkTarget: function (id, ofdlable) {
        window.setTimeout(function () {
            var hasATarget = jQuery("#" + id).find("a").length > 0 ? true : false;
            if (hasATarget) {

                jQuery("#" + id).children().hide();
                jQuery("#" + id).append('<p  style="color:red">' + ofdlable + '</p>');

            } else if (oDocUtil.count < 100) {
                oDocUtil.count++;
                oDocUtil.checkTarget(id, ofdlable);
            }
        }, 100, id, ofdlable);
    },
    checkFJTarget: function (fjid, fjlable) {

        window.setTimeout(function () {
            var ids=fjid.split(",");

            var hasATarget = ids.length > 0 ? true : false;
            if (hasATarget) {
                for(var i=0;i<ids.length;i++){
                    var jsobj= oDocUtil.getElementByAttr("div","data-fieldmark",ids[i]);
                    var jeqobj=$(jsobj);
                    //jeqobj.children().hide();
                    jeqobj.append('<p  style="color:red">' + fjlable + '</p>');
                }

            } else if (oDocUtil.countfj < 100) {
                oDocUtil.countfj++;
                oDocUtil.checkFJTarget(fjid, fjlable);
            }

        }, 100, fjid, fjlable);
    },
    getElementByAttr:function (tag,attr,value)
    {
        var aElements=document.getElementsByTagName(tag);
        var aEle=[];
        for(var i=0;i<aElements.length;i++)
        {
            if(aElements[i].getAttribute(attr)==value)
                aEle.push( aElements[i] );
        }
        return aEle;
    },
    //根据文档目录,获取必要的表单上的信息
    loadDocInfoBySecid: function (secifeldid) {
        var secifeldvalue = -1;
        if(-1!=secifeldid){
            secifeldvalue = WfForm.getFieldValue(secifeldid);
        }
        var workflowid = jQuery("#workflowid").val();
        jQuery.ajax({
            type: "POST",
            url: "/odoc/docs/odocCommonAjax.jsp",
            data: {
                workflowid: workflowid,
                selectValue: secifeldvalue,
                requestid : jQuery("#requestid").val(),
                action: "getData"
            },
            cache: false,
            dataType: 'json',
            success: function (returndata) {
                var docInfonew = WfForm.getOdocConfig();
                docInfonew.docParam.secid = returndata.seccategoryid;
                docInfonew.docParam.editmouldCount = returndata.editmouldCount;
                docInfonew.docParam.showmouldCount = returndata.showmouldCount;
                docInfonew.docParam.showMouldId = returndata.showMouldId;
                docInfonew.docParam.editMouldId = returndata.editMouldId;
                docInfonew.formFieldList = returndata.formFieldList;
                WfForm.changeOdocConfig(docInfonew);
                //TODO
                if (window.console) console.log("setDocParam--", docInfonew);
            }
        });

    },
    getFromFieldValue: function (fieldList) {
        var retObj = new Object();
        for (var i = 0; i < fieldList.length; i++) {
            var fieldid = fieldList[i];
            if (fieldid == "-3") {
                var fieldvalue = WfForm.getFieldValue("field-1");
                retObj["requestname"] = fieldvalue;
            } else {
                var fieldvalue = WfForm.getFieldValue("field" + fieldid);
                retObj["field" + fieldid] = fieldvalue;
            }
        }
        retObj["requestname"] = WfForm.getFieldValue("field-1");
        return retObj;
    },
    setDocParam: function () {
        var docInfonew = WfForm.getOdocConfig();
        var documentFieldId = docInfonew.docParam.documentTitleField;
        if(documentFieldId === -3 || documentFieldId === 0)documentFieldId = -1;
        if (WfForm.getFieldValue("field" + documentFieldId) === "" && WfForm.getFieldCurViewAttr('field' + + documentFieldId) > 1) {
            alert("\"" + WfForm.getFieldInfo(documentFieldId).fieldlabel + "\""+ecCom.WeaLocaleProvider.getLabel(503020,'字段未填写'));
            oDocUtil.uploadPDFCanClick = true
            WfForm.switchTab("form");
            return false;
        }
        var formFieldList = docInfonew.formFieldList;
        var fieldTotalList = new Array();
        //编辑模板字段
        for (var i = 0; formFieldList && i < formFieldList.length; i++) {
            var fieldid = formFieldList[i];
            if (jQuery.inArray(fieldid, fieldTotalList) >= 0) continue;
            fieldTotalList.push(fieldid);
        }
        //选择框目录字段
        if (jQuery.inArray(docInfonew.docParam.secFieldid, fieldTotalList) == -1) fieldTotalList.push(docInfonew.docParam.secFieldid);


        //文档标题
        if (jQuery.inArray(docInfonew.docParam.secFieldid, fieldTotalList) == -1) {
            fieldTotalList.push(docInfonew.docParam.secFieldid);
        }

        //选择框目录字段
        if (jQuery.inArray(docInfonew.docParam.documentTitleField, fieldTotalList) == -1) fieldTotalList.push(docInfonew.docParam.documentTitleField);

        if (window.console) console.log("fieldTotalList", fieldTotalList);
        var fieldTotalObj = oDocUtil.getFromFieldValue(fieldTotalList);
        if (window.console) console.log("fieldTotalObj", fieldTotalObj);
        // for (var fieldInfo in fieldTotalObj) {//不使用过滤
        //     docInfonew.docParam[fieldInfo] = fieldTotalObj[fieldInfo];
        // }
        //保留需要带入URL参数的内容
        docInfonew.nowDocParam = new Object();
        docInfonew.nowDocParam = oDocUtil.cloneObject(docInfonew.docParam);
        for (var fieldInfo in fieldTotalObj) {//不使用过滤
            docInfonew.nowDocParam[fieldInfo] = fieldTotalObj[fieldInfo];
        }


        //模板书签对应字段
        var formFieldList = docInfonew.formFieldList;
        var formFieldObj = oDocUtil.getFromFieldValue(formFieldList?formFieldList:[]);
        //模板书签对应,不需要带入URL参数中,但是需要记录变化
        for (var fieldInfo in formFieldObj) {
            docInfonew.nowDocParam[fieldInfo] = formFieldObj[fieldInfo];
        }

        //是否需要重新加载url
        docInfonew.needReload = false;
        if (!oDocUtil.ObjectEquals(docInfonew.nowDocParam, docInfonew.lasttimeDocParam)) {

            docInfonew.needReload = true;

            var odocWin;
			if(jQuery(".req-workflow-odoc").length>0){
				odocWin = jQuery(".req-workflow-odoc")[0].contentWindow;
				//关闭控件
				try {
					odocWin.onbeforeunload = null;
				} catch (e) {
				}
				try {
					window.onbeforeunload = null;
				} catch (e) {
				}
				try {
					odocWin.document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice").saved = true;
				} catch (e) {
				}
				try {
					odocWin.document.getElementById("webOffice").contentWindow.onbeforeunload = null;
				} catch (e) {
				}
				try {
					odocWin.document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice").WebClose();
				} catch (e) {
				}
				if (window.console) console.log(jQuery(".req-workflow-odoc")[0].src);
				docInfonew.lasttimeDocParam = new Object();
				docInfonew.lasttimeDocParam = oDocUtil.cloneObject(docInfonew.nowDocParam);
			}
        } else {
            docInfonew.needReload = false;
        }
        if (window.console) console.log("docInfonew---new", docInfonew);
        WfForm.changeOdocConfig(docInfonew);
        if (docInfonew.needReload) {
            var url = docInfonew.docUrl + "?";
            var count = 0;
            var router = docInfonew.docParam.router;
            if (docInfonew.docParam.isEdit == 1) {
                router = "#/main/document/edit";
            } else {
                router = "#/main/document/detail";
            }
            for (var key in docInfonew.docParam) {
                if (key == "router") continue;
                if(!(docInfonew.docParam[key])) continue;
                if (count > 0) url += "&";
                url += key + "=" + encodeURIComponent(docInfonew.docParam[key]);
                count++;
            }
            var dataJson = oDocUtil.cloneObject(docInfonew.nowDocParam);
            dataJson.action = 'setUrlParams';
            jQuery.ajax({
                type: "POST",
                url: "/api/odoc/odocWorkflow/setUrlParams?date="+new Date(),
                data: dataJson,
                async: false,
                cache: false,
                dataType: 'json',
                success: function (returndata) {
                    retFlag = returndata.success;
                    url += "&uuid=" + returndata.uuid;
					oDocUtil.uuid=returndata.uuid;
                }
            });
            url += router;
            try {
                jQuery(".req-workflow-odoc")[0].contentWindow.onbeforeunload = null;
            } catch (e) {
            }
            
            jQuery(".wf-req-odoc").css("margin-top", "10px");
            jQuery(".wf-req-odoc").css("margin-bottom", "10px");
            jQuery(".wf-req-odoc").height(jQuery(".wea-new-top-req-content").height() - 20);
            jQuery(".req-workflow-odoc").height(jQuery(".wf-req-odoc").height());
            jQuery(".req-workflow-odoc").attr("src", url);
        }
    },
    ObjectEquals: function (obj1, obj2) {
        if (obj1 == obj2)
            return true;
        if (typeof(obj2) == "undefined" || obj2 == null || typeof(obj2) != "object")
            return false;
        var length = 0;
        var length1 = 0;
        for (var ele in obj1) {
            length++;
        }
        for (var ele in obj2) {
            length1++;
        }
        if (length != length1)
            return false;
        if (obj2.constructor == obj1.constructor) {
            for (var ele in obj1) {
                if (typeof(obj1[ele]) == "object") {
                    if (obj1[ele].constructor == Array) {
                        if (obj1[ele].toString() != obj2[ele].toString()) {
                            return false;
                        }
                    } else if (!obj1[ele].equals(obj2[ele])) {
                        return false;
                    } else if (typeof(obj1[ele]) == "function") {
                        if (obj1[ele].toString() != obj2[ele].toString()) {
                            return false;
                        }
                    }
                } else if (obj1[ele] != obj2[ele]) {
                    return false;
                }
            }
            return true;
        }
        return false;
    },
    cloneObject: function (obj) {
        // Handle the 3 simple types, and null or undefined
        if (null == obj || "object" != typeof obj) return obj;

        // Handle Date
        if (obj instanceof Date) {
            var copy = new Date();
            copy.setTime(obj.getTime());
            return copy;
        }

        // Handle Array
        if (obj instanceof Array) {
            var copy = [];
            for (var i = 0; i < obj.length; i++) {
                copy[i] = oDocUtil.cloneObject(obj[i]);
            }
            return copy;
        }

        // Handle Object
        if (obj instanceof Object) {
            var copy = {};
            for (var attr in obj) {
                if (obj.hasOwnProperty(attr)) copy[attr] = oDocUtil.cloneObject(obj[attr]);
            }
            return copy;
        }

        throw new Error("Unable to copy obj! Its type isn't supported.");
    },
    odocBtnEvent: function (eventKey) {
        var docInfo = WfForm.getOdocConfig();
        var odocWin = jQuery(".req-workflow-odoc")[0].contentWindow;
        //获取事件参数
        var onclickParam;
        for (var i = 0; i < docInfo.buttons.length; i++) {
            if (docInfo.buttons[i].key == eventKey) {
                onclickParam = docInfo.buttons[i].onclickParam;
                break;
            }
        }
        //保存
        if (eventKey == "saveDoc") {
            odocWin.onSave();
            setWebOfficeSaved();
            setWebOffice2015Saved();
            //返回表单
        } else if (eventKey == "backToForm") {
            try{
                odocWin.backToForm();
            }catch (e) {
                parent.WfForm.switchTab('form');
            }
            //选择其他编辑模板
        } else if (eventKey == "selectTemplate2") {
            //  odocWin.selectTemplate2();
            oDocUtil.selectTemplate(true)
            //签章
        } else if (eventKey == "CreateSignature") {
            odocWin.CreateSignature(0);
            //契约锁Office单体签章
        } else if (eventKey == "CreateSignature_Sign") {
            odocWin.CreateSignature(0,1);
            //契约锁Office单体手写签批
        } else if (eventKey == "CreateSignatureSign_SignHandSig") {
            odocWin.CreateSignature(0,2);
            //契约锁Office单体骑缝章
        } else if (eventKey == "CreateSignature_SignPageSeal") {
            odocWin.CreateSignature(0,3);
            //签章确认
        } else if (eventKey == "saveIsignatureFun") {
            if(docInfo.docParam.isQysSignNode){
                odocWin.saveSignOfQys();
            }else{
                odocWin.saveIsignatureFun();
                setWebOfficeSaved();
                setWebOffice2015Saved();
            }
            //保存新版本
        } else if (eventKey == "SaveNewVersion") {
            odocWin.onSave();
            //显示/隐藏痕迹
        } else if (eventKey == "toggleTrace") {
        	if(docInfo.docParam.noplugninText){
        		var webOfficeWin = odocWin.document.getElementById('webOffice').contentWindow;
        		webOfficeWin.exportRevision();
        	}else{
            	odocWin.OnMenuClick(101);
        	}
            //清稿
        } else if (eventKey == "clearTrace") {
        	
        	if(docInfo.docParam.noplugninText){
        		var webOfficeWin = odocWin.document.getElementById('webOffice').contentWindow;
        		webOfficeWin.exportAllRevision();
        	}else{
            	odocWin.OnMenuClick(102);
        	}
            //套红确认
        } else if (eventKey == "saveTHTemplate") {
            if (onclickParam != undefined && onclickParam.length == 1) {
                odocWin.saveTHTemplate(onclickParam[0]);
                odocWin.afterTempleteEditButton(true);
                setWebOfficeSaved();
                setWebOffice2015Saved();
            } else {
                if (window.console) console.log("saveTHTemplate "+ecCom.WeaLocaleProvider.getLabel(503024,'方法参数个数不正确'));
            }
            //选择其他模板
        } else if (eventKey == "selectTemplate") {
            if (onclickParam != undefined && onclickParam.length == 2) {
            	// odocWin.selectThTemplate();
                oDocUtil.selectTemplate(false);
            } else {
                if (window.console) console.log("selectTemplate "+ecCom.WeaLocaleProvider.getLabel(503024,'方法参数个数不正确'));
            }
            //套红取消
        } else if (eventKey == "useTempletCancel") {
            odocWin.useTempletCancel();
            //保存
        } else if (eventKey == "saveTHTemplateNoConfirm") {
            if (onclickParam != undefined && onclickParam.length == 1) {
                odocWin.onSave(onclickParam[0]);
                setWebOfficeSaved();
                setWebOffice2015Saved();
            } else {
                if (window.console) console.log("saveTHTemplateNoConfirm "+ecCom.WeaLocaleProvider.getLabel(503024,'方法参数个数不正确'));
            }
            //打印
        } else if (eventKey == "printDoc") {
            odocWin.printDoc();
            //odocWin.OnMenuClick(47);
        }else if(eventKey == "fullScreen"){//全屏查看
            odocWin.fullScreen();
        }else if(eventKey == "uploadPDF"){
            this.clickAddOdoc(false,true,'',true,"PDF");
        }else if(eventKey == "uploadOFD"){
            this.clickAddOdoc(false,true,'',true,"OFD");
        }else if(eventKey == "replacePDF" || eventKey == "replaceOFD"){
            odocWin.uploadPDF();
        }else if(eventKey == "download"){
            odocWin.filedownload();
        }else if(eventKey == "openLocalFile"){ //打开本地文件
            if(docInfo.wpsEditor){ //使用wps无插件
                var suffix = "docx,doc";
                if(docInfo.extendName && docInfo.extendName != ""){
                    if(docInfo.extendName == ".wps"){
                        suffix = "wps";
                    }
                    oDocUtil.uploadDocFile(suffix);
                }
            }else{
                odocWin.OnMenuClick(1);
            }

        }else if(eventKey == "openversionList"){
            odocWin.openversionfiles();
        }else if(eventKey == "onEditDoc"){
            odocWin.onEditDoc();
        }

    },
    setFieldValue: function (fieldid, value, namefieldid) {
        if(namefieldid == "-3")namefieldid = -1;
        WfForm.changeFieldValue("field" + fieldid, {
            value: value,
            specialobj: [
                {id: "" + value, name: WfForm.getFieldValue("field" + namefieldid)}
            ]
        });
    },
    getOfdSignatureCount : function(){
        var retValue= false;
        jQuery.ajax({
            type: "POST",
            url: "/odoc/docs/odocCommonAjax.jsp",
            data: {
                requestid : jQuery("#requestid").val(),
                nodeid : jQuery('#nodeid').val(),
                action: "getGinatureCount",
            },
            async: false,
            cache: false,
            dataType: 'json',
            success: function (returndata) {
                if(returndata.success && returndata.singCount > 0){
                    retValue = true;
                }
            }
        });
        return retValue;
    }
}


doctopdfandsubmitReturn = function(returnvalue,pdfDocId,DecryptpdfDocId){
    var docInfonew = WfForm.getOdocConfig();
    if(!docInfonew.TexttoPDF) return;
    if(returnvalue==1 &&docInfonew.TexttoPDF != null && docInfonew.TexttoPDF.isTexttoPDF === "1" && docInfonew.TexttoPDF.operationtype === 1){
        var titleField = docInfonew.TexttoPDF.documentTitleField;
        if(titleField == -3){
            titleField == -1
        }
        //将生成的PDF字段赋值给表单字段
        if(pdfDocId>0){
            oDocUtil.setFieldValue(docInfonew.TexttoPDF.pdffieldid, pdfDocId,titleField);
        }
        if(DecryptpdfDocId>0){
            oDocUtil.setFieldValue(docInfonew.TexttoPDF.decryptpdffieldid, DecryptpdfDocId,titleField);
        }
        //转换失败后,不再执行转PDF的动作
        docInfonew.TexttoPDF = null;
        WfForm.changeOdocConfig(docInfonew);
        WfForm.doSubmit();
    }else{
        //Label125968
        if(confirm(ecCom.WeaLocaleProvider.getLabel(125968,'正文转PDF异常,是否依然提交流程?'))){
            docInfonew.TexttoPDF = null;
            WfForm.changeOdocConfig(docInfonew);
            WfForm.doSubmit();
        }else{
            return ;
        }
    }
}

function odocregisterCheckEvent() {

//Label23043

    var docInfo = WfForm.getOdocConfig();
    var __onbeforeunload = window.onbeforeunload;
    window.onbeforeunload = function(e){
        //关闭页面时正文保存确认
        try {
            if(jQuery(".req-workflow-odoc")[0] && jQuery(".req-workflow-odoc")[0].contentDocument
                && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice") && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument
                &&((jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")
                    &&jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify)
                    || getWebOffice2015IsModify() == "true" )
				&&((jQuery("#requestdocInForm")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")
                    &&jQuery("#req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify)
                    || getWebOffice2015IsModifyInForm() == "true" )
            ){
                return ecCom.WeaLocaleProvider.getLabel(19006,'文档还没保存,真的要离开吗?');
            }else{
                return __onbeforeunload(e);
            }
        }catch (e) {

        }
    }
    if (docInfo != null && docInfo.docFlag) {

        //  保存流程时提示保存正文
        WfForm.registerCheckEvent(WfForm.OPER_SAVE, function (callback) {
            if ((docInfo.docParam.isTextInForm||docInfo.docParam.isColumnShow=='1')&&docInfo.docParam.isTextInFormCanEdit&&oDocUtil.onlySave!='1') {
                onSaveInForm('Save');
            }			
            if(jQuery(".req-workflow-odoc")[0] && jQuery(".req-workflow-odoc")[0].contentDocument
                && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice") && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument
                &&((jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")
                    &&jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify)
                    || getWebOffice2015IsModify() == "true"  )
				&&((jQuery("#requestdocInForm")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")
                    &&jQuery("#req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify)
                    || getWebOffice2015IsModifyInForm() == "true" )					
            ){
                if(window.confirm(ecCom.WeaLocaleProvider.getLabel(19006,'文档还没保存,真的要离开吗?'))){
                    callback();
                }else{
                    return;
                }
            }else{
                callback();
            }

        });
        WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, function (callback) {

            var retFlag = true;
            if (docInfo == null || docInfo.docParam == null) {
                callback();
            }
            if (docInfo.docParam && docInfo.docParam.isUseTempletNode && docInfo.docParam.hasUsedTemplet != "1"&&docInfo.docParam.docfiletype!=12) {

                //Label21252
                alert(ecCom.WeaLocaleProvider.getLabel(21252,'请先执行套红操作!'));
				if(!(docInfo.docParam.isTextInFormCanEdit&&(docInfo.docParam.isTextInForm||docInfo.docParam.isColumnShow=='1'))){
					WfForm.switchTab("odoc");
				}
                retFlag = false;
                return false;
            }
            if (docInfo.docParam.isMustSignatureNodes && !oDocUtil.getOfdSignatureCount() && !docInfo.docParam.hasSignatureSucceed&&(docInfo.docParam.docfiletype!=12||docInfo.docParam.isQysPdfSingleSign)) {
                alert(ecCom.WeaLocaleProvider.getLabel(130844,'该节点为签章节点,请先签章,再提交'));
                retFlag = false;
                return false;
            }
            //Label23043
            if (docInfo.docParam.isSignatureNodes && !oDocUtil.getOfdSignatureCount() && !docInfo.docParam.hasSignatureSucceed && !window.confirm(ecCom.WeaLocaleProvider.getLabel(23043,'该节点为签章节点,您未执行签章操作,是否确定提交?'))) {
                retFlag = false;
                return false;
            }
            if (!docInfo.docParam.openyozo && !docInfo.docParam.openWpsToPdf &&docInfo.docParam.docfiletype!=12&&docInfo.TexttoPDF != null && docInfo.TexttoPDF.isTexttoPDF === "1" && docInfo.TexttoPDF.operationtype === 1 && docInfo.docParam.docid > 0) {
                //WfForm.doLoading(true);
                if(docInfo.office2015 === "1"){
                    jQuery(".req-workflow-odoc")[0].src ="/odoc/odoc/weboffice2015/OfficeToPDF.jsp?id="+docInfo.docParam.docid+"&requestid="+docInfo.TexttoPDF.requestid+"&workflowid="+docInfo.TexttoPDF.workflowid+"&nodeid="+docInfo.TexttoPDF.nodeid+ "&fromFlowDocsubmit=1";;
                }else{
                    jQuery(".req-workflow-odoc")[0].src = "/odoc/odoc/OfficeToPDF.jsp?docid=" + docInfo.docParam.docid + "&workflowid=" + docInfo.TexttoPDF.workflowid + "&requestid=" + docInfo.TexttoPDF.requestid + "&nodeid=" + docInfo.TexttoPDF.nodeid + "&fromFlowDocsubmit=1";
                }
                retFlag = false;
                return false;
            }
            if(jQuery(".req-workflow-odoc")[0] && jQuery(".req-workflow-odoc")[0].contentDocument
                && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice") && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument
                &&((jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")
                    &&jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify)
                   || getWebOffice2015IsModify() == "true")
            ){
                if(!window.confirm(ecCom.WeaLocaleProvider.getLabel(19006,'文档还没保存,真的要离开吗?'))){
                    retFlag = false;
                    return false;
                }
            }
            if (docInfo.docParam.docfiletype==12&&docInfo.TexttoPDF != null && docInfo.TexttoPDF.isTexttoPDF === "1" && docInfo.TexttoPDF.operationtype === 1 && docInfo.docParam.docid > 0) {
                jQuery.ajax({
                    type: "GET",
                    url: "/odoc/docs/odocCommonAjax.jsp?date="+new Date(),
                    data: {
                        workflowid: docInfo.TexttoPDF.workflowid,
                        docid: docInfo.docParam.docid,
                        requestid:docInfo.TexttoPDF.requestid,
                        nodeid:docInfo.TexttoPDF.nodeid,
                        fromFlowDocsubmit:1,
                        action: "updateDocToPdf"
                    },
                    async: false,
                    cache: false,
                    dataType: 'json',
                    success: function (returndata) {
                        retFlag = returndata.success;
                        if(window.console)
                            console.log("===returndata.fieldValue:"+returndata.fieldValue+"===returndata.PdfName:"+returndata.PdfName);
                        if(retFlag)
                        {
                            WfForm.changeFieldValue("field" + returndata.fieldId, {
                                value: returndata.fieldValue,
                                specialobj: [
                                    {id: "" + returndata.fieldValue, name: returndata.PdfName}
                                ]
                            });
                        }else
                        {
                            if(confirm(ecCom.WeaLocaleProvider.getLabel(125968,'正文转PDF异常,是否依然提交流程?'))){
                                retFlag = true;
                            }else{
                                retFlag = false;
                            }
                        }
                    }
                });
            }
            if ((docInfo.docParam.isTextInForm||docInfo.docParam.isColumnShow=='1')&&docInfo.docParam.isTextInFormCanEdit&&oDocUtil.onlySave!='1') {
                onSaveInForm('Submit');
            }
            if (retFlag) callback(); //继续提交需调用callback,不调用代表阻断
        });
    }

}
window.onWeaDialogOpen = function(){
    showOrHideTextInForm(true);
};
window.onWeaDialogClose = function(){
	showOrHideTextInForm(false);
};					
var contentWidth;
function showOrHideTextInForm(isHide){
	try{
		var docInfonew = WfForm.getOdocConfig();
		var win;
		if(docInfonew.docParam.isColumnShow=='1'){
			win = jQuery(".wf-req-form-odoc-iframe");
		}else{
			win = jQuery("#requestdocInForm");
		}	
		if(isHide){	
			contentWidth = win.width();		
			win.width(1);
		}else{
			win.width(contentWidth);
		}
	}catch(e){}
}
function setTextShowInForm() {
    var docInfonew = WfForm.getOdocConfig();
	var srcurl = WfForm.getOdocConfig().srcUrl;
	var docfiletype = docInfonew.docParam.docfiletype;
	var isEdit = docInfonew.docParam.isEdit;
    var url = "/odoc/odoc/index_odoc4formShow.jsp?";
    if((docInfonew.docParam.isTextInFormCanEdit&&(docInfonew.docParam.isTextInForm||docInfonew.docParam.isColumnShow=='1'))&&(docfiletype=='3'||docfiletype=='7'||docfiletype=='6')&&isEdit=='1'){
        oDocUtil.setDocParam();
		if(docInfonew.docParam.useyozoorwps!='1'){
			url = "/odoc/odoc/index_odoc_router.jsp?requestdocInForm=1&uuid="+oDocUtil.uuid+"&";
		}else{
			url = "/odoc/odoc/index_odoc4formShowContent.jsp?requestdocInForm=1&uuid="+oDocUtil.uuid+"&";
		}
		WfForm.getOdocConfig().srcUrl = srcurl+"&uuid="+oDocUtil.uuid;
    }
    //没有开启正文显示在表单或没有开启预览,则不将正文显示在表单
    if (!docInfonew.docParam.isTextInForm ){
        return;
    }	
    var count = 0;
    for (var key in docInfonew.docParam) {
        if (key == "router") continue;
        if (count > 0) url += "&";
        url += key + "=" + encodeURIComponent(docInfonew.docParam[key]);
        count++;
    }
    try {
        jQuery("#requestdocInForm")[0].contentWindow.onbeforeunload = null;
    } catch (e) {
    }
    if (window.console) console.log(jQuery("#field" + docInfonew.docParam.docFieldId));
    if (jQuery("#requestdocInForm").length <= 0) {
        if(jQuery("#ODocIframe").length<=0){
            jQuery("#field" + docInfonew.docParam.docFieldId).closest("tr").after("<tr><td colspan='100'><iframe id = requestdocInForm /></td></tr>");
        }else{
            try{
                jQuery("#ODocIframe").html("<iframe id = requestdocInForm />");
                jQuery("#ODocIframe").css("display","");
                jQuery("#ODocIframe").parent().parent().css("display","");
            }catch (e) {
            }
        }
    }
    jQuery("#requestdocInForm").css("width", "100%");
    jQuery("#requestdocInForm").css("height", "650px");
    jQuery("#requestdocInForm").attr("src", url);
    jQuery("#requestdocInForm").show();
}

function onSaveOnly(isSub){
	oDocUtil.onlySave = '1';
	if(isSub){
		window.WfForm.doSave();
	}
}
function onSaveInForm(key){

    try{
		var win;
		if(WfForm.getOdocConfig().docParam.isColumnShow=='1'){
			win = jQuery(".wf-req-form-odoc-iframe")[0].contentWindow;
		}else{
			win = jQuery("#requestdocInForm")[0].contentWindow;
		}		
        win.onSave(key);
    }catch (e) {

    }
}
function renderDialog(hideBtn,docid,odocfileType){
    var uploadComponent = document.createElement("div");
    uploadComponent.setAttribute("id","uploadComponent");
    if(hideBtn){
        uploadComponent.setAttribute("docid",docid);
        uploadComponent.setAttribute("odocfileType",odocfileType);
    }else{
        uploadComponent.setAttribute("showBtn","true");
    }
    document.body.appendChild(uploadComponent);
    var UploadFileComp = weaOdoc.components.uploadFileComp;
    ReactDOM.render(
        UploadFileComp,
        document.getElementById("uploadComponent")
    )
}

/** 保存后,更新插件变更状态 */
function setWebOfficeSaved(){

    if(jQuery(".req-workflow-odoc")[0] && jQuery(".req-workflow-odoc")[0].contentDocument
        && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice") && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument
        && jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")){
        jQuery(".req-workflow-odoc")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify = false;
    }
}

/** 2015插件保存后,更新插件变更状态 */
function setWebOffice2015Saved(){
    try {
        if(jQuery(".req-workflow-odoc")[0].contentWindow.getIwebOfficeObj()
            &&jQuery(".req-workflow-odoc")[0].contentWindow.getIwebOfficeObj().obj){
            jQuery(".req-workflow-odoc")[0].contentWindow.getIwebOfficeObj().obj.IsModify(0);
        }
    }catch (e) {

    }
}

/** 2015插件未保存提示 */
function getWebOffice2015IsModify(){
    var isModify = "false";
    try {
        if(jQuery(".req-workflow-odoc")[0].contentWindow.getIwebOfficeObj()
            &&jQuery(".req-workflow-odoc")[0].contentWindow.getIwebOfficeObj().obj
            &&jQuery(".req-workflow-odoc")[0].contentWindow.getIwebOfficeObj().obj.IsModify(1)){
            isModify = "true";
            return isModify;
        }else {
            return isModify;
        }
    }catch (e) {
        return isModify;
    }
}

/** 保存后,更新插件变更状态 */
function setWebOfficeSavedInForm(){
	if(WfForm.getOdocConfig().docParam.isColumnShow=='1'){
		if(jQuery(".wf-req-form-odoc-iframe")[0] && jQuery(".wf-req-form-odoc-iframe")[0].contentDocument
			&& jQuery(".wf-req-form-odoc-iframe")[0].contentDocument.getElementById("webOffice") && jQuery(".wf-req-form-odoc-iframe")[0].contentDocument.getElementById("webOffice").contentDocument
			&& jQuery(".wf-req-form-odoc-iframe")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")){
			jQuery(".wf-req-form-odoc-iframe")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify = false;
		}
	}else{
		if(jQuery("#requestdocInForm")[0] && jQuery("#requestdocInForm")[0].contentDocument
			&& jQuery("#requestdocInForm")[0].contentDocument.getElementById("webOffice") && jQuery("#requestdocInForm")[0].contentDocument.getElementById("webOffice").contentDocument
			&& jQuery("#requestdocInForm")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice")){
			jQuery("#requestdocInForm")[0].contentDocument.getElementById("webOffice").contentDocument.getElementById("WebOffice").modify = false;
		}		
	}
}

/** 2015插件保存后,更新插件变更状态 */
function setWebOffice2015SavedInForm(){
    try {
		if(WfForm.getOdocConfig().docParam.isColumnShow=='1'){
			if(jQuery(".wf-req-form-odoc-iframe")[0].contentWindow.getIwebOfficeObj()
				&&jQuery(".wf-req-form-odoc-iframe")[0].contentWindow.getIwebOfficeObj().obj){
				jQuery(".wf-req-form-odoc-iframe")[0].contentWindow.getIwebOfficeObj().obj.IsModify(0);
			}			
		}else{
			if(jQuery("#requestdocInForm")[0].contentWindow.getIwebOfficeObj()
				&&jQuery("#requestdocInForm")[0].contentWindow.getIwebOfficeObj().obj){
				jQuery("#requestdocInForm")[0].contentWindow.getIwebOfficeObj().obj.IsModify(0);
			}
		}
    }catch (e) {

    }
}

/** 2015插件未保存提示 */
function getWebOffice2015IsModifyInForm(){
    var isModify = "false";
    try {
		if(WfForm.getOdocConfig().docParam.isColumnShow=='1'){
			if(jQuery(".wf-req-form-odoc-iframe")[0].contentWindow.getIwebOfficeObj()
				&&jQuery(".wf-req-form-odoc-iframe")[0].contentWindow.getIwebOfficeObj().obj
				&&jQuery(".wf-req-form-odoc-iframe")[0].contentWindow.getIwebOfficeObj().obj.IsModify(1)){
				isModify = "true";
				return isModify;
			}else {
				return isModify;
			}			
		}else{	
			if(jQuery("#requestdocInForm")[0].contentWindow.getIwebOfficeObj()
				&&jQuery("#requestdocInForm")[0].contentWindow.getIwebOfficeObj().obj
				&&jQuery("#requestdocInForm")[0].contentWindow.getIwebOfficeObj().obj.IsModify(1)){
				isModify = "true";
				return isModify;
			}else {
				return isModify;
			}
		}
    }catch (e) {
        return isModify;
    }
}


$(function(){
    var timer = setInterval(function () {
        if(window.WfForm && window.WfForm.getOdocConfig().docFlag != null){
            clearInterval(timer);
            if(WfForm.getOdocConfig().docFlag){
                if(!window.weaOdoc){
                    window.eventRegister && window.eventRegister.loadModule('f_odoc',
                        function(){
                            if(window.console) console.log("公文模块加载成功");
                        },
                        function(){
                            if(window.console) console.log("公文模块加载失败");
                        }
                    );
                }
            }

        }
    },2000)
});

window.uploadLoacalFile = function(imagefileId,suffix){
    if(imagefileId && imagefileId > 0){
        var docInfo = WfForm.getOdocConfig();
        var isCompellentMark = docInfo.docParam.isCompellentMark;
        var isCancelCheck = docInfo.docParam.isCancelCheck;
        if((docInfo.docParam.isStartNode && !docInfo.docParam.saveRevision) || docInfo.docParam.isUseTempletNode){
            isCompellentMark ='0';
        }
        jQuery(".req-workflow-odoc")[0].contentWindow.document.getElementById("webOffice").src='/docs/e9/weboffice_wps.jsp?fromOdoc=1&mFileType=.'+suffix+'&fileid='+imagefileId+'&isCompellentMark='+isCompellentMark+'&isCancelCheck='+isCancelCheck;
        jQuery(".req-workflow-odoc")[0].contentWindow.document.getElementById("extendName").value = '.'+suffix;
    }
}