prj_project_maintain_bak.lview 137 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 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei5743  
    $Date: 2014-10-8 下午3:16:19  
    $Revision: 1.0  
    $Purpose: 租赁申请创建   维护界面  
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="get_special_fields_link_id" model="cont.CON500.con_contract_get_special_fields" modelaction="update"/>
        <a:link id="get_calc_id" model="prj.PRJ500D.calc_quotation" modelaction="update"/>
        <a:link id="submit_approval_link" model="prj.PRJ500D.prj_project_workflow_start" modelaction="update"/>
        <a:link id="prj500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="prj500_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="check_product_package_bag_link_id" model="prj.PRJ500D.prj_project_before_workflow_start" modelaction="update"/>
        <a:link id="get_id_card_no_info_id" model="prj.PRJ500D.hls_bp_master_np_v" modelaction="query"/>
        <a:link id="get_organization_code_id" model="prj.PRJ500D.hls_bp_master_org_v" modelaction="query"/>
        <a:link id="get_id_card_no_tenant_sec_id" model="prj.PRJ500D.hls_bp_master_np_tenant_sec_v" modelaction="query"/>
        <a:link id="get_id_card_no_info_guar_id" model="prj.PRJ500D.hls_bp_master_np_guar" modelaction="query"/>
        <a:link id="get_org_code_info_guar_id" model="prj.PRJ500D.hls_bp_master_org_guar" modelaction="query"/>
        <a:link id="get_calc_validate_sql_link" model="prj.PRJ500D.prj_get_calc_validate_sql" modelaction="query"/>
        <a:link id="get_car_organization_id_link" model="prj.PRJ500D.get_hls_car_organization" modelaction="query"/>
        <a:link id="tenant_history_project_link" url="${/request/@context_path}/modules/prj/PRJ501N/tenant_history_project.lview"/>
        <a:link id="prj_project_dowload_uploadfile" url="${/request/@context_path}/modules/prj/lease_atm_batch_dl.lsc"/>
        <link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
        <a:link id="get_plate_source_link" model="prj.PRJ500D.prj_project_get_license_type" modelaction="query"/>
        <a:link id="get_atch_download_link" url="${/request/@context_path}/modules/batch_download/lease_atm_batch_dl.lsc"/>
        <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>
        <script src="${/request/@context_path}/modules/prj/PRJ500N/javascripts/input_validator.js" type="text/javascript"/>
        <a:link id="con_item_frame_number_link" model="cont.CON501N.con_item_frame_number" modelaction="execute"/>
        <a:link id="get_gps_flag_link" model="prj.PRJ500D.prj_gps_flag" modelaction="update"/>
        <a:link id="get_purchase_tax_flag_link" model="prj.PRJ500D.prj_purchase_tax_flag" modelaction="update"/>
        <!-- <script src="${/request/@context_path}/modules/prj/PRJ500N/javascripts/check_org_code.js" type="text/javascript"/> -->
        <script type="text/javascript"><![CDATA[
            // zjwfl5110_ApproveChecker_add('wfl_prj_lease_item_save', function(type) {
            //
            // if (type == 'agree') {
            // var prj_project_family_visit_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_family_visit');
            // if ($L.CmpManager.get(prj_project_family_visit_ds_id)) {
            // var feedback = $(prj_project_family_visit_ds_id).getCurrentRecord().get('feedback');
            // if (Ext.isEmpty(feedback)) {
            // Leaf.showMessage('${l:PROMPT}', '访问反馈,不可为空!');
            // return false;
            // } else {
            // return true;
            // }
            // }
            // }
            // });calc_deposit_ratio
            //忽略保存校验方法
            window['${/parameter/@layout_code}_ignore_required_before_save'] = function() {
                window['${/parameter/@layout_code}_not_ignore_required_flag'] = false;
            };
            var global_save_flag = 'N';
            var num = 1;
            
            if ('${/parameter/@save_source_type}' == 'WFL' || '${/parameter/@save_source_type}' == 'JF') {
            
            
                zjwfl5110_ApproveChecker_add('zjwfl5110_submit', function(type) {
                    if ('${/parameter/@save_source_type}' == 'WFL') {
                        window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
                        if (type == 'agree') {
                            var project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');
                            var prj_project_lease_item_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                            var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                            var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
                            var hls_fin_calculator_ln_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_fin_calculator_ln');
                            var prj_project_bp_contact_info_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp_contact_info');
                            var prj_cdd_item_doc_ref_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
                            var prj_project_bp_biao_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'DANBAOREN', 'prj_project_bp');
                            var ast_car_insurance_biao_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_T_INSURANCE', 'ast_car_insurance');
                            //prj_project_lease_item  ast_car_insurance
                            // if ($(project_ds_id).validate() && $(prj_project_lease_item_id).validate() && $(prj_project_ds_id).validate() && $(prj_quotation_ds_id).validate() && $(hls_fin_calculator_ln_ds_id).validate() && $(prj_project_bp_contact_info_ds_id).validate() && $(prj_cdd_item_doc_ref_ds_id).validate() && $(prj_project_bp_biao_ds_id).validate() && $(ast_car_insurance_biao_ds_id).validate()) {
                            // if (global_save_flag == 'Y') {
                            // return true;
                            // } else {
                            // Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
                            // return false;
                            // }
                            // }
                            // return false;
                            if ($(project_ds_id).isModified() || $(prj_project_lease_item_id).isModified() || $(prj_project_ds_id).isModified() || $(prj_quotation_ds_id).isModified() || $(hls_fin_calculator_ln_ds_id).isModified() || $(prj_project_bp_contact_info_ds_id).isModified() || $(prj_cdd_item_doc_ref_ds_id).isModified() || $(prj_project_bp_biao_ds_id).isModified() || $(ast_car_insurance_biao_ds_id).isModified()) {
                                Leaf.showMessage('${l:HLS.PROMPT}', '数据有修改,请先点击保存!');
                                return;
                            } else {
                                if ($(project_ds_id).validate() && $(prj_project_lease_item_id).validate() && $(prj_project_ds_id).validate() && $(prj_quotation_ds_id).validate() && $(hls_fin_calculator_ln_ds_id).validate() && $(prj_project_bp_contact_info_ds_id).validate() && $(prj_cdd_item_doc_ref_ds_id).validate() && $(prj_project_bp_biao_ds_id).validate() && $(ast_car_insurance_biao_ds_id).validate()) {
            
                                    $(project_ds_id).submit();
                                    $(prj_project_lease_item_id).submit();
                                    $(prj_project_ds_id).submit();
                                    $(ast_car_insurance_biao_ds_id).submit();
                                    $(prj_quotation_ds_id).submit();
                                    $(hls_fin_calculator_ln_ds_id).submit();
                                    $(prj_project_bp_contact_info_ds_id).submit();
                                    $(prj_project_bp_biao_ds_id).submit();
                                    $(prj_cdd_item_doc_ref_ds_id).submit();
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        }if (type == 'do_proc') {
                            return true;
                        }
                    } else if ('${/parameter/@save_source_type}' == 'JF') {
                        if (type == 'agree') {
                            var prj_project_family_visit_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_family_visit');
                            $(prj_project_family_visit_ds_id).submit();
                            return true;
                        }
                    }
                });
            }
            //是否邮寄发票
            
            function mail_if(lease_ds_id, ds_id) {
                if ($(lease_ds_id).getAt(0).get('postage_flag') == 'N') {
                    $(lease_ds_id).getAt(0).getField('postage').setReadOnly(true);
                    $(lease_ds_id).getAt(0).set('postage', '0');
            
                    $(ds_id).getAt(0).getField('invoice_send_address').setReadOnly(true);
                    $(ds_id).getAt(0).getField('invoice_send_address').setRequired(false);
                    $(ds_id).getAt(0).set('invoice_send_address', '');
                } else {
                    $(lease_ds_id).getAt(0).getField('postage').setReadOnly(false);
                    $(lease_ds_id).getAt(0).getField('postage').setRequired(true);
            
                    $(ds_id).getAt(0).getField('invoice_send_address').setReadOnly(false);
                    $(ds_id).getAt(0).getField('invoice_send_address').setRequired(true);
                }
            } //mail_if end
            //直系亲属。证件类型改变性别,出生日期是否只读
            
            function set_immediate_by_id_card(name, ds_id) {
                var immediate_recode = $(ds_id).getAt(0);
                if (immediate_recode.get('card_type_sp') == 'ID_CARD') {
                    immediate_recode.getField('date_of_birth_sp').setReadOnly(true);
                    immediate_recode.getField('old_sp').setReadOnly(true);
                    immediate_recode.getField('gender_sp').setReadOnly(true);
                    immediate_recode.getField('gender_sp_n').setReadOnly(true);
                } else {
                    immediate_recode.getField('date_of_birth_sp').setReadOnly(false);
                    immediate_recode.getField('old_sp').setReadOnly(false);
                    immediate_recode.getField('gender_sp').setReadOnly(false);
                    immediate_recode.getField('gender_sp_n').setReadOnly(false);
                    immediate_recode.getField('date_of_birth_sp').setRequired(true);
                    immediate_recode.getField('old_sp').setRequired(true);
                    immediate_recode.getField('gender_sp').setRequired(true);
                    immediate_recode.getField('gender_sp_n').setRequired(true);
                }
            } //set_immediate_by_id_card end
            //是否融保险信息
            
            function premium_if(baodan_ds_id, name, data_ds, bao_ds_id) {
                //
                if (name == 'insurance_flag') {
                    if ($(baodan_ds_id).getAt(0).get('insurance_flag') == 'Y') {
                        $(data_ds).getAt(0).set('insurance_flag', 'Y');
                        $(data_ds).getAt(0).set('insurance_flag_n', '是');
            
            
                        //选是   去掉只读
                        $(bao_ds_id).getAt(0).getField('insurance_years').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('insurance_years_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('compulsory_insurance_flag').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('travel_tax_flag').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('travel_tax_flag_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('rot_insurance').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('rot_insurance_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('damage_insurance_limit').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('third_party_insurance').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('third_party_insurance_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('compulsory_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('travel_tax').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('pilfer_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('damage_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('third_party_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_driver').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_driver_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_passenger').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_passenger_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('nick_insurance').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('nick_insurance_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('stop_walking_insurance').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('stop_walking_insurance_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('combustion_insurance_flag').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('combustion_insurance_flag_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_d_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_p_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('nick_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('stop_walk_insu_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('combustion_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('glass_insurance').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('glass_insurance_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('specify_insurance_flag').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('specify_insurance_flag_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('wading_driving_insurance').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('wading_driving_insurance_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('damage_nopay_insurance_flag').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('damage_nopay_insurance_flag_n').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('glass_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('specify_insurance_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('wading_driving_insu_amount').setReadOnly(false);
                        $(bao_ds_id).getAt(0).getField('damage_nopay_insu_amount').setReadOnly(false);
                    } else {
                        $(data_ds).getAt(0).set('insurance_flag', 'N');
                        $(data_ds).getAt(0).set('insurance_flag_n', '否');
            
                        //选否  置空
                        $(bao_ds_id).getAt(0).set('insurance_years', '');
                        $(bao_ds_id).getAt(0).set('insurance_years_n', '');
                        $(bao_ds_id).getAt(0).set('compulsory_insurance_flag', '');
                        $(bao_ds_id).getAt(0).set('travel_tax_flag', '');
                        $(bao_ds_id).getAt(0).set('travel_tax_flag_n', '');
                        $(bao_ds_id).getAt(0).set('rot_insurance', '');
                        $(bao_ds_id).getAt(0).set('rot_insurance_n', '');
                        $(bao_ds_id).getAt(0).set('damage_insurance_limit', '');
                        $(bao_ds_id).getAt(0).set('third_party_insurance', '');
                        $(bao_ds_id).getAt(0).set('third_party_insurance_n', '');
                        $(bao_ds_id).getAt(0).set('compulsory_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('travel_tax', '');
                        $(bao_ds_id).getAt(0).set('pilfer_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('damage_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('third_party_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('vehicle_resp_ins_driver', '');
                        $(bao_ds_id).getAt(0).set('vehicle_resp_ins_driver_n', '');
                        $(bao_ds_id).getAt(0).set('vehicle_resp_ins_passenger', '');
                        $(bao_ds_id).getAt(0).set('vehicle_resp_ins_passenger_n', '');
                        $(bao_ds_id).getAt(0).set('nick_insurance', '');
                        $(bao_ds_id).getAt(0).set('nick_insurance_n', '');
                        $(bao_ds_id).getAt(0).set('stop_walking_insurance', '');
                        $(bao_ds_id).getAt(0).set('stop_walking_insurance_n', '');
                        $(bao_ds_id).getAt(0).set('combustion_insurance_flag', '');
                        $(bao_ds_id).getAt(0).set('combustion_insurance_flag_n', '');
                        $(bao_ds_id).getAt(0).set('vehicle_resp_ins_d_amount', '');
                        $(bao_ds_id).getAt(0).set('vehicle_resp_ins_p_amount', '');
                        $(bao_ds_id).getAt(0).set('nick_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('stop_walk_insu_amount', '');
                        $(bao_ds_id).getAt(0).set('combustion_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('glass_insurance', '');
                        $(bao_ds_id).getAt(0).set('glass_insurance_n', '');
                        $(bao_ds_id).getAt(0).set('specify_insurance_flag', '');
                        $(bao_ds_id).getAt(0).set('specify_insurance_flag_n', '');
                        $(bao_ds_id).getAt(0).set('wading_driving_insurance', '');
                        $(bao_ds_id).getAt(0).set('wading_driving_insurance_n', '');
                        $(bao_ds_id).getAt(0).set('damage_nopay_insurance_flag', '');
                        $(bao_ds_id).getAt(0).set('damage_nopay_insurance_flag_n', '');
                        $(bao_ds_id).getAt(0).set('glass_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('specify_insurance_amount', '');
                        $(bao_ds_id).getAt(0).set('wading_driving_insu_amount', '');
                        $(bao_ds_id).getAt(0).set('damage_nopay_insu_amount', '');
            
            
                        //选否  设置只读
                        $(bao_ds_id).getAt(0).getField('insurance_years').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('insurance_years_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('compulsory_insurance_flag').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('travel_tax_flag').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('travel_tax_flag_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('rot_insurance').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('rot_insurance_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('damage_insurance_limit').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('third_party_insurance').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('third_party_insurance_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('compulsory_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('travel_tax').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('pilfer_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('damage_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('third_party_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_driver').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_driver_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_passenger').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_passenger_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('nick_insurance').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('nick_insurance_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('stop_walking_insurance').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('stop_walking_insurance_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('combustion_insurance_flag').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('combustion_insurance_flag_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_d_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('vehicle_resp_ins_p_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('nick_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('stop_walk_insu_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('combustion_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('glass_insurance').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('glass_insurance_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('specify_insurance_flag').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('specify_insurance_flag_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('wading_driving_insurance').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('wading_driving_insurance_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('damage_nopay_insurance_flag').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('damage_nopay_insurance_flag_n').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('glass_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('specify_insurance_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('wading_driving_insu_amount').setReadOnly(true);
                        $(bao_ds_id).getAt(0).getField('damage_nopay_insu_amount').setReadOnly(true);
                    }
                }
            } //premium_if end
            //根据证件类型改变生日,年龄,性别  是否必输
            //根据申请人的家庭状况,控制直系亲属栏里   与申请人关系的可选状况
            
            function set_immediate_family_members(ds, name, ds_id, bp_copy_flag) {
                //
                var project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');
                if (name == 'relationship_sp' && !Ext.isEmpty($(ds_id).getAt(0).get('relationship_sp'))) {
                    var vv = $(ds_id).getAt(0).get('relationship_sp');
                    if ($(ds_id).getAt(0).get('marital_status') == 'MARRIED' || $(ds_id).getAt(0).get('marital_status') == 'MARRIED_1') {
                        if (vv != '30') {
                            $(ds_id).getAt(0).set('relationship_sp', '30');
                            $(ds_id).getAt(0).set('relationship_sp_n', '配偶');
                            Leaf.showMessage('${l:HLS.PROMPT}', '已婚,直系亲属必须是配偶');
                        }
                    } else if (!Ext.isEmpty($(ds_id).getAt(0).get('marital_status'))) {
                        if (vv == '30') {
                            $(ds_id).getAt(0).set('relationship_sp', '');
                            $(ds_id).getAt(0).set('relationship_sp_n', '');
                            Leaf.showMessage('${l:HLS.PROMPT}', '未婚,不能选择配偶');
                        }
                    }
            
                } else if (name == 'marital_status' && bp_copy_flag == 'N') {
                    $(ds_id).getAt(0).set('relationship_sp', '');
                    $(ds_id).getAt(0).set('relationship_sp_n', '');
                } else if (name == 'id_type') {
                    if ($(ds_id).getAt(0).get('id_type') == 'ID_CARD') {
                        $(ds_id).getAt(0).getField('date_of_birth').setReadOnly(true);
                        $(ds_id).getAt(0).getField('age').setReadOnly(true);
                        $(ds_id).getAt(0).getField('gender').setReadOnly(true);
                        $(ds_id).getAt(0).getField('gender_n').setReadOnly(true);
                    } else {
                        $(ds_id).getAt(0).getField('date_of_birth').setReadOnly(false);
                        $(ds_id).getAt(0).getField('age').setReadOnly(false);
                        $(ds_id).getAt(0).getField('gender').setReadOnly(false);
                        $(ds_id).getAt(0).getField('gender_n').setReadOnly(false);
                        $(ds_id).getAt(0).getField('date_of_birth').setRequired(true);
                        $(ds_id).getAt(0).getField('age').setRequired(true);
                        $(ds_id).getAt(0).getField('gender').setRequired(true);
                        $(ds_id).getAt(0).getField('gender_n').setRequired(true);
                    }
            
                }
            } // set_immediate_family_members end
            //根据新车或二手车改变发票信息和备注栏是否必输
            
            function change_note(ds) {
                var ds_id = ds.id;
                var project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_lease_item_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                if (ds_id == prj_project_lease_item_id) {
                    if ($(project_ds_id).getAt(0).get('division') == '00') {
                        $(prj_project_lease_item_id).getField('issue_ticket').setRequired(true);
                        $(prj_project_lease_item_id).getField('remarks').setRequired(true);
                    } else {
                        $(prj_project_lease_item_id).getField('issue_ticket').setRequired(false);
                        $(prj_project_lease_item_id).getField('remarks').setRequired(false);
                    }
                }
            
            } //change_note end
            //计算车船税和保险费
            
            function calculate_premium_car(bao_ds_id, data_ds) {
                //
                var all_money = 0;
                var tt_money = 0;
                var datas = $(bao_ds_id).getAll();
                var num_tt = 0;
                for (var i = 0;i < datas.length;i++) {
                    var data_tt = datas[i].get('travel_tax'); //车船税
                    var data_cia = datas[i].get('compulsory_insurance_amount'); //交强险
                    var data_oia = datas[i].get('ompulsory_insurance_amount');
                    var data_pia = datas[i].get('pilfer_insurance_amount'); //盗抢险
                    var data_dia = datas[i].get('damage_insurance_amount'); // 车辆损失险金额
                    var data_tpia = datas[i].get('third_party_insurance_amount');
                    var data_vrida = datas[i].get('vehicle_resp_ins_d_amount');
                    var data_vripa = datas[i].get('vehicle_resp_ins_p_amount');
                    var data_nia = datas[i].get('nick_insurance_amount');
                    var data_swia = datas[i].get('stop_walk_insu_amount');
                    var data_gia = datas[i].get('glass_insurance_amount');
                    var data_sia = datas[i].get('specify_insurance_amount'); //指定专修险  specify_insurance_flag  specify_insurance_amount
                    var data_wia = datas[i].get('wading_driving_insu_amount');
                    var data_ania = datas[i].get('damage_nopay_insu_amount'); //pilfer_insurance_amount
                    var data_ciaa = datas[i].get('combustion_insurance_amount'); //自然损失险   combustion_insurance_flag
                    if (datas[i].get('travel_tax_flag') == 'Y') {
                        num_tt++;
                        if (!Ext.isEmpty(data_tt)) {
                            tt_money = tt_money + data_tt;
                        }
                    }
                    if (datas[i].get('compulsory_insurance_flag') == 'Y') { //compulsory_insurance_flag
                        if (!Ext.isEmpty(data_cia)) {
                            all_money = all_money + data_cia;
                        }
                    }
                    if (!Ext.isEmpty(data_oia)) {
                        all_money = all_money + data_oia;
                    }
                    if (!Ext.isEmpty(data_pia)) {
                        all_money = all_money + data_pia;
                    }
                    if (!Ext.isEmpty(data_dia)) {
                        all_money = all_money + data_dia;
                    }
                    if (!Ext.isEmpty(data_tpia)) {
                        all_money = all_money + data_tpia;
                    }
                    if (!Ext.isEmpty(data_vrida)) {
                        all_money = all_money + data_vrida;
                    }
                    if (!Ext.isEmpty(data_vripa)) {
                        all_money = all_money + data_vripa;
                    }
                    if (!Ext.isEmpty(data_nia)) {
                        all_money = all_money + data_nia;
                    }
                    if (!Ext.isEmpty(data_swia)) {
                        all_money = all_money + data_swia;
                    }
                    if (!Ext.isEmpty(data_gia)) {
                        all_money = all_money + data_gia;
                    }
                    if (datas[i].get('specify_insurance_flag') == 'Y') {
                        if (!Ext.isEmpty(data_sia)) {
                            all_money = all_money + data_sia;
                        }
                    }
                    if (!Ext.isEmpty(data_wia)) {
                        all_money = all_money + data_wia;
                    }
                    if (datas[i].get('damage_nopay_insurance_flag') == 'Y') {
                        if (!Ext.isEmpty(data_ania)) {
                            all_money = all_money + data_ania;
                        }
                    }
                    if (datas[i].get('combustion_insurance_flag') == 'Y') { //combustion_insurance_flag
                        if (!Ext.isEmpty(data_ciaa)) {
                            all_money = all_money + data_ciaa;
                        }
                    }
                }
                tt_money = Leaf.removeNumberFormat(Leaf.formatMoney(tt_money)); //add by 20160920 Spencer 页面显示2位,js里还是获取的输入的多位小数
                all_money = Leaf.removeNumberFormat(Leaf.formatMoney(all_money)); //add by 20160920 Spencer 页面显示2位,js里还是获取的输入的多位小数
                $(data_ds).getAt(0).set('travel_tax', tt_money);
                $(data_ds).getAt(0).set('insurance_amount', all_money);
                if (num_tt == 0) {
                    $(data_ds).getAt(0).set('travel_tax_flag', 'N');
                    $(data_ds).getAt(0).set('travel_tax_flag_n', '否');
                } else {
            
                    $(data_ds).getAt(0).set('travel_tax_flag', 'Y');
                    $(data_ds).getAt(0).set('travel_tax_flag_n', '是');
                }
            } //calculate_premium_car end
            Ext.ux.Lightbox.register('a[ref=img]', true);
            
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                new Leaf.Window({
                    id: 'contract_history_window',
                    url: $('tenant_history_project_link').getUrl(),
                    params: {
                        project_id: '${/parameter/@project_id}'
                    },
                    fullScreen: true
                });
            };
            
            //审批页面中打包下载
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
                var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_record = $(prj_project_ds_id).getAt(0);
                var tenant_info_record = $('${/parameter/@layout_code}_BP_INFO_prj_project_bp_ds').getAt(0);
                var project_id = prj_project_record.get('project_id');
                var project_number = prj_project_record.get('project_number');
                var bp_name = tenant_info_record.get('bp_name');
                var doc_code = project_number + '_' + bp_name;
                var url_l = $('prj_project_dowload_uploadfile').getUrl() + '?document_id=' + project_id + '&document_table=PRJ_PROJECT' + '&doc_code=' + encodeURI(doc_code) + '&all_flag=Y';
                window.open(href = url_l, target = "_self");
            
            };
            
            //全局变量,提交工作流标志,默认为Y
            var submit_wfl_flag = 'N';
            //保存前调用,生成项目编号
            window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
            
                //
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var ds1 = $('${/parameter/@layout_code}_BP_INFO_prj_project_bp_ds');
                var ds1Record = ds1.getCurrentRecord();
                if (ds1Record) {
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone'))) {
                        if (!checkMobile(ds1Record.get('cell_phone'))) {
                            Leaf.showMessage('提示', '申请人信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    // if (!Leaf.isEmpty(ds1Record.get('organization_code'))) {
                    // if (check_org_code(ds1Record.get('organization_code')) != 0) {
                    // Leaf.showMessage('提示', '申请人组织机构代码格式错误,请重新维护!');
                    // window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    // return false;
                    // }
                    // }
                    if (!Leaf.isEmpty(ds1Record.get('id_card_no'))) {
                        if (ds1Record.get('bp_class') == 'NP' && ds1Record.get('id_type') == 'ID_CARD') {
                            if (!checkCard(ds1Record.get('id_card_no'))) {
                                Leaf.showMessage('提示', '申请人信息中,请输入正确格式的身份证!');
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                return false;
                            }
                        }
                    }
                    //申请人工作年限 不的大于 年龄
                    if (!Leaf.isEmpty(ds1Record.get('industry_work_experience'))) {
                        if (ds1Record.get('industry_work_experience') * 1 > ds1Record.get('age') * 1) {
                            Leaf.showMessage('提示', '申请人信息中,工作年限不得大于年龄!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    //直系亲属工作年限 不的大于 年龄
                    if (!Leaf.isEmpty(ds1Record.get('industry_work_experience'))) {
                        if (ds1Record.get('industry_work_exper') * 1 > ds1Record.get('old_sp') * 1) {
                            Leaf.showMessage('${l:PROMPT}', '直系亲属中,工作年限不能大于年龄!');
                            record.set('industry_work_exper', '');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
            
                    //现居地年限 不的大于 年龄
                    if (!Leaf.isEmpty(ds1Record.get('years_of_living_house'))) {
                        if (ds1Record.get('years_of_living_house') * 1 > ds1Record.get('age') * 1) {
                            Leaf.showMessage('提示', '申请人信息中,现居地年限不得大于年龄!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    // 直系亲属  校验
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone_sp'))) {
                        if (!checkMobile(ds1Record.get('cell_phone_sp'))) {
                            Leaf.showMessage('提示', '直系亲属信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    if (!Leaf.isEmpty(ds1Record.get('id_no_sp'))) {
                        if (ds1Record.get('card_type_sp') == 'ID_CARD') {
                            if (!checkCard(ds1Record.get('id_no_sp'))) {
                                Leaf.showMessage('提示', '直系亲属信息中,请输入正确格式的身份证!');
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                return false;
                            }
                        }
                    }
                    //担保人电话号码校验
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone'))) {
                        if (!checkMobile(ds1Record.get('cell_phone'))) {
                            Leaf.showMessage('提示', '担保人信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    //联系人电话号码校验
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone'))) {
                        if (!checkMobile(ds1Record.get('cell_phone'))) {
                            Leaf.showMessage('提示', '担保人信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone_1'))) {
                        if (!checkMobile(ds1Record.get('cell_phone_1'))) {
                            Leaf.showMessage('提示', '联系人信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    //担保人电话号码校验 liukang
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone'))) {
                        if (!checkMobile(ds1Record.get('cell_phone'))) {
                            Leaf.showMessage('提示', '担保人信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    //联系人电话号码校验
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone'))) {
                        if (!checkMobile(ds1Record.get('cell_phone'))) {
                            Leaf.showMessage('提示', '担保人信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    if (!Leaf.isEmpty(ds1Record.get('cell_phone_1'))) {
                        if (!checkMobile(ds1Record.get('cell_phone_1'))) {
                            Leaf.showMessage('提示', '联系人信息中,请输入正确格式的手机号码!');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    //法人社会信用代码校验
                    if (ds1Record.get('bp_class') == 'ORG') {

                        if (!Leaf.isEmpty(ds1Record.get('social_credit_code'))) {
                            if (!checkSccode(ds1Record.get('social_credit_code'))) {
                                Leaf.showMessage('提示', '申请企业信息中,请输入正确的18位社会信用代码');
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                return false;
                            }
                        }
                    }
                }
                //  车辆二手车 车架号校验
                var ds2 = $('${/parameter/@layout_code}_INSURANCE_INFO_prj_project_lease_item_ds');
                var ds2Record = ds2.getCurrentRecord();
                if (ds2Record) {
            
                    if (!Leaf.isEmpty(ds2Record.get('item_frame_number'))) {
                        if (!Leaf.isEmpty(ds2Record.get('item_frame_number'))) {
                            if (!checkVumber(ds2Record.get('item_frame_number'))) {
                                Leaf.showMessage('提示', '请输入正确格式的车架号!');
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                return false;
                            }
                        }
                    }
                }
                var check_flag = false;
                var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_record = $(prj_project_ds_id).getAt(0);
                //紧急联系人不能为申请人和联合承租人、担保人,紧急联系人电话不能重复
                if (prj_project_record.get('bp_class') == 'NP') {
                    var tenant_info_record = $('${/parameter/@layout_code}_BP_INFO_prj_project_bp_ds').getAt(0);
                    //var g_tenant_sec_info_record = $('${/parameter/@layout_code}_BP_TENANT_SEC_INFO_prj_project_bp_ds').getAt(0);
                    //var guar_info_record = $('${/parameter/@layout_code}_G_INS_LP_prj_project_bp_ds').getAt(0);
                    var prj_project_bp_contact_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp_contact_info');
                    prj_project_bp_contact_record = $(prj_project_bp_contact_ds).getAt(0);
                    //申请人和紧急联系人存在
                }
                if (record.get('project_number')) {
                    return true;
                }
                Leaf.request({
                    url: $('get_special_fields_link_id').getUrl(),
                    para: {
                        document_category: '${/parameter/@document_category}',
                        document_type: record.get('document_type'),
                        function_code: '${/parameter/@function_code}',
                        function_usage: '${/parameter/@function_usage}'
                    },
                    success: function(res) {
            
                        var document_number = res.result.document_number;
                        record.set('project_number', document_number);
                        record.set('document_category', '${/parameter/@document_category}');
                        check_flag = true;
                    },
                    error: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    sync: true,
                    scope: this
                });
            
                return check_flag;
            };
            
            //提交审批 modify by liukang 20160505
            // window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
            
            // Leaf.showConfirm('${l:HLS.PROMPT}', '确认提交审批?', function() {
            
            // window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
            // var root_ds = $('${/parameter/@layout_code}_virtual_ds');
            // if (root_ds.validate()) {
            // //设置提交字段为Y
            // submit_wfl_flag = 'Y';
            // //提交先保存
            // window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
            // }
            // });
            
            // };
            window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
                //
                var prj_project_bp_danbaoren = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'DANBAOREN', 'prj_project_bp');
                var prj_lease_item_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                var plan_record = $(prj_lease_item_id).getAt(0);
                var product_type = plan_record.get('product_type');
                var product_plan_id = plan_record.get('product_plan_id');
                var down_payment_ratio = plan_record.get('down_payment_ratio') * 1;
                var balloon_ratio = plan_record.get('balloon_ratio') * 1;
                var deposit_ratio = plan_record.get('deposit_ratio') * 1;
                var lease_times = plan_record.get('lease_times') * 1;
            
                //担保人(法人)信息
                var g_ins_p_org_gua_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_INS_P_ORG', 'prj_project_bp');
                //担保人
                var gua_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'DANBAOREN', 'prj_project_bp');
                // $L.CmpManager.get(prj_project_record_ds)
            
                var size = 0;
                if ($L.CmpManager.get(g_ins_p_org_gua_ds_id)) {
                    var g_ins_p_org_gua_ds_res = $(g_ins_p_org_gua_ds_id).getAll();
                    size = size + g_ins_p_org_gua_ds_res.length;
                }
                if ($L.CmpManager.get(gua_ds_id)) {
                    var gua_ds_id_res = $(gua_ds_id).getAll();
                    size = size + gua_ds_id_res.length;
                }
            
                if (size > 1) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '担保人只能有一个!');
                    return;
                }
            
            
            
                if (product_type != 'PACKAGE_BAG') {
                    Leaf.request({
                        url: $('check_product_package_bag_link_id').getUrl(),
                        para: {
                            product_plan_id: product_plan_id,
                            down_payment_ratio: down_payment_ratio,
                            balloon_ratio: balloon_ratio,
                            deposit_ratio: deposit_ratio,
                            lease_times: lease_times
                        },
                        success: function(res) {
                            var package_bag = res.result.package_bag;
                            //alert(package_bag);
                            if (package_bag != 0) {
                                Leaf.showConfirm('${l:HLS.PROMPT}', '您的申请符合套餐包产品,是否选择套餐包产品重新报价?', function() {}, function() {
                                    window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
                                    Leaf.showConfirm('${l:HLS.PROMPT}', '确认提交?', function() {
                                        window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
                                        var root_ds_1 = $('${/parameter/@layout_code}_virtual_ds');
                                        if (root_ds_1.validate()) {
                                            submit_wfl_flag = 'Y';
                                            //提交先保存
                                            window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
                                            //设置提交字段为Y
                                        }
                                    });
                                });
                            } else if (package_bag == 0) {
                                window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
                                Leaf.showConfirm('${l:HLS.PROMPT}', '确认提交?', function() {
                                    window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
                                    var root_ds_4 = $('${/parameter/@layout_code}_virtual_ds');
                                    if (root_ds_4.validate()) {
                                        submit_wfl_flag = 'Y';
                                        //提交先保存
                                        window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
                                        //设置提交字段为Y
                                    }
                                });
                            }
                        },
                        error: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        failure: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        sync: true,
                        scope: this
                    });
                } else if (product_type == 'PACKAGE_BAG') {
                    Leaf.showConfirm('${l:HLS.PROMPT}', '确认提交?', function() {
                        window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
                        var root_ds_2 = $('${/parameter/@layout_code}_virtual_ds');
                        if (root_ds_2.validate()) {
                            submit_wfl_flag = 'Y';
                            //提交先保存
                            window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
                            //设置提交字段为Y
                        }
                    });
                }
            };
            
            //行批量下载
            
            function batch_download(check_id) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                // var document_id = $(ds_id).getAt(0).get('project_id');
                var project_number = $(ds_id).getAt(0).get('project_number');
                var project_id = $(ds_id).getAt(0).get('project_id');
                var document_table = 'PRJ_PROJECT';
                url = '${/request/@context_path}/modules/prj/lease_atm_batch_dl.lsc?document_table=' + document_table + '&document_id=' + project_id + '&check_id=' + check_id + '&doc_code=' + project_number + '&type=ZIP';
                window.open(url);
            }
            
            function upload_file(id, name, query_only) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                if (record.get('check_id')) {
                    var url;
                    if (query_only == 'Y' || '${/parameter/@function_usage}' == 'QUERY') {
                        url = $('prj500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    } else {
                        url = $('prj500_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    }
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: 'prj500_cdd_uploadFile_screen_id',
                        width: 850,
                        height: 400
                    });
            
                    win.on('close', function() {
                        record.ds.query();
                    });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
                }
            }
            //超链接渲染
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                var link_function = '';
                window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                if (name == 'attachment') {
                    link_function = 'upload_file';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                } else if (name == 'attach_file_name') {
                    if (value != null) {
                        var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                        var str = value.split(';;');
                        var url = '';
                        for (var i = 0;i < str.length;i++) {
                            var temp = str[i].split('--');
                            if (!Leaf.isEmpty(temp[0])) {
                                var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
                                if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
                                    url = url + '<a ref="img" href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                } else {
                                    url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                }
                            }
                        }
                        return url;
                    }
                } else if (name == 'batch_download') {
                    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                    var project_id = $(ds_id).getAt(0).get('project_id');
                    return '<a href="javascript:batch_download(' + record.get('check_id') + ')">' + config_record.get('prompt') + '</a>';
                }
            };
            //保存submitsuccess调用
            window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function(ds, record, res) {
            
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                // 电调记录
                var prj_project_record_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'PRJ_PROJECT_RECORD');
                if ($L.CmpManager.get(prj_project_record_ds)) {
                    $(prj_project_record_ds).query();
                }
            
            
                var tel_rec_fraud_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'TEL_REC_FRAUD');
                if ($L.CmpManager.get(tel_rec_fraud_ds)) {
                    $(tel_rec_fraud_ds).query();
                }
            
            
                if (ds_id) {
                    record = $(ds_id).getAt(0);
                    project_id = record.get('project_id');
                    $('${/parameter/@layout_code}_ACY_prj_cdd_item_doc_ref_ds').setQueryParameter('cdd_list_id', record.get('cdd_list_id'));
                    $('${/parameter/@layout_code}_ACY_prj_cdd_item_doc_ref_ds').query();
                    $('${/parameter/@layout_code}_ACY_prj_cdd_item_doc_ref_ds').submit();
                    var prj_project_lease_item_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                    var quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
                    var cacl_ln_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_fin_calculator_ln');
                    var prj_project_bp_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');
                    $(prj_project_lease_item_id).setQueryParameter('project_id', project_id);
                    $(prj_project_lease_item_id).query();
                    $(quotation_ds_id).setQueryParameter('project_id', project_id);
                    $(quotation_ds_id).query();
                    $(cacl_ln_ds_id).setQueryParameter('project_id', project_id);
                    $(cacl_ln_ds_id).query();
                    $(prj_project_bp_id).setQueryParameter('project_id', project_id);
                    $(prj_project_bp_id).query();
                    //保存成功后,如果提交工作流标志为Y
                    if (submit_wfl_flag == 'Y') {
                        submit_wfl_flag = 'N';
                        Leaf.request({
                            url: $('submit_approval_link').getUrl(),
                            para: {
                                project_id: record.get('project_id')
                            },
                            success: function() {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                $('${/parameter/@winid}').close();
                                Leaf.SideBar.show({
                                    msg: '操作成功',
                                    duration: 2000
                                });
                            },
                            failure: function() {
                                submit_wfl_flag = 'N';
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            error: function() {
                                submit_wfl_flag = 'N';
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
            
                    } else {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    }
                }
                global_save_flag = 'Y';
            };
            //计算两个日期之间相差的月份
            
            function monthDiff(date1, date2) {
                var months = 0;
                var ymonths = date2.getFullYear() - date1.getFullYear();
                var mmonths = date2.getMonth() - date1.getMonth();
                var dmonths = date2.getDate() - date1.getDate();
                if (ymonths >= 0) {
                    months = months + ymonths * 12;
                    if (ymonths > 0) {
                        months = mmonths + months;
                    } else if (mmonths >= 0) {
                        months = mmonths + months;
                    }
                }
                return months;
            }
            
            var bp_copy_flag = 'N';
            //更新时调用  prj_project
            window['${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {
                if (record.dirty) {
                    global_save_flag = 'N';
                }
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');
                var lease_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                //担保人
                var gua_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'DANBAOREN', 'prj_project_bp');
                var prj_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                //保险信息ds
                var bao_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ast_car_insurance');
                var aci_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ast_car_insurance');
                // 融資信息帶出    是否融保险费、是否融车船税
                var baodan_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                //融资信息ds  报价方案
                var data_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                //end
                // 电调记录
                var prj_project_record_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'PRJ_PROJECT_RECORD');
                //联系人信息
                var prj_project_bp_contact_info_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp_contact_info');
                //担保人(法人)信息
                var g_ins_p_org_gua_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_INS_P_ORG', 'prj_project_bp');
                // $L.CmpManager.get(prj_project_record_ds)
            
                if (ds.id == data_ds) {
                    if (name == 'product_plan_id') {
                        var project_enter_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                        enter_record = $(project_enter_ds_id).getAt(0);
                        var car_type = enter_record.get('car_type');
                        var bp_id = enter_record.get('bp_id');
                        record.getField('product_plan_id_n').setLovPara('car_type', enter_record.get('car_type'));
                        record.getField('product_plan_id_n').setLovPara('bp_id', enter_record.get('bp_id'));
                    } else if (name == 'int_rate_display') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '租赁年利率不能为负数');
                            setTimeout(function() {
                                record.set('int_rate_display', '');
                            }, 50);
                        }
                    }
                    if (name == 'gps_flag') {
                        if (value == 'N') {
                            record.set('gps_amount', 0);
                            record.getField('gps_amount').setReadOnly(true);
                        }
                        if (value == 'Y') {
                            record.set('gps_amount', '');
                            record.getField('gps_amount').setReadOnly(false);
                        }
                    }
                    if (name == 'purchase_tax_flag') {
                        if (value == 'N') {
                            record.set('purchase_tax', 0);
                            record.getField('purchase_tax').setReadOnly(true);
                        }
                        if (value == 'Y') {
                            record.set('purchase_tax', '');
                            record.getField('purchase_tax').setReadOnly(false);
                        }
                    }
                }
            
            
                if (ds.id == g_ins_p_org_gua_ds_id) {
                    var organization_code = $(ds_id).getCurrentRecord().get('organization_code');
                    if (name == 'organization_code' && !Ext.isEmpty(value)) {
                        if (organization_code == value) {
                            Leaf.showMessage('${l:PROMPT}', '担保法人组织机构代码不能与申请企业相同!');
                            setTimeout(function() {
                                record.set('organization_code', '');
                            }, 500);
                        }
                    }
                }
                //如果修改了开票价 则将所有填写的数据置空 end
                if (ds.id == lease_ds_id) {
                    if (name == 'vin_number') {
                        if (!Ext.isEmpty(value)) {
                            var contract_lease_item_id = record.get('contract_lease_item_id');
                            Leaf.request({
                                url: $('con_item_frame_number_link').getUrl(),
                                para: {
                                    item_frame_number: value,
                                    contract_lease_item_id: contract_lease_item_id
                                },
                                success: function(res) {
                                    var number = res.result.number;
                                    if (number > 0) {
                                        Leaf.showErrorMessage('提示', '车架号已存在!');
                                        setTimeout(function() {
                                            record.set('vin_number', '');
                                        }, 50);
                                        record.set('item_frame_number', '');
                                    } else {
                                        if (value != record.get('item_frame_number')) {
                                            record.set('item_frame_number', value);
                                        }
                                    }
                                },
                                failure: function(res) {},
                                error: function() {},
                                scope: this
                            });
                        } else {
                            record.set('item_frame_number', '');
                        }
                    } else if (name == 'item_frame_number') {
                        if (value != record.get('vin_number')) {
                            record.set('vin_number', value);
                        }
            
                    }
            
                    //首付款 比例  = 首付款down_payment/ 开票价invoice_price
                    if (name == 'invoice_price' && !Ext.isEmpty(old_value)) {
                        //负数
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '开票价不能为负数');
                            setTimeout(function() {
                                record.set('invoice_price', '');
                            }, 50);
                        } else {
                            record.set('down_payment', '');
                            record.set('down_payment_ratio', '');
                            record.set('balloon', '');
                            record.set('deposit', '');
                            record.set('deposit_ratio', '');
                            record.set('purchase_tax', '');
                            record.set('balloon_ratio', '');
                            record.set('other_amount', '');
                            record.set('charge_amount', '');
                            record.set('deferred_premium', '');
                            record.set('postage', '');
                            record.set('gps_amount', '');
                            record.set('lease_charge', '');
                            record.set('lease_charge_ratio', '');
                        }
            
                    }
                    var down_payment = record.get('down_payment') || 0;
                    var invoice_price = record.get('invoice_price') || 0;
                    var down_payment_ratio = record.get('down_payment_ratio') || 0;
                    var balloon = record.get('balloon') || 0;
                    var balloon_ratio = record.get('balloon_ratio') || 0;
                    var deposit = record.get('deposit') || 0;
                    var deposit_ratio = record.get('deposit_ratio') || 0;
                    var other_amount = record.get('other_amount') || 0;
                    var charge_amount = record.get('charge_amount') || 0;
                    var deferred_premium = record.get('deferred_premium') || 0;
                    var purchase_tax_flag = record.get('purchase_tax_flag');
                    var purchase_tax = record.get('purchase_tax') || 0;
                    var insurance_flag = record.get('insurance_flag');
                    var insurance_amount = record.get('insurance_amount') || 0;
                    var travel_tax_flag = record.get('travel_tax_flag');
                    var travel_tax = record.get('travel_tax') || 0;
                    var postage_flag = record.get('postage_flag');
                    var postage = record.get('postage') || 0;
                    var gps_flag = record.get('gps_flag');
                    var gps_amount = record.get('gps_amount') || 0;
                    var lease_charge = record.get('lease_charge') || 0;
                    var lease_charge_ratio = record.get('lease_charge_ratio') || 0;
                    var car_from = record.get('car_from') || 0;
                    var car_from_id = record.get('car_from_id') || 0;
                    //选择出厂日期 带出车龄   start
                    // add by liukang
                    var now_date = new Date();
                    var factory_date = record.get('factory_date');
                    var car_old = record.get('car_old');
                    var first_register_date = record.get('first_register_date');
            
                    var invoice_price_exp = record.get('invoice_price_exp') || 0;
            
            
                    function calc_deposit_ratio(name) {
                        var data = {
                            'deposit': true,
                            'purchase_tax_flag': true,
                            'purchase_tax': true,
                            'insurance_flag': true,
                            'insurance_amount': true,
                            'travel_tax_flag': true,
                            'travel_tax': true,
                            'other_amount': true,
                            'charge_amount': true,
                            'deferred_premium': true,
                            //'postage_flag': true,
                            //'postage': true,
                            'gps_flag': true,
                            'gps_amount': true
                        };
                        if (data[name]) {
                            return true;
                        } else {
                            return false;
                        }
                    }
            
                    if (name == 'factory_date') {
                        //
                        record.set('car_old', monthDiff(factory_date, new Date()));
                        record.getField('car_old').setReadOnly(true);
                        record.set('first_register_date', '');
                    } else if (name == 'first_register_date') {
                        //
                        if (!Ext.isEmpty(first_register_date)) {
                            if (factory_date.getTime() > first_register_date.getTime()) {
                                Leaf.showMessage('${l:PROMPT}', '二手车信息中,初登日期不得早于出厂日期');
                                setTimeout(function() {
                                    record.set('first_register_date', '');
                                }, 500);
                            }
                        }
            
                    } else if (name == 'down_payment') {
                        //负数
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '首付款不能为负数');
                            setTimeout(function() {
                                record.set('down_payment_ratio', '');
                            }, 50);
                        } else {
                            record.set('down_payment_ratio', div(down_payment, invoice_price));
                        }
            
                    } else if (name == 'down_payment_ratio') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '首付款比例不能为负数');
                            setTimeout(function() {
                                record.set('down_payment_ratio', '');
                            }, 50);
                        } else {
                            record.set('down_payment', mul(down_payment_ratio, invoice_price));
                        }
            
                    } else if (name == 'balloon') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '尾付款不能为负数');
                            setTimeout(function() {
                                record.set('balloon', '');
                            }, 50);
                        } else {
                            record.set('balloon_ratio', div(balloon, invoice_price));
                        }
            
                    } else if (name == 'balloon_ratio') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '尾付款比例不能为负数');
                            setTimeout(function() {
                                record.set('balloon_ratio', '');
                            }, 50);
                        } else {
                            record.set('balloon', mul(balloon_ratio, invoice_price));
                        }
                    } else if (name == 'lease_charge') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '手续费不能为负数');
                            setTimeout(function() {
                                record.set('lease_charge', '');
                            }, 50);
                            return;
                        }
                        //record.set('lease_charge_ratio', div(lease_charge, invoice_price));//modify by Spencer 3893 20170818 处理小数位问题,使用Leaf.removeNumberFormat去除千分位字符,不去除千分位字符,div会返回NaN
                        //record.set('lease_charge_ratio', div(Leaf.removeNumberFormat(lease_charge), invoice_price));
                    } else if (name == 'lease_charge_ratio') {
                        //负数
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '手续费比例不能为负数');
                            setTimeout(function() {
                                record.set('lease_charge_ratio', '');
                            }, 50);
                            return;
                        }
                        //record.set('lease_charge', mul(lease_charge_ratio, invoice_price));//modify by Spencer 3893 20170818 处理小数位问题,使用Leaf.removeNumberFormat去除千分位字符,layout已经格式,并且配置的是数字。不去除千分位字符,会报字符转换错误
                        //record.set('lease_charge', Leaf.removeNumberFormat(Leaf.formatMoney(mul(lease_charge_ratio, invoice_price))));
                    } else if (name == 'deferred_premium') {
            
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '延保费不能为负数');
                            setTimeout(function() {
                                record.set('deferred_premium', '');
                            }, 50);
                            return;
                        }
                    } else if (name == 'deposit') { //负数
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '保证金不能为负数');
                            setTimeout(function() {
                                record.set('deposit', '');
                            }, 50);
                            return;
                        }
                    } else if (name == 'residual_value') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '留购价款不能为负数');
                            setTimeout(function() {
                                record.set('residual_value', '');
                            }, 50);
                            return;
                        }
                    } else if (name == 'other_amount') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '加装费不能为负数');
                            setTimeout(function() {
                                record.set('other_amount', '');
                            }, 50);
                            return;
                        }
            
                    } else if (name == 'charge_amount') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '后服务费不能为负数');
                            setTimeout(function() {
                                record.set('charge_amount', '');
                            }, 50);
                            return;
                        }
                    } else if (name == 'purchase_tax') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', '购置税不能为负数');
                            setTimeout(function() {
                                record.set('purchase_tax', '');
                            }, 50);
                            return;
                        }
                    } else if (name == 'gps_amount') {
                        if (value < 0) {
                            Leaf.showMessage('${l:PROMPT}', 'GPS费不能为负数');
                            setTimeout(function() {
                                record.set('gps_amount', '');
                            }, 50);
                            return;
                        }
            
                    } else if (name == 'postage_flag') {
                        mail_if(lease_ds_id, ds_id);
                    } else if (name == 'deposit_ratio' || calc_deposit_ratio(name)) {
            
                        if (purchase_tax_flag != 'Y') {
                            purchase_tax = 0;
                        }
                        if (insurance_flag != 'Y') {
                            insurance_amount = 0;
                        }
                        //是否融车船税
                        if (travel_tax_flag != 'Y') {
                            travel_tax = 0;
                        }
                        //是否邮寄发票
                        if (postage_flag != 'Y') {
                            postage = 0;
                        }
                        //是否融资gps
                        if (gps_flag != 'Y') {
                            gps_amount = 0;
                        }
                        //邮寄发票费不参与计算保证金比例
                        var sum_amount = plus(plus(plus(plus(plus(plus(plus(invoice_price, purchase_tax), insurance_amount), travel_tax), other_amount), charge_amount), deferred_premium), gps_amount);
                        //var sum_amount = plus(plus(plus(plus(plus(plus(plus(plus(invoice_price, purchase_tax), insurance_amount), travel_tax), other_amount), charge_amount), deferred_premium), postage), gps_amount);
                        if (calc_deposit_ratio(name)) {
                            var deposit_ratio_temp = div(deposit, sum_amount);
                            if (deposit_ratio_temp != deposit_ratio && !Ext.isEmpty(deposit) && !Ext.isEmpty(invoice_price)) {
                                record.set('deposit_ratio', deposit_ratio_temp);
                            }
                        } else if (name == 'deposit_ratio') {
                            if (value < 0) {
                                Leaf.showMessage('${l:PROMPT}', '保证金比例不能为负数');
                                setTimeout(function() {
                                    record.set('deposit_ratio', '');
                                }, 50);
                                return;
                            }
                            var deposit_temp = mul(deposit_ratio, sum_amount);
                            if (deposit_temp != deposit && !Ext.isEmpty(deposit_ratio) && !Ext.isEmpty(invoice_price)) {
                                record.set('deposit', Leaf.removeNumberFormat(Leaf.formatMoney(deposit_temp)));
                            }
                        }
            
                    } else if (name == 'invoice_price_exp') { //invoice_price
                        //预估价
                        if (invoice_price_exp != invoice_price) {
                            record.set('invoice_price', invoice_price_exp);
                        }
                    } else if (name == 'invoice_price') {
                        record.set('invoice_price_exp', invoice_price);
                    } else if (name == 'sit_number') { //座位数
                        if (value != record.get('sit_number_new')) {
                            record.set('sit_number_new', value);
                        }
                    } else if (name == 'sit_number_new') {
                        if (value != record.get('sit_number')) {
                            record.set('sit_number', value);
                        }
                    } else if (name == 'car_from') {
                        if (value == 10) {
                            record.set('car_from_id', '${/parameter/@invoice_agent_id}');
                            record.set('car_from_id', '${/parameter/@invoice_agent_id_n}');
                            record.getField('car_from_id').setReadOnly(true);
                        } else if (value == 20) {
                            record.set('car_from_id', '');
                            record.getField('car_from_id').setRequired(true);
                            record.getField('car_from_id').setReadOnly(false);
                        }
                    }
            
            
                    if (calc_deposit_ratio(name)) {
                        if (purchase_tax_flag != 'Y') {
                            purchase_tax = 0;
                        }
                        if (insurance_flag != 'Y') {
                            insurance_amount = 0;
                        }
                        //是否融车船税
                        if (travel_tax_flag != 'Y') {
                            travel_tax = 0;
                        }
                        //是否邮寄发票
                        // if (postage_flag != 'Y') {
                        // postage = 0;
                        // }
                        //是否融资gps
                        if (gps_flag != 'Y') {
                            gps_amount = 0;
                        }
                        //邮寄发票费不参与计算保证金比例
                        var sum_amount = plus(plus(plus(plus(plus(plus(plus(invoice_price, purchase_tax), insurance_amount), travel_tax), other_amount), charge_amount), deferred_premium), gps_amount);
                        //var sum_amount = plus(plus(plus(plus(plus(plus(plus(plus(invoice_price, purchase_tax), insurance_amount), travel_tax), other_amount), charge_amount), deferred_premium), postage), gps_amount);
                        if (calc_deposit_ratio(name)) {
                            var deposit_temp = mul(deposit_ratio, sum_amount);
                            if (deposit_temp != deposit && !Ext.isEmpty(deposit_ratio) && !Ext.isEmpty(invoice_price)) {
                                record.set('deposit', Leaf.removeNumberFormat(Leaf.formatMoney(deposit_temp)));
                            }
                        }
                    }
                } else if (ds.id == gua_ds_id) {
                    //担保人
                    var id_type = record.get('id_type');
                    var prj_bp_record = $(ds_id).getCurrentRecord();
            
                    if (name == 'id_card_no' && id_type == 'ID_CARD') {
                        if (record.get('id_card_no') == prj_bp_record.get('id_card_no')) {
                            Leaf.showMessage('${l:PROMPT}', '担保人信息中,身份证号码不能与申请人相同!');
                            setTimeout(function() {
                                record.set('id_card_no', '');
                            }, 500);
                            return;
                        }
                        if (value.length == 18) {
                            record.set('date_of_birth', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
                            record.set('age', new Date().getFullYear() - value.substr(6, 4));
                            if (value.substr(16, 1) % 2 == 1) {
                                record.set('gender', 'MALE');
                                record.set('gender_n', '男');
                            } else if (value.substr(16, 1) % 2 == 0) {
                                record.set('gender', 'FEMALE');
                                record.set('gender_n', '女');
                            }
                        }
                    } else if (name == 'liv_province' && bp_copy_flag == 'N') { //省市清空
                        record.set('liv_city', '');
                        record.set('liv_city_n', '');
            
                    } else if (name == 'add_province' && bp_copy_flag == 'N') {
                        record.set('add_city', '');
                        record.set('add_city_n', '');
            
                    } else if (name == 'work_province' && bp_copy_flag == 'N') { //省市清空
                        record.set('work_city', '');
                        record.set('work_city_n', '');
                    } else if (name == 'cell_phone' && !Ext.isEmpty(record.get('cell_phone'))) {
                        var cell_phone = prj_bp_record.get('cell_phone');
                        if (record.get('cell_phone') == cell_phone) {
                            Leaf.showMessage('${l:PROMPT}', '担保人信息中,手机号码不能与申请人相同!');
                            setTimeout(function() {
                                record.set('cell_phone', '');
                            }, 500);
                        }
                    }
                } else if (ds.id == ds_id) {
                    //
                    var prj_project_record_record;
                    if ($L.CmpManager.get(prj_project_record_ds)) {
                        prj_project_record_record = $(prj_project_record_ds).getCurrentRecord();
                    }
            
                    //直系亲属
                    var card_type_sp = record.get('card_type_sp');
                    if (name == 'id_no_sp') {
                        if ($L.CmpManager.get(prj_project_record_ds)) {
                            prj_project_record_record.set('id_no_sp', record.get('id_no_sp'));
                        }
                        if (record.get('id_no_sp') == record.get('id_card_no')) {
                            Leaf.showMessage('${l:PROMPT}', '直系亲属信息中,身份证号码不能与申请人相同!');
                            setTimeout(function() {
                                record.set('id_no_sp', '');
                            }, 500);
                        }
                        if (value.length == 18 && card_type_sp == 'ID_CARD') {
                            record.set('date_of_birth_sp', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
                            record.set('old_sp', new Date().getFullYear() - value.substr(6, 4));
                            if (value.substr(16, 1) % 2 == 1) {
                                record.set('gender_sp', 'MALE');
                                record.set('gender_sp_n', '男');
                            } else if (value.substr(16, 1) % 2 == 0) {
                                record.set('gender_sp', 'FEMALE');
                                record.set('gender_sp_n', '女');
                            }
                        }
                    } else if (name == 'organization_code' && !Ext.isEmpty(value)) { //organization_code
                        if ($L.CmpManager.get(g_ins_p_org_gua_ds_id)) {
                            var g_ins_p_org_gua_ds = $(g_ins_p_org_gua_ds_id).getAll();
                            var organization_code_leg = 0;
                            for (var i = 0;i < g_ins_p_org_gua_ds.length;i++) {
                                var organization_code = g_ins_p_org_gua_ds[i].get('organization_code');
                                if (value == organization_code) {
                                    organization_code_leg = organization_code_leg + 1;
                                }
                            }
                            if (organization_code_leg > 0) {
                                Leaf.showMessage('${l:PROMPT}', '不能与担保人(法人)信息 中的组织机构代码 相同!');
                                setTimeout(function() {
                                    record.set('organization_code', '');
                                }, 500);
                            }
                        }
                    }
                    if (name == 'id_card_no') {
            
                        var id_type_s = record.get('id_type');
                        if (value.length == 18 && id_type_s == 'ID_CARD') {
                            record.set('date_of_birth', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
                            record.set('age', new Date().getFullYear() - value.substr(6, 4));
                            if (value.substr(16, 1) % 2 == 1) {
                                record.set('gender', 'MALE');
                                record.set('gender_n', '男');
                            } else if (value.substr(16, 1) % 2 == 0) {
                                record.set('gender', 'FEMALE');
                                record.set('gender_n', '女');
                            }
                        }
                    } else if (name == 'card_type_sp') {
                        set_immediate_by_id_card(name, ds_id);
                    } else if (name == 'gender_sp') {
                        //性别匹配
                        if (record.get('relationship_sp') == '30') {
                            var gender = record.get('gender');
                            var gender_sp = record.get('gender_sp');
                            if (gender == gender_sp) {
                                Leaf.showMessage('${l:PROMPT}', '配偶双方性别不能相同!');
            
                                setTimeout(function() {
                                    record.set('gender_sp', '');
                                    record.set('gender_sp_n', '');
                                    if (record.get('card_type_sp') == 'ID_CARD') {
                                        record.set('id_no_sp', '');
                                    }
            
                                }, 500);
                                return;
                            }
            
                        }
                    } else if (name == 'plate_resource') {
                        //自有外牌备注必输,牌照提供方必填
                        var prj_ds_record = $(prj_ds_id).getCurrentRecord();
                        if (value == 'OWN_LICENCE') {
                            record.getField('nonlocal_plate_desc').setRequired(true);
                            prj_ds_record.getField('license_provider_name').setRequired(true);
                            prj_ds_record.getField('license_provider_code').setRequired(true);
                        } //自有上海牌备注不必输,牌照提供方必填
                        else if (value == 'OWN_SH_LICENCE') {
                            record.getField('nonlocal_plate_desc').setRequired(false);
                            prj_ds_record.getField('license_provider_name').setRequired(true);
                            prj_ds_record.getField('license_provider_code').setRequired(true);
                        } else {
                            record.getField('nonlocal_plate_desc').setRequired(false);
                            prj_ds_record.getField('license_provider_name').setRequired(false);
                            prj_ds_record.getField('license_provider_code').setRequired(false);
                        }
                    } else if (name == "price_list") {
                        //宝马厂商贴息产品自由选择保证金比例
                        if (value == 'YONDA_BMW_DR_PRODUCT' || value == 'YONDA_TD_PRODUCT') {
            
                            record.getField('deposit_ratio_n').setReadOnly(false);
                            record.getField('deposit_ratio_n').setRequired(true);
                        } else {
                            record.set('deposit_ratio_n', null);
                            record.set('deposit_ratio', '');
                            record.getField('deposit_ratio_n').setReadOnly(true);
                            record.getField('deposit_ratio_n').setRequired(false);
                        }
                        //根据报价设置期数,支付频率,首付款
                        if (value) {
                            Leaf.request({
                                url: $('get_calc_validate_sql_link').getUrl(),
                                para: {
                                    price_list: value
                                },
                                success: function(data) {
                                    if (data.result.record && !data.result.record.length) {
                                        //设置期数和支付频率validate_sql同时设置默认值
                                        var lese_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                                        $(lese_item_ds_id).getField('annual_pay_times_n').setOptions('${/parameter/@layout_code}G_INFO_annual_pay_times_combobox_ds');
                                        $(lese_item_ds_id).getField('lease_times_n').setOptions('${/parameter/@layout_code}G_INFO_lease_times_combobox_ds');
                                        $('${/parameter/@layout_code}G_INFO_annual_pay_times_combobox_ds').setQueryParameter('validation_sql', data.result.record.validate_sql_2);
                                        $('${/parameter/@layout_code}G_INFO_lease_times_combobox_ds').setQueryParameter('validation_sql', data.result.record.validate_sql_1);
                                        var lease_item_record = $(lese_item_ds_id).getAt(0);
                                        lease_item_record.set('annual_pay_times', data.result.record.default_value_2);
                                        lease_item_record.set('annual_pay_times_n', data.result.record.default_value_n_2);
                                        lease_item_record.set('lease_times', data.result.record.default_value_1);
                                        lease_item_record.set('lease_times_n', data.result.record.default_value_n_1);
                                        lease_item_record.set('down_payment_ratio', data.result.record.default_value_3);
                                        //修改必输
                                        lease_item_record.getField('annual_pay_times_n').setReadOnly(false);
                                        lease_item_record.getField('annual_pay_times_n').setRequired(true);
                                        lease_item_record.getField('lease_times_n').setReadOnly(false);
                                        lease_item_record.getField('lease_times_n').setRequired(true);
                                        lease_item_record.getField('down_payment_ratio').setReadOnly(false);
                                        lease_item_record.getField('down_payment_ratio').setRequired(true);
                                    }
            
                                },
                                failure: function() {
            
                                   },
                                error: function() {
            
                                   },
                                scope: this
                            });
                        } else {
                            var lese_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                            var lease_item_record = $(lese_item_ds_id).getAt(0);
                            lease_item_record.set('annual_pay_times', '');
                            lease_item_record.set('annual_pay_times_n', '');
                            lease_item_record.set('lease_times', '');
                            lease_item_record.set('lease_times_n', '');
                            lease_item_record.set('down_payment_ratio', '');
                            //修改必输
                            lease_item_record.getField('annual_pay_times_n').setReadOnly(true);
                            lease_item_record.getField('annual_pay_times_n').setRequired(false);
                            lease_item_record.getField('lease_times_n').setReadOnly(true);
                            lease_item_record.getField('lease_times_n').setRequired(false);
                            lease_item_record.getField('down_payment_ratio').setReadOnly(true);
                            lease_item_record.getField('down_payment_ratio').setRequired(false);
                        }
                    } else if (name == 'financial_range_code') {
                        //设置车牌
                        if (value == '10' || value == '20' || value == '30' || value == '80' || Ext.isEmpty(value)) {
                            record.set('plate_price', '');
                            record.getField('plate_price').setReadOnly(true);
                            record.getField('plate_price').setRequired(false);
                        } else {
                            record.getField('plate_price').setReadOnly(false);
                            record.getField('plate_price').setRequired(true);
                        }
                        //设置保险费
                        if (value == '30' || value == '40' || value == '80') {
                            record.getField('insurance_price').setReadOnly(false);
                            record.getField('insurance_price').setRequired(true);
                        } else {
                            record.set('insurance_price', '');
                            record.getField('insurance_price').setReadOnly(true);
                            record.getField('insurance_price').setRequired(false);
                        }
                        //不含购置税
                        if (value == '10' || value == '50' || value == '60' || value == '80') {
                            record.set('purchase_tax', '');
                        } else {
                            if (value && record.get('guide_price')) {
                                var purchase_tax = Math.ceil(record.get('guide_price') / 11.7);
                                record.set('purchase_tax', purchase_tax);
                            }
                        }
                    } else if (name == 'guide_price' || name == 'invoice_price') {
                        //求优惠幅度
                        if (record.get('guide_price') && record.get('guide_price')) {
                            var preferential_price = record.get('guide_price') - record.get('invoice_price');
                            record.set('preferential_price', preferential_price);
                            var guide_price_check = document.getElementById('${/parameter/@layout_code}_G_INFO_PRJ_PROJECT_LEASE_ITEM_GUIDE_PRICE');
                            var invoice_price_check = document.getElementById('${/parameter/@layout_code}_G_INFO_PRJ_PROJECT_LEASE_ITEM_INVOICE_PRICE');
                            if (record.get('guide_price') < record.get('invoice_price')) {
                                guide_price_check.style.color = "#FF0000";
                                invoice_price_check.style.color = "#FF0000";
                            } else {
                                guide_price_check.style.color = "black";
                                invoice_price_check.style.color = "black";
                            }
                        } else if (name == 'guide_price' && record.get('guide_price')) {
                            //求购置税,选购置税才算购置税
                            if (record.get('financial_range_code') == '20' || record.get('financial_range_code') == '30' || record.get('financial_range_code') == '40' || record.get('financial_range_code') == '70') {
                                purchase_tax = Math.ceil(record.get('guide_price') / 11.7);
                                record.set('purchase_tax', purchase_tax);
                            }
                        }
                    } else if (name == 'liv_province' && bp_copy_flag == 'N') { //省市清空
                        record.set('liv_city', '');
                        record.set('liv_city_n', '');
            
                    } else if (name == 'add_province' && bp_copy_flag == 'N') {
                        record.set('add_city', '');
                        record.set('add_city_n', '');
            
                    } else if (name == 'work_province' && bp_copy_flag == 'N') { //省市清空
                        record.set('work_city', '');
                        record.set('work_city_n', '');
                    } else if (name == 'resident_add_province' && bp_copy_flag == 'N') { //省市清空
                        record.set('resident_add_city', '');
                        record.set('resident_add_city_n', '');
                    } else if (name == 'living_add_province' && bp_copy_flag == 'N') { //省市清空
                        record.set('living_add_city', '');
                        record.set('living_add_city_n', '');
                    } else if (name == 'work_province_sp' && bp_copy_flag == 'N') { //省市清空
                        record.set('work_city_sp', '');
                        record.set('work_city_sp_n', '');
                    }
            
            
                    //  if ($L.CmpManager.get(prj_project_record_ds)) {
                    //     if (name == 'bp_name') { //电调
                    //          prj_project_record_record.set('bp_name', record.get('bp_name'));
                    //      } else if (name == 'cell_phone') {
                    //        prj_project_record_record.set('cell_phone', record.get('cell_phone'));
                    //     } else if (name == 'bp_name_sp') {
                    //        prj_project_record_record.set('bp_name_sp', record.get('bp_name_sp'));
                    //     } else if (name == 'cell_phone_sp') {
                    //        prj_project_record_record.set('cell_phone_sp', record.get('cell_phone_sp'));
                    //    }
                    // }
            
            
                    //zh
                    set_immediate_family_members(ds, name, ds_id, bp_copy_flag);
                    //
                    if (name == 'relationship_sp') {
                        if ($L.CmpManager.get(prj_project_record_ds)) {
                            prj_project_record_record.set('relationship_sp', record.get('relationship_sp'));
                            prj_project_record_record.set('relationship_sp_n', record.get('relationship_sp_n'));
                        }
                    } else if (name == 'cell_phone_sp' && !Ext.isEmpty(record.get('cell_phone_sp'))) {
                        if (record.get('cell_phone_sp') == record.get('cell_phone')) {
                            Leaf.showMessage('${l:PROMPT}', '直系亲属中,手机号码不能与申请人相同!');
                            setTimeout(function() {
                                record.set('cell_phone_sp', '');
                            }, 500);
                        }
                    } else if (name == 'cell_phone' && !Ext.isEmpty(record.get('cell_phone'))) {
                        var cell_phone = record.get('cell_phone');
                        if (record.get('cell_phone_sp') == cell_phone) {
                            Leaf.showMessage('${l:PROMPT}', '申请人信息中,手机号码不能与直系亲属信息中手机号码相同!');
                            setTimeout(function() {
                                record.set('cell_phone', '');
                            }, 500);
                        }
                        if ($L.CmpManager.get(gua_ds_id)) {
                            var gua_ds_id_all = $(gua_ds_id).getAll();
                            var lag = 'Y';
                            for (var index = 0;index < gua_ds_id_all.length;index++) {
                                var cell_phone2 = gua_ds_id_all[index].get('cell_phone');
                                if (cell_phone == cell_phone2) {
                                    lag = 'N';
                                }
                            }
                            if (lag == 'N') {
                                Leaf.showMessage('${l:PROMPT}', '申请人信息中,手机号码不能与担保人信息中手机号码相同!');
                                setTimeout(function() {
                                    record.set('cell_phone', '');
                                }, 500);
                            }
                        }
            
                    }
                } else if (ds.id == prj_project_bp_contact_info_ds) { //联系人
                    var prj_project_record_record;
                    if ($L.CmpManager.get(prj_project_record_ds)) {
                        prj_project_record_record = $(prj_project_record_ds).getCurrentRecord();
                        if (name == 'contact_person') {
                            prj_project_record_record.set('contact_person_1', record.get('contact_person'));
                        } else if (name == 'cell_phone') {
                            prj_project_record_record.set('cell_phone_contact_1', record.get('cell_phone'));
                        } else if (name == 'contact_person_1') {
                            prj_project_record_record.set('contact_person_2', record.get('contact_person_1'));
                        } else if (name == 'cell_phone_1') {
                            prj_project_record_record.set('cell_phone_2', record.get('cell_phone_1'));
                        }
                    }
                    if (name == 'cell_phone') {
                        var cell_phone_1 = record.get('cell_phone_1');
                        if (cell_phone_1 == value && !Ext.isEmpty(value)) {
                            Leaf.showMessage('${l:PROMPT}', '联系人信息中,两个联系人的手机号码不能相同!');
                            setTimeout(function() {
                                record.set('cell_phone', '');
                            }, 500);
                        }
                    } else if (name == 'cell_phone_1') {
                        var cell_phone = record.get('cell_phone');
                        if (cell_phone == value && !Ext.isEmpty(value)) {
                            Leaf.showMessage('${l:PROMPT}', '联系人信息中,两个联系人的手机号码不能相同!');
                            setTimeout(function() {
                                record.set('cell_phone_1', '');
                            }, 500);
                        }
                    }
                } else if (ds.id == prj_project_record_ds) { //电调记录ds update
                    var prj_project_record_record;
                    if ($L.CmpManager.get(prj_project_record_ds)) {
                        prj_project_record_record = $(prj_project_record_ds).getCurrentRecord();
            
                        //申请人信息 record
                        var requester_record = $(ds_id).getCurrentRecord();
                        //担保人 -- 取第一个
                        var gua_ds_record = $(gua_ds_id).getAt(0);
                        //联系人
                        var contact_info_record = $(prj_project_bp_contact_info_ds).getCurrentRecord();
            
                        if (name == 'record_type') { //电调
                            //个人
                            if (value == 'TENANT') {
                                if (requester_record && prj_project_record_record) {
                                    //电调
                                    prj_project_record_record.set('name', requester_record.get('bp_name'));
                                    prj_project_record_record.set('cellphone', requester_record.get('cell_phone'));
                                    prj_project_record_record.set('cell_base', '');
                                    prj_project_record_record.getField('cell_base').setReadOnly(true);
            
                                }
                            }
                            // 单位电话
                            if (value == 'WORK_UNIT_PHONE') {
                                if (requester_record && prj_project_record_record) {
                                    //电调
                                    prj_project_record_record.set('name', '');
                                    prj_project_record_record.set('cellphone', requester_record.get('work_unit_phone'));
                                    prj_project_record_record.set('cell_base', '');
                                    prj_project_record_record.getField('cell_base').setReadOnly(true);
            
                                }
                            }
                            // 配偶
                            if (value == 'SPOUSE') {
                                if (requester_record && prj_project_record_record) {
            
                                    // 如果是直系亲属 填写直系亲属中的 姓名和手机号码,否则为空
                                    //if ($(ds_id).getAt(0).get('relationship_sp') == '30') {
                                    //电调
                                    prj_project_record_record.set('name', requester_record.get('bp_name_sp'));
                                    prj_project_record_record.set('cellphone', requester_record.get('cell_phone_sp'));
                                    prj_project_record_record.set('cell_base', '');
                                    prj_project_record_record.getField('cell_base').setReadOnly(true);
                                    // } else {
                                    // prj_project_record_record.set('name', '');
                                    // prj_project_record_record.set('cellphone', '');
                                    // prj_project_record_record.set('cell_base', '');
                                    // prj_project_record_record.getField('cell_base').setReadOnly(true);
                                    // }
            
            
            
                                }
                            }
                            // 担保人
                            if (value == 'GUARANTOR') {
                                if (gua_ds_record && prj_project_record_record) {
                                    //电调
                                    prj_project_record_record.set('name', gua_ds_record.get('bp_name'));
                                    prj_project_record_record.set('cellphone', gua_ds_record.get('cell_phone'));
                                    prj_project_record_record.set('cell_base', '');
                                    prj_project_record_record.getField('cell_base').setReadOnly(true);
                                }
                            }
                            // 联系人1
                            if (value == 'CONTACT_PERSON') {
                                if (contact_info_record && prj_project_record_record) {
                                    //电调
                                    prj_project_record_record.set('name', contact_info_record.get('contact_person'));
                                    prj_project_record_record.set('cellphone', contact_info_record.get('cell_phone'));
                                    prj_project_record_record.set('cell_base', '');
                                    prj_project_record_record.getField('cell_base').setReadOnly(true);
                                }
                            }
                            // 联系人2
                            if (value == 'CONTACT_PERSON_1') {
                                if (contact_info_record && prj_project_record_record) {
                                    //电调
                                    prj_project_record_record.set('name', contact_info_record.get('contact_person_1'));
                                    prj_project_record_record.set('cellphone', contact_info_record.get('cell_phone_1'));
                                    prj_project_record_record.set('cell_base', '');
                                    prj_project_record_record.getField('cell_base').setReadOnly(true);
            
                                }
                            }
            
                            if (value == '') {
                                prj_project_record_record.set('name', '');
                                prj_project_record_record.set('cellphone', '');
                                prj_project_record_record.set('cell_base', '');
                                prj_project_record_record.getField('cell_base').setReadOnly(true);
                            }
                        }
                    }
            
            
            
            
            
            
                }
                if (ds.id == '${/parameter/@layout_code}_BP_INFO_prj_project_bp_ds') {
                    var prj_project_record_record;
                    if ($L.CmpManager.get(prj_project_record_ds)) {
                        prj_project_record_record = $(prj_project_record_ds).getCurrentRecord();
                    }
            
                    if (name == 'bp_name') {
                        project_record = $(prj_ds_id).getAt(0);
                        project_record.set('bp_name', value);
                    } else if (name == "house_loans_flag") {
                        if (value == 'N') {
                            record.set('house_month_amount', 0);
                        }
                    } else if (name == 'organization_code') {
                        Leaf.request({
                            url: $('get_org_code_info_guar_id').getUrl(),
                            para: {
                                organization_code: value
                            },
                            success: function(data) {
                                if (data.result.record && !data.result.record.length) {
                                    //申请人信息
                                    for (var name in data.result.record) {
                                        if (name != 'bp_category' && name != 'bp_type') {
                                            record.set(name, data.result.record[name]);
                                        }
                                    }
            
                                }
            
                            },
                            failure: function() {
            
                               },
                            error: function() {
            
                               },
                            scope: this
                        });
                    } else if (name == 'id_card_no') {
                        if ($L.CmpManager.get(prj_project_record_ds)) {
                            prj_project_record_record.set('id_card_no', record.get('id_card_no'));
                        }
            
                        var id_type = record.get('id_type');
                        Leaf.request({
                            url: $('get_id_card_no_info_id').getUrl(),
                            para: {
                                id_card_no: value,
                                id_type: id_type
                            },
                            success: function(data) {
                                if (data.result.record && !data.result.record.length) {
                                    //申请人信息
                                    for (var name in data.result.record) {
                                        bp_copy_flag = 'Y';
                                        if (name != 'bp_category' && name != 'bp_type') {
                                            record.set(name, data.result.record[name]);
                                        }
                                    }
            
                                }
            
                            },
                            failure: function() {
            
                               },
                            error: function() {
            
                               },
                            scope: this
                        });
                    }
                    // else if (name == 'id_card_no' && value.length == 18 && id_type == 'ID_CARD') {
                    // record.set('date_of_birth', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
                    // record.set('age', new Date().getFullYear() - value.substr(6, 4));
                    // if (value.substr(16, 1) % 2 == 1) {
                    // record.set('gender', 'MALE');
                    // record.set('gender_n', '男');
                    // } else if (value.substr(16, 1) % 2 == 0) {
                    // record.set('gender', 'FEMALE');
                    // record.set('gender_n', '女');
                    // }
                    // }
                } else if (ds.id == '${/parameter/@layout_code}_G_INS_P_ORG_prj_project_bp_ds') {
                    if (name == 'organization_code') {
                        Leaf.request({
                            url: $('get_org_code_info_guar_id').getUrl(),
                            para: {
                                organization_code: value,
                            },
                            success: function(data) {
                                if (data.result.record && !data.result.record.length) {
                                    // 担保人
                                    for (var name in data.result.record) {
                                        if (name != 'bp_category' && name != 'bp_type') {
                                            record.set(name, data.result.record[name]);
                                        }
            
                                    }
                                }
            
                            },
                            failure: function() {
            
                               },
                            error: function() {
            
                               },
                            scope: this
                        });
                    }
                } else if (ds.id == bao_ds_id) {
                    //zhanghao  start
                    //保险费和车船税计算
                    calculate_premium_car(bao_ds_id, data_ds);
                } else if (ds.id == baodan_ds_id) {
                    premium_if(baodan_ds_id, name, data_ds, bao_ds_id);
                }
                //zhanghao  end
                bp_copy_flag = 'N';
            };
            //zhanghao start
            // //新增和加载时调用(form)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function(ds, record, config_records, bp_seq) {

            
                var project_id = ${/parameter/@project_id};
                //alert(project_id);
                if (record.isNew) {
            
                    global_save_flag = 'N';
                }
                // var prj_project_record_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'PRJ_PROJECT_RECORD');
                // var prj_project_bp_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');
                // //prj_project_bp_contact_info
                // var prj_project_bp_contact_info_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp_contact_info');
                // if (ds.id == prj_project_record_ds || ds.id == prj_project_bp_ds || ds.id == prj_project_bp_contact_info_ds) {
                // //
                // if ($L.CmpManager.get(prj_project_record_ds) && $L.CmpManager.get(prj_project_bp_ds) && $L.CmpManager.get(prj_project_bp_contact_info_ds)) {
                // var prj_project_record_record = $(prj_project_record_ds).getCurrentRecord();
                // var prj_project_bp_record = $(prj_project_bp_ds).getCurrentRecord();
                // var prj_project_bp_contact_info_ds_record = $(prj_project_bp_contact_info_ds).getCurrentRecord();
                // if (prj_project_bp_record && prj_project_record_record && prj_project_bp_contact_info_ds_record) {
                // //电调
                // prj_project_record_record.set('bp_name', prj_project_bp_record.get('bp_name'));
            
                // prj_project_record_record.set('cell_phone', prj_project_bp_record.get('cell_phone'));
            
                // prj_project_record_record.set('id_card_no', prj_project_bp_record.get('id_card_no'));
                // prj_project_record_record.set('bp_name_sp', prj_project_bp_record.get('bp_name_sp'));
                // prj_project_record_record.set('cell_phone_sp', prj_project_bp_record.get('cell_phone_sp'));
                // prj_project_record_record.set('id_no_sp', prj_project_bp_record.get('id_no_sp'));
            
                // prj_project_record_record.set('relationship_sp', prj_project_bp_record.get('relationship_sp'));
                // prj_project_record_record.set('relationship_sp_n', prj_project_bp_record.get('relationship_sp_n'));
            
                // //联系人
                // prj_project_record_record.set('contact_person_1', prj_project_bp_contact_info_ds_record.get('contact_person'));
                // prj_project_record_record.set('cell_phone_contact_1', prj_project_bp_contact_info_ds_record.get('cell_phone'));
            
                // prj_project_record_record.set('contact_person_2', prj_project_bp_contact_info_ds_record.get('contact_person_1'));
                // prj_project_record_record.set('cell_phone_2', prj_project_bp_contact_info_ds_record.get('cell_phone_1'));
            
                // }
                // }
                // }
            
            
            
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
                //
                if (ds.id == ds_id && ds_id) {
                    //var gps_flag = $(ds_id).getCurrentRecord().get('gps_flag');
                    var project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                    head_record = $(project_ds_id).getAt(0);
                    if (head_record) {
                        record.getField('product_plan_id_n').setLovPara('car_type', head_record.get('car_type'));
                        record.getField('product_plan_id_n').setLovPara('bp_id', head_record.get('bp_id'));
                    }
                    Leaf.request({
                        url: $('get_gps_flag_link').getUrl(),
                        para: {
                            project_id: project_id
                        },
                        success: function(res) {
                            var gps_flag = res.result.gps_flag;
                            //alert(gps_flag);
                            if (gps_flag == 'N') {
                                record.set('gps_amount', 0);
                                record.getField('gps_amount').setReadOnly(true);
                            }
                        },
                        failure: function() {
            
                           },
                        error: function() {
            
                           },
                        scope: this
                    });
            
            
                    Leaf.request({
                        url: $('get_purchase_tax_flag_link').getUrl(),
                        para: {
                            project_id: project_id
                        },
                        success: function(res) {
                            var purchase_tax_flag = res.result.purchase_tax_flag;
                            //alert(gps_flag);
                            if (purchase_tax_flag == 'N') {
                                record.set('purchase_tax', 0);
                                record.getField('purchase_tax').setReadOnly(true);
                            }
                        },
                        failure: function() {
            
                           },
                        error: function() {
            
                           },
                        scope: this
                    });
                }
            
            };
            //打包下载
            window['${/parameter/@layout_code}_ACY_USER_BUTTON1_layout_dynamic_tab_click'] = function() {
                //
            
                var prj_project_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_record = $(prj_project_id).getAt(0);
                var project_id = prj_project_record.get('project_id');
                var url_l = $('get_atch_download_link').getUrl() + '?table_pk_value=' + project_id + '&table_name=PRJ_PROJECT' + '&doc_code=' + project_id + '&all_flag=Y';
                window.open(href = url_l, target = "_self");
            };
            //新增时调用(grid,table,gridBox)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_add'] = function(ds, record, config_records, bp_seq) {
                if (record.isNew) {
            
                    global_save_flag = 'N';
                }
            
                var gua_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'DANBAOREN', 'prj_project_bp');
                if (ds.id == gua_ds_id) {
            
                    record.set('bp_seq', 1);
                }
                var ast_insurance_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ast_car_insurance');
                //担保人(法人)信息
                var g_ins_p_org_gua_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_INS_P_ORG', 'prj_project_bp');
                //担保人
                var gua_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'DANBAOREN', 'prj_project_bp');

                if (ds.id == gua_ds_id || ds.id == g_ins_p_org_gua_ds_id) {
                    var size = 0;
                    if ($L.CmpManager.get(g_ins_p_org_gua_ds_id)) {
                        var g_ins_p_org_gua_ds_res = $(g_ins_p_org_gua_ds_id).getAll();
                        size = size + g_ins_p_org_gua_ds_res.length;
                    }
                    if ($L.CmpManager.get(gua_ds_id)) {
                        var gua_ds_id_res = $(gua_ds_id).getAll();
                        size = size + gua_ds_id_res.length;
                    }
                    if (size > 1) {
                        Leaf.showMessage('${l:HLS.PROMPT}', '担保人只能有一个!');
            
                        return;
                    }
                }
            
                //根据保险信息是否融保险为N时将表单列表中的保险set为ReadOnly
                if (ds.id == ast_insurance_ds) {
                    var insurance_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                    var records = $(insurance_ds).getAt(0);
                    var insurance_flag = records.get('insurance_flag');
                    if (!Ext.isEmpty(insurance_flag)) {
                        if (insurance_flag == 'N') {
                            record.getField('insurance_years').setReadOnly(true);
                            record.getField('insurance_years_n').setReadOnly(true);
                            record.getField('compulsory_insurance_flag').setReadOnly(true);
                            record.getField('travel_tax_flag').setReadOnly(true);
                            record.getField('travel_tax_flag_n').setReadOnly(true);
                            record.getField('rot_insurance').setReadOnly(true);
                            record.getField('rot_insurance_n').setReadOnly(true);
                            record.getField('damage_insurance_limit').setReadOnly(true);
                            record.getField('third_party_insurance').setReadOnly(true);
                            record.getField('third_party_insurance_n').setReadOnly(true);
                            record.getField('compulsory_insurance_amount').setReadOnly(true);
                            record.getField('travel_tax').setReadOnly(true);
                            record.getField('pilfer_insurance_amount').setReadOnly(true);
                            record.getField('damage_insurance_amount').setReadOnly(true);
                            record.getField('third_party_insurance_amount').setReadOnly(true);
                            record.getField('vehicle_resp_ins_driver').setReadOnly(true);
                            record.getField('vehicle_resp_ins_driver_n').setReadOnly(true);
                            record.getField('vehicle_resp_ins_passenger').setReadOnly(true);
                            record.getField('vehicle_resp_ins_passenger_n').setReadOnly(true);
                            record.getField('nick_insurance').setReadOnly(true);
                            record.getField('nick_insurance_n').setReadOnly(true);
                            record.getField('stop_walking_insurance').setReadOnly(true);
                            record.getField('stop_walking_insurance_n').setReadOnly(true);
                            record.getField('combustion_insurance_flag').setReadOnly(true);
                            record.getField('combustion_insurance_flag_n').setReadOnly(true);
                            record.getField('vehicle_resp_ins_d_amount').setReadOnly(true);
                            record.getField('vehicle_resp_ins_p_amount').setReadOnly(true);
                            record.getField('nick_insurance_amount').setReadOnly(true);
                            record.getField('stop_walk_insu_amount').setReadOnly(true);
                            record.getField('combustion_insurance_amount').setReadOnly(true);
                            record.getField('glass_insurance').setReadOnly(true);
                            record.getField('glass_insurance_n').setReadOnly(true);
                            record.getField('specify_insurance_flag').setReadOnly(true);
                            record.getField('specify_insurance_flag_n').setReadOnly(true);
                            record.getField('wading_driving_insurance').setReadOnly(true);
                            record.getField('wading_driving_insurance_n').setReadOnly(true);
                            record.getField('damage_nopay_insurance_flag').setReadOnly(true);
                            record.getField('damage_nopay_insurance_flag_n').setReadOnly(true);
                            record.getField('glass_insurance_amount').setReadOnly(true);
                            record.getField('specify_insurance_amount').setReadOnly(true);
                            record.getField('wading_driving_insu_amount').setReadOnly(true);
                            record.getField('damage_nopay_insu_amount').setReadOnly(true);
                        }
                    }
                }
            
            
            };
            
            //zhanghao end
            
            //add by Spencer 3893 20160718
            //移除事件(grid,attach,gridbox,table)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_remove'] = function(ds, record, bp_seq) {
                //
                var prj_project_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_record = $(prj_project_id).getAt(0);
                var project_id = prj_project_record.get('project_id');
                var insurance_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
            
                if (record.isNew) {
                    //
                    var insurance_ds_record = $(insurance_ds_id).getAt(0);
                    var insurance_amount = insurance_ds_record.get('insurance_amount') || 0;
                    var travel_tax = insurance_ds_record.get('travel_tax') || 0;
                    var tmp_travel_tax = record.get('travel_tax') || 0;
                    var tmp_amount = (record.get('compulsory_insurance_amount') || 0) + (record.get('pilfer_insurance_amount') || 0) + (record.get('damage_insurance_amount') || 0) + (record.get('third_party_insurance_amount') || 0) + (record.get('vehicle_resp_ins_d_amount') || 0) + (record.get('vehicle_resp_ins_p_amount') || 0) + (record.get('nick_insurance_amount') || 0) + (record.get('stop_walk_insu_amount') || 0) + (record.get('combustion_insurance_amount') || 0) + (record.get('glass_insurance_amount') || 0) + (record.get('specify_insurance_amount') || 0) + (record.get('wading_driving_insu_amount') || 0) + (record.get('damage_nopay_insu_amount') || 0);
                    if (insurance_amount > 0) {
                        insurance_ds_record.set('insurance_amount', insurance_amount - tmp_amount);
                    }
                    if (travel_tax > 0) {
                        insurance_ds_record.set('travel_tax', travel_tax - tmp_travel_tax);
                    }
                } else {
                    $(insurance_ds_id).setQueryParameter('project_id', project_id);
                    $(insurance_ds_id).query();
                }
            };
        ]]></script>
        <!-- <a:switch test="/parameter/@wfl_flag">
            <a:case value="Y">
                <script type="text/javascript"><![CDATA[
            //工作流中同意按钮调用保存
            zjwfl5110_ApproveChecker_add('agree', function() {
                prj_project_ds_save();
                return true;
            });
            
            function prj_project_ds_save(s) {
                window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
                return true;
            }
        ]]></script>
            </a:case>
        </a:switch> -->
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>