index.jsp 83.6 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 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904
<%@ 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.regex.Matcher,java.util.regex.Pattern" %>
<%@ 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="weaver.docs.category.security.MultiAclManager"%>
<%@ page import="java.util.Date"%>
<%@ page import="com.api.doc.search.util.DocSptm"%>
<%@page import="com.api.doc.category.service.CategoryService"%>
<%@page import="com.api.doc.detail.service.DocSaveService"%>
<%@ page import="com.api.doc.detail.util.ImageConvertUtil"%>
<%@page import="com.engine.doc.util.IWebOfficeConf"%>
<%@page import="com.engine.hrm.biz.HrmClassifiedProtectionBiz"%>
<%@ page import="com.engine.doc.util.DocPlugUtil" %>
<%@ page import="com.api.doc.detail.util.DocDetailUtil" %>
<%@ page import="org.apache.xpath.operations.Bool" %>
<%@ page import="weaver.docs.category.DocTreeDocFieldComInfo" %>
<%@ page import="com.api.doc.detail.bean.DocParam" %>
<%@ page import="weaver.cpt.capital.CapitalComInfo" %>
<%@ page import="weaver.crm.Maint.CustomerInfoComInfo" %>
<%@ page import="weaver.proj.Maint.ProjectInfoComInfo" %>
<%@ page import="weaver.docs.docs.DocComInfo" %>
<%@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="DocMouldComInfo" class="weaver.docs.mouldfile.DocMouldComInfo" scope="page" />


<%
	response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    User user = null;
    if("1".equals(request.getParameter("outNews"))){
    	user = new User();
    }else{
    	user = HrmUserVarify.getUser (request , response);
		if(user==null){
			response.sendRedirect("/wui/index.html");
			return ;
		}
    }
   	int languageid = user == null ? DocSptm.getDefaultLanguage() : user.getLanguage();
    
    long time0 = 0;
    long time1 = 0;
    long time2 = 0;
    long time3 = 0;
    
	Date d0 = new Date();

    // 文档ID
    int docid = Util.getIntValue(request.getParameter("id"),-1);
    int secid = Util.getIntValue(request.getParameter("secid"),-1);	//目录id
    boolean isEdit = "1".equals(request.getParameter("isEdit"));	//是否是新建或者编辑
    boolean isEditOffice = "1".equals(request.getParameter("isOffice")); //是否是 office
    boolean isCAPDF = "1".equals(request.getParameter("isCAPDF")); //是否使用北京capdf插件
    String officeType = request.getParameter("officeType"); //新建office类型
    
    int imagefileId = Util.getIntValue(request.getParameter("imagefileId"),-1);
    int versionId = Util.getIntValue(request.getParameter("versionId"),-1);
	Boolean docisLock = DocDetailUtil.isopendoclock(docid+"","doc");

    
    String _convertFile = Util.null2String(request.getParameter("convertFile"));
    BaseBean baseBean = new BaseBean();
	String backgroundColor = "";

    
    String checkOutStatus = "";
    int checkOutUserId = -1;
    String checkOutUserType = "";
    
    /*** 其他模块跳转过来的时候,不带路由,这里统一加上 ***/
    String router = request.getParameter(DocSptm.DOC_ROOT_FLAG);
    if(router == null){
	  %>
	 <script>
	 	var _href = location.href;
	 	if(_href.indexOf("#/main/document/detail") == -1 && _href.indexOf("#/main/document/edit") == -1){
	 		location.href = _href + "&<%=DocSptm.DOC_ROOT_FLAG%>=1" + "#/main/document/" + "<%=isEdit ? "edit" : "detail"%>";
	 	}else{
	 		location.href = _href.replace("#/main/document/detail","&<%=DocSptm.DOC_ROOT_FLAG%>=1#/main/document/detail")
	 							.replace("#/main/document/edit","&<%=DocSptm.DOC_ROOT_FLAG%>=1#/main/document/edit");
	 	}
	 </script>
	  
	  <%
	  return;
    }
    
    //流程新建完成,关闭当前页面
    String blnOsp = request.getParameter("blnOsp");
    String moudleFrom = request.getParameter("moudleFrom");
    if(!isEdit && !"1".equals(blnOsp) && 
    		("workflow".equals(moudleFrom) || "cube".equals(moudleFrom) || "task".equals(moudleFrom))){
    	RecordSet rs = new RecordSet();
    	rs.executeQuery("select docsubject,docstatus from docdetail where id=" + docid);
    	String docsubject = "";
    	String docstatus = "";
    	if(rs.next()){
    		docsubject = rs.getString("docsubject").replaceAll("'","\'").replaceAll("\n", "");
    		docstatus = rs.getString("docstatus");
    	}

    	/*if("1".equals(docstatus)){*/
	    	%>
	    		<script>
		    		try{
		    			if(opener && opener.__createDocFn){
							opener.__createDocFn({docid : "<%=docid%>",docSubject : "<%=docsubject%>"});
			   	  		}
		    		}catch(e){
					}finally{
                        window.close();
					}
	    		</script>
	    	<%
	    	return;
    	/*}*/
    }
    // 附件版本ID
    if(docid < 0 && imagefileId < 0 && !isEdit)
    {
        response.sendRedirect("/notice/noright.jsp?line=1") ;
        return ;
    }
    
    if(docid > 0 && imagefileId >0){  
    	RecordSet rs = new RecordSet();
    	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?line=0") ;
    		return;
    	}
    }
    
    if(docid <= 0 && imagefileId > 0){
    	RecordSet rs = new RecordSet();
    	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){
    		response.sendRedirect("/notice/noright.jsp?line=2") ;
    	    return ;
    	}
    }
    
    Map<String,String> rightParams = new HashMap<String,String>(); 
    rightParams.put("useNew","1");
    
    boolean canEdit = false;
    DocViewPermission dvps = new DocViewPermission();
    
  	//其他模块参数集
    String moudleParams = dvps.getMoudleParams(request);
  	
    if(docid > 0){ //密级判断
    	if(!dvps.hasRightForSecret(user,docid)){
    		response.sendRedirect("/notice/noright.jsp?secretNotEnough=1") ;
    		return;
    	}
    }
  	
    Map<String,Boolean> levelMap = dvps.getShareLevel(docid,user,false);
    if(!levelMap.get(DocViewPermission.READ)){ //知识没有权限,判断是否是其他模板
    	levelMap.put(DocViewPermission.READ,dvps.hasRightFromOtherMould(docid,user,request));
    }
    if(!levelMap.get(DocViewPermission.EDIT)){ //知识没有权限,判断是否是其他模块
    	dvps.hasEditRightFromOtherMould(docid,levelMap,user,request);
    }
    canEdit = levelMap.get(DocViewPermission.EDIT);
    
  	//判断浏览器类型,版本,多少位
    String agent = request.getHeader("user-agent");
    //如果非IE
    boolean canIWebOffice = true;
    boolean isIE = true;
    if((agent.contains("Firefox")||agent.contains(" Chrome")||agent.contains("Safari") )|| agent.contains("Edge")){
    	canIWebOffice = false;
    	isIE = false;
    }
    
    boolean useYozoView = false;
    boolean useWpsView = false;
    if(!canIWebOffice || agent.indexOf(" like Gecko") > -1){ //非IE或者ie11以上
    	useYozoView = true;
    }
    if(useYozoView){
    	useYozoView = ImageConvertUtil.canEditForYozo("doc",user);
    	useWpsView = ImageConvertUtil.canEditForWps("doc",user);
    }
    
    boolean openWpsView = false;
  
    //是否开启PDF转换
    boolean isUsePDFViewer = ConvertPDFUtil.isUsePDFViewer();
    
    //文件类型
    int docfileType = -1;
    //OFD页面跳转地址
    String ofdContent = "";
	//new BaseBean().writeLog("docid=======================================" + docid);
    if(docid>0 && imagefileId>0){
    	RecordSet rs = new RecordSet();
    	rs.executeQuery("select docfiletype,versionId from docimagefile where docid=? and imagefileid=?",docid,imagefileId);
    	if(rs.next()){
    		docfileType = Util.getIntValue(rs.getString(1), -1);
    		versionId = versionId<=0 ? Util.getIntValue(rs.getString(2), -1) : versionId;
    	}
    }else if(docid>0){
    	RecordSet rs = new RecordSet();
    	rs.executeQuery("select imagefileid,docfiletype from docimagefile where docid=? and docfiletype = 13",docid);
    	if(rs.next()){
    		docfileType = rs.getInt("docfiletype");
			imagefileId = rs.getInt("imagefileid");
    	}
		
	}
	if(!canIWebOffice){
		//canIWebOffice = IWebOfficeConf.canIwebOffice();
		canIWebOffice = IWebOfficeConf.canIwebOffice(agent,null);
	}
    if(docfileType == 13){
        if(!canIWebOffice)
		{
			ofdContent = "<iframe src=\"/docs/ofd/sysRemind.jsp?labelid=666\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
		}else {
			Boolean editCan=levelMap.get(DocViewPermission.EDIT);
			if (!editCan){
				RecordSet rs = new RecordSet();
				RecordSet rss = new RecordSet();
				rs.executeQuery("select d.docstatus from DocDetail d " +
						" where d.id=" + docid);
				String docstatus = "-1";
				if(rs.next()){
					docstatus = Util.null2String(rs.getString("docstatus"));

				}
				if ("9".equals(docstatus)){
					editCan=true;
				}
			}
			String requestid = Util.null2String(request.getParameter("requestid"));
			ofdContent = "<iframe id=\"ofdshow\" src=\"/docs/ofd/OfdShow.jsp?docid="+docid+"&imagefileId="+imagefileId+"&isEdit="+editCan+"&requestId="+ requestid +"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
		}

	}
    
    if(isEdit){
    	
    	
    	if(docid > 0){  //编辑
	    	RecordSet rs = new RecordSet();
    		rs.executeQuery("select doctype,docextendname,checkOutStatus,checkOutUserId,checkOutUserType from DocDetail where id=" + docid);
        	if(rs.next()){
        		String doctype = rs.getString("doctype");
       			String docextendname = "." + rs.getString("docextendname");
       			checkOutStatus = rs.getString("checkOutStatus");
    			checkOutUserId = rs.getInt("checkOutUserId");
    			checkOutUserType = rs.getString("checkOutUserType");
    			if(checkOutStatus!=null&&(checkOutStatus.equals("1")||checkOutStatus.equals("2"))&&!(checkOutUserId==user.getUID()&&checkOutUserType!=	null&&checkOutUserType.equals(user.getLogintype()))){
    				//签出状态的文档,跳转详情页
    				response.sendRedirect(DocSptm.DOC_DETAIL_LINK + "?id=" + docid + "&warmMessageStatus=checkout" + moudleParams + DocSptm.DOC_ROOT_FLAG_VALUE + DocSptm.DOC_DETAIL_ROUT) ;
    				return;
    			}
				RecordSet rs1 = new RecordSet();
				rs1.executeQuery("select imagefileid,docfiletype from docimagefile where docid=? and docfiletype = 12 ",docid);
				String docfiletype = "";
				String imagefileid = "";
				if(rs1.next()){
				    docfiletype = rs1.getString("docfiletype");
				    imagefileid = rs1.getString("imagefileid");
				}
        		if("2".equals(doctype) && !".pdf".equals(officeType)){
        			if(!canIWebOffice && !useYozoView && !useWpsView){
        				response.sendRedirect(DocSptm.DOC_DETAIL_LINK + "?id=" + docid + moudleParams + DocSptm.DOC_ROOT_FLAG_VALUE + DocSptm.DOC_DETAIL_ROUT) ;
        				return;
        			}else if(!isEditOffice || !docextendname.equals(officeType)){
    	    			response.sendRedirect(DocSptm.DOC_EDIT_LINK + "?id=" + docid + "&isOffice=1&isEdit=1&officeType=" + docextendname + moudleParams + DocSptm.DOC_ROOT_FLAG_VALUE + DocSptm.DOC_EDIT_ROUT) ;
    	    			return;
        			}
        		}else if("12".equals(docfiletype) && DocPlugUtil.isopenbjca() && DocPlugUtil.isIE(request)){
				    if(!isEditOffice || !docextendname.equals(officeType) || !isCAPDF){
						response.sendRedirect(DocSptm.DOC_EDIT_LINK + "?id=" + docid + "&isCAPDF=1&isOffice=1&isEdit=1&officeType=" + docextendname + moudleParams + DocSptm.DOC_ROOT_FLAG_VALUE + DocSptm.DOC_EDIT_ROUT) ;
						return;
					}
				} else{
					isCAPDF = false;
        			isEditOffice = false;
        		}

        	}


    		canEdit = levelMap.get(DocViewPermission.EDIT);
    	}else if(secid > 0){//新增
    		MultiAclManager am = new MultiAclManager();
    		canEdit = am.hasPermission(secid, MultiAclManager.CATEGORYTYPE_SEC, user.getUID(), user.getType(), 
    				Integer.parseInt(user.getSeclevel()), MultiAclManager.OPERATION_CREATEDOC);
    	}else{
    		canEdit = true;
    	}
    	String requestDoc = Util.null2String(request.getParameter("requestDoc"));

		if(requestDoc.equals("1")){
			canEdit = true;
		}
	    if(!canEdit){
	    	response.sendRedirect("/notice/noright.jsp?line=3") ;
	    	return ;
	    }
	    //增加到常用目录
	    CategoryService categoryService = new CategoryService();
	    categoryService.addCommonUse(secid,user);
    }
    
    boolean canRead = false;
    /**判断文档查看权限*/
    if(!isEdit && docid > 0){
    	canRead = levelMap.get(DocViewPermission.READ);
    }
    
    
    if(!isEdit && !canRead){   //没有权限
    	RecordSet rs = new RecordSet();
    	rs.executeQuery("select ishistory,doceditionid from DocDetail where id=" + docid);
    	int ishistory = 0;
    	int doceditionid = 0;
    	if(rs.next()){
    		ishistory = rs.getInt("ishistory");
    		doceditionid = rs.getInt("doceditionid");
    	}
    	if(ishistory != 1){  //不是历史文档
	    	response.sendRedirect("/notice/noright.jsp?line=4") ;
    	}else{
    		int newestid = 0;
    		
    		rs.executeQuery("select id from DocDetail where doceditionid = " + doceditionid + " and ishistory=0 and id<>"+docid+"  order by docedition desc ");
    		if(rs.next()){
    			newestid = rs.getInt("id");
    		}
    		
    		if(newestid <= 0 || newestid == docid){
    			response.sendRedirect("/notice/noright.jsp?line=5") ;
    	    	return ;
    		}
    		
    		String linkNewestDoc = DocSptm.DOC_DETAIL_LINK + "?id=" + newestid + moudleParams + DocSptm.DOC_ROOT_FLAG_VALUE+DocSptm.DOC_DETAIL_ROUT;
    		%>
    		<html>
    		<head>
    		<script language=javascript>
    			if(confirm("<%=SystemEnv.getHtmlLabelName(20300,languageid)%><%=SystemEnv.getHtmlLabelName(19986,languageid)%>")) {
					location="<%=linkNewestDoc%>";
		        }else{
					location="/notice/noright.jsp??line=6";
				}
    		</script>
    		</head>
    		<body></body>
    		</html>
    		<%
    	}
    	return;
	}


	if(docisLock && levelMap.get(DocViewPermission.EDIT)){
		docisLock = false;
	}
    
    Date d1 = new Date();
    time0 = d1.getTime() - d0.getTime();
    
    
    // 标题
    String docsubject = "";
    //最后修改人id
    int doclastmoduserid = 0;
    //批准人id
	int docapproveuserid = 0;
	//归档人id
	int docarchiveuserid = 0;
	//作废人id
	int doccanceluserid = 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 doceditionid = -1;
    //最新版本id
    int newestid = -1;
    //新闻模板
    int selectedpubmouldid = -1; 
    //创建人
    int doccreaterid = -1;
    //所有者
	int ownerid = -1;
    //创建人类型
    String usertype = "";
    //创建日期
    String doccreatedate = "";
    // 文档语言
    int doclangurage = 7;
    //文档编号
    String docCode = "";
    //回复文档id
    int replydocid = 0;
    //审批日期
    String docapprovedate = "";
    //发布类型
    String docpublishtype = "";
    //关键字
	String keyword = "";
	//摘要
	String docMain = "";
	//主文档
	int maindoc = 0;
	//密级
	String secretLevel = "";
	//失效日期
//	String docinvaldate = "";
	//虚拟目录
	String dummyIds = "";
	//关联列表
	String childDoc_value = "";
	//人力资源
	int hrmresid = 0;
	//资产id
	int assetid = 0;
	//crmid
	int crmid = 0;
	//项目id
	int projectid = 0;

    String prevname = SystemEnv.getHtmlLabelName(156,languageid);
    String imagefilename = "";
    
    boolean isOpenAcc = false; // 是否单附件打开
    String OpenAccOfFileid = "";   //单附件打开的附件id
    String OpenAccOfFilename = "";   //单附件打开的附件名称
    String OpenAccOfFiletype = "";   //单附件打开的附件类型
    String OpenAccOfVersionid = "";   //单附件打开的附件版本
    int OpenAccOfFileSize = 0;  //单附件打开的附件大小
    boolean isAutoExtendInfo = false;  //有附件时展开文档附件属性
	String OpenAccOfcomefrom = "";   //单附件打开的附件来源
	boolean showByHtml = false;  //是否是html模式展示
	String convertFile = "";  //转换文件  空-不转换,html-转成html,pdf-转成pdf
    
    
	boolean canPrint = dvps.getPrint(docid,user,levelMap,null);
	boolean canDownload = levelMap.get(DocViewPermission.DOWNLOAD);
	String moudlePictureIds = "";
    //选择显示模版的ID
    String selectedpubmould = Util.null2String(request.getParameter("selectedpubmould"));
    if(isEdit){
    	
    }else 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("doceditionid");
	    columns.add("selectedpubmouldid");
	    columns.add("doccreaterid");
	    columns.add("ownerid");
	    columns.add("usertype");
	    columns.add("doccreatedate");
	    columns.add("doclangurage");
	    columns.add("docCode");
	    columns.add("replydocid");
	    columns.add("docapprovedate");
	    columns.add("docpublishtype");
	    columns.add("checkOutStatus");
	    columns.add("checkOutUserId");
	    columns.add("checkOutUserType");
		columns.add("keyword");
		columns.add("secretLevel");
		columns.add("docapproveuserid");
		columns.add("docarchiveuserid");
		columns.add("doccanceluserid");
//		columns.add("docinvaldate");
		columns.add("maindoc");
		columns.add("hrmresid");
		columns.add("assetid");
		columns.add("crmid");
		columns.add("projectid");
	    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);
		    doceditionid = Util.getIntValue(data.get("doceditionid").toString(),-1);
		    selectedpubmouldid = Util.getIntValue(data.get("selectedpubmouldid").toString(),-1);
		    doccreaterid = Util.getIntValue(data.get("doccreaterid").toString(),-1);
			ownerid = Util.getIntValue(data.get("ownerid").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(),"");
		    checkOutUserId = Util.getIntValue(data.get("checkOutUserId").toString(),-1);
		    checkOutUserType = Util.null2String(data.get("checkOutUserType").toString(),"");
			keyword = Util.null2String(data.get("keyword").toString(),"");
			docMain = Util.null2String(data.get("docMain").toString(),"");
			secretLevel = Util.null2String(data.get("secretLevel").toString(),"");
			docapproveuserid =  Util.getIntValue(data.get("docapproveuserid").toString(),0);
			docarchiveuserid = Util.getIntValue(data.get("docarchiveuserid").toString(),0);
			doccanceluserid	= Util.getIntValue(data.get("doccanceluserid").toString(),0);
			maindoc = Util.getIntValue(data.get("maindoc").toString(),0);
			hrmresid = Util.getIntValue(data.get("hrmresid").toString(),0);
			assetid = Util.getIntValue(data.get("assetid").toString(),0);
			crmid = Util.getIntValue(data.get("crmid").toString(),0);
			projectid = Util.getIntValue(data.get("projectid").toString(),0);
	    }
	    
	    RecordSet rs = new RecordSet();
        rs.executeSql("select isOpenAttachment,isAutoExtendInfo from docseccategory where id=" + seccategory);
        if(rs.next()){ 
        	if("1".equals(rs.getString("isOpenAttachment")) && doctype == 1){ //目录是否开启单附件打开
        		isOpenAcc = true;
        	}
        	isAutoExtendInfo = "1".equals(rs.getString("isAutoExtendInfo"));
        }



	    //html文档
	    if(doctype == 1){

			//虚拟目录
			String dummyIds_value = "";
			String strSql="select catelogid from DocDummyDetail where docid="+docid;
			rs.executeQuery(strSql);
			while(rs.next()){
				dummyIds+=Util.null2String(rs.getString(1))+",";
			}
			if(!"".equals(dummyIds)) {
				dummyIds=dummyIds.substring(0,dummyIds.length()-1);
				DocTreeDocFieldComInfo dtdfc = new DocTreeDocFieldComInfo();
				for(String dummyId : dummyIds.split(",")){
					if(!dummyId.isEmpty()){
						String dummyName = dtdfc.getTreeDocFieldName(dummyId);
						String href = DocSptm.DOC_LINK + DocSptm.DOC_DUMMY_LINK_ROUT + "?dummyId=" + dummyId;
						dummyIds_value += "&nbsp;" + "<a target='_blank' href='" + href + "' >" + dummyName + "</a>";
					}
				}
			};

			//主文档
			String maindoc_value = "";
			weaver.docs.docs.DocComInfo dci = new DocComInfo();
			if(maindoc == docid){
				maindoc_value = SystemEnv.getHtmlLabelName(390563,user.getLanguage());//390563 当前文档
			}else if(maindoc > 0){
				maindoc_value = "<a target='_blank' href='" + DocSptm.DOC_DETAIL_LINK + "?id=" + maindoc + DocSptm.DOC_ROOT_FLAG_VALUE + DocSptm.DOC_DETAIL_ROUT + "'>" + dci.getDocname(maindoc + "") + "</a>";
			}

			//关联列表
			int newDocId = -1;
			String docSubject = "";
			if(doceditionid > -1){
				rs.executeQuery(" select id,docSubject from DocDetail where doceditionid = " + doceditionid + " and doceditionid > 0  and (isHistory<>'1' or isHistory is null or isHistory='') order by docedition desc ");
				rs.next();
				newDocId = Util.getIntValue(rs.getString("id"));
				docSubject = Util.null2String(rs.getString("docSubject"));
			} else {
				newDocId = docid;
				docSubject = docSubject;
			}
			if(newDocId>0){
				childDoc_value = "<a href='" + DocSptm.DOC_DETAIL_LINK + "?id="+newDocId+DocSptm.DOC_ROOT_FLAG_VALUE+DocSptm.DOC_DETAIL_ROUT + "'  target='_blank'>" + docSubject + "</a>&nbsp;";
				int childDocId=-1;
				String childDocSubject = "";
				rs.executeQuery(" select id,docSubject from DocDetail where id <> " + newDocId + " and mainDoc = " + newDocId + " and (isHistory<>'1' or isHistory is null or isHistory='') order by id asc ");
				while(rs.next()){
					childDocId = Util.getIntValue(rs.getString("id"));;
					childDocSubject = Util.null2String(rs.getString("docSubject"));
					if(childDocId>0){
						childDoc_value += "<a href='" + DocSptm.DOC_DETAIL_LINK + "?id=" + childDocId + DocSptm.DOC_ROOT_FLAG_VALUE+DocSptm.DOC_DETAIL_ROUT + "'  target='_blank' >" + childDocSubject + "</a>&nbsp";
					}
				}
			}

			/** 类型 start **/
			rs.executeQuery("select " +
					" hashrmres,hrmreslabel,hasasset,assetlabel,hascrm,crmlabel,hasitems,itemlabel,hasproject,projectlabel,hasfinance,financelabel " +
					" from docseccategory where id=?",seccategory);
			rs.next();
			String hashrmres = Util.toScreen(rs.getString("hashrmres"),user.getLanguage());
			String hrmreslabel = Util.toScreen(rs.getString("hrmreslabel"),user.getLanguage());
			String hasasset = Util.toScreen(rs.getString("hasasset"),user.getLanguage());
			String assetlabel = Util.toScreen(rs.getString("assetlabel"),user.getLanguage());
			String hascrm = Util.toScreen(rs.getString("hascrm"),user.getLanguage());
			String crmlabel = Util.toScreen(rs.getString("crmlabel"),user.getLanguage());
			String hasitems = Util.toScreen(rs.getString("hasitems"),user.getLanguage());
			String itemlabel = Util.toScreen(rs.getString("itemlabel"),user.getLanguage());
			String hasproject = Util.toScreen(rs.getString("hasproject"),user.getLanguage());
			String projectlabel = Util.toScreen(rs.getString("projectlabel"),user.getLanguage());
			String hasfinance = Util.toScreen(rs.getString("hasfinance"),user.getLanguage());
			String financelabel = Util.toScreen(rs.getString("financelabel"),user.getLanguage());

			// 人力资源
			DocSptm ds = new DocSptm();
			String hrmresid_value = "";
			if(!hashrmres.trim().equals("0")&&!hashrmres.trim().equals("")){
				String curlabel = SystemEnv.getHtmlLabelName(179,user.getLanguage());
				if(!hrmreslabel.trim().equals("")) curlabel = hrmreslabel;
				if(!user.getLogintype().equals("2")){
					if(hrmresid != 0){
						hrmresid_value = ds.getHrmCard(hrmresid + "",false);
					}
				}
			}

			// 资产
			String assetid_value = "";
			if(!hasasset.trim().equals("0")&&!hasasset.trim().equals("")){
				String curlabel = SystemEnv.getHtmlLabelName(535,user.getLanguage());
				String value = "";
				if(!assetlabel.trim().equals("")) curlabel = assetlabel;
				if(!user.getLogintype().equals("2")){
					if(assetid !=0 ){
						CapitalComInfo cci = new CapitalComInfo();
						assetid_value = "<a href='" + DocSptm.CAPITAL_LINK + DocSptm.CAPITAL_ROUT + assetid + "' target='_blank'>" + Util.toScreen(cci.getCapitalname(assetid+""),user.getLanguage()) + "</a>";
					}
				}
			}

			// CRM
			String crmid_value = "";
			if(!hascrm.trim().equals("0")&&!hascrm.trim().equals("")){
				String curlabel = SystemEnv.getHtmlLabelName(147,user.getLanguage());
				String value = "";
				if(!crmlabel.trim().equals("")) curlabel = crmlabel;
				if(crmid !=0 ){
					weaver.crm.Maint.CustomerInfoComInfo cici = new CustomerInfoComInfo();
					crmid_value = "<a href='" + DocSptm.CUSTOM_LINK + DocSptm.CUSTOM_ROUT + crmid + "' target='_blank'>" + Util.toScreen(cici.getCustomerInfoname(crmid+""),user.getLanguage()) + "</a>";
				}
			}

			// 项目
			String projectid_value ="";
			if(!hasproject.trim().equals("0")&&!hasproject.trim().equals("")){
				String curlabel = SystemEnv.getHtmlLabelName(101,user.getLanguage());
				String value = "";
				if(!projectlabel.trim().equals("")) curlabel = projectlabel;
				if(projectid!=0){
					ProjectInfoComInfo pici = new ProjectInfoComInfo();
					projectid_value = "<a href='" + DocSptm.PROJECT_LINK + DocSptm.PROJECT_ROUT + projectid + "' target='_blank'>" + Util.toScreen(pici.getProjectInfoname(""+projectid),user.getLanguage()) + "</a>";
				}

			}

	    	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
	           
	             if(isOpenAcc){  //目录是否开启单附件打开

		            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 = "";
		            int fileCount = 0;
		            while(rs.next()){   //是否是单附件
		            	fileCount++;
		            	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;
		            	}

		            }
					if(fileCount == 0){
						isOpenAcc = false;
					}

	            }


	        }else{
	        	isOpenAcc = false;
	        }
	        
			if(!isOpenAcc){
				showByHtml = true;
	        	SecCategoryDocPropertiesComInfo scdpc = new SecCategoryDocPropertiesComInfo();

	        	int docmouldid = -1;

	        	if(scdpc.getDocProperties(""+seccategory,"10")){
	        		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(user != null && 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();
	        	moudlePictureIds =mouldManager.getMouldPicId();
	        	
	        	try{
		        	int contentIndex = mouldtext.indexOf("$DOC_Content");
		        	if(contentIndex > -1){
		        		int contentPStartIndex = mouldtext.lastIndexOf("<p ", contentIndex);
		        		
						int flag = mouldtext.lastIndexOf("<p>", contentIndex);
		        		
		        		if(flag > contentPStartIndex){
		        			contentPStartIndex = flag;
		        		}
		        		
		        		if(contentPStartIndex < -1){
		        			contentPStartIndex = mouldtext.lastIndexOf("<p>", contentIndex);
		        		}
		        		int contentPEndIndex = mouldtext.indexOf("</p>", contentIndex);
		        		if(contentPStartIndex > -1 && contentPEndIndex > -1){
		            		String preMouldtext = mouldtext.substring(0,contentPStartIndex);
		            		String cenMouldtext = mouldtext.substring(contentPStartIndex,contentPEndIndex + 4);
		            		String endMouldtext = mouldtext.substring(contentPEndIndex + 4);
		            		
		            		cenMouldtext = "<div " + cenMouldtext.substring(2,cenMouldtext.length() - 4) + "</div>";
		            		mouldtext = preMouldtext + cenMouldtext + endMouldtext;
		        		}
		        	}
	        	}catch(Exception e){
	        		
	        	}
	        	
	        	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),languageid)+"</a>"));
	        	
	        	
	        	if(docContent != null){
	    		    if(docContent.contains("<body>") && docContent.contains("</body>")){
	    		    	docContent = docContent.replace("<body>","").replace("</body>","");
	    		    }

	    		    
	    		    Pattern p = Pattern.compile("<link\\s[^>]+\\s?\\/>");
	    	        Matcher m = p.matcher(docContent);
	    	       
	    	        while(m.find()){
	    	            String link = m.group(0);
	    	            docContent = docContent.replace(link, "");
	    	        }
	    	        
	    	        int tmppos = docContent.indexOf("<title>");
	    	        while (tmppos != -1) {
	    	            int endpos = docContent.lastIndexOf("</title>", tmppos);
	    	            if ((endpos - tmppos) > 1) {
	    	                String tmpcontent = docContent.substring(0, tmppos);
	    	                tmpcontent += tmpcontent.substring(endpos + 8);
	    	                docContent = tmpcontent;
	    	            } else if(endpos < 0){
	    	            	docContent = docContent.replace("<title>","");
	    	            }
	    	            tmppos = docContent.indexOf("<title>");
	    	        }
	        	} 
	        	
	        	hr.put("DOC_Content",Util.null2String(docContent));
	        	
	        	HrmClassifiedProtectionBiz hcpb = new HrmClassifiedProtectionBiz();
	        	hr.put("DOC_SecretLevel",hcpb.getResourceSecLevelShowName(secretLevel, user.getLanguage() + ""));

	        	if(usertype.equals("2"))  {
	        	    hr.put("DOC_CreatedBy",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccreaterid),languageid)));
	        	    hr.put("DOC_CreatedByLink",Util.null2String("<a href='/CRM/data/ViewCustomer.jsp?CustomerID="+doccreaterid+"'>"+Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccreaterid),languageid)+"</a>"));
	        	    hr.put("DOC_CreatedByFull",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccreaterid),languageid)));
	        	    hr.put("DOC_Owner",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+ownerid),languageid)));
					hr.put("DOC_CreatedDetail",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccreaterid),languageid)));
					hr.put("DOC_ModifiedDetail",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doclastmoduserid),languageid)));
					hr.put("DOC_ApproveDetail",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+docapproveuserid),languageid)));
					hr.put("DOC_DocarchiveDetail",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+docarchiveuserid),languageid)));
					hr.put("DOC_DoccancelDetail",Util.null2String(Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(""+doccanceluserid),languageid)));
	        	}else {
	        	    hr.put("DOC_CreatedBy",Util.null2String(Util.toScreen(ResourceComInfo.getFirstname(""+doccreaterid),languageid)));
	        	    hr.put("DOC_CreatedByLink",Util.null2String("<a href='javaScript:openhrm("+doccreaterid+");' onclick='pointerXY(event);'>"+Util.toScreen(ResourceComInfo.getResourcename(""+doccreaterid),languageid)+"</a>"));
	        	    hr.put("DOC_CreatedByFull",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+doccreaterid),languageid)));
					hr.put("DOC_Owner",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+ownerid),languageid)));
					hr.put("DOC_CreatedDetail",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+doccreaterid),languageid)));
					hr.put("DOC_ModifiedDetail",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+doclastmoduserid),languageid)));
					hr.put("DOC_ApproveDetail",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+docapproveuserid),languageid)));
					hr.put("DOC_DocarchiveDetail",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+docarchiveuserid),languageid)));
					hr.put("DOC_DoccancelDetail",Util.null2String(Util.toScreen(ResourceComInfo.getResourcename(""+doccanceluserid),languageid)));
	        	}

	        	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),languageid)));
	        	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,languageid);
	        	hr.put("DOC_Status",Util.null2String(docstatusname));
	        	hr.put("DOC_Subject",Util.null2String(docsubject));
	        	String tmppublishtype="";
	        	if(docpublishtype.equals("2")) tmppublishtype=SystemEnv.getHtmlLabelName(227,languageid);
	        	else if(docpublishtype.equals("3")) tmppublishtype=SystemEnv.getHtmlLabelName(229,languageid);
	        	else tmppublishtype=SystemEnv.getHtmlLabelName(58,languageid);
	        	hr.put("DOC_Publish",Util.null2String(tmppublishtype));
	        	hr.put("DOC_ApproveDate",Util.null2String(docapprovedate));
	        	hr.put("DOC_Doccode", Util.null2String(docCode)) ;
				hr.put("DOC_Keyword", Util.null2String(keyword)) ;
				hr.put("DOC_Summary", Util.null2String(docMain)) ;
				hr.put("DOC_Docedition",dci.getEditionView(docid));
				hr.put("DOC_Maindoc",Util.null2String(maindoc_value));//主文档
				hr.put("DOC_ChildDoc",Util.null2String(childDoc_value));//关联列表
				hr.put("DOC_DummyIds",Util.null2String(dummyIds_value));//虚拟目录
				hr.put("DOC_Hrm",Util.null2String(hrmresid_value)); //人力资源
				hr.put("DOC_Capital",Util.null2String(assetid_value)); //资产
				hr.put("DOC_CRM",Util.null2String(crmid_value)); //CRM
				hr.put("DOC_Project",Util.null2String(projectid_value)); //项目
				hr.put("DOC_Docinvaldate",Util.null2String(invalidationdate));//失效日期
				
				String mouldName = mouldManager.getMouldName();
				
				hr.put("DOC_Mould",Util.null2String(mouldName));//模板设置

	        	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));
	        	}

	        	/**
				 *模板自定义属性
				 * */
				Map<String,String> cusInfo = detailService.getCusInfoNoRight(docid,seccategory,user);
				if(cusInfo != null){
				    for(String key : cusInfo.keySet()){
						hr.put("CUS_" + key,cusInfo.get(key));
					}
				}

	        	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;
					String bodyStyle = "";
					int bodyStyleIndex = docContent.indexOf("<body");
					if(bodyStyleIndex!=-1){
						int key1 = docContent.indexOf("style",bodyStyleIndex);
						int key2 = docContent.indexOf(">",key1);
						if(key1 > -1 && key2 > -1){
							bodyStyle = docContent.substring(key1+7,key2-1);
						}
					}

					int bgindex = bodyStyle.indexOf("background-color");
					if(bgindex!=-1){
						int key1 = bodyStyle.indexOf(":",bgindex);
						int key2 = bodyStyle.indexOf(";",key1);
						if(key1 > -1 && key2 > -1){
							backgroundColor = bodyStyle.substring(key1+1,key2);
						}
					}
					docContent = docContent.replace(bodyStyle,"");
					docContent = "<div id=\"weaDocDetailHtmlContent\" style=\""+ bodyStyle +"\" >" + docContent + "</div>";
	        }
	    }else if(doctype == 12){  //pdf文档
	    	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.isextfile <> '1' or a.isextfile is null) and a.docid=" + docid + " order by versionid desc");
	    	if(rs.next()){
	    		OpenAccOfFileid = rs.getString("imagefileid");
	    		OpenAccOfFilename = rs.getString("imagefilename");
	    		OpenAccOfFiletype = rs.getString("docfiletype");
	    		OpenAccOfVersionid = rs.getString("versionId");
	    		OpenAccOfFileSize = rs.getInt("filesize");
				OpenAccOfcomefrom = rs.getString("comefrom");
	    		isOpenAcc = true;
	    	}
	    }

    }
    
    ImageConvertUtil icu = new ImageConvertUtil();
    String waterContent = icu.getWatermark(user,new HashMap<String,String>(),false); //水印内容
    if(waterContent.startsWith("&watermark_txt=")){
    	waterContent = waterContent.substring(15);
    }

	    // office文件:正文word、excel   或者是单附件打开
	    if(!isEdit && (doctype == 2  || isOpenAcc || imagefileId > 0))
	    {
	        // 附件ID
	        String imageFileid = "";
	        // 模板ID
	        String mTemplate = "";
	        // 附件名称
	    	String imageFileName="";
	        // 附件类型
	    	String fileType="";
	        // 操作用户
	    	String mUserName = user == null ? "" : user.getLastname();
	        // 编辑状态
	        String editType = "4";
	        // 附件类型标识
	    	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";
			     rs.executeSql(sql);
	        	if(rs.next()){
	        		imageFileName = Util.null2String(rs.getString("imagefilename"),"");
		            docFileType = Util.getIntValue(rs.getString("docfiletype"),0);
		            filesize = Util.getIntValue(rs.getString("filesize"),0);
					comefrom = Util.null2s(rs.getString("comefrom"),"");
	        	}
	        	 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"),"");
		            docFileType = Util.getIntValue(rs.getString("docfiletype"),0);
		            versionId = Util.getIntValue(rs.getString("versionId"),0);
		            filesize = Util.getIntValue(rs.getString("filesize"),0);
					comefrom = Util.null2s(rs.getString("comefrom"),"");
		        }
		        imagefileId = Util.getIntValue(imageFileid);
	        }else if(isOpenAcc){  //单附件打开

	            imageFileid = OpenAccOfFileid;
	            imageFileName = OpenAccOfFilename;
	            docFileType = Util.getIntValue(OpenAccOfFiletype,0);
	            versionId = Util.getIntValue(OpenAccOfVersionid,0);
	            filesize = OpenAccOfFileSize;
	            imagefileId = Util.getIntValue(imageFileid);
	            comefrom = OpenAccOfcomefrom;
	        }
	        String extname = imageFileName.indexOf(".") > -1 ? imageFileName.substring(imageFileName.lastIndexOf(".")+ 1) : "";
	        extname = extname.toLowerCase();
	        boolean IsUseDocPreviewForIE = "1".equals(rs.getPropValue("docpreview","IsUseDocPreviewForIE"));
	        boolean IsUseDocPreview = "1".equals(rs.getPropValue("docpreview","IsUseDocPreview"));  //是否开启预览
	        
	        boolean tifReadOnline = false;
	        if(extname.equals("tif") || extname.equals("tiff")){
	        	tifReadOnline = "1".equals(rs.getPropValue("docpreview","tifReadOnline"));
	        }
	        
	        useYozoView = false;
	        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+"&levelMap="+docisLock+"&canDownload="+canDownload+"&pdfimagefileid="+imageFileid+moudleParams+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
					}
				}
				//docContent = "<iframe src=\"/docs/pdfview/web/pdfViewer.jsp?canPrint="+canPrint+"&canDownload="+canDownload+"&pdfimagefileid="+imageFileid+moudleParams+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
            }else if(extname.equals("ofd") && canIWebOffice){
            	ofdContent = "<iframe id=\"ofdshow\" src=\"/docs/ofd/OfdShow.jsp?docid="+docid+"&imagefileId="+imagefileId+"&isEdit="+false+"\" 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;";
				if(docisLock){
            	    docContent+= "-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;unselectable:on;";
				}
				docContent += "\"></iframe>";
            }else if(!IsUseDocPreview && !canIWebOffice){  //未开启转换预览,且该浏览器不支持插件
	        	String sysremindurl="/wui/common/page/sysRemind.jsp?labelid=509650";
            	if(levelMap.get(DocViewPermission.DOWNLOAD)){
            		sysremindurl="/wui/common/page/sysRemind.jsp?labelid=129755&line=1";
            	}
            	docContent = "<iframe src=\""+sysremindurl+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	        }else if(useYozoView){	//永中在线预览office文档
	        	docContent = "<iframe src=\"/spa/document/weboffice.jsp?fileid="+imageFileid+"\" style=\"display: block;width: 100%;height: 100%; border:0;";
				if(docisLock){
					docContent+= "-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;unselectable:on;";
				}
				docContent += "\"></iframe>";
	        }else if(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(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>";
						}
	           		}
	           		if(extname.equals("pdf")){
	           			waterContent = "";
	           		}
	            }
	           	// 采用转换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\" 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&line=2";
	            	}
	            	docContent = "<iframe src=\""+sysremindurl+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            }
	        }
	        // IE 32 内核,直接加载控件
	        else
	        {
	        	waterContent = "";
	            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(selectedpubmouldid > 0){
	        		mTemplate = selectedpubmouldid + "";
	        	}else if(mFileType.equals(".doc")||mFileType.equals(".wps")){
	    			int  tempMouldType=3;//3:WORD显示模版
	    			if(mFileType.equals(".wps")){
	    				tempMouldType=7;//7:WPS显示模版
	    			}
	    			int selectMouldType = 0;
	    			int mouldid = 0;
	    			rs.executeQuery("select * from DocSecCategoryMould where secCategoryId = "+secid+" and mouldType=" + tempMouldType + " order by id ");
	    			while(rs.next()){
	    				String moduleid=rs.getString("mouldId");
	    				String mType = DocMouldComInfo.getDocMouldType(moduleid);
	    				String modulebind = rs.getString("mouldBind");
	    				int isDefault = Util.getIntValue(rs.getString("isDefault"),0);
    					if(Util.getIntValue(modulebind,1)==2){
    					    selectMouldType = 2;
    					    mouldid = Util.getIntValue(moduleid);
    				    } else if(Util.getIntValue(modulebind,1)==1&&isDefault==1){
    					    if(selectMouldType==0){
    					        selectMouldType = 1;
    					        mouldid = Util.getIntValue(moduleid);
    					    }
    				    } 
	    			}
	    			mTemplate = mouldid > 0 ? (mouldid + "") : "";
	        	}
	            
	            if(!mFileType.isEmpty()){
	                if(docisLock){
	                    editType = "0";
					}
					docContent = "<iframe id=\"webOffice\" src=\"/spa/document/office.jsp?isofficeview=1&mRecordID="+versionId +"_"+docid+"&mTemplate=" + mTemplate +"&canPrint="+canPrint+"&mFileName=" + URLEncoder.encode(imageFileName,"utf-8") +"&mFileType=" + mFileType +"&mEditType=" + editType + moudleParams + "\" 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&line=3";
	            	}
	            	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>";
	            } 
	       }
	    }
	    
	    //新建、编辑office
	    if(isEdit && isEditOffice){
	    	
	    	waterContent = "";
	    	 // 模板ID
	        String mTemplate = "";
	        // 附件名称
	    	String imageFileName="";
	        // 编辑状态
	        String editType = docid > 0 ? "-1,0,1,1,0,0,1" : "1";
	        //文档类型
	        String mFileType = "";
	        //附件id
	        String imagefileid = "";
	        
	        RecordSet rs = new RecordSet();
	        RecordSet rs1 = new RecordSet();
	        //rs.executeQuery("select ")
	        if(docid > 0){
	        	 String sql = "select a.imagefileid,a.imagefilename,a.docfiletype,a.versionId,b.filesize 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.executeQuery(sql);
				rs1.executeQuery("select imagefileid,docfiletype from docimagefile where docid=? and docfiletype =12 ",docid);
				if(!rs.next() && !rs1.next()){
	        		response.sendRedirect("/notice/noright.jsp?line=7") ;
	        		return ;
	        	}
	        	int docFileType = rs.getInt("docfiletype");
	        	imageFileName = rs.getString("imagefilename");
	        	versionId = rs.getInt("versionId");
	        	imagefileid = rs.getString("imagefileid");
		        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(docFileType == 6){
	            	mFileType = ".wps";
	            }else if(docFileType == 10){
	            	mFileType = ".et";
	            }else if(docFileType == 12){
					mFileType = ".html";
				}else if(imageFileName.toLowerCase().endsWith(".uot")){
					mFileType = ".doc";
				}
	        }else{
	        	mFileType = officeType;
	        	if(mFileType.equals(".doc")||mFileType.equals(".xls")||mFileType.equals(".wps")||mFileType.equals(".et")){
	    			int  tempMouldType=4;//4:WORD编辑模版
	    			if(mFileType.equals(".xls")){
	    				tempMouldType=6;//6:EXCEL编辑模版
	    			}else if(mFileType.equals(".wps")){
	    				tempMouldType=8;//8:WPS文字编辑模版
	    			}else if(mFileType.equals(".et")){
	    				tempMouldType=10;//10:et表格编辑模版
	    			}else if(mFileType.equals(".html")){
						tempMouldType=12;
					}
	    			int selectMouldType = 0;
	    			int mouldid = 0;
	    			rs.executeQuery("select * from DocSecCategoryMould where secCategoryId = "+secid+" and mouldType=" + tempMouldType + " order by id ");
	    			while(rs.next()){
	    				String moduleid=rs.getString("mouldId");
	    				String mType = DocMouldComInfo.getDocMouldType(moduleid);
	    				String modulebind = rs.getString("mouldBind");
	    				int isDefault = Util.getIntValue(rs.getString("isDefault"),0);
    					if(Util.getIntValue(modulebind,1)==2){
    					    selectMouldType = 2;
    					    mouldid = Util.getIntValue(moduleid);
    				    } else if(Util.getIntValue(modulebind,1)==1&&isDefault==1){
    					    if(selectMouldType==0){
    					        selectMouldType = 1;
    					        mouldid = Util.getIntValue(moduleid);
    					    }
    				    } 
	    			}
	    			mTemplate = mouldid > 0 ? (mouldid + "") : "";
	    		}
	        }
	        if((useYozoView || useWpsView) && 
	        		(mFileType.equals(".doc") || 
	        				mFileType.equals(".docx") || 
	        				mFileType.equals(".xls") || 
	        				mFileType.equals(".xlsx") || 
	        				mFileType.equals(".ppt") ||
	        				mFileType.equals(".pptx"))){	//永中在线预览office文档
				int _fileid = Util.getIntValue(request.getParameter("fileid"));
	        	if(_fileid > 0 && Util.getIntValue(imagefileid) <= 0){
	        		imagefileid = _fileid + "";
	        	}			
	        	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.equals(".html") && DocPlugUtil.isopenbjca()){
	            RecordSet recordSet = new RecordSet();
	            String sql = "select imagefileid from docimagefile where docid=? and docfiletype =12 order by imagefileid desc";
	            recordSet.executeQuery(sql,docid);
	            String fileid = "";
	            if(recordSet.next()){
	                fileid = recordSet.getString("imagefileid");
				}
				docContent = "<iframe id='pdfshow' src='/docs/pdfofca/pdfShow.jsp?docid="+docid+"&imagefileId="+fileid+"&isEdit="+isEdit+"' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
			}else{
	            if(docisLock){
	                editType = "0";
				}
	            
	            int maxFileSize = 0;
	            if(secid > 0){
	            	rs.executeQuery("select maxofficedocfilesize from DocSecCategory where id=?",secid);
	            }else{
	            	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=0&mRecordID="+versionId +"_"+docid+"&maxFileSize="+maxFileSize+"&mTemplate=" + mTemplate +"&mFileName=" + URLEncoder.encode(imageFileName,"utf-8") +"&mFileType=" + mFileType +"&mEditType=" + editType + moudleParams + "\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	        }
	    }
	    
	    
	//    String htmlcontent = docContent;
	    
	//    session.setAttribute("doccontent_" + user.getUID() + "_" + user.getLogintype() + "_" + docid,docContent);

	    if(showByHtml){
	 //   	docContent = "<iframe src=\"/spa/document/htmlcontent.jsp?docid=" + docid + "\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
		}

	    Date d4 = new Date();
	    time3 = d4.getTime()-d1.getTime();
	    String linkNewestDoc = "";
		if(ishistory == 1){
			RecordSet rs = new RecordSet();
			rs.executeQuery("select id from DocDetail where doceditionid = " + doceditionid + " and ishistory=0 and id<>"+docid+"  order by docedition desc ");
    		if(rs.next()){
    			newestid = rs.getInt("id");
    		}
    		if(newestid > 0 && newestid != docid){
	    		linkNewestDoc = DocSptm.DOC_DETAIL_LINK + "?id=" + newestid + moudleParams + DocSptm.DOC_ROOT_FLAG_VALUE+DocSptm.DOC_DETAIL_ROUT;
    		}else{
    			linkNewestDoc = "/notice/noright.jsp?line=8";
    		}
		}
		
		if(isEdit && !"1".equals(checkOutStatus)&&!"2".equals(checkOutStatus)){
			DocSaveService dss = new DocSaveService();
           	dss.checkOut(docid,docsubject,doccreaterid,usertype,request.getRemoteAddr(),user);
    	}
		//checkout
	    String warmMessageStatus = Util.null2String(request.getParameter("warmMessageStatus"));
	    String warmMessage = "";
	    if("checkout".equals(warmMessageStatus)){
	    	String checkOutUserName = ResourceComInfo.getLastname(checkOutUserId + "");
	    	warmMessage = SystemEnv.getHtmlLabelName(19695,user.getLanguage())+SystemEnv.getHtmlLabelName(19690,user.getLanguage())+":"+checkOutUserName;
	    }
		
		
		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/detail") == -1 && __href.indexOf("#/main/document/edit") == -1){
				//alert(location.href);
				//location.href = location.href.substring(0,location.href.indexOf("&router=1"));
				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><%= 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>
		<script type="text/javascript" src="/js/weaver_wev8.js"></script>
		<script type="text/javascript" src="/wui/theme/ecology8/jquery/js/zDialog_wev8.js"></script>
		<script type="text/javascript" src="/js/ecology8/lang/weaver_lang_<%=languageid%>_wev8.js"></script>
		
		<script type="text/javascript" src="/docs/e9/pagewatermark_canvas.js"></script>
		
		<script>
			/**分享*/
			function onDocShare(){
				var message='[{"shareid":<%=docid%>,"sharetitle":"<%= docsubject %>","sharetype":"doc","objectname":"FW:CustomShareMsg"}]';
				socialshareToEmessage(message);
			}
			/**调用子层office保存*/
			function saveDocument(docsubject){
				try{
					if(<%=isCAPDF && DocPlugUtil.isopenbjca()%>){
                        var bjcasave = document.getElementById("pdfshow").contentWindow.save_pdf();
                        if(bjcasave.off_status == 0){
                            bjcasave.msg = "<%=SystemEnv.getHtmlLabelName(84544, user.getLanguage())%>";
                        }else if(bjcasave.off_status == 1){
                            bjcasave.msg = "保存成功!";
						}
                        return bjcasave;
					}else{
                        var obj = document.getElementById("webOffice").contentWindow.toSaveDocument({fileName : docsubject});

                        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};
				}
			}
			/**子层office调用保存事件是,保存office*/
			function __saveDocument(){
				var obj = document.getElementById("webOffice").contentWindow.SaveDocument();
			}
			/**调用子层office保存草稿*/
			function saveDocumentAsDraft(){
				return saveDocument();
			}
			/**子层office调用保存草稿事件是,保存office*/
			function __saveDocumentAsDraft(){
				
			}
			
			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;
			}
			
			function changeOfficeMould(mouldid){
				//mTemplate
				
				try{
					var _src = document.getElementById("webOffice").src;
					_src = _src.replace(/&mTemplate=-?\d*/g,"&mTemplate=" + mouldid);
					document.getElementById("webOffice").src = _src;
				}catch(e){}
				
			}
			function changeOfficeFile(fileid,fileExtendName){
			
				if("<%=isEditOffice ? "1" : "0"%>" == "0"){
					location.href = location.href.replace("&router=1","&router=1&fileid=" + fileid+"&isOffice=1&officeType=."+fileExtendName.toLocaleLowerCase());
					return;
				}
			
				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};

                    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;
                        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
                        };
                    }
				}
			}	
			
			function initFlashVideo(){}
			
			//打开应用连接
			function openAppLink(obj,linkid){

				var linkType=jQuery(obj).attr("linkType");
				if(linkType=="doc")
					window.open("/docs/docs/DocDsp.jsp?id="+linkid);
				else if(linkType=="task")
					window.open("/proj/process/ViewTask.jsp?taskrecordid="+linkid);
				else if(linkType=="crm")
					window.open("/CRM/data/ViewCustomer.jsp?CustomerID="+linkid);
				else if(linkType=="workflow")
					window.open("/workflow/request/ViewRequest.jsp?requestid="+linkid);
				else if(linkType=="project")
					window.open("/proj/data/ViewProject.jsp?ProjID="+linkid);
				else if(linkType=="workplan")
					window.open("/workplan/data/WorkPlanDetail.jsp?workid="+linkid);
				return false;
			}
			//打开留言附件(回复)
			function openReplyAcc(url,fileid){
				window.open(url);
			}
			//下载附件(回复)
			function downloadFile(url,fileid){
				window.open(url);
			}
			function docPrint(){
				var $obj = document.getElementById("webOffice");
				if(!$obj || $obj.length == 0){
					$obj = document.getElementById("officeShow");					
				}
				if(!$obj || $obj.length == 0){
					$obj = document.getElementById("previewDoc").contentWindow.document.getElementById("officeShow");
				}
				if($obj){
					if(window.__useWpsView){
						$obj.contentWindow.postMessage(JSON.stringify({action : "logic.print"}),"*");
					}else if($obj.src && $obj.src.indexOf("/weaver/weaver.file.FileDownload") != -1){
						$obj.contentWindow.print();
					}else{
						$obj.contentWindow.docPrint();
					}
				}
				
			}
		</script>
    <style type="text/css">
      body{
        margin: 0;
        overflow: hidden;
      }
      .chatImgPagWrap  .carousel-fullpane .control-pane .ctrlbtn {
        margin: 0
      }
      .wea-doc-detail-content-main img{
      	max-width:1024px;
      }
      .wea-doc-detail-content-main ul,.wea-doc-detail-content-main ol{
      	padding-left:40px;
      	list-style: decimal;
      }
	  .wea-doc-detail-content-main ul{
      	list-style: disc;
      }
	  .wea-doc-detail-content-main ol{
      	list-style: decimal;
      }
      #weaDocDetailHtmlContent p{
      	line-height: normal;
      }
    </style>
	</head>
		<body>
		
		<input type="hidden" id="isOffice" value="<%=isEditOffice ? 1 : 0%>"/>
		<input type="hidden" name="docid" value="<%=docid %>"/>
		
	<div id="container" style="height:100%;">
		
	</div>
	<%if(showByHtml){%>
		<div id="docContentPre" style="display: none;">
			<%= docContent %>
		</div>
	<%}%>
		<script type="text/javascript">
			window.__time0 = "判断权限耗时:<%=time0%>";
			window.__time1 = "获取属性耗时:<%=time1%>";
			window.__time2 = "获取正文耗时:<%=time2%>";
			window.__time3 = "业务逻辑总耗时:<%=time3%>";

			window.__imagefilename = "<%=imagefilename%>";
			window.__showByHtml = "<%=showByHtml ? 1 : 0%>";	//文档类型是html
			window.__moudleParams = "<%=moudleParams %>";		//其他模块参数集
            window.__moudlePicIds = "<%=moudlePictureIds %>";		//文档显示模板图片id
			window.__hasNewestWarm = "<%=ishistory == 1 ? 1 : 0%>";	//是否给出有最新文档的提示
			window.__linkNewestDoc = "<%=linkNewestDoc%>";		//跳转到最新版本文档的链接
			window.__isAutoExtendInfo = "<%=isAutoExtendInfo ? 1 : 0%>";//有附件时展开文档附件属性
			window.__warmMessage = "<%=warmMessage%>";//弹出提示语
			window.__currentUser = "<%=user == null ? 0 : user.getUID()%>";
			window.bgColor = "<%=backgroundColor%>";
			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};
                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);
            }

            if(jQuery("#frame1").length > 0){
				
			}else{
				jQuery("table[id='content']").show();
			}
			
			jQuery(document).ready(function(){
						//不修改人力资源链接的target属性
				jQuery("a").each(function(){
					var _this=jQuery(this);
					var href=_this.attr("href");
					if(href){
						href = href.toLowerCase();
						if(-1 == href.indexOf("javascript:openhrm(")){
							_this.attr("target","_blank");
						}else if(href.indexOf("openfullwindowforxtable(")>0){
							_this.attr("target","_self");
						}else if(href.indexOf("#")==0){
							_this.attr("target","_self");
						}
					}
				});
			
			
			<%if(!waterContent.isEmpty()){%>
				window.waterInterval = setInterval(function(){
					doWater();
				},100)	
			<%}%>
      });
      
      function doWater(){
      		if(!document.getElementById("weaDocDetailHtmlContent"))
      			return;
			clearInterval(window.waterInterval)
      		var markUrl = new Object();
			markUrl.watermark_txt="<%=waterContent%>";
			watermark(markUrl,document.getElementById("weaDocDetailHtmlContent"));
      }
      window.__docsubject = '<%=docsubject.replace("'","\\'")%>';
      //window.__preTitle = $('.wea-new-top-req-title-text').html();// 应该没用了,就先去掉好了 by caoyun 20180830
      <%if(showByHtml){%>
	      window.__preContent = $('#docContentPre').html();
		  $('#docContentPre').remove();
	  <%}else{%>
	  	  window.__preContent = '<%=!"".equals(ofdContent) ? ofdContent.replace("'","\\'") : docContent.replace("'","\\'")%>'
	  <%}%>
		</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=20180830"></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="/social/js/drageasy/drageasy.js"></script>
    <script type="text/javascript" src="/social/js/bootstrap/js/bootstrap.js?v=20171218"></script>
    <script type="text/javascript" src="/social/im/js/IMUtil_wev8.js"></script>
    <script type="text/javascript" src="/social/js/imcarousel/imcarousel.js"></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>