index_odoc.jsp 106 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 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782
<%@ 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="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.*"%>
<%@ page import="java.net.*"%>
<%@ page import="com.alibaba.fastjson.JSONObject"%>
<%@ page import="weaver.file.Prop" %>

<%@ page import="com.api.doc.search.util.DocSptm"%>
<%@page import="com.api.doc.search.service.DocLogService"%>
<%@page import="com.api.doc.category.service.CategoryService"%>
<%@ page import="weaver.workflow.request.RequestDocDocAddExt" %>
<%@ page import="weaver.docs.bookmark.MouldBookMarkEditComInfo" %>
<%@ page import="com.weaver.cssRenderHandler.JsonUtils" %>
<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="SecCategoryComInfo" class="weaver.docs.category.SecCategoryComInfo" 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" />
<jsp:useBean id="BaseBean" class="weaver.general.BaseBean" scope="page" />
<jsp:useBean id="WorkflowBarCodeSetManager" class="weaver.workflow.workflow.WorkflowBarCodeSetManager" scope="page" />
<jsp:useBean id="TexttoPDFManager" class="weaver.workflow.request.TexttoPDFManager" scope="page" />
<%@ taglib uri="/browserTag" prefix="brow"%>
<%
	User user = HrmUserVarify.getUser (request , response) ;
	response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    
    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 workflowid = Util.getIntValue(request.getParameter("workflowid"),-1);
    int requestid = Util.getIntValue(request.getParameter("requestid"),-1);
    int secFieldid = Util.getIntValue(request.getParameter("secFieldid"),-1);
    String requestname = Util.null2String(request.getParameter("requestname"));
    int secid = Util.getIntValue(request.getParameter("secid"),-1);	//目录id
    boolean isEdit = "1".equals(request.getParameter("isEdit"));	//是否是新建或者编辑
    boolean isEditOffice = "1".equals(request.getParameter("isOffice")); //是否是 office
    String officeType = request.getParameter("officeType"); //新建office类型
    int nodeid = Util.getIntValue(request.getParameter("nodeid"),-1);	//节点id
    
    int docFieldId = Util.getIntValue(request.getParameter("docFieldId"),-1);	//正文字段id
    int docNameField = Util.getIntValue(request.getParameter("docNameField"),-1);	//正文名称id
    
    int imagefileId = Util.getIntValue(request.getParameter("imagefileId"),-1);
    int versionId = Util.getIntValue(request.getParameter("versionId"),-1);

    String documentTitleField = request.getParameter("documentTitleField"); //文档标题存放字段

    boolean isUseTempletNode = "true".equals(request.getParameter("isUseTempletNode")); 
    boolean isSignatureNodes = "true".equals(request.getParameter("isSignatureNodes")); 
    boolean isCleanCopyNodes = "true".equals(request.getParameter("isCleanCopyNodes")); 
    //是否使用iWebOfficeChina
    boolean isNewObject = "true".equals(request.getParameter("isNewObject"));
    //webwps
	boolean webwps = "true".equals(request.getParameter("webwps"));
	//永中Office
	boolean yozoOffice = "true".equals(request.getParameter("yozoOffice"));
	
	//文档编辑状态,0:非修订状态,不保护文档;1,修订状态,不保护文档;2,保护文档,锁定状态
	String mEditType = "0";
	if(docid < 0){
		mEditType = "0";
	}else if(isEdit){
		mEditType = "1";
	}else{
		mEditType = "0";
	}
    %>
<script>

    <%--var isNewObject = <%=isNewObject%>;--%>
    window.notThrowCss = true;
</script>
<%
    
    //流程新建完成,关闭当前页面

	String isIE = (String)session.getAttribute("browser_isie");
	if (isIE == null || "".equals(isIE)) {
		isIE = "true";
		session.setAttribute("browser_isie", "true");
	}
	String agent = (String)request.getHeader("user-agent");
	if((agent.contains("Firefox")||agent.contains(" Chrome")||agent.contains("Safari") )|| agent.contains("Edge")){
		isIE = "false";
	}else{
		isIE = "true";
	}
	//非IE浏览器,进入查看页面
	if(isIE.equals("false") && !isNewObject && !webwps && !yozoOffice) isEdit = false;
    new weaver.general.BaseBean().writeLog("docid================================" + docid );
    new weaver.general.BaseBean().writeLog("imagefileId================================" + imagefileId );
    new weaver.general.BaseBean().writeLog("isEdit================================" + isEdit );
    // 附件版本ID
    if(docid < 0 && imagefileId < 0 && !isEdit)
    {
        response.sendRedirect("/wui/common/page/sysRemind.jsp?labelid=27969") ;
        return ;
    }
    
    
    if(docid <= 0 && imagefileId > 0){
    	RecordSet rs = new RecordSet();
    	rs.executeQuery("select docid from DocImageFile where imagefileid=" + imagefileId + (versionId > 0 ? (" and versionid=" + versionId) : ""));
    	if(rs.next()){
    		docid = rs.getInt("docid");
    	}
    	if(docid < 0){
    		response.sendRedirect("/notice/noright.jsp") ;
    	    return ;
    	}
    }



    
    String useNew = Util.null2String(request.getParameter("useNew")); //是否使用新的权限判断
    useNew = "1";
    Map<String,String> rightParams = new HashMap<String,String>(); 
    rightParams.put("useNew",useNew);
    
    boolean canEdit = false;
    DocViewPermission dvps = new DocViewPermission();
    
  	//其他模块参数集
    String moudleParams = dvps.getMoudleParams(request);
    Map<String,Boolean> levelMap = dvps.getShareLevel(docid,user,false);
    if(!levelMap.get(DocViewPermission.READ)){ //知识没有权限,判断是否是其他模板
    	levelMap.put(DocViewPermission.READ,dvps.hasRightFromOtherMould(docid,user,request));
    }

    //如果非IE
    boolean canIWebOffice = true;
    if((agent.contains("Firefox")||agent.contains(" Chrome")||agent.contains("Safari") )|| agent.contains("Edge")){
    	canIWebOffice = false;
    }
    //国产中间件
	if(isNewObject || webwps || yozoOffice){
		canIWebOffice = true;
	}

    if(isEdit){
    	
    	
    	if(docid > 0){  //编辑
	    	RecordSet rs = new RecordSet();
    		rs.executeQuery("select doctype,docextendname from DocDetail where id=" + docid);
        	if(rs.next()){
        		String doctype = rs.getString("doctype");
       			String docextendname = "." + rs.getString("docextendname");
        		if("2".equals(doctype)){

        		}else{
        			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") ;
	    	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") ;
    	}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") ;
    	    	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,user.getLanguage())%><%=SystemEnv.getHtmlLabelName(19986,user.getLanguage())%>")) {
					location="<%=linkNewestDoc%>";
		        }else{
					location="/notice/noright.jsp";
				}
    		</script>
    		</head>
    		<body></body>
    		</html>
    		<%
    	}
    	return;
	}
    
    Date d1 = new Date();
    time0 = d1.getTime() - d0.getTime();
    
    
    // 标题
    String docsubject = ""; //新建office类型
    //最后修改人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 doceditionid = -1;
    //最新版本id
    int newestid = -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;  //单附件打开的附件大小
    boolean isAutoExtendInfo = false;  //有附件时展开文档附件属性

	boolean showByHtml = false;  //是否是html模式展示
	String convertFile = "";  //转换文件  空-不转换,html-转成html,pdf-转成pdf
    
    
	boolean canPrint = dvps.getPrint(docid,user,levelMap,null);
	boolean canDownload = levelMap.get(DocViewPermission.DOWNLOAD);
    //选择显示模版的ID
    String selectedpubmould = Util.null2String(request.getParameter("selectedpubmould")); 
    
    if(isEdit){
    	
    }else if(imagefileId > 0){
    	
    }else{
    	DocLogService docLogService = new DocLogService();
    	String ipAddress = request.getRemoteAddr();
    	//docLogService.addReadLog(docid,user,ipAddress);
    	
	    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("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);
		    doceditionid = Util.getIntValue(data.get("doceditionid").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(),"");
	    }

	    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){
	    	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 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");
		            	}
		            	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") && "1".equals(scdpc.getVisible())){
	        		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();

	    		int languageid = user.getLanguage();
	        	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>"));
	        	hr.put("DOC_Content",Util.null2String(docContent));

	        	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)));
	        	}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_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_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(!isEdit && (doctype == 2  || isOpenAcc || imagefileId > 0))
	    {
	        // 附件ID
	        String imageFileid = "";
	        // 模板ID
	        String mTemplate = "";
	        // 附件名称
	    	String imageFileName="";
	        // 附件类型
	    	String fileType="";
	        // 操作用户
	    	String mUserName = user == null ? "" : user.getLastname();
	        // 编辑状态
	        String editType = "0";
	        // 附件类型标识
	    	int docFileType = 0;
	        // 附件大小
	        int filesize = 0;
	        // 是否文件过大
	        boolean isToLarge = false;
	        //最大文件大小
	        int maxSize = 20*1024*1024;
	        //最大excle大小
	        int maxExcleSize = 15*1024*1024;


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

			 if(imagefileId > 0){
	        	 sql = "select a.imagefileid,a.imagefilename,a.docfiletype,a.versionId,b.filesize 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);
	        	}
	        	 imageFileid = imagefileId + "";
	        	 imagefilename = imageFileName;
	        }else if(doctype == 2){  // office文件
		        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.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);
		        }
		        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);
	        }

	        String extname = imageFileName.indexOf(".") > -1 ? imageFileName.substring(imageFileName.lastIndexOf(".")+ 1) : "";
	        extname = extname.toLowerCase();

	        if(extname.equals("pdf")){
            	docContent = "<iframe src=\"/docs/pdfview/web/pdfViewer.jsp?canPrint="+canPrint+"&canDownload="+canDownload+"&pdfimagefileid="+imageFileid+"\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
            }else if(extname.equals("jpg") || extname.equals("jpeg") || extname.equals("png") || extname.equals("gif")){
				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 + "'/></td></tr></table>";
			}else if(!canIWebOffice){
	            //是否开启PDF转换
	            boolean isUsePDFViewer = ConvertPDFUtil.isUsePDFViewer();
	           	// 采用转换PDF预览
	            if(isUsePDFViewer &&
	            		(extname.equals("doc") ||
	            		extname.equals("docx") ||
	            		extname.equals("xls") ||
	            		extname.equals("xlsx") ||
	            		extname.equals("ppt") ||
	            		extname.equals("pptx") ||
	            		extname.equals("wps") ||
	            		extname.equals("txt") ||
	            		extname.equals("sql") ||
	            		extname.equals("json") ||
	            		extname.equals("js") ||
	            		extname.equals("css") ||
	            		extname.equals("log")
	            		))
	            {

	                int pdffileid = -1;
	                sql = "select pdfimagefileid from pdf_imagefile where imagefileid = " + imageFileid;
					rs.executeSql(sql);
					if(rs.next()){
					    pdffileid = Util.getIntValue(rs.getString("pdfimagefileid"),0);
					}
					else
				    {
						if((extname.equals("xlsx") || extname.equals("xls")) && filesize > maxExcleSize){
							isToLarge = true;
						}else if(filesize > maxSize){
							isToLarge = true;
						}

						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(pdffileid > 0){
						docContent = "<iframe src=\"/docs/pdfview/web/pdfViewer.jsp?canPrint="+canPrint+"&canDownload=" + canDownload + moudleParams + "&pdfimagefileid="+pdffileid+"\" 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\" style=\"display: block;width: 100%;height: 100%; border:0\"></iframe>";
	            }else{
	            	//不支持的格式
	            	String sysremindurl="/wui/common/page/sysRemind.jsp?labelid=129757";
	            	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>";

	            }
	        }
	        // IE 32 内核,直接加载控件
	        else
	        {
	        	mTemplate = selectedpubmouldid + "";
	            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";
	            }
	            if(!mFileType.isEmpty()){

					if(yozoOffice){
						docContent = "<iframe id='webOffice' src='/spa/odoc/yozoOffice/yozoOffice_iframecontent.jsp' style='display: block;width: 100%;height: 100%; border:0;z-index:-10;'></iframe>";
					}else if(webwps){
						docContent = "<iframe id='webOffice' src='/spa/odoc/webwps/webwps_iframecontent.jsp' style='display: block;width: 100%;height: 100%; border:0;z-index:-10;'></iframe>";
                    }else if(isNewObject){
                        docContent = "<iframe id='webOffice' src='/spa/odoc/iwebofficechina/OpenAndSave/OpenAndSave_Word3.jsp?isEdit=false&onRequestDoc=true&mRecordID="+versionId +"_"+docid+"&mTemplate=" + mTemplate +"&mFileName=" + imageFileName+"&FileType=" + officeType +"&mFileType=" + officeType +"&mEditType=" + mEditType + moudleParams +"' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
                    }else{
						docContent = "<iframe id='webOffice' src='/spa/odoc/office_odoc_0309.jsp?isEdit=false&onRequestDoc=true&mRecordID="+versionId +"_"+docid+"&mTemplate=" + mTemplate +"&mFileName=" + imageFileName+"&FileType=" + officeType +"&mFileType=" + officeType +"&mEditType=" + mEditType + moudleParams + "' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
                    }

	            }else{
	            	//不支持的格式
	            	String sysremindurl="/wui/common/page/sysRemind.jsp?labelid=129757";
	            	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>";

	            } 
	       }
	    }

				//文件后缀名
		String suffix = "";

	    //新建、编辑office
	    if(isEdit && isEditOffice){
	    	 // 模板ID
	        String mTemplate = "";
	        // 附件名称
	    	String imageFileName="";
	        // 编辑状态
	        String editType = "1";
	        //文档类型
	        String mFileType = "";
	        
	        RecordSet rs = 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);
	        	if(!rs.next()){
	        		response.sendRedirect("/notice/noright.jsp") ;	
	        		return ;
	        	}
	        	int docFileType = rs.getInt("docfiletype");
	        	imageFileName = rs.getString("imagefilename");
	        	versionId = rs.getInt("versionId");
				imagefileId = rs.getInt("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 == 5){
					mFileType = ".ppt";
				} else if(docFileType == 6){
					mFileType = ".wps";
				} else if(docFileType == 9){
					mFileType = ".pptx";
				}
				suffix = mFileType;
	        }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;//8: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(yozoOffice) {
				docContent = "<iframe id='webOffice' src='/spa/odoc/yozoOffice/yozoOffice_iframecontent.jsp' style='display: block;width: 100%;height: 100%; border:0;z-index:-10;'></iframe>";
			}else if(webwps){
				docContent = "<iframe id='webOffice' src='/spa/odoc/webwps/webwps_iframecontent.jsp' style='display: block;width: 100%;height: 100%; border:0;z-index:-10;'></iframe>";
			}else if(isNewObject){
				docContent = "<iframe id='webOffice' src='/spa/odoc/iwebofficechina/OpenAndSave/OpenAndSave_Word3.jsp?isEdit=true&onRequestDoc=true&mRecordID="+versionId +"_"+docid+"&mTemplate=" + mTemplate +"&mFileName=" + imageFileName +"&FileType=" + officeType+"&mFileType=" + officeType +"&mEditType=" + mEditType + moudleParams + "' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
	        }else{
				docContent = "<iframe id='webOffice' src='/spa/odoc/office_odoc_0309.jsp?isEdit=true&onRequestDoc=true&mRecordID="+versionId +"_"+docid+"&mTemplate=" + mTemplate +"&mFileName=" + imageFileName +"&FileType=" + officeType+"&mFileType=" + officeType +"&mEditType=" + mEditType + moudleParams + "' style='display: block;width: 100%;height: 100%; border:0'></iframe>";
			}
        }
	    
	    
	    if(showByHtml){
		    if(docContent.contains("</body>")){
		    	docContent = docContent.replace("<body","<div ").replace("</body>","</div>");
		    }
		    docContent = "<div id=\"weaDocDetailHtmlContent\" style=\"height:100%\">" + docContent + "</div>";
		    
		    Pattern p = Pattern.compile("<link\\s[^>]+\\s?\\/>");
	        Matcher m = p.matcher(docContent);
	       
	        while(m.find()){
	            String link = m.group(0);
	            docContent = docContent.replace(link, "");
	        } 
	    }
	//    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";
    		}
		}

		int languageId = user.getLanguage();


%>
<!--<!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>

	<%@ include file="/docs/docs/PDF417ManagerConf.jsp" %>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
		<meta name="description" content="">
		<meta name="author" content="">
		<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="./docutils4Object.js"></script>

		<script>
			var hasUsedTemplet = '0';
			var noSavePDF = "";
			var versionId = "";
		</script>
		<%
		String mClientName=BaseBean.getPropValue("weaver_obj","iWebOfficeClientName");
		if(mClientName==null||mClientName.trim().equals("")){
			mClientName="iWebOffice2003.ocx#version=6,6,0,0";
		}
		String mClassId=BaseBean.getPropValue("weaver_obj","iWebOfficeClassId");
		if(mClassId==null||mClassId.trim().equals("")){
			mClassId="clsid:23739A7E-5741-4D1C-88D5-D50B18F7C347";
		}

		String isHandWriteForIWebOffice2009=BaseBean.getPropValue("weaver_obj","isHandWriteForIWebOffice2009");
		boolean isIWebOffice2006 = (mClientName.indexOf("iWebOffice2006")>-1||mClientName.indexOf("iWebOffice2009")>-1)?true:false;
		boolean isIWebOffice2003 = (mClientName.indexOf("iWebOffice2003")>-1)?true:false;
		String canPostil = "";
		if(isIWebOffice2006 == true){
			canPostil = ",0";
		}
		String isNoComment="";
		if(isIWebOffice2006){
			isNoComment="1".equals(isHandWriteForIWebOffice2009)?"false":"true";
		}

		int editMouldId = Util.getIntValue(request.getParameter("editMouldId"),-1);
		int showMouldId = Util.getIntValue(request.getParameter("showMouldId"),-1);
		//正文ImageFileId
		int fileId = 0;

		String bookmarkJson = "";
		//获取套红书签对应关系
		if(isUseTempletNode){
			JSONObject json = new JSONObject();
			RecordSet rs =  new RecordSet();
			rs.executeQuery("select b.name,a.bookMarkValue from DocMouldBookMark a,MouldBookMark b where" +
					" a.bookMarkId=b.id and a.docid=? and a.mouldId=?", docid,showMouldId);
			while(rs.next()){
				String key = rs.getString("name");
				String value = rs.getString("bookMarkValue");
				if(!"".equals(key) && !"".equals(value)){
					json.put(key,value);
				}
			}
			bookmarkJson = json.toJSONString();

			rs.executeQuery("select imagefileId,imagefilename from docimagefile where docid=? and  ( isextfile is null or isextfile<>1) order by imagefileid desc",docid);
			if(rs.next()){
				fileId = rs.getInt("imagefileId");
			}
		}

		String ifVersion= "";
		RecordSet RecordSet = new RecordSet();
		RecordSet.executeQuery("select ifVersion from workflow_base where id="+workflowid);
		if(RecordSet.next()){
			ifVersion = Util.null2String(RecordSet.getString("ifVersion"));
		}
		//正文转PDF相关内容
		boolean showSignatureAPI;
		boolean isSavePDF;
		boolean isSaveDecryptPDF;
		List attachmentList;
		int operationtype;
		Map  texttoPDFMap=TexttoPDFManager.getTexttoPDFMap(requestid, workflowid, nodeid,docid);
		showSignatureAPI="1".equals((String)texttoPDFMap.get("showSignatureAPI"))?true:false;
		isSavePDF="1".equals((String)texttoPDFMap.get("isSavePDF"))?true:false;
		isSaveDecryptPDF="1".equals((String)texttoPDFMap.get("isSaveDecryptPDF"))?true:false;
		attachmentList=(List)texttoPDFMap.get("attachmentList");
		operationtype=Util.getIntValue((String)texttoPDFMap.get("operationtype"),0);
		/* 子目录信息 START */
		//子目录信息
		RecordSet.executeProc("Doc_SecCategory_SelectByID",seccategory+"");
		RecordSet.next();
		String categoryname=Util.toScreenToEdit(RecordSet.getString("categoryname"),languageId);
		String subcategoryid=Util.null2String(""+RecordSet.getString("subcategoryid"));
		//String docmouldid=Util.null2String(""+RecordSet.getString("docmouldid"));
		String publishable=Util.null2String(""+RecordSet.getString("publishable"));
		String replyable=Util.null2String(""+RecordSet.getString("replyable"));
		String shareable=Util.null2String(""+RecordSet.getString("shareable"));
		String cusertype=Util.null2String(""+RecordSet.getString("cusertype"));
		cusertype = cusertype.trim();
		String cuserseclevel=Util.null2String(""+RecordSet.getString("cuserseclevel"));
		if(cuserseclevel.equals("255")) cuserseclevel="0";
		String cdepartmentid1=Util.null2String(""+RecordSet.getString("cdepartmentid1"));
		String cdepseclevel1=Util.null2String(""+RecordSet.getString("cdepseclevel1"));
		if(cdepseclevel1.equals("255")) cdepseclevel1="0";
		String cdepartmentid2=Util.null2String(""+RecordSet.getString("cdepartmentid2"));
		String cdepseclevel2=Util.null2String(""+RecordSet.getString("cdepseclevel2"));
		if(cdepseclevel2.equals("255")) cdepseclevel2="0";
		String croleid1=Util.null2String(""+RecordSet.getString("croleid1"));
		String crolelevel1=Util.null2String(""+RecordSet.getString("crolelevel1"));
		String croleid2=Util.null2String(""+RecordSet.getString("croleid2"));
		String crolelevel2=Util.null2String(""+RecordSet.getString("crolelevel2"));
		String croleid3=Util.null2String(""+RecordSet.getString("croleid3"));
		String crolelevel3=Util.null2String(""+RecordSet.getString("crolelevel3"));
		String approvewfid=RecordSet.getString("approveworkflowid");
		String needapprovecheck="";
		if(approvewfid.equals(""))  approvewfid="0";
		if(approvewfid.equals("0"))
			needapprovecheck="0";
		else
			needapprovecheck="1";

		String readoptercanprint = Util.null2String(""+RecordSet.getString("readoptercanprint"));

		/*现在把附件的添加从由文档管理员确定改成了由用户自定义的方式.*/
		// String hasaccessory =Util.toScreen(RecordSet.getString("hasaccessory"),languageId);
		// int accessorynum = Util.getIntValue(RecordSet.getString("accessorynum"),languageId);
		String hasasset=Util.toScreen(RecordSet.getString("hasasset"),languageId);
		String assetlabel=Util.toScreen(RecordSet.getString("assetlabel"),languageId);
		String hasitems =Util.toScreen(RecordSet.getString("hasitems"),languageId);
		String itemlabel =Util.toScreenToEdit(RecordSet.getString("itemlabel"),languageId);
		String hashrmres =Util.toScreen(RecordSet.getString("hashrmres"),languageId);
		String hrmreslabel =Util.toScreenToEdit(RecordSet.getString("hrmreslabel"),languageId);
		String hascrm =Util.toScreen(RecordSet.getString("hascrm"),languageId);
		String crmlabel =Util.toScreenToEdit(RecordSet.getString("crmlabel"),languageId);
		String hasproject =Util.toScreen(RecordSet.getString("hasproject"),languageId);
		String projectlabel =Util.toScreenToEdit(RecordSet.getString("projectlabel"),languageId);
		String hasfinance =Util.toScreen(RecordSet.getString("hasfinance"),languageId);
		String financelabel =Util.toScreenToEdit(RecordSet.getString("financelabel"),languageId);
		String approvercanedit=Util.toScreen(RecordSet.getString("approvercanedit"),languageId);

		int maxOfficeDocFileSize = Util.getIntValue(RecordSet.getString("maxOfficeDocFileSize"),8);

		boolean isEditionOpen = SecCategoryComInfo.isEditionOpen(seccategory);

		//打印申请
		boolean canPrintApply=false;
		String isagentOfprintApply="0";
		String isPrintControl=Util.null2String(RecordSet.getString("isPrintControl"));

		/* 子目录信息 END */
		/* 判断打印控制 START*/
		boolean canDoPrintByApply=false;
		boolean canDoPrintByDocDetail=false;
		boolean hasPrintNode=false;
		boolean isPrintNode=false;
		if(isPrintControl.equals("1")){
			//判断是否已经有申请成功的打印份数
			StringBuffer canDoPrintByApplySb=new StringBuffer();
			canDoPrintByApplySb.append(" select 1   ")
					.append(" from workflow_requestbase a,Bill_DocPrintApply b ")
					.append(" where a.requestId=b.requestid ")
					.append("   and a.currentNodeType='3' ")
					.append("   and b.resourceId=").append(user.getUID())
					.append("   and b.relatedDocId=").append(docid)
					.append("   and printNum>hasPrintNum ")
			;
			RecordSet.executeSql(canDoPrintByApplySb.toString());
			if(RecordSet.next()){
				canDoPrintByApply=true;
				canPrint = true;
			}
			//判断是否有默认的打印份数
			RecordSet.executeSql("select 1 from DocDetail where id="+docid+" and canPrintedNum>hasPrintedNum");
			if(RecordSet.next()){
				canDoPrintByDocDetail=true;
			}
			if(canDoPrintByApply || canDoPrintByDocDetail){
				canPrint = true;
			}else{
				canPrint = false;
			}
		}
		String nodeName = "";
		RecordSet.executeSql("select nodeName from workflow_nodebase where id="+nodeid);
		if(RecordSet.next()){
			nodeName = Util.null2String(RecordSet.getString("nodeName"));
		}
		/* 判断打印控制 END*/
		RecordSet.writeLog("--------index_odocadd.jsp-----docid"+docid);
		//新建正文
		if(docid <= 0){
			%>

			<jsp:include page="/spa/odoc/index_odocadd.jsp">

				<jsp:param name="docid" value="<%=docid%>" />
				<jsp:param name="isIWebOffice2006" value="<%=(isIWebOffice2006?1:0)%>" />
				<jsp:param name="requestid" value="<%=requestid%>" />
				<jsp:param name="requestname" value="<%=requestname%>" />
				<jsp:param name="docstatus" value="<%=docstatus%>" />
				<jsp:param name="languageId" value="<%=languageId%>" />
				<jsp:param name="isEdit" value="<%=isEdit%>" />
				<jsp:param name="editMouldId" value="<%=editMouldId%>" />
				<jsp:param name="workflowid" value="<%=workflowid%>" />
				<jsp:param name="requestid" value="<%=requestid%>" />
				<jsp:param name="secid" value="<%=secid%>" />
				<jsp:param name="requestname" value="<%=requestname%>" />
				<jsp:param name="secFieldid" value="<%=secFieldid%>" />
				<jsp:param name="isNewObject" value="<%=isNewObject%>" />
				<jsp:param name="webwps" value="<%=webwps%>" />
				<jsp:param name="yozoOffice" value="<%=yozoOffice%>" />

			</jsp:include>

			<%
		}else if(isEdit){%>

			<jsp:include page="/spa/odoc/index_odocedit.jsp">
				<jsp:param name="docid" value="<%=docid%>" />
				<jsp:param name="isIWebOffice2006" value="<%=(isIWebOffice2006?1:0)%>" />
				<jsp:param name="requestid" value="<%=requestid%>" />
				<jsp:param name="docstatus" value="<%=docstatus%>" />
				<jsp:param name="languageId" value="<%=languageId%>" />
				<jsp:param name="isEdit" value="<%=isEdit%>" />
				<jsp:param name="editMouldId" value="<%=editMouldId%>" />
				<jsp:param name="workflowid" value="<%=workflowid%>" />
				<jsp:param name="requestid" value="<%=requestid%>" />
				<jsp:param name="secid" value="<%=secid%>" />
				<jsp:param name="imagefileId" value="<%=imagefileId%>" />
				<jsp:param name="requestname" value="<%=requestname%>" />
				<jsp:param name="secFieldid" value="<%=secFieldid%>" />
				<jsp:param name="canPrint" value="<%=canPrint%>" />
				<jsp:param name="canDownload" value="<%=canDownload%>" />
				<jsp:param name="isNewObject" value="<%=isNewObject%>" />
				<jsp:param name="showMouldId" value="<%=showMouldId%>" />
				<jsp:param name="webwps" value="<%=webwps%>" />
				<jsp:param name="yozoOffice" value="<%=yozoOffice%>" />

			</jsp:include>
			<%
		}else{%>
			<jsp:include page="/spa/odoc/index_odocdsp.jsp">
				<jsp:param name="docid" value="<%=docid%>" />
				<jsp:param name="isIWebOffice2006" value="<%=(isIWebOffice2006?1:0)%>" />
				<jsp:param name="requestid" value="<%=requestid%>" />
				<jsp:param name="docstatus" value="<%=docstatus%>" />
				<jsp:param name="languageId" value="<%=languageId%>" />
				<jsp:param name="isEdit" value="<%=isEdit%>" />
				<jsp:param name="editMouldId" value="<%=editMouldId%>" />
				<jsp:param name="workflowid" value="<%=workflowid%>" />
				<jsp:param name="requestid" value="<%=requestid%>" />
				<jsp:param name="secid" value="<%=secid%>" />
				<jsp:param name="requestname" value="<%=requestname%>" />
				<jsp:param name="canPrint" value="<%=canPrint%>" />
				<jsp:param name="canDownload" value="<%=canDownload%>" />
				<jsp:param name="isNewObject" value="<%=isNewObject%>" />
				<jsp:param name="showMouldId" value="<%=showMouldId%>" />
				<jsp:param name="webwps" value="<%=webwps%>" />
				<jsp:param name="yozoOffice" value="<%=yozoOffice%>" />

			</jsp:include>
		<% }%>
			    
			    
		<script>
		
			/**分享*/
			function onDocShare(){
				var message='[{"shareid":<%=docid%>,"sharetitle":"<%= docsubject %>","sharetype":"doc","objectname":"FW:CustomShareMsg"}]';
				socialshareToEmessage(message);
			}
			/**调用子层office保存*/
			function saveDocumentForFlowdoc(){
				try{
					var obj = document.getElementById("webOffice").contentWindow.SaveDocument();
					if(obj.off_status == 0){
						obj.msg = "保存失败!";
					}
					return obj;
				}catch(e){
					return {off_status : 1};
				}
			}
			/**子层office调用保存事件是,保存office*/
			function __saveDocument(){
				var obj = document.getElementById("webOffice").contentWindow.SaveDocument();
			}
			/**调用子层office保存草稿*/
			function saveDocumentAsDraft(){
				return saveDocument();
			}
			/**子层office调用保存草稿事件是,保存office*/
			function __saveDocumentAsDraft(){
				
			}
			
			function changeOfficeMould(mouldid){
				//mTemplate
				
				try{
					var _src = WebOfficeObj.src;
					_src = _src.replace(/&mTemplate=-?\d*/g,"&mTemplate=" + mouldid);
					WebOfficeObj.src = _src;
				}catch(e){}
				
			}

			
			//异步加载完附件之后
			function afterConvertFile (data){
				if(!data)
					return;
				var _src = "";
				if(data.status == "1"){
					if("<%=convertFile%>" == "pdf"){
						_src = "/docs/pdfview/web/pdfViewer.jsp?canPrint=<%=canPrint%>&canDownload=<%=canDownload%><%=moudleParams%>&pdfimagefileid="+data.convertId;
					}else if("<%=convertFile%>" == "html"){
						_src = "/weaver/weaver.file.FileDownload?fileid="+data.convertId+ "<%=moudleParams%>" ;
					}
				} 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;
				}	
				document.getElementById("officeShow").src = _src;
			}
			
			
			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);
			}
		</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-new-top-req-main{
		  height:38px !important;
	  }
    </style>
	</head>
		<body id="mybody">
		
		<input type="hidden" id="isOffice" value="<%=isEditOffice ? 1 : 0%>"/>
		<input type="hidden" name="docid" value="<%=docid %>"/>
		
		
		
										
	<div id="container" style="height:100%;">
										</div>
		<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.__hasNewestWarm = "<%=ishistory == 1 ? 1 : 0%>";	//是否给出有最新文档的提示
		window.__linkNewestDoc = "<%=linkNewestDoc%>";		//跳转到最新版本文档的链接
		if("<%=convertFile%>" != ""){
			window.__convertFile = "convertFile=<%=convertFile%>&fileid=<%=imagefileId%>&docid=<%=docid%>&versionId=<%=versionId%>";		//是否需要异步转换文档
		}
		
		if(jQuery("#frame1").length > 0){
			
		}else{
			jQuery("table[id='content']").show();
		}
		
		jQuery(document).ready(function(){
            parent.jQuery(".req-workflow-odoc").height(parent.jQuery(".wf-req-odoc").height());
            //不修改人力资源链接的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");
					}
				}
			});
		});
      window.__docsubject = '<%=docsubject.replace("'","\\'")%>';
        //window.__preTitle = $('.wea-new-top-req-title-text').html();// 应该没用了,就先去掉好了 by caoyun 20180830
        window.__preContent = $('#docContentPre').html();
        $('#docContentPre').remove();
	</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'
      );
      jQuery.browser.msie && parseInt(jQuery.browser.version, 10) === 10 &&
        document.write('<div><script src="/cloudstore/resource/pc/polyfill/polyfill.min.js"><\/script></div>');
    </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="/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="/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/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>
		<script type="text/javascript" src="/js/odoc/common/DocUtil_e9.js"></script>
		
<script type="text/javascript">
    var js_docFieldId = '<%=docFieldId%>';
    var js_docNameField = '<%=docNameField%>';
// 返回表单页面
function backToForm() {
	parent.WfForm.switchTab('form');
}


function onSave(){
    <%if(!isNewObject && !webwps && !yozoOffice){%>
   		 var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
    <%}
	//新建时
    if(docid <= 0){
		Map readOnlyMap = request.getParameterMap();
		String UrlParam = "";
		//遍历map中的键 
		Iterator<Map.Entry<String, String[]>> entries = readOnlyMap.entrySet().iterator(); 
		JSONObject paramMap = new JSONObject();
		while (entries.hasNext()) { 
			Map.Entry<String, String[]> entry = entries.next(); 
			if(entry.getKey() != null && !entry.getKey().equals("")){
				String requestValue = "";
				if(entry.getValue().length==1){  
					requestValue = entry.getValue()[0];
		        } else {  
		            String[] values = entry.getValue();  
		            for(int i=0; i<values.length; i++){  
		            	requestValue = values[i] + ",";  
		            }  
		            requestValue = requestValue.substring(0, requestValue.length()-1);  
		        }
				if(!UrlParam.equals("")) UrlParam += "&";
				UrlParam += entry.getKey() + "=" + requestValue;
				String url = requestValue.replaceAll("%(?![0-9a-fA-F]{2})", "%25");  
				String urlStr = URLEncoder.encode(url, "UTF-8"); 
				paramMap.put(entry.getKey(),urlStr);
			}
		}
		paramMap.put(com.api.doc.detail.util.DocParamItem.SEC_CATEGORY.getName(),secid);
		paramMap.put(com.api.doc.detail.service.DocSaveService.DOC_CONTENT,"");
		new BaseBean().writeLog("paramMap==================" + paramMap);
		%>
		var retObj;
		<%if(isNewObject || webwps || yozoOffice){%>
			retObj = createDoc();
    		if(retObj.off_status == 0) return ;
		<%}else{%>
			WebOfficeObj.WebSetMsgByName("FLOWDOCADDPARAM","<%=paramMap.toJSONString().replace("\"","\\\"")%>");
			retObj = document.getElementById("webOffice").contentWindow.SaveDocument();
		<%}%>
		retObj.isAddFlowDoc = true;
    	retObj.workflowid = <%=workflowid%>;
    	if(window.console)console.log('retObj',retObj);
		var docSaveRet = window.__onRightMenuClick('BTN_SUBMIT',1,retObj);
		setTimeout(function(){
            if(window.console)console.log('docSaveRet',docSaveRet);
            if(window.console)console.log('js_docFieldId',js_docFieldId);
            if(window.console)console.log('js_docNameField',js_docNameField);
            if(js_docNameField <= 0) js_docNameField = -1;
            <%if(!isNewObject && !webwps && !yozoOffice){%>
            	WebOfficeObj.WebClose();
            <%}%>
            parent.oDocUtil.setFieldValue(js_docFieldId, retObj.off_docid,js_docNameField);
            backToForm();
            //parent.window.doBeforeSubmit({actiontype:"requestOperation",src:"save"});
            parent.window.WfForm.doSave();
		},3000);

	<%
    }else{
	%>
	    var retObj;
		<%if(isNewObject || webwps || yozoOffice){%>
			retObj = editDoc(<%=ifVersion%>);
			if(retObj.off_status == 0){ return ;}
		<%}else{%>
			retObj = SaveDocumentEdit(<%=ifVersion%>); 
		<%}%>
		window.__onRightMenuClick('BTN_SUBMIT',1,retObj);
		parent.oDocUtil.setFieldValue(js_docFieldId, retObj.off_docid,js_docNameField);
	<%}%>
	var docInfo = parent.WfForm.getOdocConfig();
	if(docInfo.docParam.isUseTempletNode){
		docInfo.docParam.hasUsedTemplet = hasUsedTemplet;
	}
	if(docInfo.docParam.isSignatureNodes){
		docInfo.docParam.hasSignatureSucceed = (totalSignatureCount > 0);
	}
	parent.WfForm.changeOdocConfig(docInfo);
    <%if(!isNewObject && !webwps && !yozoOffice){%>
		WebOfficeObj.saved= true;
	<%}%>
	mybody.onbeforeunload=null;
	//backToForm();
	//parent.window.doBeforeSubmit({actiontype:"requestOperation",src:"save"});
    // parent.WfForm.registerCheckEvent(WfForm.OPER_SAVE, function(callback){
    //     callback(); //继续提交需调用callback,不调用代表阻断
    // });
	
}
mybody.onbeforeunload=null;
function SaveDocumentEdit(isVersion,notInputVDetail){

	var fileSize=document.getElementById("webOffice").contentWindow.getFileSize();

	if(parseFloat(fileSize)>parseFloat(<%=maxOfficeDocFileSize%>)){
		window.top.alert("<%=SystemEnv.getHtmlLabelName(24028,languageId)%>"+fileSize+"M<%=SystemEnv.getHtmlLabelName(24029,languageId)%><%=maxOfficeDocFileSize%>M");
		return false;
	}
	WebOfficeObj.WebSetMsgByName("SAVETYPE","EDIT");
	
	//增加提示信息  开始
	//showPrompt("<%=SystemEnv.getHtmlLabelName(18886,languageId)%>");
	
	//增加提示信息  结束
	//WebOfficeObj.WebSetMsgByName("HASUSEDTEMPLET", document.getElementById("hasUsedTemplet").value);
	
	//WebOfficeObj.FileType=changeFileType(WebOfficeObj.FileType);
	
    var tempFileName="<%=docsubject%>";
	if("" == tempFileName){
		tempFileName = docsubject;
	}
	tempFileName=tempFileName.replace(/\\/g,'\');
	tempFileName=tempFileName.replace(/\//g,'/');
	tempFileName=tempFileName.replace(/:/g,':');
	tempFileName=tempFileName.replace(/\*/g,'×');
	tempFileName=tempFileName.replace(/\?/g,'?');
	tempFileName=tempFileName.replace(/\"/g,'“');
	tempFileName=tempFileName.replace(/</g,'<');
	tempFileName=tempFileName.replace(/>/g,'>');
	tempFileName=tempFileName.replace(/\|/g,'|');
	tempFileName=tempFileName.replace(/\./g,'.');

	tempFileName = tempFileName+WebOfficeObj.FileType;

    WebOfficeObj.FileName=tempFileName;

	<%if(false && isIWebOffice2003&&officeType.equals(".doc")){%>
		try{
			var fileSize=0;
			//WebOfficeObj.WebObject.SaveAs();
			fileSize=WebOfficeObj.WebObject.BuiltinDocumentProperties(22);
			WebOfficeObj.WebSetMsgByName("NEWFS",fileSize);
		}catch(e){
		}
	<%}%>
	
	//套红时保存
	if(isUseTempletNode && hasUsedTemplet!= '1'){
		
		hasUsedTemplet = '1';
		WebOfficeObj.WebSetMsgByName("HASUSEDTEMPLET","1");
		WebOfficeObj.WebSetMsgByName("SAVETYPE","NEWVERSION");
		WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
        var vDetailonLoad="<%=SystemEnv.getHtmlLabelName(23030,user.getLanguage())%>";
        WebOfficeObj.WebSetMsgByName("VERSIONDETAIL", vDetailonLoad);
		var retObj = document.getElementById("webOffice").contentWindow.SaveDocument();
		WebOfficeObj.WebSetMsgByName("NONEWVERSION","FALSE");
		if(retObj.off_status === 1){
            <%
            //另存为PDF
            if(operationtype ==0 && requestid > 0){
            %>
            onSavePDF();
            <%}%>
			setWebObjectSaved();
			window.top.alert("<%=SystemEnv.getHtmlLabelName(18758,user.getLanguage())%>!");
			return {
		    	off_status : 1,
		    	isflowdoc : 1,
		    	docid : WebOfficeObj.RecordID.substring(WebOfficeObj.RecordID.indexOf("_") + 1),
		    	off_docid : WebOfficeObj.RecordID.substring(WebOfficeObj.RecordID.indexOf("_") + 1),
		    	off_versionid : WebOfficeObj.RecordID.substring(0,WebOfficeObj.RecordID.indexOf("_"))
		    };
		} else {
			window.top.alert("<%=SystemEnv.getHtmlLabelName(84544,user.getLanguage())%>!");
		}
	}else{
		
		var vDetail = notInputVDetail ? "<%=SystemEnv.getHtmlLabelName(28121,languageId)%>" : "";
		if(isVersion == 1){
			WebOfficeObj.WebSetMsgByName("HASUSEDTEMPLET", hasUsedTemplet);
            WebOfficeObj.WebSetMsgByName("SAVETYPE","NEWVERSION");
			WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
			vDetail="<%=user.getUsername()%>"+"<%=TimeUtil.getCurrentDateString()%>"+" "+"<%=TimeUtil.getOnlyCurrentTimeString()%>"+"<%=SystemEnv.getHtmlLabelName(18805,languageId)%>"+"<%=nodeName%>"+"<%=SystemEnv.getHtmlLabelName(15586,languageId)%>"+"<%=SystemEnv.getHtmlLabelName(21706,languageId)%>";
		}else{
            WebOfficeObj.WebSetMsgByName("SAVETYPE","EDIT");
			WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
		}
		WebOfficeObj.WebSetMsgByName("VERSIONDETAIL", vDetail);
		if (!WebOfficeObj.WebSave()){
			StatusMsg(WebOfficeObj.Status);
			window.top.alert("<%=SystemEnv.getHtmlLabelName(19007,languageId)%>");
			//增加提示信息  开始
			//hiddenPrompt();
			//增加提示信息  结束

            parent.antd.message.error("<%=SystemEnv.getHtmlLabelName(84544,user.getLanguage())%>");
			return false;
		}else{
			StatusMsg(WebOfficeObj.Status);
			//alert(WebOfficeObj.WebGetMsgByName("CREATEID"));
			//weaver.docId.value=WebOfficeObj.WebGetMsgByName("CREATEID");
			//weaver.docType.value=WebOfficeObj.WebGetMsgByName("DOCTYPE");
			//alert(weaver.docId.value);
			//alert(weaver.docType.value);

			//增加提示信息  开始
			//hiddenPrompt();
			//增加提示信息  结束
			<%
			//另存为PDF
			if(operationtype ==0 && requestid > 0){
			%>
            	onSavePDF();
			<%}%>
			parent.antd.message.success("<%=SystemEnv.getHtmlLabelName(83551,user.getLanguage())%>");
            return {
                off_status : 1,
                isflowdoc : 1,
                docid : WebOfficeObj.RecordID.substring(WebOfficeObj.RecordID.indexOf("_") + 1),
                off_docid : WebOfficeObj.RecordID.substring(WebOfficeObj.RecordID.indexOf("_") + 1),
                off_versionid : WebOfficeObj.RecordID.substring(0,WebOfficeObj.RecordID.indexOf("_"))
            };

		}
	}
}
function saveTHTemplate(){
	onSave();
}
var secFieldid = 'field<%=secFieldid%>';
function selectThTemplate(seccategory,wordmouldid){
	//jQuery("#selectTaohongMouldBtn").trigger("click");
	var selectvalue = parent.WfForm.getFieldValue('field<%=secFieldid%>');
	 var url = "/docs/docs/DocTemplateList.jsp?iseditmould=false&selectvalue="+selectvalue+"&wordmouldid="+wordmouldid+"&workflowid=<%=workflowid%>";
	var dialog = new window.top.Dialog();
	dialog.currentWindow = window;
	dialog.URL = url;
	dialog.callbackfun = afterSelectMould;
	dialog.Title = "<%=SystemEnv.getHtmlLabelName(23039,user.getLanguage())%>";
	dialog.Width = 550 ;
	dialog.Height = 550 ;
	dialog.Drag = true;
	dialog.maxiumnable = true;
	dialog.show();  
	
}

	<%
	Map readOnlyMap = request.getParameterMap();
	String UrlParam = "";
	//遍历map中的键 
	Iterator<Map.Entry<String, String[]>> entries = readOnlyMap.entrySet().iterator(); 
	JSONObject paramMap = new JSONObject();
	while (entries.hasNext()) { 
		Map.Entry<String, String[]> entry = entries.next(); 
		if(entry.getKey() != null && !entry.getKey().equals("")){
			String requestValue = "";
			if(entry.getValue().length==1){  
				requestValue = entry.getValue()[0];
	        } else {  
	            String[] values = entry.getValue();  
	            for(int i=0; i<values.length; i++){  
	            	requestValue = values[i] + ",";  
	            }  
	            requestValue = requestValue.substring(0, requestValue.length()-1);  
	        }
			if(!UrlParam.equals("")) UrlParam += "&";
			UrlParam += entry.getKey() + "=" + requestValue;
			String url = requestValue.replaceAll("%(?![0-9a-fA-F]{2})", "%25");  
			  String urlStr = URLEncoder.encode(url, "UTF-8"); 
			  paramMap.put(entry.getKey(),urlStr);
		}
	}
	%>
<%
RecordSet rs = new RecordSet();
String maxImageFieldId = "";
rs.executeSql("select MIN(imagefileid) from DocImageFile where docid="+docid+" and (isextfile is null or isextfile=0) and (hasusedtemplet='1' or versiondetail='"+SystemEnv.getHtmlLabelName(23030,7)+"')");
if(rs.next()&&Util.getIntValue(rs.getString(1))>0){
	String minImageFieldId=rs.getString(1);
	rs.executeSql("select max(versionid) from DocImageFile where docid="+docid+" and (isextfile is null or isextfile=0) and imagefileid<"+minImageFieldId);
	if(rs.next()&&Util.getIntValue(rs.getString(1))>0){
		maxImageFieldId=rs.getString(1);

	}
}

//获取编辑模板书签
String editMouldBookmarkObj = "";
if(editMouldId > 0){
	
    //Map parpMap = new HashMap();
	paramMap.put("requestId",""+requestid);
	paramMap.put("workflowId",""+workflowid);
	paramMap.put("languageId",""+languageId);
	paramMap.put("editMouldId",""+editMouldId);
	try{
		RequestDocDocAddExt requestDocDocAddExt = new RequestDocDocAddExt();
		List bookmarkList = requestDocDocAddExt.getBookmarkList(paramMap);
		MouldBookMarkEditComInfo mouldBookMarkEditComInfo = new MouldBookMarkEditComInfo();
		int bookmarkid=0;
		String bookmarkvalue=null;
		String bookmarkname=null;
		Map bookmarkMap=null;
		Map<String,String> bookmarkValueMap = new HashMap<String,String>();
		for(int i=0;i<bookmarkList.size();i++){
			bookmarkMap=(Map)bookmarkList.get(i);
			bookmarkid = Util.getIntValue((String)bookmarkMap.get("bookmarkid"),0);
			bookmarkvalue = Util.null2String((String)bookmarkMap.get("bookmarkvalue"));
			bookmarkname = mouldBookMarkEditComInfo.getMouldBookMarkEditName(bookmarkid+"");
			bookmarkValueMap.put(bookmarkname,bookmarkvalue);
		}
		editMouldBookmarkObj = JsonUtils.map2json(bookmarkValueMap);
	}catch (Exception e){
	}
}

%>

//套红取消
function useTempletCancel(){
    <%if(isNewObject || webwps || yozoOffice){%>
    	reTemplateForTH();
	<%}else{%>
		acceptAllRevisions();
		useTemplete(0,"<%=maxImageFieldId%>");
		createBarCode();
	<%}%>

	hasUsedTemplet = '0';
	afterTempleteEditButton(false);
}

//套用编辑模板
function useEditTemplate(){
    var params = new Object();
    params.prop_mouldId = "<%=editMouldId%>";
    params.prop_bookmarkObj = new Object();
    <%if(null != editMouldBookmarkObj && !("").equals(editMouldBookmarkObj)){%>
   		 params.prop_bookmarkObj = <%=editMouldBookmarkObj%>;
    <%}%>
    //替换公文域
    replaceCustomField(params);
}

//选择编辑模板
function selectEditTemplate(mouldid){
    var params = new Object();
    params.prop_type = "editMould";
    params.prop_mouldId = mouldid;
    params.prop_bookmarkObj = new Object();
    <%if(null != editMouldBookmarkObj && !("").equals(editMouldBookmarkObj)){%>
    	params.prop_bookmarkObj = <%=editMouldBookmarkObj%>;
    <%}%>
    //打开新编辑模板并插入公文域内容
    replaceFieldWithMould(params);
}

//套红(iWebofficeChina)
function useTemplateForTH(){
	var params = new Object();
	params.prop_mouldId = "<%=showMouldId%>";
    params.prop_fileId = "<%=fileId%>";
	params.prop_bookmarkObj = new Object();
	<%if(null != bookmarkJson && !("").equals(bookmarkJson)){%>
		params.prop_bookmarkObj = <%=bookmarkJson%>;
	<%}%>
	//替换公文域
	replaceDocField(params);
}

//套红取消
function reTemplateForTH(){
    var params = new Object();
    params.prop_type = "showMould";
	params.prop_mouldId = "<%=showMouldId%>";
    params.prop_bookmarkObj = new Object();
    <%if(null != bookmarkJson && !("").equals(bookmarkJson)){%>
    	params.prop_bookmarkObj = <%=bookmarkJson%>;
    <%}%>
    jQuery.ajax({
        url:"iWebOfficeOperation.jsp",
        type:"POST",
        async:false,
        data:{
            id: "<%=docid%>",
            operation:"reTemplate"
        },
        dataType:"json",
        success:function(msg){
            //获取未套红的文档imagefileId
            params.prop_fileId =  msg.imagefileid;
            //重新套红
            reTemplate(params);
        },
        error:function(){
            alert("套红取消失败");
        }
    });
}


function afterTempleteEditButton(isUseTemplete){
	//设置按钮状态
    var docInfo = parent.WfForm.getOdocConfig();
    var buttonList = docInfo.buttons;
    for(var cnt = 0 ; cnt < buttonList.length; cnt++){
    	
		//套红确认
    	if(buttonList[cnt]["key"] == "saveTHTemplate"){
    		buttonList[cnt]["isshow"] = !isUseTemplete;
    	}
		//保存
    	if(buttonList[cnt]["key"] == "saveTHTemplateNoConfirm"){
    		buttonList[cnt]["isshow"] = isUseTemplete;
    	}
		//套红取消
    	if(buttonList[cnt]["key"] == "useTempletCancel"){
    		buttonList[cnt]["isshow"] = isUseTemplete;
    	}
		//选择其他模板
    	if(buttonList[cnt]["key"] == "selectTemplate"){
    		buttonList[cnt]["isshow"] = !isUseTemplete;
    	}
    }
    parent.WfForm.changeOdocConfig(docInfo);
}
function onSaveNewVersion(notSubmit){
	jQuery.ajax({
			type: "POST",
			url: "/docs/reply/OperDocReply.jsp",
			data: {
			operation: 'workflowremark',
			requestid: <%=requestid%>,
			currentnodeid:<%=nodeid%>
			},
			cache: false,
			async:false,
			dataType: 'json',
			success: function(msg){	
				if("success"==msg.result){
					onSaveNewVersion2(notSubmit);
				}else{
					window.top.alert("<%=SystemEnv.getHtmlLabelName(24338,user.getLanguage())%>");
				}
		}
	});	
}
function onSaveNewVersion2(notSubmit){
	disableBtn();
	setTimeout("entableBtn();",10000);
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
	
	jQuery.ajax({
			type: "POST",
			url: "/docs/docs/DocCheckInOutUtilIframe.jsp",
			data: {
			operation: 'ifCheckOutByCurrentUser',
			docid: <%=docid%>,
			userid:<%=user.getUID()%>
			},
			cache: false,
			async:false,
			dataType: 'json',
			success: function(msg){	
				if(msg.returnValue){
					//if(!checkresult) return checkCanSubmit("onSaveNewVersion",null);

					//checkDocSubject($GetEle("docsubject"),function(){
					//	if($GetEle("namerepeated").value==1){
					//		return;
					//	}
						afterSaveNewValidate();
					//});
				}else{
					top.Dialog.alert("<%=SystemEnv.getHtmlLabelName(26090,user.getLanguage())%>");
					return;
				}
			}
	});	
}
function StatusMsg(mString){
  //StatusBar.innerText=mString;
}

function disableBtn(){
	try{
		document.getElementById("wfbtn_save").disabled=true;
	}catch(e){}
	try{
		document.getElementById("wfbtn_signature1").disabled=true;
	}catch(e){}
	try{
		document.getElementById("BUTTONbtn_save").disabled=true;
	}catch(e){}
	try{
		document.getElementById("BUTTONbtn_draft").disabled=true;
	}catch(e){}
	try{
		document.getElementById("BUTTONbtn_preview").disabled=true;
	}catch(e){}
	try{
		document.getElementById("BUTTONmenuTypeChanger").disabled=true;
	}catch(e){}
	try{
		WebOfficeObj.DisableMenu("<%=SystemEnv.getHtmlLabelName(19718,user.getLanguage())%>(&S)");
	}catch(e){}
	try{
		WebOfficeObj.DisableMenu("<%=SystemEnv.getHtmlLabelName(19719,user.getLanguage())%>");
	}catch(e){}
	try{
		WebOfficeObj.DisableMenu("<%=SystemEnv.getHtmlLabelName(221,user.getLanguage())%>");
	}catch(e){}
	try{
		WebOfficeObj.DisableMenu("<%=SystemEnv.getHtmlLabelName(16386,user.getLanguage())%>");
	}catch(e){}
	try{
		parent.disableTabBtn();
	}catch(e){}
}

function entableBtn(){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	try{
		document.getElementById("wfbtn_save").disabled=false;
	}catch(e){}
	try{
		document.getElementById("wfbtn_signature1").disabled=false;
	}catch(e){}
	try{
		document.getElementById("BUTTONbtn_save").disabled=false;
	}catch(e){}
	try{
		document.getElementById("BUTTONbtn_draft").disabled=false;
	}catch(e){}
	try{
		document.getElementById("BUTTONbtn_preview").disabled=false;
	}catch(e){}
	try{
		document.getElementById("BUTTONmenuTypeChanger").disabled=false;
	}catch(e){}
	try{
		WebOfficeObj.EnableMenu("<%=SystemEnv.getHtmlLabelName(19718,user.getLanguage())%>(&S)");
	}catch(e){}
	try{
		WebOfficeObj.EnableMenu("<%=SystemEnv.getHtmlLabelName(19719,user.getLanguage())%>");
	}catch(e){}
	try{
		WebOfficeObj.EnableMenu("<%=SystemEnv.getHtmlLabelName(221,user.getLanguage())%>");
	}catch(e){}
	try{
		WebOfficeObj.EnableMenu("<%=SystemEnv.getHtmlLabelName(16386,user.getLanguage())%>");
	}catch(e){}
	try{
		parent.enableTabBtn();
	}catch(e){}	
}
function afterSaveNewValidate(){
	//if(check_form(document.weaver,getneedinputitems())&&checkSubjectRepeated()&&checkDocMain()){
		document.weaver.docstatus.value=1;
		document.weaver.operation.value='editsave';
        if(SaveDocumentNewV()){
			mybody.onbeforeunload=null;
			showPrompt("<%=SystemEnv.getHtmlLabelName(18893,user.getLanguage())%>");
			document.weaver.submit();
		}
    //}
}
//
var isflowdoc = 1;
function getDocumentName(){
	return parent.WfForm.getFieldValue('field<%=documentTitleField.equals("-3")?"-1":documentTitleField%>');
}
<%

String signatureType = Util.null2String(Prop.getPropValue("wps_office_signature","wps_office_signature"));

String wps_version=Util.null2String(Prop.getPropValue("wps_office_signature","wps_version"));
%>
//作用:设置活动文档对象
function SetActiveDocument(){
			
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	if(WebOfficeObj.WebObject != null){
		//若为360签章
		if("2" == "<%=signatureType%>"){
			SignatureAPI.SetActiveDocument(WebOfficeObj.WebObject);   //设置WORD对象
		}else{
			SignatureAPI.ActiveDocument=WebOfficeObj.WebObject;   //设置WORD对象
		}
	}
}

/* 接受痕迹 */
function acceptAllRevisions(){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	    try{

		    WebOfficeObj.Template="";
		    if(WebOfficeObj.WebOpen()){
		        WebOfficeObj.WebObject.AcceptAllRevisions(); //接受痕迹

		        WebOfficeObj.WebSetMsgByName("SAVETYPE","NEWVERSION");
		        WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
		        noSavePDF="TRUE";
		        var vDetailonLoad="<%=SystemEnv.getHtmlLabelName(23030,user.getLanguage())%>";
		        WebOfficeObj.WebSetMsgByName("VERSIONDETAIL", vDetailonLoad);
                WebOfficeObj.FileType=changeFileType(WebOfficeObj.FileType);
		        WebOfficeObj.WebSave(<%=isNoComment%>);
		        WebOfficeObj.WebSetMsgByName("NONEWVERSION","FALSE");
		        var tempVersionId=WebOfficeObj.WebGetMsgByName("VERSIONID");
		        if(tempVersionId>=1){
		            versionId=tempVersionId;
		        }
		    }
        }catch(e){
        	if(window.console)console.log("acceptAllRevisions----" ,e);
		}
		
}

/* 套红操作 */
function useTemplete(mouldid,thVersionid){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	if(mouldid == undefined || mouldid <= 0){
		WebOfficeObj.Template="<%=showMouldId%>";
	}else{
		WebOfficeObj.Template=mouldid;
	}
	
	var tempVersionid = "";
	if(thVersionid == undefined || thVersionid <= 0){
		tempVersionid = "<%=(versionId==0?"":versionId+"")%>";
	}else{
		tempVersionid = thVersionid;
	}
	WebOfficeObj.WebSetMsgByName("SHOWDOCMOULDBOOKMARK","1");//载入是否显示“文档模板书签表”数据,这根据“是否来源于流程建文挡”来确定。
    //WebToolsVisible("iSignature",false);
    WebToolsVisibleISignatureFalse();
	WebOfficeObj.WebSetMsgByName("COMMAND","LOADVIEWMOULD");//载入显示模板

	if(WebOfficeObj.WebLoadTemplate()){//如果打开模板成功

		var t_EditType = WebOfficeObj.EditType;
		WebOfficeObj.EditType = "-1,0,0,0,0,0,1<%=canPostil%>";
	    WebOfficeObj.RecordID= tempVersionid + "_<%=docid%>";
		WebOfficeObj.WebLoadBookMarks();//替换书签
	    WebOfficeObj.WebInsertFile();//插入正文
	    WebOfficeObj.RecordID="<%=(versionId==0?"":versionId+"")%>_<%=docid%>";
	}
}


/* 替换编辑模板书签 */
function LoadEditMould(){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	<%
    String editMouldIdAndSecCategoryId = editMouldId + "," + secid;
    if(editMouldId > 0 && secid > 0){%>                
    	MOULDURLPARAM = getFormValueByMould();
        WebOfficeObj.WebSetMsgByName("ISEDITMOULD","TRUE");
        WebOfficeObj.WebSetMsgByName("EDITMOULDID","<%=editMouldId%>");
        WebOfficeObj.WebSetMsgByName("MOULDURLPARAM",JSON.stringify(MOULDURLPARAM));
        WebOfficeObj.WebSetMsgByName("REQUESTID","<%=requestid%>");
        WebOfficeObj.WebSetMsgByName("WORKFLOWID","<%=workflowid%>");
        WebOfficeObj.WebSetMsgByName("LANGUAGEID","<%=languageId%>");
        WebOfficeObj.WebSetMsgByName("SHOWDOCMOULDBOOKMARK","1");//载入是否显示“文档模板书签表”数据,这根据“是否来源于流程建文挡”来确定。
        WebOfficeObj.WebLoadBookMarks();//替换书签
    <%}%> 
}
/* 替换显示模板书签 */
function loadShowMould(){        
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
    MOULDURLPARAM = getFormValueByMould();
    WebOfficeObj.WebSetMsgByName("MOULDURLPARAM",JSON.stringify(MOULDURLPARAM));
    WebOfficeObj.WebSetMsgByName("WORKFLOWID","<%=workflowid%>");
    WebOfficeObj.WebSetMsgByName("SHOWMOULDID","<%=showMouldId%>");
    WebOfficeObj.WebSetMsgByName("SHOWDOCMOULDBOOKMARK","1");//载入是否显示“文档模板书签表”数据,这根据“是否来源于流程建文挡”来确定。
    WebOfficeObj.WebLoadBookMarks();//替换书签
}

/* 根据模板需要的字段,获取页面上的值 */
function getFormValueByMould(){

    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	
    var docInfo = parent.WfForm.getOdocConfig();
    var MOULDURLPARAM = <%=paramMap.toJSONString()%>;
    var needFieldList = docInfo.formFieldList;
    if(window.console)console.log("needFieldList===",needFieldList);
    var addedFieldList = new Array();
    for(var cnt = 0 ; cnt < needFieldList.length; cnt++){
        var needFieldid = needFieldList[cnt];
        if(needFieldid == "-1") continue;
        if(addedFieldList.indexOf(needFieldid) > 0){
            continue;
        }
        addedFieldList.push(needFieldid);
        
        var needFieldvalue = encodeURI(parent.WfForm.getFieldValue("field" + needFieldid));
        if(needFieldid == "-3"){
            needFieldvalue = encodeURI(parent.WfForm.getFieldValue("field-1"));
            MOULDURLPARAM["requestname"] = needFieldvalue;
        }else{
            MOULDURLPARAM["field" + needFieldid] = needFieldvalue;
        }
    
    }
    return MOULDURLPARAM;
}

/* 生成二维码 */
function createBarCode(){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	<%
	//判断是否启用二维条码
	RecordSet.executeSql("select * from Workflow_BarCodeSet where workflowId="+workflowid+" and isUse='1'");
	if(RecordSet.next()){
		String isUseBarCodeThisJsp="1";
		int barCodeSetId=Util.getIntValue(RecordSet.getString("id"),0);
		String measureUnit=Util.null2String(RecordSet.getString("measureUnit"));
		int printRatio = Util.getIntValue(RecordSet.getString("printRatio"),96);
		int minWidth = Util.getIntValue(RecordSet.getString("minWidth"),30);
		int maxWidth = Util.getIntValue(RecordSet.getString("maxWidth"),70);
		int minHeight = Util.getIntValue(RecordSet.getString("minHeight"),10);
		int maxHeight = Util.getIntValue(RecordSet.getString("maxHeight"),25);
		int bestWidth = Util.getIntValue(RecordSet.getString("bestWidth"),50);
		int bestHeight = Util.getIntValue(RecordSet.getString("bestHeight"),20);
	
		if(measureUnit.equals("1")){
			minWidth=(int)(0.5+minWidth*printRatio/25.4);
			maxWidth=(int)(0.5+maxWidth*printRatio/25.4);
			minHeight=(int)(0.5+minHeight*printRatio/25.4);
			maxHeight=(int)(0.5+maxHeight*printRatio/25.4);
			bestWidth=(int)(0.5+bestWidth*printRatio/25.4);
			bestHeight=(int)(0.5+bestHeight*printRatio/25.4);
		}
	
		String PDF417TextValue=WorkflowBarCodeSetManager.getPDF417TextValue(requestid,barCodeSetId,user.getLanguage());
	%>
	    
	    var hasBarCodeLabel=false;
	    var barCodeLabelNum =  WebOfficeObj.WebObject.Bookmarks.Count;
	
		for (var i=1;i<=barCodeLabelNum;i++){
			if(WebOfficeObj.WebObject.Bookmarks.Item(i).Name=="barcode"){
				hasBarCodeLabel=true;
				break;
			}
		}
	
	  if(hasBarCodeLabel){
	
	    weaver.PDF417Manager.CopyRight = "<%=PDF417ManagerCopyRight%>";
	    //设置图片宽度和高度范围,
	    //设置最小和最大均为0,则使用当前图片宽度,高度自动设置
	    var minWidth = <%=minWidth%>;
	    var maxWidth = <%=maxWidth%>;
	    var minHeight = <%=minHeight%>;
	    var maxHeight = <%=maxHeight%>;
	    weaver.PDF417Manager.LimitWidth(minWidth, maxWidth);
	    weaver.PDF417Manager.LimitHeight(minHeight, maxHeight);
	
	    //设置图片宽度,实际宽度将接近且不大于设置值;
	    //设置为0,则使用当前图片宽度,高度自动设置
	    weaver.PDF417Manager.BestWidth = <%=bestWidth%>;
	    weaver.PDF417Manager.BestHeight = <%=bestHeight%>;
	
		var PDF417TextValue="<%=PDF417TextValue%>"; 
	    //设置编码字符串
	    mResult = weaver.PDF417Manager.SetBarCodeString(PDF417TextValue,false);
	
	    if (mResult){
			window.top.alert("<%=SystemEnv.getHtmlLabelName(21471,user.getLanguage())%>");
		}else{
			var codeFileUrl = weaver.PDF417Manager.GetBarCodeFile(".gif");  //获取条码图片数据_路径
		    codeFileUrl=codeFileUrl.replace(/\\\\/g,'\\');
		    codeFileUrl=codeFileUrl.replace(/\\/g,'\\\\');
	
	        WebOfficeObj.WebObject.Application.Selection.GoTo(-1,0,0,"barcode");
			WebOfficeObj.WebObject.Application.Selection.InlineShapes.AddPicture (codeFileUrl);
		}
	  }
	   
	
	<%
	}
	%>
}
//选择模板以后
function afterSelectMould(e,rt,name,params){
		<%if(webwps || yozoOffice){%>
			return selectShowMould(rt.id);
	    <%}%>
        //document.getElementById("selectedpubmouldid").value=rt.id;
		acceptAllRevisions();
		useTemplete(rt.id,"<%=maxImageFieldId%>");
		createBarCode();27
}

//选择其他模板进行套红
function selectShowMould(mouldid){
	if(!mouldid || mouldid <= 0){
		return;
	}
	var params = new Object();
	params.prop_type = "showMould";
	params.prop_mouldId = mouldid;
	jQuery.ajax({
		url:"iWebOfficeOperation.jsp",
		type:"POST",
		async:false,
		data:{
			id: "<%=docid%>",
			operation:"reTemplate"
		},
		dataType:"json",
		success:function(msg){
			//获取未套红的文档imagefileId
			params.prop_fileId =  msg.imagefileid;
		}
	});
	jQuery.ajax({
		url:"iWebOfficeOperation.jsp",
		type:"POST",
		async:false,
		data:{
			id: "<%=docid%>",
			mouldid:mouldid,
			operation:"getBookmarkObj"
		},
		dataType:"json",
		success:function(msg){
			params.prop_bookmarkObj = msg.bookmarkJson;
		}
	});
	//套红
	reTemplate(params);
}


function WebToolsVisibleISignatureFalse(){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
  try{
    WebOfficeObj.WebToolsVisible("iSignature","false");
  }catch(e){}
  try{

  }catch(e){}
}

function setWebObjectSaved(){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	try{
		WebOfficeObj.Saved=true;
	}catch(e){}
}
var __label19716 = "<%=SystemEnv.getHtmlLabelName(19716,languageId)%>"
var __label19006 = "<%=SystemEnv.getHtmlLabelName(19006,languageId)%>";

var secFieldid = '<%=secFieldid%>';
//选择编辑模板
function selectTemplate2(seccategoryid){
	var selectvalue = parent.WfForm.getFieldValue('field<%=secFieldid%>');
	 var url = "/docs/docs/DocTemplateList.jsp?iseditmould=true&selectvalue="+selectvalue+"&wordmouldid="+wordmouldid+"&workflowid=<%=workflowid%>";
	var dialog = new window.top.Dialog();
	dialog.currentWindow = window;
	dialog.URL = url;
	dialog.callbackfun = afterSelectEditMould;
	dialog.Title = "<%=SystemEnv.getHtmlLabelName(23039,user.getLanguage())%>";
	dialog.Width = 550 ;
	dialog.Height = 550 ;
	dialog.Drag = true;
	dialog.maxiumnable = true;
	dialog.show();  
}
//选择编辑模板以后

var wordmouldid = "<%=editMouldId%>";
function afterSelectEditMould(e,rt,name,params){
    if(rt != null){
        try{
            window.onbeforeunload=null;
        }catch(e){
        }
        <%if(webwps || yozoOffice){%>
			return selectEditTemplate(rt.id);
		<%}%>
		var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
		var seccategory = <%=secid%>;


		WebOfficeObj.Template = rt.id;
		WebOfficeObj.WebOpen();
		wordmouldid = rt.id;
		WebOfficeObj.WebSetMsgByName("ISEDITMOULD","TRUE");
		WebOfficeObj.WebSetMsgByName("EDITMOULDID",rt.id);
		var MOULDURLPARAM = getFormValueByMould();
		WebOfficeObj.WebSetMsgByName("MOULDURLPARAM",JSON.stringify(MOULDURLPARAM));
		WebOfficeObj.WebSetMsgByName("REQUESTID","<%=requestid%>");
		WebOfficeObj.WebSetMsgByName("WORKFLOWID","<%=workflowid%>");
		WebOfficeObj.WebSetMsgByName("LANGUAGEID","<%=languageId%>");
		WebOfficeObj.WebSetMsgByName("SHOWDOCMOULDBOOKMARK","1");//载入是否显示“文档模板书签表”数据,这根据“是否来源于流程建文挡”来确定。
		WebOfficeObj.WebLoadBookMarks();//替换书签

	}
}


function OnMenuClick(vIndex,vCaption){
	return document.getElementById("webOffice").contentWindow.OnMenuClick(vIndex,vCaption);
}

function saveTHTemplateNoConfirm(wordmouldid){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	jQuery.ajax({
			type: "POST",
			url: "/docs/reply/OperDocReply.jsp",
			data: {
			operation: 'workflowremark',
			requestid: <%=requestid%>,
			currentnodeid:<%=nodeid%>
			},
			cache: false,
			async:false,
			dataType: 'json',
			success: function(msg){	
				if("success"==msg.result){			
					//btndisabledtrue();
					//setTimeout("btndisabledfalse();",10000);
					if(wordmouldid != null){
						hasUsedTemplet='1';
						<%--
						if(<%=isSignatureNodes%>){
							WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
							noSavePDF="TRUE";	
							if(<%if (!ifVersion.equals("1")) {%> SaveDocument()<%} else {%>SaveDocumentNewV()<%}%>){
								document.getElementById("ClearDocAccessoriesTraceIframe").src="/docs/docs/ClearDocAccessoriesTraceIframe.jsp?operation=useTempletUpdate&docId=<%=docid%>&requestId=<%=requestid%>";
							}
							WebOfficeObj.WebSetMsgByName("NONEWVERSION","FALSE");
						}else{
							//useTemplet();
							WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
							var saveFlag = SaveDocumentOrSaveDocumentNewV();
							WebOfficeObj.WebSetMsgByName("NONEWVERSION","FALSE");
							if(saveFlag){
								alert("<%=SystemEnv.getHtmlLabelNames("18758",user.getLanguage())%>");
							}
						}
                        --%>
						onSave();

					}else{
						alert("<%=SystemEnv.getHtmlLabelName(21252,user.getLanguage())%>");
					}	
				}else{
					alert("<%=SystemEnv.getHtmlLabelName(24338,user.getLanguage())%>");
				}
		}
	});



}
var signatureType = "<%=signatureType%>";
var stSign = 0x00000001;     //电子签章
var stHand = 0x00000002;     //手写签名
var stSign_360 = 0x00000000;  //360电子签章
var stHand_360 = 0x00000001;  //360手写签名
var  ssSucceeded = 0x0000;   //成功
var  ssDocumentLocked    = 0x0003;     //文档已经锁定

var totalSignatureCount = 0;
var signatureCount=0;
//创建签章
function CreateSignature(id){
    var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
  <%if(isIWebOffice2006 == true){%>
	   if(WebOfficeObj.Pages >=1){
		  WebOfficeObj.ShowType="1";								 
	   }
  <%}%>
  SetActiveDocument();   //设置活动文档

    var revisionsCount=0;

    try{
	    revisionsCount=WebOfficeObj.Revisions.Count;
    }catch(e){
    }

    try{
		try{
			SignatureAPI.InitSignatureItems();  //当签章数据发生变化时,请重新执行该方法
		}catch(e){}
		if("1" == signatureType){//WPS混合签章
		    signatureCount = SignatureAPI.iSignatureCount();
		}else if("2" == signatureType){//360签章
			signatureCount = SignatureAPI.AllSignatureCount;
		}else{
		    signatureCount=SignatureAPI.SignatureCount;
		}
    }catch(e){
    }
    if(revisionsCount>0&&signatureCount<=0){
		WebOfficeObj.WebSetMsgByName("NONEWVERSION","TRUE");
		noSavePDF="TRUE";

        WebOfficeObj.WebSetMsgByName("NONEWVERSION","FALSE");	
		if("1" == signatureType){//WPS混合签章
		    SignatureAPI.UnLockDocument();	//解保护
		}else{
			if(SignatureAPI.SelectionState==ssDocumentLocked) {
				SignatureAPI.UnLockDocument();	//解保护
			}
		}
        //在清样稿上加盖公章
        WebOfficeObj.WebObject.AcceptAllRevisions(); //接受痕迹
        hasAcceptAllRevisions="true";
    }

    var t_EditType = WebOfficeObj.EditType;
	WebOfficeObj.EditType = "-1,0,0,0,0,0,1<%=canPostil%>";

    var t_TrackRevisions = false;
	try{
		t_TrackRevisions = WebOfficeObj.WebObject.TrackRevisions;
	    WebOfficeObj.WebObject.TrackRevisions = false;  //取消修订
	}catch(e){}

  //如果为电子签章
  if(id==0){
	   		//WPS混合签章
	   if("1" == signatureType){
			SignatureAPI.ActiveDocument=WebOfficeObj.WebObject;
			try{
			  SignatureAPI.CreateSignature(stSign);	//建立电子签章			
			}catch(e){
				try{
					SignatureAPI.EndLoadSignature();          //释放调用资源             
					SignatureAPI.ReleaseActiveDocument();
				}catch(e){}		
			}
	
		}else if("2" == signatureType){//360签章
		   	try{
				SignatureAPI.SetSignatureParam("SealPosLock","true",1); 	//锁定签章不移动
				SignatureAPI.Action_Do(stSign_360);	//建立电子签章		
			}catch(e){
			}		
		} else{//Office签章
			if(SignatureAPI.SelectionState==ssSucceeded) {			
				try{
					SignatureAPI.CreateSignature(stSign);	//建立电子签章
				}catch(e){
					try{
						SignatureAPI.ActionAddinButton(stSign);	//建立电子签章
						SignatureAPI.ReleaseActiveDocument();
					}catch(e){}		
				}
			}else if(SignatureAPI.SelectionState==ssDocumentLocked) {
				 SignatureAPI.UnLockDocument();	//解保护
				try{
					SignatureAPI.CreateSignature(stSign);	//建立电子签章
				}catch(e){
					try{
						SignatureAPI.ActionAddinButton(stSign);	//建立电子签章
						SignatureAPI.ReleaseActiveDocument();
					}catch(e){}		
				}
			}
		}
    }
	
	//如果为手写签名
	if(id==1){
		if("2" == signatureType){
			try{
				SignatureAPI.Action_Do(stHand_360); 
			}catch(e){}
		}else{
			if(SignatureAPI.SelectionState==ssSucceeded){
				SignatureAPI.CreateSignature(stHand);  //建立手写签名
			}
		}
	}
	
	try{
		WebOfficeObj.WebObject.TrackRevisions = t_TrackRevisions;  
	}catch(e){}

	WebOfficeObj.EditType = t_EditType;
}

 //签章确认
 function saveIsignatureFun(){
     var WebOfficeObj = document.getElementById("webOffice").contentWindow.document.getElementById("WebOffice");
	//btndisabledtrue();
	//setTimeout("btndisabledfalse();",10000);

  <%if(isIWebOffice2006 == true){%>
	   if(WebOfficeObj.Pages >=1){
		  WebOfficeObj.ShowType="1";								 
	   }
  <%}%>


  if(window.confirm('<%=SystemEnv.getHtmlLabelName(21667,user.getLanguage())%>')){

	   try{
		   SetActiveDocument();   //设置活动文档
		   try{
			   SignatureAPI.InitSignatureItems();  //当签章数据发生变化时,请重新执行该方法
		   }catch(e){}
		   //签章个数
		   var newSignatureCount=0;
		   if("1" == signatureType){//WPS混合签章
				newSignatureCount = SignatureAPI.iSignatureCount();
		   }else if("2" == signatureType){//360签章
				newSignatureCount = SignatureAPI.AllSignatureCount;
		   }else{
				newSignatureCount = SignatureAPI.SignatureCount;
		   }
		   if(newSignatureCount==undefined) newSignatureCount = 0;
			if(newSignatureCount!=signatureCount){
				//DocCheckInOutUtil.saveIsignatureFun(<%=requestid%>,<%=nodeid%>,<%=user.getUID()%>,<%=Util.getIntValue(user.getLogintype(),1)%>,newSignatureCount-document.getElementById("signatureCount").value,saveIsignatureFunReturn);
				
				totalSignatureCount = newSignatureCount-signatureCount;
				document.getElementById("DocCheckInOutUtilIframe").src="/docs/docs/DocCheckInOutUtilIframe.jsp?operation=saveIsignatureFun&requestid=<%=requestid%>&nodeId=<%=nodeid%>&userId=<%=user.getUID()%>&loginType=<%=Util.getIntValue(user.getLogintype(),1)%>&signNum="+(newSignatureCount-signatureCount);
				return ;
			}
	   }catch(e){

	   }

        WebOfficeObj.WebSetMsgByName("CLEARHANDWRITTEN","TRUE");//ClearHandwritten   清除手写批注
		onSave();

  }
}
    function onSavePDF(){

        var iframe2 = document.createElement('iframe');
        iframe2.id ="DocCheckInOutUtilIframeAttach";
        iframe2.name ="DocCheckInOutUtilIframeAttach";
        document.body.appendChild(iframe2);
        iframe2.src="/spa/odoc/OfficeToPDF.jsp?docid=<%=docid%>&workflowid=<%=workflowid%>&requestid=<%=requestid%>&nodeid=<%=nodeid%>";

	}
    //另存为PDF
    function  onSavePDFOfText(pdfDocId,DecryptpdfDocId,pdffieldid,decryptpdffieldid){
        var docInfo = parent.WfForm.getOdocConfig();
        var titleFieldid = docInfo.TexttoPDF.documentTitleField;
        if(titleFieldid == -3 || titleFieldid == 0){
            titleFieldid = -1;
		}
        if(pdfDocId>0){
            parent.oDocUtil.setFieldValue(pdffieldid, pdfDocId,titleFieldid);
        }
        if(DecryptpdfDocId>0){
            parent.oDocUtil.setFieldValue(decryptpdffieldid, DecryptpdfDocId,titleFieldid);
        }
		return;
    }
function saveIsignatureFunReturn(){
    var WebOfficeObj = WebOfficeObj.contentWindow.document.getElementById("WebOffice");
	WebOfficeObj.WebSetMsgByName("CLEARHANDWRITTEN","TRUE");//ClearHandwritten   清除手写批注
	onSave();
}
function OnMenuClick(vIndex){
	
			if(vIndex == 1) {
				document.getElementById("webOffice").contentWindow.WebOpenLocal(); //打开本地文件
			}
			if(vIndex == 2) {
				document.getElementById("webOffice").contentWindow.WebSaveLocal2(); //保存本地文件
			}
			if(vIndex == 3) {
				document.getElementById("webOffice").contentWindow.SaveDocument(); //保存正文到服务器上(不退出)
			}
			if(vIndex == 5) {
				document.getElementById("webOffice").contentWindow.WebOpenSignature(); //签名印章
			}
			if(vIndex == 6) {
				document.getElementById("webOffice").contentWindow.WebShowSignature(); //验证签章
			}
			if(vIndex == 8) {
				document.getElementById("webOffice").contentWindow.WebSaveVersion(); //保存版本
			}
			if(vIndex == 9) {
				document.getElementById("webOffice").contentWindow.WebOpenVersion(); //打开版本
			}
			if(vIndex == 11) {
				document.getElementById("webOffice").contentWindow.SaveDocument(); //保存正文到服务器上
				document.getElementById("webOffice").contentWindow.webform.submit(); //然后退出
			}
			if(vIndex == 13) {
				document.getElementById("webOffice").contentWindow.WebOpenPrint(); //打印文档
			}
			if(vIndex == 47) {
				document.getElementById("webOffice").contentWindow.WebOpenPrint(); //打印文档
			}
			if(vIndex == 101) {
				<%if(isNewObject || webwps || yozoOffice){%>
                	showOrHideRevision(); //显示/隐藏痕迹
				<%}else{%>
					document.getElementById("webOffice").contentWindow.ShowRevision(); //显示/隐藏痕迹
				<%}%>
			}
			if(vIndex == 102) {
				document.getElementById("webOffice").contentWindow.acceptAll();  //接受文档
			}
}

//新建文档
function createDoc(){
	var flag;
	var params = new Object();	
	var docType = "<%=suffix%>";
       //文件名		
	params.prop_fileName = docsubject + docType;		
	try{			
		var imagefileName = save(params);
		if(!imagefileName || imagefileName == ""){
			flag = {off_status : 0};
		}else{
			jQuery.ajax({
				url:"iWebOfficeOperation.jsp",
				type:"POST",
				async:false,
				data:{imagefileName:imagefileName,
						  docType:'<%=officeType%>',
						  docsubject:encodeURIComponent(encodeURIComponent(docsubject)),
						  operation:"createDoc"
					  },
				dataType:"json",
				success:function(msg){
					if(msg.result == "success"){
						flag = {
					    	off_status : 1,
					    	off_docid : msg.docId,
					    	off_versionid : msg.versionId
						};
					}else{
						flag = {off_status : 0};
					}
				},
				error:function(){
					flag = {off_status : 0};
				}
			});
		}			
	}catch(e){
	    if(window.console){
		   window.console.log(e);
	    }
	    flag = {off_status : 0};
	}
	return flag;
}


//编辑文档(参数控制是否存为新版)
function editDoc(isVersion){
	var flag;
	var params = new Object();	
	//文件后缀名
	var docType = "<%=suffix%>";
	var id = "<%=docid%>";
	var imagefileId = "<%=imagefileId%>";
	hasUsedTemplet = "<%=isUseTempletNode ? "1" : "0"%>"
	var operation = "updateDoc";
	if("1" == isVersion){
		operation = "saveAsNewVersion";
	}
	if("1" == hasUsedTemplet){
        operation = "saveAsNewVersion";
	}	
	//文件名		
	params.prop_fileName = docsubject + docType;
	try{			
		var imagefileName = save(params);
		if(!imagefileName){
			flag = {off_status : 0};	
		}else{
			jQuery.ajax({
				url:"iWebOfficeOperation.jsp",
				type:"POST",
				async:false,
				data:{id:id,
				      imagefileId:imagefileId,
                      imagefileName:imagefileName,
					  docType:docType,
					  hasTemplate:hasUsedTemplet,
				      docsubject:encodeURIComponent(encodeURIComponent(docsubject)),
				      operation:operation
				     },
				dataType:"json",
				success:function(msg){
					if(msg.result == "success"){
						flag = {
						    	off_status : 1,
						    	isflowdoc : 1,
						    	docid : msg.docId,
						    	off_docid : msg.docId,
						    	off_versionid : msg.versionId
							   };
					}else{
						flag = {off_status : 0};
					}
				},
				error:function(){
					flag = {off_status : 0};
				}
			});
		}		
	}catch(e){
		if(window.console){
		   window.console.log(e);
		}
		flag = {off_status : 0}; 
	}
	return flag;
}

var OfficeIframeHeight;
//全屏查看正文
function fullScreen(){
    <%if(webwps || yozoOffice){%>
    	return docviewOfFullscreen();
	<%}%>
    //文档Iframe
	var OfficeIframe = window.parent.jQuery("iframe.req-workflow-odoc")[0];
    OfficeIframeHeight = jQuery(OfficeIframe).css("height");
	if(!OfficeIframe){
	    alert("未获取到父页面对象元素");
	    return;
	}
	var ClientHeight = getClientHeight();

	jQuery(OfficeIframe).css({"position":"fixed","top":"0px","left":"0px","height":ClientHeight + "px","width":"100%","margin-top":"-35px"});
	//文档父级元素
	var OfficeDiv = window.parent.jQuery("div.wea-new-top-req-content")[0];
	if(OfficeDiv){
	    //隐藏文档相邻元素
        jQuery(OfficeDiv).siblings().css({"display":"none"});
	}

	//var tempHeight = jQuery(OfficeIframe).height();
    //文档
    var contentDiv = jQuery("#container").find("div.wea-new-top-req-content");
    if(contentDiv){
        jQuery(contentDiv).siblings().css({"display":"none"});
        var contentTab = jQuery(contentDiv).find("div.wea-doc-detail-content-main");
        if(contentTab){
            jQuery(contentTab).parent().prepend("<button class='ant-btn ant-btn-primary' style='margin:5px;float:right' onclick='exitFullscreen(this)'><%=SystemEnv.getHtmlLabelNames("1205,26096", user.getLanguage())%></button>");
        }
    }



}

//退出全屏
function exitFullscreen(obj){
    //文档
    var contentDiv = jQuery("#container").find("div.wea-new-top-req-content");
    if(contentDiv){
        jQuery(contentDiv).siblings().css({"display":"block"});
    }
    //文档父级元素
    var OfficeDiv = window.parent.jQuery("div.wea-new-top-req-content")[0];
    if(OfficeDiv){
        //隐藏文档相邻元素
        jQuery(OfficeDiv).siblings().css({"display":"block"});
    }
    //文档Iframe
    var OfficeIframe = window.parent.jQuery("iframe.req-workflow-odoc")[0];
    if(!OfficeIframe){
        alert("未获取到父页面对象元素");
        return;
    }
    jQuery(OfficeIframe).css({"position":"","top":"","left":"","height":OfficeIframeHeight +"","width":"100%","margin-top":""});
    jQuery(obj).remove();

}

function getClientHeight()
{
	var clientHeight=0;
	if(parent.document.body.clientHeight&&parent.document.documentElement.clientHeight)
	{
		var clientHeight = (parent.document.body.clientHeight<parent.document.documentElement.clientHeight)?parent.document.body.clientHeight:parent.document.documentElement.clientHeight;
	}
	else
	{
		var clientHeight = (parent.document.body.clientHeight>parent.document.documentElement.clientHeight)?parent.document.body.clientHeight:parent.document.documentElement.clientHeight;
	}
	return clientHeight;
}

  </script>
  
		<div style="display:none;">
			<brow:browser name="__selectTaohongMould" viewType="0" getBrowserUrlFn="selectEditMould" getBrowserUrlFnParams='<%=""+ secid%>'
				_callback="afterSelectEditMould" browserBtnID="selectTaohongMouldBtn" isMustInput="1"></brow:browser>
			
			<%
			//if(isSignatureNodes||isSaveDecryptPDF){
			if(isSignatureNodes){
			  if("1".equals(signatureType)){%>
				<OBJECT id=SignatureAPI classid="clsid:A0689619-3E99-4012-A83F-E902CF3505BD"  codebase="iSignatureWPS_APIP.ocx#version=<%=wps_version%>" 
				width=0 height=0 align=center hspace=0 vspace=0></OBJECT>
			<%}else if("2".equals(signatureType)){%>
				<object id="SignatureAPI" width="0" height="0" classid="clsid:857F9703-BE32-4BD4-92A4-D8079C10BD41"></object>
			<%}else{%>	
				<OBJECT id=SignatureAPI classid="clsid:79F9A6F8-7DBE-4098-A040-E6E0C3CF2001"  codebase="iSignatureAPI.ocx#version=5,0,2,0" width=0 height=0 align=center hspace=0 vspace=0></OBJECT>
			<%}}%>
			<iframe id="DocCheckInOutUtilIframe" frameborder=0 scrolling=no src=""  style="display:none"></iframe>
		</div>
		
	</body>

</html>