index2file.jsp 51.9 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 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="weaver.conn.*"%>
<%@ page import="weaver.general.*"%>
<%@ page import="weaver.hrm.*" %>
<%@ page import="java.util.Map,java.util.HashMap,java.util.Hashtable,java.util.List,java.util.ArrayList" %>
<%@ page import="weaver.docs.pdf.docpreview.ConvertPDFUtil"%>
<%@ page import="weaver.docs.pdf.docpreview.ConvertPDFTools" %>
<%@ page import="com.api.doc.detail.service.DocDetailService"%>
<%@ page import="weaver.docs.category.SecCategoryDocPropertiesComInfo"%>
<%@ page import="weaver.docs.category.SecCategoryComInfo"%>
<%@ page import="weaver.docs.mould.MouldManager"%>
<%@ page import="weaver.systeminfo.SystemEnv"%>
<%@ page import="com.api.doc.detail.service.DocViewPermission"%>
<%@ page import="java.util.Date"%>
<%@ page import="com.api.doc.detail.service.DocSaveService"%>
<%@ page import="com.api.doc.search.util.DocSptm"%>
<%@ page import="com.api.doc.detail.util.ImageConvertUtil"%>
<%@page import="com.engine.doc.util.IWebOfficeConf"%>
<%@ page import="com.engine.doc.util.DocPlugUtil" %>
<%@ page import="com.api.doc.detail.util.DocDetailUtil" %>
<%@ page import="org.apache.bcel.generic.NEW" %>
<%@page import="java.net.*" %>
<jsp:useBean id="DocComInfo" class="weaver.docs.docs.DocComInfo" scope="page"/>
<jsp:useBean id="DocPreviewHtmlManager" class="weaver.docs.docpreview.DocPreviewHtmlManager" scope="page"/>
<jsp:useBean id="DepartmentComInfo" class="weaver.hrm.company.DepartmentComInfo" scope="page"/>
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
<jsp:useBean id="CustomerInfoComInfo" class="weaver.crm.Maint.CustomerInfoComInfo" scope="page" />
<jsp:useBean id="LanguageComInfo" class="weaver.systeminfo.language.LanguageComInfo" scope="page" />
<jsp:useBean id="DocDsp" class="weaver.docs.docs.DocDsp" scope="page" />

<%

	/*** 其他模块跳转过来的时候,不带路由,这里统一加上 ***/
	String router = request.getParameter(DocSptm.DOC_ROOT_FLAG);
	if(router == null){
	  %>
	 <script>
	 	var _href = location.href;
	 	if(_href.indexOf("#/main/document/fileView") == -1){
	 		location.href = _href + "&<%=DocSptm.DOC_ROOT_FLAG%>=1" + "#/main/document/fileView";
	 	}else{
	 		location.href = _href.replace("#/main/document/fileView","&<%=DocSptm.DOC_ROOT_FLAG%>=1#/main/document/fileView");
	 	}
	 </script>
	  
	  <%
	  return;
	}

	response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    User user = HrmUserVarify.getUser (request , response);
	  if(user==null){
		  response.sendRedirect("/wui/index.html");
		  return ;
	  }

    long time1 = 0;
    long time2 = 0;
    long time3 = 0;

	Date d1 = new Date();

    // 文档ID
    int docid = Util.getIntValue(request.getParameter("id"),-1);
    
    boolean isEdit = "1".equals(request.getParameter("isEdit"));
    String attachtype = request.getParameter("attachtype");

    int imagefileId = Util.getIntValue(request.getParameter("imagefileId"),-1);
    int versionId = Util.getIntValue(request.getParameter("versionId"),-1);
    
    String _convertFile = Util.null2String(request.getParameter("convertFile"));
    
    String checkOutStatus = "";
    
    String model = Util.null2String(request.getParameter("model"));
    boolean isReplyAcc = "reply".equals(model);
    
    if(isReplyAcc){
    	docid = Util.getIntValue(request.getParameter("docid"),-1);
    }

    Boolean docisLock = DocDetailUtil.isopendoclock(docid+"","doc");
    Boolean fromRequest = false;
    String isrequest = Util.null2s(request.getParameter("isrequest"),"");
	  if((Util.getIntValue(request.getParameter("requestid"),0) > 0) || "1".equals(isrequest)){
		  fromRequest = true;
	  }
    // 附件版本ID
    if(docid < 0 && imagefileId < 0)
    {
        response.sendRedirect("/notice/noright.jsp") ;
        return ;
    }
    
    if(docid > 0 && imagefileId >0){  
    	RecordSet rs = new RecordSet();
    	if(isReplyAcc){
    		rs.executeQuery("select b.id from REPLY_IMAGEFILE a,DOC_REPLY b where a.REPLY_ID=b.id and a.IMAGEFILEID=? and b.docid=?",imagefileId,docid);
    	}else if(versionId > 0){
    		rs.executeQuery("select id from DocImageFile where imagefileid=? and docid=? and versionid=?",imagefileId,docid,versionId);
    	}else{
    		rs.executeQuery("select id from DocImageFile where imagefileid=? and docid=?",imagefileId,docid);
    	}
    	if(!rs.next()){//附件和文档不匹配
    		response.sendRedirect("/notice/noright.jsp") ;
    		return;
    	}
    }
    
    if(docid <= 0 && imagefileId > 0){
    	
    	int oldimagefileId = imagefileId;
    	RecordSet rs = new RecordSet();
    	rs.executeQuery("select imagefileid from PDF_IMAGEFILE where pdfimagefileid=" + imagefileId);
    	if(rs.next()){
    		imagefileId = rs.getInt("imagefileid") > 0 ? rs.getInt("imagefileid") : imagefileId;
    		versionId = -1;
    	}else{
    		rs.executeQuery("select imagefileid from DocPreviewHtml where htmlfileid=" + imagefileId);
    		if(rs.next()){
        		imagefileId = rs.getInt("imagefileid") > 0 ? rs.getInt("imagefileid") : imagefileId;
        		versionId = -1;
        	}
    	}
    	
    	rs.executeQuery("select docid,versionid from DocImageFile where imagefileid=" + imagefileId + (versionId > 0 ? (" and versionid=" + versionId) : ""));
    	if(rs.next()){
    		docid = rs.getInt("docid");
    		versionId = rs.getInt("versionid");
    	}
    	if(docid > 0){
	    	%>
	    		<script>
	    			location.href = location.href.replace("imagefileId=<%=oldimagefileId%>","imagefileId=<%=imagefileId%>&id=<%=docid%>&versionId=<%=versionId%>");
	    		</script>
	    	<%
	    	return;
    	}
    }else if(docid > 0 && imagefileId <= 0){
    	RecordSet rs = new RecordSet();
    	rs.executeQuery("select imagefileid,versionid from DocImageFile where docid=" + docid + (versionId > 0 ? (" and versionid=" + versionId) : "") + " order by versionid desc");
    	if(rs.next()){
    		imagefileId = rs.getInt("imagefileid");
    		versionId = rs.getInt("versionid");
    		%>
    			<script>
    			location.href = location.href.replace("&imagefileId=","&_imagefileId=").replace("&versionId","&_versionId").replace("#/main/document/fileView","&imagefileId=<%=imagefileId%>&versionId=<%=versionId%>#/main/document/fileView");
    			</script>
    		<%
    		return;
    	}else{
    		response.sendRedirect("/notice/noright.jsp") ;
            return ;
    	}
    }


    if(versionId <= 0 && docid > 0)
	{
		RecordSet rs = new RecordSet();
		rs.executeQuery("select versionid from DocImageFile where docid=" + docid + " and imagefileid=" + imagefileId + " order by versionid desc");
		if(rs.next()){
			versionId = rs.getInt("versionid");
		}

	}

    boolean canRead = false;
    boolean canEdit = false;
    /**判断文档查看权限*/
    
    String useNew = "1";//是否使用新的权限判断
    Map<String,String> rightParams = new HashMap<String,String>(); 
    rightParams.put("useNew",useNew);
    
    DocViewPermission dvps = new DocViewPermission();
    Map<String,Boolean> levelMap = new HashMap<String,Boolean>();
    
    if(docid > 0){
    	
    	 //密级判断
       	if(!dvps.hasRightForSecret(user,docid)){
       		response.sendRedirect("/notice/noright.jsp?secretNotEnough=1") ;
       		return;
       	}
    	
    	levelMap = dvps.getShareLevel(docid,user,false);
		if(!levelMap.get(DocViewPermission.EDIT)){ //知识没有权限,判断是否是其他模块
			dvps.hasEditRightFromOtherMould(docid,levelMap,user,request);
		}

		canEdit = levelMap.get(DocViewPermission.EDIT);

    	if(isEdit){
			RecordSet rs = new RecordSet();
    		rs.executeQuery("select doctype,docextendname,checkOutStatus,checkOutUserId,checkOutUserType from DocDetail where id=" + docid);
        	if(rs.next()){
        		checkOutStatus = rs.getString("checkOutStatus");
    			int checkOutUserId = rs.getInt("checkOutUserId");
    			String checkOutUserType = rs.getString("checkOutUserType");
	        	if(checkOutStatus!=null&&(checkOutStatus.equals("1")||checkOutStatus.equals("2"))&&!(checkOutUserId==user.getUID()&&checkOutUserType!=	null&&checkOutUserType.equals(user.getLogintype()))){
					//签出状态的文档,跳转详情页
	        		canEdit = false;
				}
        	}
			
			
			if(!canEdit){
			%>
				<script>
					location.href = location.href.replace("&isEdit","").replace("?isEdit","?");
				</script>
			<%
				return;
			}
			String sql = "select imagefileid,versionid from DocImageFile where id=(select id from DocImageFile where imagefileid=? and docid=? and versionid=?) order by versionid desc";
			rs.executeQuery(sql,imagefileId,docid,versionId);
			if(rs.next()){
				imagefileId = rs.getInt("imagefileid");
				versionId = rs.getInt("versionid");
			}
			
			canRead = true;
    	}else{
    		canRead = levelMap.get(DocViewPermission.READ);
    	}
    }else{
    	levelMap.put(DocViewPermission.READ,true);
		levelMap.put(DocViewPermission.DOWNLOAD,false);
		canRead = true;
    }
    RecordSet rsrq = new RecordSet();
    fromRequest = false; //会导致查看不了历史,公文多个附件时,点击哪个都看到的是最后一个
	if(fromRequest){
		rsrq.executeQuery("select docid,imagefileid,versionid from docimagefile where docid in (select docid from docimagefile where imagefileid = ?) order by versionid desc",imagefileId);
		int newimagefileid = imagefileId;
		int newversionId = versionId;
		if(rsrq.next()){
			newversionId = rsrq.getInt("versionid");
			newimagefileid = rsrq.getInt("imagefileid");
			if(newimagefileid>imagefileId){
				%>
					<script>
						location.href = location.href.replace("imagefileId=<%=imagefileId%>","imagefileId=<%=newimagefileid%>").replace("versionId=<%=versionId%>","versionId=<%=newversionId%>");
					</script>
				<%
				return;
			}
		}
	}
    if(!canRead){
    	levelMap.put(DocViewPermission.READ,dvps.hasRightFromOtherMould(docid,user,request));
    	canRead = levelMap.get(DocViewPermission.READ);
    }
    
    if(!canRead){
    	response.sendRedirect("/notice/noright.jsp") ;
    }

	if(docisLock && levelMap.get(DocViewPermission.EDIT)){
		docisLock = false;
	}
    //其他模块参数集
    String moudleParams = dvps.getMoudleParams(request);
    
    // 标题
    String docsubject = "";
    //最后修改人id
    int doclastmoduserid = 0;
	// 最后修改人
	String username = "";
    // 修改日期+时间
    String modifyDate = "";
    // 修改日期
    String doclastmoddate = "";
    // 修改时间
    String doclastmodtime = "";
    // 加载内容
    String docContent = "";
    // 文档类型
    int doctype = -1;
    //文档目录
    int seccategory = -1;
    //文档状态
    String docstatus = "0";
    //失效日期
    String invalidationdate = "";
    //文档所属部门
    String docdepartmentid = "";
    //是否是历史文档
    int ishistory = -1;
    //新闻模板
    int selectedpubmouldid = -1;
    //创建人
    int doccreaterid = -1;
    //创建人类型
    String usertype = "";
    //创建日期
    String doccreatedate = "";
    // 文档语言
    int doclangurage = 7;
    //文档编号
    String docCode = "";
    //回复文档id
    int replydocid = 0;
    //审批日期
    String docapprovedate = "";
    //发布类型
    String docpublishtype = "";

    String prevname = SystemEnv.getHtmlLabelName(156,user.getLanguage()) + ": ";
    String imagefilename = "";

    boolean isOpenAcc = false; // 是否单附件打开
    String OpenAccOfFileid = "";   //单附件打开的附件id
    String OpenAccOfFilename = "";   //单附件打开的附件名称
    String OpenAccOfFiletype = "";   //单附件打开的附件类型
    String OpenAccOfVersionid = "";   //单附件打开的附件版本
    int OpenAccOfFileSize = 0;  //单附件打开的附件大小
	String OpenAccOfcomefrom = "";   //单附件打开的附件来源
    
    boolean canPrint = dvps.getPrint(docid,user,levelMap,null);
	boolean canDownload = levelMap.get(DocViewPermission.DOWNLOAD);

    String convertFile = "";  //转换文件  空-不转换,html-转成html,pdf-转成pdf
    
    boolean openWpsView = false;

    //是否开启PDF转换
    boolean isUsePDFViewer = ConvertPDFUtil.isUsePDFViewer();

	String _extname = "";

    //选择显示模版的ID
    String selectedpubmould = Util.null2String(request.getParameter("selectedpubmould"));

    if(imagefileId > 0){

    }else{

	    List<String> columns = new ArrayList<String>();
	    columns.add("doctype");
	    columns.add("seccategory");
	    columns.add("docstatus");
	    columns.add("invalidationdate");
	    columns.add("docdepartmentid");
	    columns.add("ishistory");
	    columns.add("selectedpubmouldid");
	    columns.add("doccreaterid");
	    columns.add("usertype");
	    columns.add("doccreatedate");
	    columns.add("doclangurage");
	    columns.add("docCode");
	    columns.add("replydocid");
	    columns.add("docapprovedate");
	    columns.add("docpublishtype");

	    DocDetailService detailService = new DocDetailService();
	    Map<String,Object> baseInfo = detailService.getBasicInfoNoRight(docid,user,columns);
		Date d2 = new Date();
		time1 = d2.getTime() - d1.getTime();
	    if(baseInfo != null && baseInfo.get("data") != null){
		    Map data = (Map)baseInfo.get("data");

		    docsubject = Util.null2String(data.get("docSubject").toString(),"");
		    doclastmoduserid = Util.getIntValue(data.get("doclastmoduserid").toString(),0);
		    username = Util.null2String(data.get("doclastmoduser").toString(),"");
		    modifyDate = Util.null2String(data.get("doclastmoddatetime").toString(),"");
		    doclastmoddate = Util.null2String(data.get("doclastmoddate").toString(),"");
		    doclastmodtime = Util.null2String(data.get("doclastmodtime").toString(),"");
		    doctype = Util.getIntValue(data.get("doctype").toString(),-1);
		    seccategory = Util.getIntValue(data.get("seccategory").toString(),-1);
		    docstatus = Util.null2String(data.get("docstatus").toString(),"");
		    invalidationdate = Util.null2String(data.get("invalidationdate").toString(),"");
		    docdepartmentid = Util.null2String(data.get("docdepartmentid").toString(),"");
		    ishistory = Util.getIntValue(data.get("ishistory").toString(),-1);
		    selectedpubmouldid = Util.getIntValue(data.get("selectedpubmouldid").toString(),-1);
		    doccreaterid = Util.getIntValue(data.get("doccreaterid").toString(),-1);
		    usertype = Util.null2String(data.get("usertype").toString(),"");
		    doccreatedate = Util.null2String(data.get("doccreatedate").toString(),"");
		    doclangurage = Util.getIntValue(data.get("doclangurage").toString(),7);
		    docCode = Util.null2String(data.get("docCode").toString(),"");
		    doclangurage = Util.getIntValue(data.get("replydocid").toString(),0);
		    docapprovedate = Util.null2String(data.get("docapprovedate").toString(),"");
		    docpublishtype = Util.null2String(data.get("docpublishtype").toString(),"");
	    }


	    //html文档
	    if(doctype == 1){
	    	docContent = detailService.getDocContent(docid,user);
			//Date d3 = new Date();
			//time2 = d3.getTime() - d2.getTime();
	    	//if(contentMap != null && contentMap.get("data") != null){
	    	//	Map data = (Map)contentMap.get("data");
		    //	docContent = Util.null2String(data.get("doccontent"));
	    	//}
	        if(DocDetailService.ifContentEmpty(docContent))
	        {
	            //根据目录判断是否单附件直接打开,附件类型是不是word,excel,pdf,ppt
	            RecordSet rs = new RecordSet();

	            rs.executeSql("select isOpenAttachment from docseccategory where id=" + seccategory);
	            if(rs.next() && "1".equals(rs.getString("isOpenAttachment"))){  //目录是否开启单附件打开
	            	isOpenAcc = true;

		            rs.executeSql("select a.id,a.imagefileid,a.imagefilename,a.docfiletype,a.versionId,b.filesize,b.comefrom from docimagefile a,imagefile b " +
		            		" where a.imagefileid=b.imagefileid and a.docid=" + docid + " order by versionid desc");
		            String id = "";
		            isOpenAcc  = true;
		            while(rs.next()){   //是否是单附件
		            	if("".equals(id)){
		            		id = rs.getString("id");
		            		OpenAccOfFileid = rs.getString("imagefileid");
		            		OpenAccOfFilename = rs.getString("imagefilename");
		            		OpenAccOfFiletype = rs.getString("docfiletype");
		            		OpenAccOfVersionid = rs.getString("versionId");
		            		OpenAccOfFileSize = rs.getInt("filesize");
		            		OpenAccOfcomefrom = rs.getString("comefrom");
		            	}
		            	if(!id.equals(rs.getString("id"))){
		            		isOpenAcc = false;
		            	}

		            }


	            }


	        }else{
	        	SecCategoryDocPropertiesComInfo scdpc = new SecCategoryDocPropertiesComInfo();

	        	int docmouldid = -1;

	        	if(scdpc.getDocProperties(""+seccategory,"10") && "1".equals(scdpc.getVisible())){
	       			RecordSet rs = new RecordSet();
	        		rs.executeSql("select t1.* from DocSecCategoryMould t1 right join DocMould t2 on t1.mouldId = t2.id where t1.secCategoryId = "+seccategory+" and t1.mouldType=1 order by t1.id");
	        		int selectMouldType = 0;
	        		int selectDefaultMould = 0;
	        		while(rs.next()){
	       				String moduleid=rs.getString("mouldId");
	       				String modulebind = rs.getString("mouldBind");
	       				int isDefault = Util.getIntValue(rs.getString("isDefault"),0);

	       				if(invalidationdate !=null && !"".equals(invalidationdate)){

	       					if(Util.getIntValue(modulebind,1)==3){
	       					    selectMouldType = 3;
	       					    selectDefaultMould = Util.getIntValue(moduleid);
	       				    } else if(Util.getIntValue(modulebind,1)==1&&isDefault==1){
	       				        if(selectMouldType==0){
	       					        selectMouldType = 1;
	       						    selectDefaultMould = Util.getIntValue(moduleid);
	       				        }
	       				    }

	       				} else {

	       					if(Util.getIntValue(modulebind,1)==2){
	       					    selectMouldType = 2;
	       					    selectDefaultMould = Util.getIntValue(moduleid);
	       				    } else if(Util.getIntValue(modulebind,1)==1&&isDefault==1){
	       				        selectMouldType = 1;
	       					    selectDefaultMould = Util.getIntValue(moduleid);
	       				    }
	       				}
	       			}

	       			if(HrmUserVarify.checkUserRight("DocEdit:Publish",user,docdepartmentid) && docstatus.equals("6") && (ishistory!=1) && docstatus.equals("6")){
	       			    if(Util.getIntValue(Util.null2String(selectedpubmould),0)<=0){
	       					if(selectMouldType>0){
	       					    docmouldid = selectDefaultMould;
	       					}
	       			    } else {
	       			        docmouldid = Util.getIntValue(selectedpubmould);
	       			    }
	       			} else {
	       			    if(Util.getIntValue(Util.null2String(selectedpubmould),0)<=0){
	       			    	if(selectedpubmouldid<=0){
	       			    	    if(selectMouldType>0)
	       			    	        docmouldid = selectDefaultMould;
	       			    	} else {
	       			    	    docmouldid = selectedpubmouldid;
	       			    	}
	       			    } else {
	       			        docmouldid = Util.getIntValue(selectedpubmould);
	       			    }
	       			}
	       		}

	        	MouldManager mouldManager = new MouldManager();
	        	if(docmouldid<=0)
	        	    docmouldid = mouldManager.getDefaultMouldId();
	        	mouldManager.setId(docmouldid);
	        	mouldManager.getMouldInfoById();
	        	String mouldtext = mouldManager.getMouldText();

	        	Hashtable<String,String> hr = new Hashtable<String,String>();
	        	SecCategoryComInfo scci = new SecCategoryComInfo();
	        	hr.put("DOC_SecCategory",Util.null2String(scci.getSecCategoryname(""+seccategory)));
	        	hr.put("DOC_Department",Util.null2String("<a href='/hrm/company/HrmDepartmentDsp.jsp?id="+docdepartmentid+"'>"+Util.toScreen(DepartmentComInfo.getDepartmentname(""+docdepartmentid),user.getLanguage())+"</a>"));
	        	hr.put("DOC_Content",Util.null2String(docContent));

	        	if(usertype.equals("2"))  {
	        	    hr.put("DOC_CreatedBy",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccreaterid),user.getLanguage())));
	        	    hr.put("DOC_CreatedByLink",Util.null2String("<a href='/CRM/data/ViewCustomer.jsp?CustomerID="+doccreaterid+"'>"+Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccreaterid),user.getLanguage())+"</a>"));
	        	    hr.put("DOC_CreatedByFull",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccreaterid),user.getLanguage())));
	        	}else {
	        	    hr.put("DOC_CreatedBy",Util.null2String(Util.toScreen(ResourceComInfo.getFirstname(""+doccreaterid),user.getLanguage())));
	        	    hr.put("DOC_CreatedByLink",Util.null2String("<a href='javaScript:openhrm("+doccreaterid+");' onclick='pointerXY(event);'>"+Util.toScreen(ResourceComInfo.getResourcename(""+doccreaterid),user.getLanguage())+"</a>"));
	        	    hr.put("DOC_CreatedByFull",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+doccreaterid),user.getLanguage())));
	        	}

	        	hr.put("DOC_CreatedDate",Util.null2String(doccreatedate));
	        	hr.put("DOC_DocId",Util.null2String(Util.add0(docid,12)));
	        	hr.put("DOC_ModifiedBy",Util.null2String(Util.toScreen(ResourceComInfo.getFirstname(""+doclastmoduserid),user.getLanguage())));
	        	hr.put("DOC_ModifiedDate",Util.null2String(doclastmoddate));
	        	hr.put("DOC_Language",Util.null2String(LanguageComInfo.getLanguagename(""+doclangurage)));
	        	hr.put("DOC_ParentId",Util.null2String(Util.add0(replydocid,12)));
	        	String docstatusname = DocComInfo.getStatusView(docid,user);
	        	hr.put("DOC_Status",Util.null2String(docstatusname));
	        	hr.put("DOC_Subject",Util.null2String(docsubject));
	        	String tmppublishtype="";
	        	if(docpublishtype.equals("2")) tmppublishtype=SystemEnv.getHtmlLabelName(227,user.getLanguage());
	        	else if(docpublishtype.equals("3")) tmppublishtype=SystemEnv.getHtmlLabelName(229,user.getLanguage());
	        	else tmppublishtype=SystemEnv.getHtmlLabelName(58,user.getLanguage());
	        	hr.put("DOC_Publish",Util.null2String(tmppublishtype));
	        	hr.put("DOC_ApproveDate",Util.null2String(docapprovedate));
	        	hr.put("DOC_NO", Util.null2String(docCode)) ;

	        	String doccontentbackgroud="";
	        	int strindex = docContent.indexOf("data-background=");
	        	if(strindex!=-1){
	        		strindex = docContent.indexOf("\"", docContent.indexOf("data-background="))+1;
	        		doccontentbackgroud=docContent.substring(strindex, docContent.indexOf("\"", strindex));
	        	}

	        	if("".equals(doccontentbackgroud)){
	        		int strindextemp=mouldtext.indexOf("data-background=");
	        		if(strindextemp!=-1){
	        			strindextemp=mouldtext.indexOf("\"", strindextemp)+1;
	        			doccontentbackgroud=mouldtext.substring(strindextemp, mouldtext.indexOf("\"", strindextemp));
	        		}
	        	}

	        	    mouldManager.closeStatement();
	        		mouldtext = Util.fillValuesToString(mouldtext,hr);

	        		docContent = mouldtext != null ? mouldtext : docContent;
	        }
	    }

    }
    	
	    // office文件:正文word、excel   或者是单附件打开
	    if(doctype == 2  || isOpenAcc || imagefileId > 0)
	    {
	        // 附件ID
	        String imageFileid = "";
	        // 模板ID
	        String mTemplate = "";
	        // 附件名称
	    	String imageFileName="";
	        // 附件类型
	    	String fileType="";
	        // 操作用户
	    	String mUserName = user.getLastname();
	        // 编辑状态
	        String editType = isEdit ? "-1,0,1,1,0,0,1" : "4";
	        String isofficeview = isEdit ? "0" : "1";
	        // 附件类型标识
	    	int docFileType = 0;
	        // 附件大小
	        int filesize = 0;
	        // 是否文件过大
	        boolean isToLarge = false;
	        String comefrom = "";

	        RecordSet rs = new RecordSet();
	        String sql = "";

			 if(imagefileId > 0){
	        	 sql = "select a.imagefileid,a.imagefilename,a.docfiletype,a.versionId,b.filesize,b.comefrom from DocImageFile a,Imagefile b " +
	        	 " where a.imagefileid=b.imagefileid and a.imagefileid="+imagefileId+
	        	 (versionId > 0 ? " and a.versionId=" + versionId : "")
	        	 +" order by versionId desc";
	        	 
	        	 if(isReplyAcc || docid <= 0){  //是回复里的文档、或者是
	        		 sql = "select b.imagefilename,b.filesize from Imagefile b where b.imagefileid=" + imagefileId;
	        	 }
	        	 
			     rs.executeSql(sql);
	        	if(rs.next()){
	        		imageFileName = Util.null2String(rs.getString("imagefilename"),"");
					comefrom = Util.null2s(rs.getString("comefrom"),"");
		            docFileType = Util.getIntValue(rs.getString("docfiletype"),0);
		            filesize = Util.getIntValue(rs.getString("filesize"),0);
	        	}
	        	 imageFileid = imagefileId + "";
	        	 imagefilename = imageFileName;
	        }else if(doctype == 2){  // office文件
		        sql = "select a.imagefileid,a.imagefilename,a.docfiletype,a.versionId,b.filesize,b.comefrom from DocImageFile a,Imagefile b " +
		        	" where a.imagefileid=b.imagefileid and a.docid="+docid+" and (a.isextfile <> '1' or a.isextfile is null) order by a.versionId desc";
		        rs.executeSql(sql);
		        if(rs.next())
		        {
		            imageFileid = Util.null2String(rs.getString("imagefileid"),"");
		            imageFileName = Util.null2String(rs.getString("imagefilename"),"");
					comefrom = Util.null2String(rs.getString("comefrom"),"");
		            docFileType = Util.getIntValue(rs.getString("docfiletype"),0);
		            versionId = Util.getIntValue(rs.getString("versionId"),0);
		            filesize = Util.getIntValue(rs.getString("versionId"),0);
		        }
	        }else if(isOpenAcc){  //单附件打开

	            imageFileid = OpenAccOfFileid;
	            imageFileName = OpenAccOfFilename;
	            docFileType = Util.getIntValue(OpenAccOfFiletype,0);
	            versionId = Util.getIntValue(OpenAccOfVersionid,0);
	            filesize = OpenAccOfFileSize;
	            comefrom = OpenAccOfcomefrom;
	        }

	        String extname = imageFileName.indexOf(".") > -1 ? imageFileName.substring(imageFileName.lastIndexOf(".")+ 1) : "";
	        extname = extname.toLowerCase();
			_extname = imagefilename;
			
	        //判断浏览器类型,版本,多少位
	        String agent = request.getHeader("user-agent");
	        boolean canIWebOffice = !(agent.contains("Firefox")||agent.contains(" Chrome")||agent.contains("Safari") || agent.contains("Edge"));
	        boolean isIE = canIWebOffice;
	        if(!canIWebOffice){
	    		canIWebOffice = IWebOfficeConf.canIwebOffice(agent,null);
	    	}
	        boolean IsUseDocPreviewForIE = "1".equals(rs.getPropValue("docpreview","IsUseDocPreviewForIE"));
           	boolean IsUseDocPreview = "1".equals(rs.getPropValue("docpreview","IsUseDocPreview"));  //是否开启预览
	        boolean useYozoView = false;
	        boolean useWpsView = false;
	        if(!canIWebOffice || agent.indexOf(" like Gecko") > -1){ //非IE或者ie11以上
	        	useYozoView = true;
	        }
	        if(useYozoView){
	        	useYozoView = ImageConvertUtil.canEditForYozo(extname,user);
	        	useWpsView = ImageConvertUtil.canEditForWps("doc",user);
	        }

	        if( isEdit && (!DocSptm.isOfficeDoc(_extname) || (!useYozoView && !canIWebOffice && !useWpsView))){
				%>
				<script>
					location.href = location.href.replace("&isEdit","").replace("?isEdit","?");
				</script>
				<%
				return;
			}
	        
	        boolean tifReadOnline = false;
	        if(extname.equals("tif") || extname.equals("tiff")){
	        	tifReadOnline = "1".equals(rs.getPropValue("docpreview","tifReadOnline"));
	        }
	        
	        ImageConvertUtil icu = new ImageConvertUtil();
	        if(extname.equals("jpg") || extname.equals("jpeg") || extname.equals("png") || extname.equals("gif") || extname.equals("bmp")){
				docContent = "<table style='width:100%;height:100%;background-color:#ffffff'><tr><td style='height:100%; vertical-align:middle; text-align:center;'><img style='vertical-align:middle;' src='/weaver/weaver.file.FileDownload?fileid=" + imageFileid +moudleParams+ "&nolog=1'/></td></tr></table>";
			}else if(extname.equals("pdf")){
				String pdfConvert = rs.getPropValue("doc_custom_for_weaver", "pdfConvert");
				boolean convertForClient = icu.convertForClient();
				boolean isUseIwebPdf = false;
				if(isIE){
					isUseIwebPdf = "1".equals(rs.getPropValue("weaver_iWebPDF", "isUseiWebPDF"));
				}
				
				if(isUseIwebPdf){  // iwebpdf
					String sessionParaPDF=""+docid+"_"+imagefileId+"_"+user.getUID()+"_"+user.getLogintype();
					session.setAttribute("canView_"+sessionParaPDF,canRead ? "1" : "0");
					session.setAttribute("canEdit_"+sessionParaPDF,canEdit ? "1" : "0");
					session.setAttribute("canPrint_"+sessionParaPDF,canPrint ? "1" : "0");
				
					docContent = "<iframe id=\"ofdshow\" src=\"/docs/e9/iwebpdf.jsp?docid="+docid +"&imagefileid="+imagefileId + moudleParams + "\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
				}else if("1".equals(pdfConvert) && convertForClient){	//移动端只判断pdfConvert,PC端需要同时判断单独转换服务器不为空时,pdf也会在单独服务器预览
					convertFile = "pdf";
					if(DocPlugUtil.isopenbjca()&&DocPlugUtil.isIE(request)){
						docContent = "<iframe id='pdfshow' src='/docs/pdfofca/pdfShow.jsp?docid="+docid+"&imagefileId="+imagefileId+"&isEdit="+isEdit+"' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
					}else{
						docContent = "<iframe id=\"officeShow\" src=\"/docs/pdfview/web/sysRemind.jsp?labelid=996\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
					}
				}else{
					if(DocPlugUtil.isopenbjca()&&DocPlugUtil.isIE(request)){
						docContent = "<iframe id='pdfshow' src='/docs/pdfofca/pdfShow.jsp?docid="+docid+"&imagefileId="+imagefileId+"&isEdit="+isEdit+"' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
					}else{
						docContent = "<iframe id=\"officeShow\" src=\"/docs/pdfview/web/pdfViewer.jsp?canPrint="+canPrint+"&docisLock="+docisLock+"&canDownload="+canDownload+"&pdfimagefileid="+imageFileid+moudleParams+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
					}
				}
            }else if(extname.equals("ofd") && canIWebOffice){
            	docContent = "<iframe id=\"ofdshow\" src=\"/docs/ofd/OfdShow.jsp?docid="+docid+"&imagefileId="+imagefileId+"&isEdit="+canEdit+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
            }else if(tifReadOnline || "WorkflowToDoc".equals(comefrom)){
            	docContent = "<iframe src=\"/weaver/weaver.file.FileDownload?fileid=" + imageFileid + moudleParams + "&nolog=1\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
            }else if(!isEdit && IsUseDocPreview && (isUsePDFViewer && !isIE || !canIWebOffice || IsUseDocPreviewForIE && isIE)){ //开启预览,非ie浏览器或者ie下开启预览
	            //是否是支持转换的文档
	           	boolean canConvert = ImageConvertUtil.canConvertType(extname);
	            
	           	if(extname.equals("zip") ||extname.equals("rar")){ //不开启单独转换,不支持压缩包
	           		if(!icu.convertForClient()){
	           			canConvert = false;
	           		}
	           	}
	           	
	           	// 采用转换PDF预览
	           	if(!IsUseDocPreview){  //未开启转换预览,且该浏览器不支持插件
		        	
		        	String sysremindurl="/wui/common/page/sysRemind.jsp?labelid=509650";
	            	if(levelMap.get(DocViewPermission.DOWNLOAD)){
	            		sysremindurl="/wui/common/page/sysRemind.jsp?labelid=129755";
	            	}
	            	docContent = "<iframe src=\""+sysremindurl+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
		        }else if(isUsePDFViewer && canConvert){
					
					isToLarge = icu.isTooLarge(extname,filesize + "");

					if(!isToLarge){
						convertFile = "pdf";
					}
					if(isToLarge){
	           			//文件过大
	           			docContent = "<iframe src=\"/docs/pdfview/web/sysRemind.jsp?labelid=999\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	           		}else{
						if(DocPlugUtil.isopenbjca()&&DocPlugUtil.isIE(request)&&extname.equals("pdf")){
							docContent = "<iframe id='pdfshow' src='/docs/pdfofca/pdfShow.jsp?docid="+docid+"&imagefileId="+imagefileId+"&isEdit="+isEdit+"' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
						}else{
							docContent = "<iframe id=\"officeShow\" src=\"/docs/pdfview/web/sysRemind.jsp?labelid=996\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
						}
	           		}
	            }
	           	// 采用转换html查看
	            else if(extname.equals("doc") ||
	            		extname.equals("docx") ||
	            		extname.equals("xls") ||
	            		extname.equals("xlsx"))
	            {

	            	convertFile = "html";
	                ///weaver/weaver.file.FileDownload?fileid="+htmlFileId+ moudleParams +"
	                docContent = "<iframe id=\"officeShow\" src=\"/docs/pdfview/web/sysRemind.jsp?labelid=996\" onload=\"hideLoading();displayRightMenu(this);\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            }else{
	            	//不支持的格式
	            	int requestid = Util.getIntValue(request.getParameter("requestid"),0);
	            	if(requestid > 0){
	            		moudleParams += "&fromrequest=1"; 
	            	}
	            	String sysremindurl="/wui/common/page/sysRemind.jsp?labelid=509650";
	            	if(levelMap.get(DocViewPermission.DOWNLOAD)){
	            		sysremindurl="/wui/common/page/sysRemind.jsp?labelid=129755";
	            	}
	            	docContent = "<iframe src=\""+sysremindurl+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            	//docContent = "<iframe src=\"/docs/pdfview/web/sysRemind.jsp?labelid=997\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            }
	        }
	        // IE 32 内核,直接加载控件
	        else
	        {
	            String mFileType = "";
	            if(docFileType == 3)
	            {
	                mFileType = ".doc";
	            }
	            else if(docFileType == 7)
	            {
	                mFileType = ".docx";
	            }
	            else if(docFileType == 4)
	            {
	                mFileType = ".xls";
	            }
	            else if(docFileType == 8)
	            {
	                mFileType = ".xlsx";
	            }else if(extname.equals("wps") || extname.equals("ppt") || extname.equals("pptx") || extname.equals("et")){
	            	mFileType = "." + extname;
	            }else if(extname.equals("uot")){
	            	mFileType = ".doc";
	            }
	            if((useYozoView || useWpsView) &&
	            		(mFileType.equals(".doc") || 
	        				mFileType.equals(".docx") || 
	        				mFileType.equals(".xls") || 
	        				mFileType.equals(".xlsx") || 
	        				mFileType.equals(".ppt") ||
	        				mFileType.equals(".pptx"))){
	            	if(useWpsView){
	            		openWpsView = true;
		            	docContent = "<iframe id=\"webOffice\" src=\"/docs/e9/weboffice_wps.jsp?fileid="+imageFileid+"&isEdit=1&mFileType="+mFileType+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            	}else{
		            	docContent = "<iframe id=\"webOffice\" src=\"/spa/document/weboffice.jsp?fileid="+imageFileid+"&isEdit=1&mFileType="+mFileType+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            	}
	            }else if(!mFileType.isEmpty() && canIWebOffice){
	                if(docisLock){
	                    editType = "0";
					}
	                
	                
	                int maxFileSize = 0;
		            rs.executeQuery("select a.maxofficedocfilesize from DocSecCategory a,DocDetail b where a.id=b.seccategory and b.id=?",docid);
		            if(rs.next()){
		            	maxFileSize = rs.getInt("maxofficedocfilesize");
		            }
	                
					docContent = "<iframe id=\"webOffice\" src=\"/spa/document/office.jsp?isofficeview"+ isofficeview +"&mRecordID="+versionId +"_"+docid+"&maxFileSize="+maxFileSize+"&mTemplate=" + mTemplate +"&canPrint="+canPrint+"&mFileName=" + URLEncoder.encode(imageFileName,"utf-8") +"&mFileType=" + mFileType +"&mEditType=" + editType + "\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            }else{
	            	//不支持的格式
	            	String sysremindurl="/wui/common/page/sysRemind.jsp?labelid=509650";
	            	if(levelMap.get(DocViewPermission.DOWNLOAD)){
	            		sysremindurl="/wui/common/page/sysRemind.jsp?labelid=129755";
	            	}
	            	docContent = "<iframe src=\""+sysremindurl+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            	//docContent = "<iframe src=\"/docs/pdfview/web/sysRemind.jsp?labelid=997\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            } 
	       }
	    }

	    RecordSet rs = new RecordSet();
	    rs.executeQuery("select 1 from DocImageFile where docid="+docid+" and id in(select id from DocImageFile where docid="+docid+" and versionId="+versionId+" and isextfile=1) ");
		int versionCounts=rs.getCounts();
		
    	String versionSpan = "";
    	if(versionCounts > 1){
    		int versionNum = DocDsp.getVersionCounts(docid,versionId);
    		//versionSpan = "<span style='margin-left:3px'>(<span class='wea-new-top-req-title-version'>V" + versionNum + "</span>)</span>";
    	}
    	
	    Date d4 = new Date();
	    time3 = d4.getTime()-d1.getTime();
	    
		if(_convertFile != null && !_convertFile.isEmpty()){
			if("jpg".equals(_convertFile) || "pdf".equals(_convertFile) || "html".equals(_convertFile)){
				convertFile = _convertFile;
			}
		}
%>
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">-->
<html>

	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit"/>
		<meta name="force-rendering" content="webkit"/>
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
		<meta name="description" content="">
		<meta name="author" content="">
		<script>
			var __href = location.href;
			if(__href.indexOf("#/main/document/fileView") == -1){
				//alert(location.href);
				
				if(__href.indexOf("#/") == -1){
					location.href = __href.replace("&router=1","");
				}else{
					__href = __href.replace("&router=1","");
					location.href = __href.substring(0,__href.indexOf("#/"));
				}
				
			}
		</script>
		<title><%= imagefileId > 0 ? imagefilename : docsubject %></title>
		<link rel="stylesheet" type="text/css" href="/cloudstore/resource/pc/com/v1/index.min.css?v=20170904">
		<link rel="stylesheet" type="text/css" href="/cloudstore/resource/pc/com/v1/ecCom.min.css?v=20170904">
		<link rel="stylesheet" type="text/css" href="/spa/document/static4Detail/index.css?v=20170811">
		<script type="text/javascript" src="/cloudstore/resource/pc/jquery/jquery-1.8.3.min.js"></script>
		<style type="text/css">
			body{margin: 0;overflow: hidden;}
			table#content{display:table !important;}
			.wea-new-top-req-title-version{
				color:#30B5FF;
				cursor:pointer;
			}
			.wea-new-top-req-title-label{
				color:gray;
			}
			.wea-new-top-req-wapper .wea-new-top-req-content{
				background-color:inherit;
			}
			.wea-doc-detail-content-main img{
				max-width:1024px;
			}
		</style>
	</head>
		<body>
		<div id="container" style="height:100%;">
		
		</div>
		<script type="text/javascript">
			window.pre_title = $('.wea-new-top-req-title-text').html();
			window.pre_subtitle = $('.wea-new-top-req-title-text-sub').html();
			window.pre_docDetail = $('.wea-doc-detail-content-main').html();
			//console.log('docContent: ', window.pre_docDetail)
			window.__time1 = "<%=SystemEnv.getHtmlLabelName(500850, user.getLanguage())%> <%=time1%>";// 获取属性耗时:
			window.__time2 = "<%=SystemEnv.getHtmlLabelName(500851, user.getLanguage())%> <%=time2%>";//获取正文耗时:
			window.__time3 = "<%=SystemEnv.getHtmlLabelName(500852, user.getLanguage())%> <%=time3%>";//业务逻辑总耗时:
			window.__extname = "<%=_extname%>";
			
			window.__moudleParams = "<%=moudleParams %>";
			window.__imagefilename = "<%=imagefilename%>";
			
			if("<%=convertFile%>" != ""){
				window.__convertFile = "convertFile=<%=convertFile%>&converSelf=<%=_convertFile%>&fileid=<%=imagefileId%>&docid=<%=docid%>&versionId=<%=versionId%>";		//是否需要异步转换文档
			}
            if(<%=docisLock%>){
                var ifmObj = window.document.body;
                ifmObj.style.cssText += ';-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;unselectable:on;';
                ifmObj.onselectstart = function(){return false};
            }
			<%if(isEdit){%>
				/**调用子层office保存*/
				function saveDocument(){
					try{
						var obj = document.getElementById("webOffice").contentWindow.toSaveDocument();
						
						if(obj.off_status == 0){
							obj.msg = obj.off_msg ? obj.off_msg : "<%=SystemEnv.getHtmlLabelName(84544, user.getLanguage())%>";// 保存失败!
						}
						
						return obj;
					}catch(e){
						return {off_status : 0};
					}
				}
				
				window.__useWpsView = <%=openWpsView%>;
				function sendSaveMsg(btnkey){
					window.__savekey = btnkey;
					document.getElementById("webOffice").contentWindow.sendSaveMsg();
				}
				function acceptSaveMsg(){
					window.__wpsSaved = true;
					window.__onRightMenuClick(window.__savekey ? window.__savekey : "BTN_SUBMIT");
					window.__wpsSaved = false;
				}
				
				/**子层office调用保存事件是,保存office*/
				function __saveDocument(){
					var obj = document.getElementById("webOffice").contentWindow.SaveDocument();
				}
				/**调用子层office保存草稿*/
				function saveDocumentAsDraft(){
					return saveDocument();
				}
				/**子层office调用保存草稿事件是,保存office*/
				function __saveDocumentAsDraft(){
					
				}
				function changeOfficeFile(fileid){
					try{
						var _src = document.getElementById("webOffice").src;
						_src = _src.replace(/&fileid=-?\d*/g,"&fileid=" + fileid);
						_src = _src.replace(/\?fileid=-?\d*/g,"?fileid=" + fileid);
						document.getElementById("webOffice").src = _src;
					}catch(e){}
				}
			<%}%>
			
			
			function refreshSign(sign){
				jQuery.ajax({
					url : "/api/doc/acc/getWpsSign",
					type : "get",
					data : {sign : sign},
					dataType : "json",
					success : function(data){
						if(data && data.status == 1){
							var pdata = {};
							for(var k in data.params){
								pdata[k] = data.params[k];
							}	
            				//document.getElementById("officeShow").contentWindow.postMessage("logic.setToken",pdata);
            				
            				var sendData = JSON.stringify({"action":"logic.setToken", data:pdata});
            				document.getElementById("officeShow").contentWindow.postMessage(sendData, '*');
            				
            				setTimeout(function(){
            					refreshSign(data.sign);
            				},data.timeout);
						}else{
							refreshSign(sign);
						}
					},
					error : function(){
						refreshSign(sign);
					}
					
				})
			}
			//异步加载完附件之后
			function afterConvertFile (data){
				if(!data)
					return;
				var _src = "";
				if(data.convert == "client"){
					if(data.result == "0"){
						if(data.data[0].path){
							_src = data.data[0].path;
							var _expIndex = _src.indexOf("?");
							if(_expIndex > -1 && _src.indexOf("&appid=") > -1){ //wps预览
								var _expires = _src.substring(_expIndex+1);
								_expires = decodeURIComponent(_expires).replace(/&/g,"^_^");
								setTimeout(function(){
		            				refreshSign(_expires);
		            			},10*1000);
							}
						}else{
							if("<%=convertFile%>" == "pdf"){
                                if(<%=DocPlugUtil.isopenbjca()&&DocPlugUtil.isIE(request)%>){
                                    _src = "/docs/pdfofca/pdfShow.jsp?docid=<%=docid%>&imagefileId=<%=imagefileId%>&isEdit=<%=isEdit%>";
                                }else{
                                    _src = "/docs/pdfview/web/pdfViewer.jsp?canPrint=<%=canPrint%>&docisLock=<%=docisLock%>&canDownload=<%=canDownload%><%=moudleParams%>&pdfimagefileid="+data.data[0].id;
                                }
							}else if("<%=convertFile%>" == "html"){
								_src = "/weaver/weaver.file.FileDownload?fileid="+data.data[0].id+ "<%=moudleParams%>&nolog=1" ;
							}
						}
					}else{
						_src = "/wui/common/page/sysRemindDocpreview.jsp?labelid=" + data.message;
					}
				}else{
					if(data.status == "1"){
						if("<%=convertFile%>" == "pdf"){
                            if(<%=DocPlugUtil.isopenbjca()&&DocPlugUtil.isIE(request)%>){
                                _src = "/docs/pdfofca/pdfShow.jsp?docid=<%=docid%>&imagefileId=<%=imagefileId%>&isEdit=<%=isEdit%>";
                            }else{
                                _src = "/docs/pdfview/web/pdfViewer.jsp?canPrint=<%=canPrint%>&docisLock=<%=docisLock%>&canDownload=<%=canDownload%><%=moudleParams%>&pdfimagefileid="+data.convertId;
                            }
						}else if("<%=convertFile%>" == "html"){
							_src = "/weaver/weaver.file.FileDownload?fileid="+data.convertId+ "<%=moudleParams%>&nolog=1" ;
						}
					} if(data.status == "-1"){
						_src = "/docs/pdfview/web/sysRemind.jsp?labelid=998";
					}else if(data.status == "-2"){
						_src = "/wui/common/page/sysRemindDocpreview.jsp?labelid=" + data.msg;
					}	
				}
				if(_src != ""){
					document.getElementById("officeShow").src = _src;
				}
                if(<%=docisLock%>){
                    var ifmObj = document.getElementById("officeShow");
                    ifmObj.style.cssText += ';-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;unselectable:on;';
                    ifmObj.onselectstart = function(){return false};
                    setIframeBodyLock();
                }
			}

            function setIframeBodyLock(){
                window.setTimeout(function(){
                    try{
                        var  osframe = document.getElementById("webOffice");
                        if(!osframe || osframe.length == 0){
                            osframe = document.getElementById("officeShow");
                        }
                        if(!osframe || osframe.length == 0){
                            osframe = document.getElementById("previewDoc").contentWindow.document.getElementById("officeShow");
                        }
                        if(osframe) {
                            var osframebody = osframe.contentWindow.document.body;
                            if(osframebody){
                                osframebody.style.cssText += ';-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;unselectable:on;';
                                osframebody.onselectstart = function () {
                                    return false
                                };
                            } else {
                                setIframeBodyLock();
                            }
                        }
                    }catch(e){}
                },1000);
            }
      //window.__preTitle = $('.wea-new-top-req-title-text').html();
	  window.__preTitleObj = {
		  prevname: '<%=prevname%>',
		  title: "<%= imagefileId > 0 ? imagefilename: docsubject%>",
		  versionname: "<%=versionSpan %>"
	  };
      window.__preContent = '<%= docContent.replace("'","\\'") %>';
		</script>
		<script type="text/javascript">
            try{
                document.body.style.overflow="hidden";
            }catch(e){}
            function hideLoading(){
                try{
                    var $body = document.getElementById("officeShow").contentWindow.document.body;
                    top.window.__html = $body;
                    replaceSpace($body);
                }catch(e){

                }
                try{
                    parent.finalDo("view");
                }catch(e){
                    window.setTimeout(function(){
                        try{
                            parent.finalDo("view");
                        }catch(e){}
                    },1000);
                }
            }

            function replaceSpace(obj){
                if(obj && !obj.tagName){
                    obj.nodeValue = obj.nodeValue.replace(/&nbsp;/g,"");
                }
                if(obj && obj.childNodes && obj.childNodes.length > 0){
                    for(var i = 0;i < obj.childNodes.length;i++){
                        replaceSpace(obj.childNodes[i]);
                    }
                }
            }
		</script>
    <script type="text/javascript" src="/cloudstore/resource/pc/polyfill/polyfill.min.js"></script>
		<!--[if lt IE 10]>
    <script type="text/javascript" src="/cloudstore/resource/pc/shim/shim.min.js"></script>
    <![endif]-->
    <script type="text/javascript">
      jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 9 && (
        window.location.href = '/login/Login.jsp'
      );
    </script>
    <!-- 底层库 -->
    <!-- <script type="text/javascript" src="/cloudstore/resource/pc/react16/react.development.js"></script>
    <script type="text/javascript" src="/cloudstore/resource/pc/react16/react-dom.development.js"></script> -->
    <script type="text/javascript" src="/cloudstore/resource/pc/react16/react.production.min.js"></script>
    <script type="text/javascript" src="/cloudstore/resource/pc/react16/react-dom.production.min.js"></script>
    <script type="text/javascript" src="/cloudstore/resource/pc/react16/prop-types.min.js"></script>
    <script type="text/javascript" src="/cloudstore/resource/pc/react16/create-react-class.min.js"></script>
    <script>
      //console.log(createReactClass);
      React.PropTypes = PropTypes;
      React.createClass = createReactClass;
    </script>
		<!-- <script type="text/javascript" src="/cloudstore/resource/pc/react/react-with-addons.min.js"></script>
		<script type="text/javascript" src="/cloudstore/resource/pc/react/react-dom.min.js"></script> -->
		<!-- 组件库 -->
		<script type="text/javascript" src="/cloudstore/resource/pc/promise/promise.min.js"></script>
		<script type="text/javascript" src="/cloudstore/resource/pc/fetch/fetch.min.js"></script>
		<script type="text/javascript" src="/cloudstore/resource/pc/ckeditor-4.6.2/ckeditor.js"></script>
		<script type="text/javascript" src="/cloudstore/resource/pc/plupload-2.3.1/js/plupload.full.min.js?v=20170809"></script>
		<script type="text/javascript" src="/spa/moduleConfig.js?v=1560540617484"></script>
		<script type="text/javascript" src="/spa/coms/ssoConfig/config.js?v=1560540617484"></script>
		<script type="text/javascript" src="/cloudstore/resource/pc/com/v1/index.min.js?v=20170904"></script>
		<script type="text/javascript" src="/cloudstore/resource/pc/com/v1/ecCom.min.js?v=20170904"></script>
		<!-- mobx -->
		<script type="text/javascript" src="/cloudstore/resource/pc/mobx-3.1.16/mobx.umd.js"></script>
    	<script type="text/javascript" src="/cloudstore/resource/pc/mobx-react-4.2.1/index.js"></script>
    	<script type="text/javascript" src="/cloudstore/resource/pc/react-router/ReactRouter.min.js"></script>
		<script type="text/javascript" src="/spa/coms/index.mobx.js?v=20180320"></script>
		<!-- 二维码之前在门户 -->
		<script type="text/javascript" src="/wui/theme/ecology9/js/lib.js?v=20170705"></script>
		<!-- spa -->
		<script type="text/javascript" src="/spa/document/static4Detail/index.js?v=20170811"></script>
		<script type="text/javascript" src="/spa/document/static4Detail/index4single.js?v=20170811"></script>
	</body>

</html>