psr_report_create.lview 112 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: xiaobo  
    $Date: 2012-11-23 下午1:50:45  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="basic.hls_sys_time_default_value" rootPath="default_value_path"/>
        <a:model-query autoCount="false" defaultwhereclause="default_table_flag=&apos;Y&apos;" fetchAll="true" model="psr.PSR1010.psr_base_tables" rootPath="default_table"/>
        <a:model-query defaultWhereClause="report_header_id=${/parameter/@report_header_id}" fetchAll="true" model="psr.PSR1010.psr_report_fields" rootPath="fields"/>
        <!-- <a:model-query autoCount="false" defaultwhereclause="report_type=&apos;CONDITION_REPORT&apos;" fetchAll="true" model="psr.PSR1010.psr_report_headers" rootPath="report_list"/> -->
        <a:model-query defaultWhereClause="t.layout_code=&apos;RPT_CATALOG_&apos;||${/parameter/@report_header_id}" fetchAll="true" model="psr.PSR1010.psr_report_column_query" rootPath="select_parameter_path"/>
        <a:model-query defaultWhereClause="t.layout_code=&apos;RPT_CATALOG&apos; and not exists(select 1 from hls_doc_layout_config hdlc where hdlc.layout_code=&apos;RPT_CATALOG_&apos;||${/parameter/@report_header_id} and hdlc.tab_code=hdlc.layout_code and hdlc.column_name=d.column_name)" fetchAll="true" model="psr.PSR1010.psr_report_column_query" rootPath="category_parameter_path"/>
    </a:init-procedure>
    <a:view>
        <div/>
        <a:link id="psr_report_datarelation" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_datarelation.lview"/>
        <a:link id="psr_report_field_selection" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_field_selection.lview"/>
        <a:link id="psr_report_add_expression" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_add_expression.lview"/>
        <a:link id="psr_report_field_editor" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_field_editor.lview"/>
        <a:link id="psr_report_add_condition" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_add_condition.lview"/>
        <a:link id="psr_report_save" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_save.lsc"/>
        <a:link id="psr_report_create" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_create.lview"/>
        <a:link id="psr_report_test" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_test.lsc"/>
        <a:link id="psr_report_parameter_preview_create_dynamic" url="${/request/@context_path}/modules/psr/PSR1020/psr_report_parameter_preview_dynamic.lview"/>
        <a:link id="psr_report_preview_create_link" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_preview.lview"/>
        <a:link id="psr_report_output_create" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_output.lsc"/>
        <a:link id="psr_report_table_selection_link" url="${/request/@context_path}/modules/psr/PSR1040/psr_report_base_table_selection.lview"/>
        <a:link id="psr_report_field_style_link" url="${/request/@context_path}/modules/psr/PSR1010/psr_report_field_style.lview"/>
        <a:link id="psr_report_parameter_create_dynamic" url="${/request/@context_path}/modules/psr/PSR1020/psr_report_parameter_dynamic.lview"/>
        <style><![CDATA[
        	.item-btn-icon div{
        	    padding-left:26px;
        	}
        ]]></style>
        <script type="text/javascript"><![CDATA[
            var step = 0;
            var styles_data = [];
            var current_index = 0,
                forward_index = 0;
            
            //删除
            
            
            function delFunction(index, dataSetName) {
                var dataSet = $(dataSetName);
                var record = dataSet.find('line_number', index);
                dataSet.remove(record);
            }
            
            function step_0NextStep() {
                var headers_ds = $('psr_report_headers_ds');
                var record = headers_ds.getAt(0);
                var report_type = typeof(record.get('report_type')) == 'undefined' ? 0 : record.get('report_type');
            
                if (report_type == 0 || report_type == '') {
                    Leaf.showMessage('提示', '请确认报表类型!');
                } else {
                    nextStep();
                }
            }
            
            function step_1NextStep() {
                var tables_ds = $('psr_report_tables_ds'),
                    headers_ds = $('psr_report_headers_ds'),
                    header_record = headers_ds.getCurrentRecord();
                var fieldRecords = tables_ds.getAll();
                //var report_type = typeof(record.get('report_type')) == 'undefined' ? 0 : record.get('report_type');
                var fieldLength = fieldRecords.length;
                if (fieldLength < 1 && !header_record.get('sql_statement')) {
                    Leaf.showMessage('提示', '请添加数据源!');
            
                    //nodeDetailTempUnLockScreen();
                } else {
                    if (header_record.get('report_type') == 'USERDEFINE_REPORT') {
                        nextStep();
                        nextStep();
                    }
                    nextStep();
                }
            }
            
            function step_3NextStep() {
                var headers_ds = $('psr_report_headers_ds');
                var record = headers_ds.getAt(0);
                var report_type = typeof(record.get('report_type')) == 'undefined' ? 0 : record.get('report_type');
            
                if (report_type == 'CONDITION_REPORT') {
                    nextStep();
                    nextStep();
                } else {
                    nextStep();
                }
            }
            
            function step_4NextStep() {
                var groups_ds = $('psr_report_groups_ds');
                var orders_ds = $('psr_report_orders_ds');
                if (dataSetValidate(groups_ds) && dataSetValidate(orders_ds)) {
                    nextStep();
                }
            }
            
            function step_5UpStep() {
                var headers_ds = $('psr_report_headers_ds');
                var record = headers_ds.getAt(0);
                var report_type = typeof(record.get('report_type')) == 'undefined' ? 0 : record.get('report_type');
                if (report_type == 'CONDITION_REPORT') {
                    upStep();
                    upStep();
                } else if (report_type == 'USERDEFINE_REPORT') {
                    upStep();
                    upStep();
                    upStep();
                } else {
                    upStep();
                }
            }
            
            //下一步
            
            function nextStep() {
                var stepTabPanel = $('step');
            
                step = step + 1;
                // stepTabPanel.setEnabled(step);
                stepTabPanel.selectTab(step);
                // stepTabPanel.setDisabled(step - 1);
            }
            //上一步
            
            function upStep() {
                var stepTabPanel = $('step');
            
                step = step - 1;
                // stepTabPanel.setEnabled(step);
                stepTabPanel.selectTab(step);
                // stepTabPanel.setDisabled(step + 1);
            
            }
            //取消
            
            function cancelFun() {
                Leaf.showConfirm('提示', '确定取消?', function okFun() {
                    window.location.href = $('psr_report_create').getUrl();
                }, function canFun() {});
            }
            
            
            //保存
            
            function saveFun() {
                Leaf.showConfirm('提示', '确定保存?', function okFun() {
                    $('saveFun_id').disable();
                    nodeDetailTempLockScreen();
                    var headers_ds = $('psr_report_headers_ds');
                    var tables_ds = $('psr_report_tables_ds');
                    var fields_ds = $('psr_report_fields_ds');
                    var fieldRecords = fields_ds.getAll();
                    var fieldLength = fieldRecords.length;
                    var conditions_ds = $('psr_report_conditions_ds');
                    var groups_ds = $('psr_report_groups_ds');
                    var orders_ds = $('psr_report_orders_ds');
                    var aut_trx_user_report_ds = $('aut_trx_user_report_ds');
                    var psr_report_layout_select_ds = $('psr_report_layout_select_ds');
            
            
                    if (dataSetValidate(headers_ds)) {
            
                        if (fieldLength < 1) {
                            Leaf.showMessage('提示', '请添加显示字段!');
            
                            var stepTabPanel = $('step');
                            step = 2;
                            // stepTabPanel.setEnabled(step);
                            stepTabPanel.selectTab(step);
                            // stepTabPanel.setDisabled(5);
            
                            $('saveFun_id').enable();
                            nodeDetailTempUnLockScreen();
                        } else {
                            var header_record = headers_ds.getAt(0);
                            var tmp = [];
                            for (var i = 0;i < styles_data.length;i++) {
                                tmp[i] = styles_data[i];
                            }
                            var parameter_records = $('psr_report_layout_select_ds').getAll();
                            var parameter_flag;
                            if (parameter_records.length != 0) {
                                parameter_flag = 'Y';
                            } else {
                                parameter_flag = 'N';
                            }
                            var synchronization_flag;
                            if (header_record.get('unsynchronization_flag') == 'Y') {
                                synchronization_flag = 'N';
                            } else {
                                synchronization_flag = 'Y';
                            }
                            Leaf.request({
                                url: $('psr_report_save').getUrl(),
                                para: {
                                    report_header_id: header_record.get('report_header_id'),
                                    report_header_name: header_record.get('report_header_name'),
                                    parameter_flag: parameter_flag,
                                    synchronization_flag: synchronization_flag,
                                    layout_code: header_record.get('layout_code'),
                                    report_header_description: header_record.get('report_header_description'),
                                    view_range: header_record.get('view_range'),
                                    report_type: header_record.get('report_type'),
                                    sql_statement: header_record.get('sql_statement'),
                                    fixed_time_flag: header_record.get('fixed_time_flag'),
                                    start_date: header_record.get('start_date'),
                                    push_cycle: header_record.get('push_cycle'),
                                    other_report_flag: header_record.get('other_report_flag'),
                                    other_report_header_id: header_record.get('other_report_header_id'),
                                    tables: tables_ds.getJsonData(),
                                    fields: fields_ds.getJsonData(),
                                    conditions: conditions_ds.getJsonData(),
                                    groups: groups_ds.getJsonData(),
                                    orders: orders_ds.getJsonData(),
                                    aut_trx_report: aut_trx_user_report_ds.getJsonData(),
                                    layout_detail: psr_report_layout_select_ds.getJsonData(),
                                    styles: tmp
                                },
                                success: function(res) {
                                    var report_header_id = res.result.report_header_id;
                                    allQuery(report_header_id, 'Y');
                                    document.getElementById("other_button_id").style.display = "";
                                    document.getElementById("sql_statement_id").style.display = "";
                                    $('saveFun_id').enable();
                                    nodeDetailTempUnLockScreen();
                                },
                                error: function() {
                                    $('saveFun_id').enable();
                                    document.getElementById("other_button_id").style.display = "none";
                                    document.getElementById("sql_statement_id").style.display = "none";
                                    nodeDetailTempUnLockScreen();
                                }
                            });
            
                        }
                    } else {
                        $('saveFun_id').enable();
                    }
            
                });
            }
            
            //数据验证
            
            function dataSetValidate(dataSet) {
                var validate = dataSet.validate();
                return validate;
            }
            //设置行号
            
            function setLineNumber(dataSet, record, index) {
                var records = dataSet.getAll();
                var number = 0;
                if (records.length > 0) {
                    for (var i = 0;i < records.length;i++) {
                        number = (i + 1) * 10;
                        records[i].set('line_number', number);
                    }
                } else {
                    number = index * 10;
                    record.set('line_number', number);
                }
            }
            //字段行号
            
            function report_groups_setLineNumber(dataSet, record, index) {
                var records = dataSet.getAll();
                var number = 0;
                if (records.length > 0) {
                    for (var i = 0;i < records.length;i++) {
                        number = (i + 1);
                        records[i].set('line_number', number);
                    }
                } else {
                    number = index;
                    record.set('line_number', number);
                }
            }
            
            //数据显示
            
            function tableNameFun(value, record, name) {
                var table_name = record.get('table_name');
                var line_number = record.get('line_number');
                var table_description = record.get('table_description');
                var table_alias = record.get('table_alias');
                return '<a href="javascript:fieldSelectionFun(' + line_number + ')">' + table_name + '-' + table_description + '</a>';
            }
            
            //报表显示字段选择
            
            function fieldSelectionFun(line_number) {
                new Leaf.Window({
                    id: 'report_field_selection_win',
                    closeable: false,
                    url: $('psr_report_field_selection').getUrl() + '?line_number=' + line_number,
                    title: '字段选择',
                    height: 450,
                    width: 480
                });
            }
            
            //关联表
            
            function addTableFun(value, record, name) {
            
                var datarelation_ds = $('psr_report_tables_ds');
                var index = datarelation_ds.indexOf(record);
                return '<a href="javascript:addTableFunction(' + index + ')">关联</a>';
            }
            
            function addTableFunction(index) {
            
                new Leaf.Window({
                    id: 'report_datarelation_win',
                    closeable: false,
                    url: $('psr_report_datarelation').getUrl() + '?index=' + index,
                    title: '表关联',
                    height: 425,
                    width: 480
                });
            }
            //去关联表
            
            function delTableFun(value, record, name) {
                var table_name = record.get('table_name');
                var line_number = record.get('line_number');
                if (line_number == 10) {
                    return '';
                }
                return '<a href="javascript:delTableFunction(\'' + line_number + '\')">删除</a>';
            }
            
            function delTableFunction(line_number) {
                Leaf.showConfirm('提示', '是否删除?', function okFun() {
                    var report_tables_ds = $('psr_report_tables_ds');
                    var record = report_tables_ds.find('line_number', line_number);
                    var table_name = record.get('table_name');
                    var table_alias = record.get('table_alias');
                    //移除显示字段
            
                    var report_fields_ds = $('psr_report_fields_ds');
                    var report_fields_selection_ds = $('psr_report_fields_selection_ds');
                    var report_conditions_ds = $('psr_report_conditions_ds');
                    var report_groups_ds = $('psr_report_groups_ds');
                    var report_orders_ds = $('psr_report_orders_ds');
            
            
            
                    batchDelFunction(table_alias, 'field_name', report_orders_ds);
                    batchDelFunction(table_alias, 'field_name', report_groups_ds);
                    batchDelFunction(table_alias, 'field_1', report_conditions_ds);
                    batchDelFunction(table_alias, 'field_2', report_conditions_ds);
                    batchDelFunction(table_alias, 'field_name', report_fields_selection_ds);
                    batchDelFunction(table_alias, 'field_name', report_fields_ds);
            
            
                    //移除显示
                    report_tables_ds.remove(record);
                });
            
            }
            
            //清除 表 相关 字段
            
            function batchDelFunction(table_alias, name, dataSet) {
                var records = dataSet.getAll();
                var length = records.length;
                var del_ds = $('psr_report_del_ds');
                var index, field_name;
            
                for (var j = 0;j < length;j++) {
            
                    var record = records[j];
                    field_name = record.get(name);
                    index = field_name.indexOf('.');
                    if (table_alias == field_name.substring(0, index)) {
                        del_ds.add(new Leaf.Record({
                            line_number: record.get('line_number')
                        }));
                    }
                }
            
            
                var dRecords = del_ds.getAll();
                for (var i = 0;i < dRecords.length;i++) {
                    dataSet.remove(dataSet.find('line_number', dRecords[i].get('line_number')));
                }
                del_ds.removeAll();
            
            }
            
            
            
            function test() {
                Leaf.showMessage('提示', '开发中...');
            }
            
            //字段编辑  编辑
            
            
            function fieldEditorFun(value, record, name) {
                var dataSet = $('psr_report_fields_ds');
                var index = record.get('line_number'); //indexOf(record);
                var field_category = record.get('field_category');
                if (field_category == 'FIELD') {
                    return '<a href="javascript:fieldEditorFunction(' + index + ')">编辑</a>';
                } else {
                    return '<a href="javascript:editorExpressionFunction(' + index + ')">编辑</a>';
                }
            }
            
            function fieldEditorFunction(index) {
                new Leaf.Window({
                    id: 'report_field_editor_win',
                    closeable: false,
                    url: $('psr_report_field_editor').getUrl() + '?index=' + index,
                    title: '字段编辑',
                    height: 250,
                    width: 480
                });
            }
            
            //编辑表达式
            
            function editorExpressionFunction(index) {
                new Leaf.Window({
                    id: 'report_add_expression_win',
                    closeable: false,
                    url: $('psr_report_add_expression').getUrl() + '?index=' + index,
                    title: '编辑表达式',
                    height: 300,
                    width: 480
                });
            }
            
            //排序
            
            
            // function fieldSeqencingFun(value, record, name) {
            // var dataSet = $('psr_report_fields_ds');
            // var index = dataSet.indexOf(record);
            // return "<a href='javascript:upFun(" + index + ",\"psr_report_fields_ds\")'>上移</a>&nbsp;&nbsp;<a href='javascript:downFun(" + index + ",\"psr_report_fields_ds\")'>下移</a>";
            // }
            
            function fieldDownFun() {
                var dataSet = $('psr_report_fields_ds');
                var record = dataSet.getCurrentRecord();
                var index = dataSet.indexOf(record);
            
                downFun(index, 'psr_report_fields_ds');
            }
            
            function fieldUpFun() {
                var dataSet = $('psr_report_fields_ds');
                var record = dataSet.getCurrentRecord();
                var index = dataSet.indexOf(record);
            
                upFun(index, 'psr_report_fields_ds');
            }
            
            // function groupSeqencingFun(value, record, name) {
            // var dataSet = $('psr_report_groups_ds');
            // var index = dataSet.indexOf(record);
            // return "<a href='javascript:upFun(" + index + ",\"psr_report_groups_ds\")'>上移</a>&nbsp;&nbsp;<a href='javascript:downFun(" + index + ",\"psr_report_groups_ds\")'>下移</a>";
            // }
            
            function groupDownFun() {
                var dataSet = $('psr_report_groups_ds');
                var record = dataSet.getCurrentRecord();
                var index = dataSet.indexOf(record);
                if (index != dataSet.length - 1) {
                    downFun(index, 'psr_report_groups_ds');
                }
            }
            
            function groupUpFun() {
                var dataSet = $('psr_report_groups_ds');
                var record = dataSet.getCurrentRecord();
                var index = dataSet.indexOf(record);
                if (index != 0) {
                    upFun(index, 'psr_report_groups_ds');
                }
            }
            
            // function orderSeqencingFun(value, record, name) {
            // var dataSet = $('psr_report_orders_ds');
            // var index = dataSet.indexOf(record);
            // return "<a href='javascript:upFun(" + index + ",\"psr_report_orders_ds\")'>上移</a>&nbsp;&nbsp;<a href='javascript:downFun(" + index + ",\"psr_report_orders_ds\")'>下移</a>";
            // }
            
            function orderDownFun() {
                var dataSet = $('psr_report_orders_ds');
                var record = dataSet.getCurrentRecord();
                var index = dataSet.indexOf(record);
                if (index != dataSet.length - 1) {
                    downFun(index, 'psr_report_orders_ds');
                }
            }
            
            function orderUpFun() {
                var dataSet = $('psr_report_orders_ds');
                var record = dataSet.getCurrentRecord();
                var index = dataSet.indexOf(record);
                if (index != 0) {
                    upFun(index, 'psr_report_orders_ds');
                }
            }
            
            
            //下移
            
            function downFun(index, name) {
                var dataSet = $(name);
                var record = dataSet.getAt(index);
                var nextIndex = index + 1;
                var nextRecord = dataSet.getAt(nextIndex);
                recordsexchange(record, nextRecord, name);
                dataSet.next();
                dataSet.select(nextRecord);
                setLineNumber(dataSet, record, index);
            }
            
            //上移
            
            function upFun(index, name) {
                var dataSet = $(name);
                var record = dataSet.getAt(index);
                var preIndex = index - 1;
                var preRecord = dataSet.getAt(preIndex);
                recordsexchange(record, preRecord, name);
                dataSet.pre();
            
                dataSet.select(preRecord);
                setLineNumber(dataSet, record, index);
            }
            
            // 数据交换
            
            function recordsexchange(r1, r2, name) {
                var newRecord;
                if (name == 'psr_report_fields_ds') {
                    newRecord = new Leaf.Record({
                        report_field_id: r1.get('report_field_id'),
                        line_number: r1.get('line_number'),
                        report_header_id: r1.get('report_header_id'),
                        table_name: r1.get('table_name'),
                        field_name: r1.get('field_name'),
                        report_fields_dis: r1.get('report_fields_dis'),
                        field_description: r1.get('field_description'),
                        field_description_dis: r1.get('field_description_dis'),
                        field_type: r1.get('field_type'),
                        field_type_dis: r1.get('field_type_dis'),
                        field_size: r1.get('field_size'),
                        field_decimal: r1.get('field_decimal'),
                        field_category: r1.get('field_category'),
                        field_category_dis: r1.get('field_category_dis'),
                        statistics_type: r1.get('statistics_type'),
                        subtotal_type: r1.get('subtotal_type'),
                        aggregate_function_flag: r1.get('aggregate_function_flag')
            
                    });
            
                } else if (name == 'psr_report_groups_ds') {
                    newRecord = new Leaf.Record({
                        report_group_id: r1.get('report_group_id'),
                        line_number: r1.get('line_number'),
                        report_header_id: r1.get('report_header_id'),
                        table_name: r1.get('table_name'),
                        field_name: r1.get('field_name'),
                        field_description: r1.get('field_description'),
                        field_line_number: r1.get('field_line_number'),
                        group_description: r1.get('group_description')
                    });
                } else if (name == 'psr_report_orders_ds') {
                    newRecord = new Leaf.Record({
                        report_order_id: r1.get('report_order_id'),
                        order_code: r1.get('order_code'),
                        order_code_dis: r1.get('order_code_dis'),
                        line_number: r1.get('line_number'),
                        report_header_id: r1.get('report_header_id'),
                        table_name: r1.get('table_name'),
                        field_name: r1.get('field_name'),
                        field_description: r1.get('field_description')
                    });
                }
                r1.setObject(r2.data);
                r2.setObject(newRecord.data);
            }
            
            //字段编辑 删除
            
            
            function fieldSDelFun(value, record, name) {
            
                var dataSet = $('psr_report_fields_selection_ds');
                var field_name = record.get('field_name'); //dataSet.indexOf(record);
                var line_number = record.get('line_number');
                return '<a href="javascript:fieldSDelFunction(\'' + field_name + '\',' + line_number + ')">删除</a>';
            }
            
            function fieldDelFun(value, record, name) {
                var dataSet = $('psr_report_fields_ds');
                var index = record.get('line_number'); //dataSet.indexOf(record);
                return '<a href="javascript:fieldDelFunction(' + index + ')">删除</a>';
            }
            
            function fieldDelFunction(index) {
                var dataSet = $('psr_report_fields_selection_ds');
                var ds2 = $('psr_styles_ds');
            
                var record = dataSet.find('line_number', index); //getAt(index);
                var record2 = ds2.find('line_number', index);
            
                dataSet.remove(record);
                ds2.remove(record2);
            
            }
            
            //字段删除
            
            function fieldSDelFunction(field_name, line_number) {
                var selection_ds = $('psr_report_fields_selection_ds');
                var style_ds = $('psr_styles_ds');
                var field_ds = $('psr_report_fields_ds');
            
                var record = selection_ds.find('line_number', line_number); //getAt(index);
                var report_field_id = record.get('report_field_id');
                selection_ds.remove(record);
                style_ds.remove(style_ds.find('line_number', line_number));
            
                if (report_field_id) {
                    field_ds.remove(field_ds.find('report_field_id', record.get('report_field_id')));
                } else {
                    //field_ds.remove(selection_ds.find('report_fields_dis', record.get('report_fields_dis')));
                    field_ds.remove(field_ds.find('line_number', line_number));
                }
            }
            
            function fieldsDisFun(value, record, name) {

                return record.get('field_name');
            }
            
            //添加表达式
            
            function addExpression() {
                new Leaf.Window({
                    id: 'report_add_expression_win',
                    closeable: false,
                    url: $('psr_report_add_expression').getUrl(),
                    title: '添加表达式',
                    height: 300,
                    width: 480
                });
            }
            
            //新增条件  编辑
            
            function conditionsEditorFun(value, record, name) {
                var editor_flag = record.get('editor_flag');
                if (editor_flag == 'N') {
                    return '';
                }
                var dataSet = $('psr_report_conditions_ds');
                var index = record.get('line_number'); //dataSet.indexOf(record);
                return '<a href="javascript:conditionsEditorFunction(' + index + ')">编辑</a>';
            }
            
            function conditionsEditorFunction(index) {
                var head_record = $('psr_report_headers_ds').getCurrentRecord();
                new Leaf.Window({
                    id: 'report_add_condition_win',
                    closeable: false,
                    url: $('psr_report_add_condition').getUrl(),
                    params: {
                        layout_code: head_record.get('layout_code'),
                        index: index
                    },
                    title: '添加标准',
                    height: 350,
                    width: 480
                });
            }
            
            //新增条件  删除
            
            function conditionsDelFun(value, record, name) {
                var editor_flag = record.get('editor_flag');
                if (editor_flag == 'N') {
                    return '';
                }
                var dataSet = $('psr_report_conditions_ds');
                var index = record.get('line_number');
                return '<a href="javascript:conditionsDelFunction(' + index + ')">删除</a>';
            }
            
            function conditionsDelFunction(index) {
                var dataSet = $('psr_report_conditions_ds');
                var record = dataSet.find('line_number', index); //getAt(index);
                dataSet.remove(record);
            }
            
            //新增条件  添加
            
            function addConditionFun() {
                var record = $('psr_report_headers_ds').getCurrentRecord();
                var layout_code = record.get('layout_code');
                new Leaf.Window({
                    id: 'report_add_condition_win',
                    closeable: false,
                    url: $('psr_report_add_condition').getUrl(),
                    params: {
                        layout_code: layout_code
                    },
                    title: '添加条件',
                    height: 350,
                    width: 480
                });
            }
            
            //逻辑编辑
            
            function editorFun(record, name) {
                var editor_flag = record.get('editor_flag');
                if (editor_flag == 'N') {
                    return '';
                } else {
                    return 'comboBoxEditor';
                }
            
            }
            
            //记录
            
            function previewFun(value, record, name) {
                return '<a href="javascript:test1()" >预览</a>';
            }
            
            function runFun(value, record, name) {
                return '<a href="javascript:test1()" >运行</a>';
            }
            
            function test1() {
                Leaf.showMessage('提示', '开发中...');
            }
            
            function reportHeaderAddFun(dataSet, record, index) {
                setLineNumber(dataSet, record, index);
                record.set('report_creation_date', new Date());
            }
            
            function set_user_define_style(record, name, value) {
                if (name == 'report_type') {
                    var sql_statement_field = record.getField('sql_statement');
                    if (value == 'USERDEFINE_REPORT') {
                        sql_statement_field.setReadOnly(false);
                        sql_statement_field.setRequired(true);
                        Ext.get('userdefine_sql_id').setStyle('display', '');
                        Ext.get('ref_table_id').setStyle('display', 'none');
                        Ext.get('step_3').setStyle('display', 'none');
                        Ext.get('step_4').setStyle('display', 'none');
                        $('selectTableFun_id').setVisible(false);
                        $('addFieldFun_id').setVisible(true);
                        $('clearFieldsFun_id').setVisible(true);
                    } else {
                        sql_statement_field.setReadOnly(true);
                        sql_statement_field.setRequired(false);
                        Ext.get('userdefine_sql_id').setStyle('display', 'none');
                        Ext.get('ref_table_id').setStyle('display', '');
                        Ext.get('step_3').setStyle('display', '');
                        Ext.get('step_4').setStyle('display', '');
                        $('selectTableFun_id').setVisible(true);
                        $('addFieldFun_id').setVisible(false);
                        $('clearFieldsFun_id').setVisible(true);
                    }
                }
            }
            
            //报表头数据更新
            
            function reportHeaderUpdateFun(ataSet, record, name, value, oldvalue) {
                if (name == 'fixed_time_flag') {
                    if (value == 'Y') {
                        record.getField('start_date').setReadOnly(false);
                        record.getField('start_date').setRequired(true);
            
                        record.getField('push_cycle_dis').setReadOnly(false);
                        record.getField('push_cycle_dis').setRequired(true);
                    } else {
                        record.getField('start_date').setReadOnly(true);
                        record.getField('start_date').setRequired(false);
            
                        record.getField('push_cycle_dis').setReadOnly(true);
                        record.getField('push_cycle_dis').setRequired(false);
                    }
                } else if (name == 'other_report_flag') {
                    if (value == 'Y') {
                        record.getField('other_report_header_name').setReadOnly(false);
                        record.getField('other_report_header_name').setRequired(true);
                    } else {
                        record.getField('other_report_header_name').setReadOnly(true);
                        record.getField('other_report_header_name').setRequired(false);
                    }
                } else if (name == 'layout_code') {
                    $('psr_report_layout_ds').setQueryParameter('layout_code', value);
                    $('psr_report_layout_ds').query();
                } else if (name == 'report_type') {
                    set_user_define_style(record, name, value);
                }
            }
            
            
            
            function reportHeaderLoadFun(dataSet) {
                function isExitsFunction(funcName) {
                    if (typeof(funcName) == "function") {
                        return true;
                    } else {
                        return false;
                    }
                }
                // if (isExitsFunction(nodeDetailTempUnLockScreen)) {
                // nodeDetailTempUnLockScreen();
                // }
                var record = dataSet.getAt(0);
                // set_user_define_style(record, 'report_type', record.get('report_type'));
                var other_report_flag = record.get('other_report_flag');
                if (other_report_flag == 'Y') {
                    record.getField('other_report_header_name').setReadOnly(false);
                    record.getField('other_report_header_name').setRequired(true);
                }
            
                var fixed_time_flag = record.get('fixed_time_flag');
                if (fixed_time_flag == 'Y') {
                    record.getField('start_date').setReadOnly(false);
                    record.getField('start_date').setRequired(true);
            
                    record.getField('push_cycle_dis').setReadOnly(false);
                    record.getField('push_cycle_dis').setRequired(true);
                }
            }
            
            Leaf.onReady(function() {
                var record = $('psr_report_headers_ds').getCurrentRecord();
                set_user_define_style(record, 'report_type', record.get('report_type'));
            });
            
            //报表头编辑
            
            
            function reportHeaderEditorFun(value, record, name) {
                return '<a href="javascript:reportHeaderEditorFunction()" >编辑</a>';
            }
            
            function reportHeaderEditorFunction() {
                var stepTabPanel = $('step');
                step = step;
                stepTabPanel.setDisabled(step);
                stepTabPanel.setEnabled(0);
                stepTabPanel.selectTab(0);
                step = 0;
            }
            
            //添加分组
            
            
            function addGroupFun() {
                //必须指定统计列
                var fieldDataSet = $('psr_report_fields_ds');
                var records = fieldDataSet.getAll();
                var flag = false;
                for (var i = 0;i < records.length;i++) {
                    var record = records[i];
                    var subtotal_type = typeof(record.get('subtotal_type')) == 'undefined' ? 0 : record.get('subtotal_type');
                    if (subtotal_type != 0 || subtotal_type != 'NULL') {
                        flag = true;
                        break;
                    }
                }
            
                if (flag) {
                    var dataSet = $('psr_report_groups_ds');
                    dataSet.create();
                } else {
                    Leaf.showMessage('提示', '请选择需要统计的列!');
                }
            }
            //添加分组
            
            
            function addOrderFun() {
                var dataSet = $('psr_report_orders_ds');
                dataSet.create();
            }
            
            function groupDelFun(value, record, name) {
                var dataSet = $('psr_report_groups_ds');
                var index = record.get('line_number'); //dataSet.indexOf(record);
                return '<a href="javascript:delFunction(' + index + ',\'psr_report_groups_ds\')">删除</a>';
            }
            
            function orderDelFun(value, record, name) {
                var dataSet = $('psr_report_orders_ds');
                var index = record.get('line_number'); //dataSet.indexOf(record);
                return '<a href="javascript:delFunction(' + index + ',\'psr_report_orders_ds\')">删除</a>';
            }
            
            
            //基表批量刪除ds
            
            function removeDataSet(ds_name) {
                var ds = $(ds_name);
                var length = ds.getAll().length;
                for (var i = 0;i < length;i++) {
                    record = ds.getAt(i);
                    ds.remove(record);
                }
            }
            
            //清空显示字段
            
            function clearFieldsFun() {
                Leaf.showConfirm('提示', '确定清空?', function okFun() {
                    var dataSet = $('psr_report_fields_selection_ds');
                    var records = dataSet.getAll();
                    for (var i = 0;i < records.length;i++) {
                        if (records[i].get('report_field_id')) {
                            record = $('psr_report_fields_ds').find('report_field_id', records[i].get('report_field_id'));
                        } else {
                            record = $('psr_report_fields_ds').find('report_fields_dis', records[i].get('report_fields_dis'));
                        }
                        $('psr_report_fields_ds').remove(record);
                    }
                    var headers_ds = $('psr_report_headers_ds');
                    var headerRecord = headers_ds.getAt(0);
                    headerRecord.set('sql_statement', '');
            
                    removeDataSet('psr_report_groups_ds');
                    removeDataSet('psr_report_orders_ds');
                    // $('psr_report_groups_ds').removeAll();
                    // $('psr_report_orders_ds').removeAll();
                    $('psr_styles_ds').removeAll();
                    dataSet.removeAll();
                });
            }
            
            function addFieldFun() {
                $('psr_report_fields_selection_grid_id').showEditorByRecord($('psr_report_fields_selection_ds').create());
            }
            
            
            function on_psr_report_fields_selection_ds_update(ds, record, name, value, old_value) {
            
                record.getField('field_description_dis').setPropertity('tooltip', record.get('field_description'));
            
                var report_fields_ds = $('psr_report_fields_ds');
                var style_ds = $('psr_styles_ds');
                var current_report_field_record = report_fields_ds.find('line_number', record.get('line_number'));
                var current_style_record = style_ds.find('line_number', record.get('line_number'));
                if (name == 'report_fields_dis') {
                    record.set('field_name', value);
                }
            
            
                if (current_report_field_record) {
                    current_report_field_record.set(name, value);
                }
                if (current_style_record) {
                    current_style_record.set(name, value);
                }
            }
            
            
            function set_record_data() {
                for (var name in record.data) {
                    report_fields_record.set(name, record.get(name));
                }
            }
            
            function on_psr_report_fields_selection_ds_add(ds, record, index) {
                record.set('field_category', 'FIELD');
                record.set('field_category_dis', '字段');
                var report_fields_ds = $('psr_report_fields_ds');
                var style_ds = $('psr_styles_ds');
            
                report_fields_ds.create(Ext.apply({}, record.data));
                style_ds.create(Ext.apply({}, record.data));
            
                setLineNumber(ds, record, index);
                setLineNumber(report_fields_ds, record, index);
                setLineNumber(style_ds, record, index);
            
            }
            
            function on_psr_report_fields_selection_ds_load(ds) {
                if (ds.getAll().length > 0) {
                    for (var i = 0;i < ds.getAll().length;i++) {
                        var record = ds.getAt(i);
                        record.set('report_fields_dis', record.get('field_name'));
                        record.getField('field_description_dis').setPropertity('tooltip', record.get('field_description'));
                    }
                }
            }
            
            //选择基表
            
            function selectTableFun() {
                new Leaf.Window({
                    id: 'psr_report_table_selection_win',
                    url: $('psr_report_table_selection_link').getUrl(),
                    title: '选择基表',
                    height: 480,
                    width: 510
                });
            }
            
            //报表关联
            
            function reportHeadersRelation() {
                var dataSet = $('psr_report_headers_relation_ds');
                dataSet.create();
            }
            
            function formatDate(value, record, name) {
                return Leaf.formatDate(value, record, name).substr(0, 10);
            }
            
            function goQueryFun() {
                window.location.href = '${/request/@context_path}/modules/psr/PSR1020/psr_report_query.lview';
            }
            
            
            //字段变更
            
            
            function fieldUpdateFun(ataSet, record, name, value, oldvalue) {
                if (name == 'line_number') {
                    var groupDataSet = $('psr_report_groups_ds');
                    var groupRecords = groupDataSet.getAll();
                    if (groupRecords.length > 0) {
                        var gRecord = groupDataSet.find('field_name', record.get('field_name'));
                        if (gRecord === null) {
            
                           } else {
                            var field_name = typeof(gRecord.get('field_name')) == 'undefined' ? 0 : gRecord.get('field_name');
                            if (field_name == record.get('field_name')) {
                                gRecord.set('field_line_number', value);
                            }
                        }
                    }
                }
            }
            
            //
            
            function fieldLoadFun(dataSet) {
                var groups_ds = $('psr_report_groups_ds');
                var orders_ds = $('psr_report_orders_ds');
                var headers_ds = $('psr_report_headers_ds');
                var record = headers_ds.getCurrentRecord();
                //var report_header_id = '${/parameter/@report_header_id}';
                var report_header_id = record.get('report_header_id');
                groups_ds.setQueryParameter('report_header_id', report_header_id);
                orders_ds.setQueryParameter('report_header_id', report_header_id);
            
                groups_ds.query();
                orders_ds.query();
            
            }
            
            //
            // function webTest(){
            
            // var data = {};
            // data['details'] = [];
            
            // for (var i = 0;i < 5;i++) {
            // var detailData = {
            // log_text: '数据:'+i
            // };
            // data['details'].push(detailData);
            // }
            // Leaf.request({
            // url: $('psr_report_test').getUrl(),
            // para: data,
            // success: function() {
            
            // }
            // });
            // }
            //预览
            
            function outputPreview_create(record_id) {
                var record = $('psr_report_headers_ds').getCurrentRecord();
                var report_header_id = record.get('report_header_id'),
                    layout_code = record.get('layout_code'),
                    width = record.get('width'),
                    height = record.get('height');
                var fullScreen = true;
                if (width && height) {
                    fullScreen = false;
                }
                if (layout_code) {
                    new Leaf.Window({
                        url: $('psr_report_parameter_preview_create_dynamic').getUrl(),
                        title: '选择预览参数',
                        params: {
                            winid: 'psr_report_parameter_preview_create_dynamic_winid',
                            report_header_id: report_header_id,
                            layout_code: layout_code,
                            create_flag: 'Y'
                        },
                        id: 'psr_report_parameter_preview_create_dynamic_winid',
                        fullScreen: fullScreen,
                        width: width,
                        height: height,
                        draggable: true
                    });
                } else {
                    finnal_outputpreview_create({
                        report_header_id: report_header_id
                    });
                }
            }
            
            function finnal_outputpreview_create(params) {
                params['winid'] = 'psr_report_preview_create_screen';
                new Leaf.Window({
                    url: $('psr_report_preview_create_link').getUrl(),
                    params: params,
                    id: 'psr_report_preview_create_screen',
                    fullScreen: true
                });
            }
            
            function synchronization_ajax_download_deal_create(report_id, path, name) {
                var file_path = path;
                var file_name_desc = name;
                file_path = file_path.replace(/\\/g, '/');
                var index = file_path.lastIndexOf('/');
                index = index + 1;
                var fileName = file_path.substring(index);
                if (!file_name_desc) {
                    file_name_desc = fileName;
                }
                var download_url = '${/request/@context_path}/task_report/download?report_id=' + report_id + '&fileName=' + fileName + '&fileNameDesc=' + file_name_desc;
                Leaf.post(download_url);
            }
            
            function synchronization_ajax_report_create(params) {
                if (params['synchronization_flag'] == 'Y') {
                    if (params['winid']) {
                        Leaf.Masker.mask($(params['winid']).wrap, '${l:HLS.EXECUTING}');
                    }
                    Ext.Ajax.request({
                        url: $('psr_report_output_create').getUrl(),
                        params: {
                            _request_data: Ext.util.JSON.encode({
                                parameter: params
                            })
                        },
                        success: function(res) {
                            var obj = eval('(' + res.responseText + ')');
                            synchronization_ajax_download_deal_create(obj.result.report_id, obj.result.file_path, obj.result.file_name);
                            if (params['winid']) {
                                Leaf.Masker.unmask($(params['winid']).wrap);
                            }
                        }
                    });
                } else {
                    Leaf.request({
                        url: $('psr_report_output_create').getUrl(),
                        para: params,
                        success: function(res) {
                            Leaf.showMessage('${l:HLS.PROMPT}', '文件生成中,请稍后查看任务列表');
                        },
                        scope: this
                    });
                }
            }
            //运行
            
            function outputFun_create() {
                var record = $('psr_report_headers_ds').getCurrentRecord();
                var report_header_id = record.get('report_header_id'),
                    layout_code = record.get('layout_code'),
                    width = record.get('width'),
                    height = record.get('height'),
                    unsynchronization_flag = record.get('unsynchronization_flag'),
                    synchronization_flag;
                var fullScreen = true;
                if (width && height) {
                    fullScreen = false;
                }
                if (unsynchronization_flag == 'Y') {
                    synchronization_flag = 'N';
                } else {
                    synchronization_flag = 'Y';
                }
                if (layout_code) {
                    new Leaf.Window({
                        url: $('psr_report_parameter_create_dynamic').getUrl(),
                        title: '选择运行参数',
                        params: {
                            winid: 'psr_report_parameter_create_dynamic_winid',
                            report_header_id: report_header_id,
                            layout_code: layout_code,
                            synchronization_flag: synchronization_flag,
                            function_code: 'PSR1020',
                            create_flag: 'Y'
                        },
                        id: 'psr_report_parameter_create_dynamic_winid',
                        fullScreen: fullScreen,
                        width: width,
                        height: height,
                        draggable: true
                    });
                } else {
                    synchronization_ajax_report_create({
                        report_header_id: report_header_id,
                        layout_code: layout_code,
                        synchronization_flag: synchronization_flag
                    });
                }
            }
            
            function Fields_afterremoveFun(ds) {
                var dataSet = $('psr_report_fields_selection_ds');
                var report_header_id = ds.getAt(0).get('report_header_id');
                dataSet.setQueryParameter('report_header_id', report_header_id);
                dataSet.setQueryParameter('field_category', 'FIELD');
                dataSet.query();
            }
            
            function headerRender(value, record, name) {
                if (value != null) {
                    return '已设置';
                } else {
                    return '';
                }
            }
            
            function cellRender(value, record, name) {
                if (value != null) {
                    return '已设置';
                } else {
                    return '';
                }
            }
            
            function setTitleBatch() {
                var records = $('psr_styles_ds').getSelected();
                if (!records.length) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先选择批量设置的行!');
                    return;
                }
                new Leaf.Window({
                    id: 'titleStyle',
                    url: $('psr_report_field_style_link').getUrl(),
                    params: {
                        grid_id: '1',
                        batch_flag: 'Y',
                        winid: 'titleStyle'
                    },
                    title: '表头样式批量设置',
                    height: 550,
                    width: 700
                });
            }
            
            function setCellBatch() {
                var records = $('psr_styles_ds').getSelected();
                if (!records.length) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先选择批量设置的行!');
                    return;
                }
                new Leaf.Window({
                    id: 'titleStyle',
                    url: $('psr_report_field_style_link').getUrl(),
                    params: {
                        grid_id: '2',
                        batch_flag: 'Y',
                        winid: 'titleStyle'
                    },
                    title: '单元格样式批量设置',
                    height: 550,
                    width: 700
                });
            }
            
            function fields_selection_grid_editorfunction(record, name) {
                var head_record = $('psr_report_headers_ds').getCurrentRecord();
                if (!head_record) {
                    return '';
                }
                if (head_record.get('report_type') == 'USERDEFINE_REPORT') {
                    if (name == 'field_type_dis') {
                        return 'fields_selection_grid_combobox_id';
                    } else if (name == 'report_fields_dis') {
                        return 'fields_selection_grid_textfield_upper_id';
                    } else {
                        return 'fields_selection_grid_textfield_id';
                    }
                } else {
                    return '';
                }
            
            }
            
            function on_tabpannel_select(tab, index) {
                step = index;
            }
            
            function layout_parameter_right() {
                var psr_report_layout_ds = $('psr_report_layout_ds'),
                    psr_report_layout_select_ds = $('psr_report_layout_select_ds');
                var records = psr_report_layout_ds.getSelected();
                if (records.length > 0) {
                    for (var i = 0;i < records.length;i++) {
                        var record = records[i];
                        var select_record = psr_report_layout_select_ds.find('column_name', record.get('column_name'));
                        if (!select_record) {
                            psr_report_layout_ds.removeLocal(record);
                            psr_report_layout_select_ds.create(Ext.apply({}, record.data));
                            i = i - 1;
                        }
                    }
                } else {
                    return;
                }
            }
            
            function layout_parameter_left() {
                var psr_report_layout_ds = $('psr_report_layout_ds'),
                    psr_report_layout_select_ds = $('psr_report_layout_select_ds');
                var records = psr_report_layout_select_ds.getSelected();
                if (records.length > 0) {
                    for (var i = 0;i < records.length;i++) {
                        var record = records[i];
                        var select_record = psr_report_layout_ds.find('column_name', record.get('column_name'));
                        if (!select_record) {
                            psr_report_layout_ds.create(Ext.apply({}, record.data));
                            psr_report_layout_select_ds.removeLocal(record);
                            i = i - 1;
                        }
                    }
                } else {
                    return;
                }
            }
            
            function aut_trx_report_record(record) {
                var header_record = $('psr_report_headers_ds').getCurrentRecord();
                if (header_record) {
                    record.set('trx_id', header_record.get('report_header_id'));
                    record.set('trx_category', 'CONFIG_REPORT');
                    record.set('trx_number', header_record.get('report_header_name'));
                    record.set('trx_name', header_record.get('report_header_description'));
                }
            }
            
            function aut_trx_user_report_ds_add(ds, record, index) {
                aut_trx_report_record(record);
            }
            
            function aut_trx_user_report_ds_load(ds) {
                // var records = ds.getAll();
                // for (var i = 0;i < records.length;i++) {
                // var record = records[i];
                // aut_trx_report_record(record);
                // }
            }
            
            function psr1010lovFunction(record, name) {
                if (record.isNew) {
                    return 'psr1010_grid_lov';
                } else {
                    return '';
                }
            }
            
            function aut_trx_user_report_ds_query(ds, qpara) {
                var header_record = $('psr_report_headers_ds').getCurrentRecord();
                if (header_record) {
                    qpara['report_header_id'] = header_record.get('report_header_id');
                }
            }
            
            
            
            //grid行上下移动
            
            
            function field_change_index(ds_name, record, line_number, gap) {
                //排序,按line_number大小顺排
            
                function sortFunc(a, b) {
                    return a.get('line_number') - b.get('line_number');
                }
            
                var ds = $(ds_name);
                var index = ds.indexOf(record);
                var next_record = ds.getAt(index + gap);
                if (!Ext.isEmpty(next_record)) {
                    record.set('line_number', next_record.get('line_number'));
                    next_record.set('line_number', line_number);
                }
                ds.data.sort(sortFunc);
                ds.fireEvent('load', ds);
            
            }
            
            
            //上移
            
            function fieldMoveUp(record_id) {
                var record = $('psr_report_fields_selection_ds').findById(record_id);
            
                var line_number = record.get('line_number');
                field_change_index('psr_report_fields_selection_ds', record, line_number, -1);
            
                var style_record = $('psr_styles_ds').find('line_number', line_number);
                field_change_index('psr_styles_ds', style_record, line_number, -1);
            
                var field_record = $('psr_report_fields_ds').find('line_number', line_number);
                field_change_index('psr_report_fields_ds', field_record, line_number, -1);
            
            }
            
            
            //下移
            
            function fieldMoveDown(record_id) {
                var record = $('psr_report_fields_selection_ds').findById(record_id);
            
                var line_number = record.get('line_number');
                field_change_index('psr_report_fields_selection_ds', record, line_number, 1);
            
                var style_record = $('psr_styles_ds').find('line_number', line_number);
                field_change_index('psr_styles_ds', style_record, line_number, 1);
            
                var field_record = $('psr_report_fields_ds').find('line_number', line_number);
                field_change_index('psr_report_fields_ds', field_record, line_number, 1);
            }
            
            
            //显示字段上移
            
            
            function fieldMoveUpRender(value, record, name) {
                if ($('psr_report_fields_selection_ds').indexOf(record) != 0) {
                    return '<a href="javascript:fieldMoveUp(' + record.id + ')">上移</a>';
                }
            }
            
            //显示字段下移
            
            function fieldMoveDownRender(value, record, name) {
                if (record.get('max_index_flag') == 'Y') {
                    return '';
                } else {
                    return '<a href="javascript:fieldMoveDown(' + record.id + ')">下移</a>';
                }
            }
            
            
            function psr_styles_ds_update(ds, record, name, value, oldvalue) {
                var field_name = record.get('field_name');
                var grid_id = record.get('grid_id');
                if (name == 'header_style' || name == 'cell_style') {
                    var field_record = $('psr_report_fields_ds').find('field_name', record.get('field_name'));
                    if (Ext.isEmpty(value)) {
                        var style_length = styles_data.length;
                        for (var i = 0;i < style_length;i++) {
                            if (styles_data[i]['field_name'] == field_name && (name == 'header_style' || name == 'cell_style')) {
                                styles_data.splice(i, 1);
                            }
                        }
            
                        if (name == 'header_style') {
                            field_record.set('header_style', '');
                        } else if (name == 'cell_style') {
                            field_record.set('cell_style', '');
                        }
            
                    }
            
            
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="leftBracket_ds">
                <a:datas>
                    <a:record code_value=" " code_value_name=" "/>
                    <a:record code_value="(" code_value_name="("/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="rightBracket_ds">
                <a:datas>
                    <a:record code_value=" " code_value_name=" "/>
                    <a:record code_value=")" code_value_name=")"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="psr_view_range_code_ds" lookupCode="PSR_VIEW_RANGE_CODE"/>
            <a:dataSet id="psr_report_type_code_ds" lookupCode="PSR_REPORT_TYPE_CODE"/>
            <a:dataSet id="psr_field_type_code_ds" lookupCode="PSR_FIELD_TYPE_CODE"/>
            <a:dataSet id="psr_condition_type_code_ds" lookupCode="PSR_CONDITION_TYPE_CODE"/>
            <a:dataSet id="psr_field_1_category_code_ds" lookupCode="PSR_FIELD_1_CATEGORY_CODE"/>
            <a:dataSet id="psr_field_2_category_code_ds" lookupCode="PSR_FIELD_2_CATEGORY_CODE"/>
            <a:dataSet id="psr_logic_code_ds" lookupCode="PSR_LOGIC_CODE"/>
            <a:dataSet id="psr_parenthesis_code_ds" lookupCode="PSR_PARENTHESIS_CODE"/>
            <a:dataSet id="psr_field_category_code_ds" lookupCode="PSR_FIELD_CATEGORY_CODE"/>
            <a:dataSet id="psr_table_join_code_ds" lookupCode="PSR_TABLE_JOIN_CODE"/>
            <a:dataSet id="psr_field_order_code_ds" lookupCode="PSR_FIELD_ORDER_CODE"/>
            <a:dataSet id="psr_report_push_cycle_code_ds" lookupCode="PSR_REPORT_PUSH_CYCLE_CODE"/>
            <a:dataSet id="psr_subtotal_type_code_ds" lookupCode="PSR_SUBTOTAL_TYPE_CODE"/>
            <a:dataSet id="psr_statistics_type_code_ds" lookupCode="PSR_STATISTICS_TYPE_CODE"/>
            <a:dataSet id="report_list_ds" model="psr.PSR1010.psr_report_headers" queryUrl="${/request/@context_path}/autocrud/psr.PSR1010.psr_report_headers/query?report_type=&apos;CONDITION_REPORT&apos;"/>
            <!--报表数据 -->
            <a:dataSet id="psr_report_headers_ds" loadData="true" model="psr.PSR1010.psr_report_headers">
                <a:fields>
                    <a:field name="report_header_name" defaultValue="新建未保存报表" required="true"/>
                    <a:field name="report_header_description" defaultValue="新建未保存报表" required="true"/>
                    <a:field name="view_range" defaultValue="PRIVATE"/>
                    <a:field name="view_range_dis" defaultValue="私有" displayField="code_value_name" options="psr_view_range_code_ds" required="true" returnField="view_range" valueField="code_value"/>
                    <a:field name="report_type_dis" displayField="code_value_name" options="psr_report_type_code_ds" required="true" returnField="report_type" valueField="code_value"/>
                    <a:field name="fixed_time_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="unsynchronization_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="other_report_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="other_report_header_name" displayField="report_header_name" options="report_list_ds" returnField="other_report_header_id" valueField="report_header_name">
                        <a:mapping>
                            <!-- <a:map from="report_header_name" to="other_report_header_name"/> -->
                            <a:map from="report_header_id" to="other_report_header_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="push_cycle_dis" displayField="code_value_name" options="psr_report_push_cycle_code_ds" returnField="push_cycle" valueField="code_value"/>
                    <a:field name="sql_statement" readOnly="true"/>
                    <a:field name="layout_code"/>
                    <a:field name="layout_code_desc" autoComplete="true" autoCompleteField="layout_code" lovGridHeight="300" lovHeight="460" lovLabelWidth="100" lovService="psr.PSR1010.psr_report_layout_query" lovWidth="530" prompt="参数描述" title="参数描述">
                        <a:mapping>
                            <a:map from="layout_code" to="layout_code"/>
                            <a:map from="description" to="layout_code_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="validation_sql"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="reportHeaderAddFun"/>
                    <a:event name="update" handler="reportHeaderUpdateFun"/>
                    <a:event name="load" handler="reportHeaderLoadFun"/>
                </a:events>
            </a:dataSet>
            <!--报表数据表 -->
            <a:dataSet id="psr_report_tables_ds" fetchAll="true" model="psr.PSR1010.psr_report_tables">
                <a:fields>
                    <a:field name="table_name"/>
                    <a:field name="table_description"/>
                    <a:field name="table_alias"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="setLineNumber"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="tmp_ds">
                <a:datas dataSource="/model/fields"/>
            </a:dataSet>
            <a:dataSet id="psr_styles_ds" selectable="true">
                <a:fields>
                    <a:field name="header_style_name" lovAutoQuery="true" lovGridHeight="320" lovHeight="550" lovUrl="${/request/@context_path}/modules/psr/PSR1010/psr_report_field_style.lview?grid_id=1" lovWidth="700" prompt="表头样式" title="表头样式">
                        <a:mapping>
                            <a:map from="header_style" to="header_style"/>
                            <a:map from="header_style_name" to="header_style_name"/>
                            <!-- <a:map from="name" to="header_style_name"/> -->
                        </a:mapping>
                    </a:field>
                    <a:field name="header_style"/>
                    <a:field name="cell_style_name" lovAutoQuery="true" lovGridHeight="320" lovHeight="550" lovUrl="${/request/@context_path}/modules/psr/PSR1010/psr_report_field_style.lview?grid_id=2" lovWidth="700" prompt="单元格样式" title="单元格样式">
                        <a:mapping>
                            <a:map from="cell_style" to="cell_style"/>
                            <a:map from="cell_style_name" to="cell_style_name"/>
                            <!-- <a:map from="name" to="cell_style_name"/> -->
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="psr_styles_ds_update"/>
                </a:events>
            </a:dataSet>
            <!--报表显示字段 -->
            <a:dataSet id="psr_report_fields_ds" fetchAll="true" model="psr.PSR1010.psr_report_fields">
                <a:fields>
                    <a:field name="number_allowformat" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="field_category_dis" displayField="code_value_name" options="psr_field_category_code_ds" returnField="field_category" valueField="code_value"/>
                    <a:field name="field_type_dis" displayField="code_value_name" options="psr_field_type_code_ds" required="true" returnField="field_type" valueField="code_value"/>
                    <a:field name="subtotal_type_dis" displayField="code_value_name" options="psr_subtotal_type_code_ds" required="true" returnField="subtotal_type" valueField="code_value"/>
                    <a:field name="statistics_type_dis" displayField="code_value_name" options="psr_statistics_type_code_ds" required="true" returnField="statistics_type" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <!-- <a:event name="add" handler="setLineNumber"/> -->
                    <a:event name="update" handler="fieldUpdateFun"/>
                    <a:event name="load" handler="fieldLoadFun"/>
                    <!-- <a:event name="afterremove" handler="Fields_afterremoveFun"/> -->
                </a:events>
            </a:dataSet>
            <!--选择显示字段 -->
            <a:dataSet id="psr_report_fields_selection_ds" fetchAll="true" model="psr.PSR1010.psr_report_fields">
                <a:fields>
                    <a:field name="field_category_dis" displayField="code_value_name" options="psr_field_category_code_ds" returnField="field_category" valueField="code_value"/>
                    <a:field name="field_type_dis" displayField="code_value_name" options="psr_field_type_code_ds" required="true" returnField="field_type" valueField="code_value"/>
                    <a:field name="statistics_type_dis" displayField="code_value_name" options="psr_statistics_type_code_ds" returnField="statistics_type" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="on_psr_report_fields_selection_ds_add"/>
                    <a:event name="update" handler="on_psr_report_fields_selection_ds_update"/>
                    <a:event name="load" handler="on_psr_report_fields_selection_ds_load"/>
                </a:events>
            </a:dataSet>
            <!--报表条件-->
            <a:dataSet id="psr_report_conditions_ds" fetchAll="true" model="psr.PSR1010.psr_report_conditions">
                <a:fields>
                    <a:field name="condition_type_dis" displayField="code_value_name" options="psr_condition_type_code_ds" returnField="condition_type" valueField="code_value"/>
                    <a:field name="logic_dis" displayField="code_value_name" options="psr_logic_code_ds" returnField="logic" valueField="code_value"/>
                    <a:field name="left_parenthesis_dis" displayField="code_value_name" options="leftBracket_ds" returnField="left_parenthesis" valueField="code_value"/>
                    <a:field name="right_parenthesis_dis" displayField="code_value_name" options="rightBracket_ds" returnField="right_parenthesis" valueField="code_value"/>
                    <a:field name="field_1_category_dis" displayField="code_value_name" options="psr_field_1_category_code_ds" required="true" returnField="field_1_category" valueField="code_value"/>
                    <a:field name="field_2_category_dis" displayField="code_value_name" options="psr_field_2_category_code_ds" required="true" returnField="field_2_category" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="setLineNumber"/>
                </a:events>
            </a:dataSet>
            <!--报表分组 -->
            <a:dataSet id="psr_report_groups_ds" fetchAll="true" model="psr.PSR1010.psr_report_groups">
                <a:fields>
                    <a:field name="field_name" displayField="field_name" options="psr_report_fields_ds" required="true" returnField="field_name" valueField="field_name">
                        <a:mapping>
                            <a:map from="table_name" to="table_name"/>
                            <a:map from="line_number" to="field_line_number"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="setLineNumber"/>
                </a:events>
            </a:dataSet>
            <!--报表排序 -->
            <a:dataSet id="psr_report_orders_ds" fetchAll="true" model="psr.PSR1010.psr_report_orders">
                <a:fields>
                    <a:field name="field_name" displayField="field_name" options="psr_report_fields_ds" required="true" returnField="field_name" valueField="field_name">
                        <a:mapping>
                            <a:map from="table_name" to="table_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="order_code" defaultValue="ASC"/>
                    <a:field name="order_code_dis" defaultValue="升序" displayField="code_value_name" options="psr_field_order_code_ds" required="true" returnField="order_code" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="setLineNumber"/>
                </a:events>
            </a:dataSet>
            <!--删除 中转-->
            <a:dataSet id="psr_report_del_ds"/>
            <a:dataSet id="psr_report_layout_ds" pageSize="1000" selectable="true">
                <a:datas dataSource="/model/category_parameter_path"/>
            </a:dataSet>
            <a:dataSet id="psr_report_layout_select_ds" pageSize="1000" selectable="true">
                <a:datas dataSource="/model/select_parameter_path"/>
            </a:dataSet>
            <a:dataSet id="aut_trx_user_report_ds" autoPageSize="true" autoQuery="true" model="aut.AUT103.aut_trx_user_authorize" queryUrl="${/request/@context_path}/autocrud/psr.PSR1010.aut_trx_user_report_query/query" selectable="true">
                <a:fields>
                    <a:field name="trx_category"/>
                    <a:field name="trx_category_desc"/>
                    <a:field name="trx_id"/>
                    <a:field name="trx_name"/>
                    <a:field name="trx_number"/>
                    <a:field name="user_id" required="true"/>
                    <a:field name="user_desc" autoComplete="true" lovGridHeight="350" lovHeight="550" lovService="basic.sys_user_for_lov" lovWidth="550" prompt="AUT_TRX_USER_AUTHORIZE.USER_ID" required="true" title="AUT103.USER_ID">
                        <a:mapping>
                            <a:map from="description" to="user_desc"/>
                            <a:map from="employee_name" to="user_employee_name"/>
                            <a:map from="user_id" to="user_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="user_employee_name"/>
                    <a:field name="start_date" defaultValue="${/model/default_value_path/record/@now_time}" required="true"/>
                    <a:field name="end_date" defaultValue="${/model/default_value_path/record/@never_date}"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="aut_trx_user_report_ds_add"/>
                    <!-- <a:event name="load" handler="aut_trx_user_report_ds_load"/> -->
                    <a:event name="query" handler="aut_trx_user_report_ds_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <!-- <a:fieldSet height="540" marginHeight="50" marginWidth="50" title="报表新建" width="900"/> -->
            <a:hBox>
                <a:tabPanel id="step" marginHeight="50" marginWidth="50">
                    <a:tabs>
                        <a:tab id="step_0" disabled="false" prompt="报表类型" selected="true" width="60">
                            <a:form column="1" marginWidth="55" title="报表类型">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="cancelFun" text="取消"/>
                                <a:button click="step_0NextStep" text="下一步"/>
                            </a:hBox>
                            <a:hBox>
                                <a:fieldSet height="250" title="报表类型" width="300">
                                    <a:comboBox name="report_type_dis" bindTarget="psr_report_headers_ds" prompt="报表类型" width="200"/>
                                </a:fieldSet>
                            </a:hBox>
                        </a:tab>
                        <a:tab id="step_1" disabled="false" prompt="输入参数" width="60">
                            <a:form column="1" marginWidth="55" title="报表类型">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="upStep" text="上一步"/>
                                <a:button click="nextStep" text="下一步"/>
                                <a:label width="50"/>
                                <!-- <a:button click="queryLayout" text="查询"/> -->
                            </a:hBox>
                            <a:form name="parmater_form" labelWidth="100" marginWidth="55" title="具体参数">
                                <a:box column="3" width="812">
                                    <a:vBox>
                                        <div style="font-size:20px;"><![CDATA[参数库]]></div>
                                        <a:grid bindTarget="psr_report_layout_ds" marginHeight="300" navBar="true" width="400">
                                            <a:columns>
                                                <a:column name="column_name" prompt="参数代码" width="150"/>
                                                <a:column name="prompt" prompt="参数描述" width="200"/>
                                            </a:columns>
                                        </a:grid>
                                    </a:vBox>
                                    <a:vBox style="margin-top:100px;">
                                        <a:button click="layout_parameter_right" height="50" icon="${/request/@context_path}/images/arrow_right.png" width="80"/>
                                        <a:button click="layout_parameter_left" height="50" icon="${/request/@context_path}/images/arrow_left.png" width="80"/>
                                    </a:vBox>
                                    <a:vBox>
                                        <div style="font-size:20px;"><![CDATA[已选参数]]></div>
                                        <a:grid bindTarget="psr_report_layout_select_ds" marginHeight="300" navBar="true" width="400">
                                            <a:columns>
                                                <a:column name="column_name" prompt="参数代码" width="150"/>
                                                <a:column name="prompt" prompt="参数描述" width="200"/>
                                            </a:columns>
                                        </a:grid>
                                    </a:vBox>
                                </a:box>
                            </a:form>
                        </a:tab>
                        <a:tab id="step_2" disabled="false" prompt="数据来源" selected="false" width="60">
                            <a:form column="1" marginWidth="55" title="数据来源">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="upStep" text="上一步"/>
                                <a:button click="step_1NextStep" text="下一步"/>
                                <a:label width="50"/>
                                <a:button id="selectTableFun_id" click="selectTableFun" style="display:none" text="选择基表"/>
                                <a:button id="clearFieldsFun_id" click="clearFieldsFun" style="display:none" text="清空字段"/>
                                <a:button id="addFieldFun_id" click="addFieldFun" style="display:none" text="新增字段"/>
                                <!-- <a:button click="webTest" text="测试"/> -->
                            </a:hBox>
                            <a:hBox>
                                <a:fieldSet id="userdefine_sql_id" style="display:none;" title="自定义sql">
                                    <a:form column="1" labelSeparator=" ">
                                        <a:textArea name="sql_statement" bindTarget="psr_report_headers_ds" height="330" prompt=" " width="450"/>
                                    </a:form>
                                </a:fieldSet>
                                <a:fieldSet id="ref_table_id" style="display:none;" title="关联表">
                                    <a:grid bindTarget="psr_report_tables_ds" height="350" width="450">
                                        <a:columns>
                                            <!-- <a:column name="line_number" prompt="序号" align="center"  renderer="lineNumberFun" width="35"/> -->
                                            <a:column name="dis" prompt="表名-描述" renderer="tableNameFun" width="285"/>
                                            <a:column name="table_alias" align="center" prompt="别名" width="50"/>
                                            <a:column name="add" align="center" prompt="关联" renderer="addTableFun" width="50"/>
                                            <a:column name="del" align="center" prompt="删除" renderer="delTableFun" width="45"/>
                                        </a:columns>
                                    </a:grid>
                                </a:fieldSet>
                                <a:fieldSet title="显示字段" width="720">
                                    <a:grid id="psr_report_fields_selection_grid_id" bindTarget="psr_report_fields_selection_ds" height="350" width="700">
                                        <a:columns>
                                            <a:column name="line_number" align="center" prompt="序号" width="35"/>
                                            <a:column name="report_fields_dis" editorFunction="fields_selection_grid_editorfunction" prompt="字段" renderer="fieldsDisFun" width="200"/>
                                            <a:column name="field_type_dis" editorFunction="fields_selection_grid_editorfunction" prompt="类型" width="50"/>
                                            <a:column name="field_description_dis" editor="fields_selection_grid_textfield_id" prompt="描述" width="200"/>
                                            <a:column name="statistics_type_dis" editor="fields_selection_grid_combobox_id" prompt="统计类型" width="70"/>
                                            <a:column name="move_up" align="center" prompt="上移" renderer="fieldMoveUpRender" width="45"/>
                                            <a:column name="move_down" align="center" prompt="下移" renderer="fieldMoveDownRender" width="45"/>
                                            <a:column name="field_del" align="center" prompt="删除" renderer="fieldSDelFun" width="45"/>
                                        </a:columns>
                                        <a:editors>
                                            <a:textField id="fields_selection_grid_textfield_upper_id" typeCase="UPPER"/>
                                            <a:textField id="fields_selection_grid_textfield_id"/>
                                            <a:comboBox id="fields_selection_grid_combobox_id"/>
                                        </a:editors>
                                    </a:grid>
                                </a:fieldSet>
                            </a:hBox>
                        </a:tab>
                        <a:tab id="step_3" disabled="false" prompt="新增条件" tabStyle="display:none" width="60">
                            <a:form column="1" marginWidth="55" title="新增条件">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="upStep" text="上一步"/>
                                <a:button click="step_3NextStep" text="下一步"/>
                                <a:label width="50"/>
                            </a:hBox>
                            <a:fieldSet title="条件列表">
                                <a:hBox>
                                    <a:button click="addConditionFun" text="添加条件"/>
                                </a:hBox>
                                <a:table bindTarget="psr_report_conditions_ds" height="300" marginWidth="60" width="870">
                                    <a:columns>
                                        <a:column name="line_number" align="center" prompt="序号" width="35"/>
                                        <a:column name="logic_dis" align="center" editorFunction="editorFun" prompt="逻辑" width="120"/>
                                        <a:column name="left_parenthesis_dis" align="center" editorFunction="editorFun" prompt="左括号" width="60"/>
                                        <a:column name="field_1" align="center" prompt="表达式1" width="150"/>
                                        <a:column name="condition_type_dis" align="center" prompt="条件类型" width="60"/>
                                        <a:column name="field_2" align="center" prompt="表达式2" width="150"/>
                                        <a:column name="right_parenthesis_dis" align="center" editorFunction="editorFun" prompt="右括号" width="60"/>
                                        <a:column name="conditions_editor" align="center" prompt="编辑" renderer="conditionsEditorFun" width="60"/>
                                        <a:column name="conditions_del" align="center" prompt="删除" renderer="conditionsDelFun" width="60"/>
                                    </a:columns>
                                    <a:editors>
                                        <a:comboBox id="comboBoxEditor"/>
                                    </a:editors>
                                </a:table>
                            </a:fieldSet>
                        </a:tab>
                        <a:tab id="step_4" disabled="false" prompt="分组排序" tabStyle="display:none" width="60">
                            <a:form column="1" marginWidth="55" title="分组排序">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="upStep" text="上一步"/>
                                <a:button click="step_4NextStep" text="下一步"/>
                                <a:label width="50"/>
                            </a:hBox>
                            <a:fieldSet title="分组列表">
                                <a:hBox>
                                    <a:button click="addGroupFun" text="添加分组"/>
                                    <a:button click="groupUpFun" text="上移"/>
                                    <a:button click="groupDownFun" text="下移"/>
                                </a:hBox>
                                <a:table bindTarget="psr_report_groups_ds" height="300" marginWidth="60" width="870">
                                    <a:columns>
                                        <a:column name="line_number" align="center" prompt="序号" width="35"/>
                                        <a:column name="field_name" editor="groupComboBoxEditor" prompt="分组字段" width="120"/>
                                        <a:column name="group_description" editor="groupTextEditor" prompt="分组描述" width="120"/>
                                        <!-- <a:column name="field_seqencing" align="center" prompt="分组排序" renderer="groupSeqencingFun" width="120"/> -->
                                        <a:column name="group_del" align="center" prompt="删除" renderer="groupDelFun" width="50"/>
                                    </a:columns>
                                    <a:editors>
                                        <a:textField id="groupTextEditor"/>
                                        <a:comboBox id="groupComboBoxEditor"/>
                                    </a:editors>
                                </a:table>
                            </a:fieldSet>
                            <a:hBox height="50"/>
                            <a:fieldSet title="排序列表">
                                <a:hBox>
                                    <a:button click="addOrderFun" text="添加排序"/>
                                    <a:button click="orderUpFun" text="上移"/>
                                    <a:button click="orderDownFun" text="下移"/>
                                </a:hBox>
                                <a:table bindTarget="psr_report_orders_ds" height="300" marginWidth="60" width="870">
                                    <!-- <a:toolBar >
                                    	<a:button type="add" />
                                    </a:toolBar> -->
                                    <a:columns>
                                        <a:column name="line_number" align="center" prompt="序号" width="35"/>
                                        <a:column name="field_name" editor="orderComboBoxEditor" prompt="排序字段" width="120"/>
                                        <a:column name="order_code_dis" editor="orderComboBoxEditor" prompt="排序方式" width="120"/>
                                        <!-- <a:column name="field_seqencing" align="center" prompt="排序" renderer="orderSeqencingFun" width="120"/> -->
                                        <a:column name="order_del" align="center" prompt="删除" renderer="orderDelFun" width="120"/>
                                    </a:columns>
                                    <a:editors>
                                        <a:comboBox id="orderComboBoxEditor"/>
                                    </a:editors>
                                </a:table>
                            </a:fieldSet>
                        </a:tab>
                        <a:tab id="step_5" disabled="false" prompt="输出样式" width="60">
                            <a:form column="1" marginWidth="55" title="输出样式">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="step_5UpStep" text="上一步"/>
                                <a:button click="nextStep" text="下一步"/>
                                <a:label width="50"/>
                            </a:hBox>
                            <a:fieldSet title="字段列表">
                                <!-- <a:hBox>
                                    <a:button click="addExpression" text="添加表达式"/>
                                    <a:button click="fieldUpFun" text="上移"/>
                                    <a:button click="fieldDownFun" text="下移"/>
                                </a:hBox> -->
                                <a:hBox>
                                    <a:button click="setTitleBatch" text="批量设置表头样式"/>
                                    <a:button click="setCellBatch" text="批量设置单元格样式"/>
                                </a:hBox>
                                <a:table id="psr_styles_table_id" bindTarget="psr_styles_ds" height="300" marginWidth="60" width="870">
                                    <!--  <a:columns>
                                        <a:column name="line_number" align="center" prompt="序号" width="35"/>
                                        <a:column name="field_name" align="center" prompt="字段" width="120"/>
                                        <a:column name="field_description" align="center" prompt="字段描述" width="120"/>
                                        <a:column name="field_description_dis" align="center" prompt="显示描述" width="120"/>
                                        <a:column name="field_type" align="center" prompt="数据类型" width="120"/>
                                        <a:column name="field_category_dis" align="center" prompt="字段类别" width="120"/>
                                        <a:column name="field_editor" align="center" prompt="编辑" renderer="fieldEditorFun" width="60"/>
                                        <a:column name="number_allowformat" editor="report_fields_chk" prompt="是否千分位" width="70"/>
                                        <a:column name="header_style" editor="psr_sheet_lov" renderer="headerRender" width="80"/>
                                        <a:column name="field_del" align="center" prompt="删除" renderer="fieldDelFun" width="60"/>
                                    </a:columns> -->
                                    <a:columns>
                                        <a:column name="line_number" align="center" prompt="序号" width="35"/>
                                        <a:column name="field_name" prompt="字段" width="120"/>
                                        <a:column name="field_description_dis" prompt="字段描述" width="120"/>
                                        <a:column name="field_type" prompt="数据类型" width="120"/>
                                        <a:column name="header_style_name" editor="psr_sheet_lov" width="80"/>
                                        <a:column name="cell_style_name" editor="psr_sheet_lov" width="80"/>
                                        <a:column name="field_del" align="center" prompt="删除" renderer="fieldSDelFun" width="60"/>
                                    </a:columns>
                                    <a:editors>
                                        <a:checkBox id="report_fields_chk"/>
                                        <a:lov id="psr_sheet_lov"/>
                                    </a:editors>
                                </a:table>
                            </a:fieldSet>
                        </a:tab>
                        <a:tab id="step_6" disabled="false" prompt="报表授权" width="60">
                            <a:form column="1" marginWidth="55" title="报表类型">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="upStep" text="上一步"/>
                                <a:button click="nextStep" text="下一步"/>
                            </a:hBox>
                            <a:grid id="aut_trx_user_report_grid" bindTarget="aut_trx_user_report_ds" marginHeight="230" marginWidth="100" navBar="true">
                                <a:toolBar>
                                    <a:button type="add"/>
                                    <a:button type="delete"/>
                                </a:toolBar>
                                <a:columns>
                                    <!-- <a:column name="trx_category_desc" prompt="AUT103.TRX_CATEGORY" width="120"/> -->
                                    <a:column name="trx_number" prompt="AUT103.TRX_NUMBER" width="120"/>
                                    <a:column name="trx_name" prompt="AUT103.TRX_NAME" width="150"/>
                                    <a:column name="trx_id" align="center" prompt="AUT103.TRX_ID" width="100"/>
                                    <a:column name="user_desc" editorFunction="psr1010lovFunction" prompt="AUT_TRX_USER_AUTHORIZE.USER_ID" width="100"/>
                                    <a:column name="user_employee_name" prompt="EXP_EMPLOYEES.NAME"/>
                                    <a:column name="start_date" editor="psr1010_datepicker_lov" prompt="HLS.START_DATE" renderer="Leaf.formatDate"/>
                                    <a:column name="end_date" editor="psr1010_datepicker_lov" prompt="HLS.END_DATE" renderer="Leaf.formatDate"/>
                                </a:columns>
                                <a:editors>
                                    <a:lov id="psr1010_grid_lov"/>
                                    <a:datePicker id="psr1010_datepicker_lov"/>
                                </a:editors>
                            </a:grid>
                        </a:tab>
                        <a:tab id="step_7" disabled="false" prompt="保存报表" width="60">
                            <a:form column="1" marginWidth="55" title="保存报表">
                                <a:hBox labelWidth="80">
                                    <a:label name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="150"/>
                                    <a:label name="report_header_description" bindTarget="psr_report_headers_ds" prompt="描述" width="150"/>
                                </a:hBox>
                            </a:form>
                            <a:hBox height="50">
                                <a:button click="upStep" text="上一步"/>
                                <a:button id="saveFun_id" click="saveFun" text="保存"/>
                                <a:label width="50"/>
                                <div id="other_button_id">
                                    <a:hBox>
                                        <a:button click="outputPreview_create" text="预览"/>
                                        <a:button click="outputFun_create" text="运行"/>
                                        <a:button click="goQueryFun" text="报表查询页"/>
                                    </a:hBox>
                                </div>
                            </a:hBox>
                            <a:hBox height="50"/>
                            <a:hBox>
                                <a:vBox labelWidth="150">
                                    <a:textField name="report_header_name" bindTarget="psr_report_headers_ds" prompt="报表名称" width="200"/>
                                    <a:textField name="report_header_description" bindTarget="psr_report_headers_ds" prompt="报表描述" width="200"/>
                                    <a:comboBox name="view_range_dis" bindTarget="psr_report_headers_ds" prompt="查看范围" width="200"/>
                                    <a:checkBox name="unsynchronization_flag" bindTarget="psr_report_headers_ds" prompt="后台运行"/>
                                    <a:checkBox name="fixed_time_flag" bindTarget="psr_report_headers_ds" prompt="是否定时"/>
                                    <a:comboBox name="push_cycle_dis" bindTarget="psr_report_headers_ds" prompt="推送周期" readOnly="true" width="200"/>
                                    <a:datePicker name="start_date" bindTarget="psr_report_headers_ds" prompt="开始日期" readOnly="true" width="200"/>
                                    <a:checkBox name="other_report_flag" bindTarget="psr_report_headers_ds" prompt="关联报表"/>
                                    <a:comboBox name="other_report_header_name" bindTarget="psr_report_headers_ds" prompt="条件报表" readOnly="true" width="200"/>
                                </a:vBox>
                                <a:vBox width="50"/>
                                <div id="sql_statement_id">
                                    <a:fieldSet title="SQL预览">
                                        <a:vBox labelWidth="150">
                                            <a:textArea name="sql_statement" bindTarget="psr_report_headers_ds" height="180" prompt="" width="300"/>
                                        </a:vBox>
                                    </a:fieldSet>
                                </div>
                            </a:hBox>
                        </a:tab>
                    </a:tabs>
                    <a:events>
                        <a:event name="select" handler="on_tabpannel_select"/>
                    </a:events>
                </a:tabPanel>
            </a:hBox>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            //进入页面查询,锁屏
            
            function nodeDetailTempLockScreen() {
                Leaf.Masker.mask(Ext.getBody(), '正在加载..');
            }
            
            //进入页面查询,解锁
            
            function nodeDetailTempUnLockScreen() {
                Leaf.Masker.unmask(Ext.getBody());
            }
            
            
            function allQuery(report_header_id, success_flag) {
                var headers_ds = $('psr_report_headers_ds');
                var tables_ds = $('psr_report_tables_ds');
                var fields_ds = $('psr_report_fields_ds');
                var fields_selection_ds = $('psr_report_fields_selection_ds');
                var conditions_ds = $('psr_report_conditions_ds');
                //var groups_ds = $('psr_report_groups_ds');
                //var orders_ds = $('psr_report_orders_ds');
                var report_list_ds = $('report_list_ds');
                var style_ds = $('psr_styles_ds');
                var tmp_ds = $('tmp_ds');
                var aut_trx_user_report_ds = $('aut_trx_user_report_ds');
                var records_line = tmp_ds.getAll();
            
                headers_ds.setQueryUrl('${/request/@context_path}/autocrud/psr.PSR1010.psr_report_headers_query/query');
            
                headers_ds.setQueryParameter('report_header_id', report_header_id);
                tables_ds.setQueryParameter('report_header_id', report_header_id);
                fields_ds.setQueryParameter('report_header_id', report_header_id);
                fields_selection_ds.setQueryParameter('report_header_id', report_header_id);
                fields_selection_ds.setQueryParameter('field_category', 'FIELD');
                conditions_ds.setQueryParameter('report_header_id', report_header_id);
                aut_trx_user_report_ds.setQueryParameter('report_header_id', report_header_id);
                // groups_ds.setQueryParameter('report_header_id', report_header_id);
                // orders_ds.setQueryParameter('report_header_id', report_header_id);
                report_list_ds.setQueryParameter('report_type', 'CONDITION_REPORT');
                if (success_flag == 'Y') {
                    headers_ds.query();
                }
                tables_ds.query();
                fields_ds.query();
                fields_selection_ds.query();
                for (var k = 0;k < records_line.length;k++) {
                    style_ds.add(records_line[k]);
                }
                conditions_ds.query();
                // groups_ds.query();
                // orders_ds.query();
                report_list_ds.query();
            }
            
            function init() {
                nodeDetailTempLockScreen();
                document.getElementById("other_button_id").style.display = "none";
                document.getElementById("sql_statement_id").style.display = "none";
            
                var report_header_id = '${/parameter/@report_header_id}';
                //添加默认  表信息
                if (report_header_id) {
                    document.getElementById("other_button_id").style.display = "";
                    document.getElementById("sql_statement_id").style.display = "";
                    allQuery(report_header_id);
                } else {
                    var headers_ds = $('psr_report_headers_ds');
                    var headerRecord = new Leaf.Record({
                        report_header_name: '新建未保存报表',
                        report_header_description: '新建未保存报表',
                        view_range: 'PRIVATE',
                        view_range_dis: '私有'
                    });
            
                    // headers_ds.add(headerRecord);
                    //修改直接新增record逻辑,gaoyang
                    if (!headers_ds.getCurrentRecord()) {
                        headers_ds.add(headerRecord);
                    }
            
                    /* var dataSet = $('psr_report_tables_ds');
                     var record = new Leaf.Record({
                     table_name: '${/model/default_table/record/@table_name}',
                     table_description: '${/model/default_table/record/@table_description}',
                     table_alias: 'A',
                     default_table_flag: '${/model/default_table/record/@default_table_flag}'
                     });
                     dataSet.add(record); */
            
                    var report_list_ds = $('report_list_ds');
                    report_list_ds.setQueryParameter('report_type', 'CONDITION_REPORT');
                    report_list_ds.query();
            
                }
                nodeDetailTempUnLockScreen();
            }
            Leaf.onReady(init);
        ]]></script>
    </a:view>
</a:screen>