csh_payment_req.lview 65.5 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang 
    $Date: 2015-1-27 上午09:27:36  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script"
          customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <s:server-script import="contract_print_path.js"><![CDATA[
            $ctx.parameter.file_path = con_print_path['con_print_path'];
            $ctx.parameter.tomcat_source = con_print_path['tomcat_source'];
            ]]>
        </s:server-script>
        <a:model-query autoCount="false"
                       defaultWhereClause=" document_category=&apos;PAYMENT_REQ&apos; and  document_type=&apos;STD_PREPAYMENT_REQ&apos;"
                       fetchAll="true" model="hls.HLS003.hls_document_type"
                       rootPath="default_prepayment_document_type"/>
        <a:model-query autoCount="false"
                       defaultWhereClause=" document_category=&apos;PAYMENT_REQ&apos; and  document_type=&apos;STD_PAYMENT_REQ&apos;"
                       fetchAll="true" model="hls.HLS003.hls_document_type" rootPath="default_payment_document_type"/>
        <a:model-query autoCount="false" fetchAll="true" model="basic.current_bp_category"
                       rootPath="current_bp_category"/>
        <a:model-query fetchAll="true" model="csh.CSH501.get_loan_flag" rootPath="loan_flag_path"/>
    </a:init-procedure>
    <a:view>
28 29
        <a:link id="cont811_con_sale_contract_info_print_link"
                url="${/request/@context_path}/modules/csh/CSH501/payment_req_apply_print.lview"/>
Spencer Chang's avatar
Spencer Chang committed
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
        <a:link id="csh_req_ddct_link"
                url="${/request/@context_path}/modules/csh/CSH504/csh_payment_req_ln_ddct.lview"/>
        <a:link id="csh_payment_prepayment_dk"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_prepayment_dk.lview"/>
        <a:link id="csh_payment_req_prepayment_dk_detail_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_prepayment_dk_detail.lview"/>
        <a:link id="csh_payment_req_ln_del_link" model="csh.CSH504.csh_payment_req_ln_del" modelaction="batch_update"/>
        <a:link id="csh501d_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
        <a:link id="csh_payment_req_pay_win_link"
                url="${/request/@context_path}/modules/csh/CSH502/csh_payment_req_pay.lview"/>
        <a:link id="csh501_csh_payment_auto_ddct" model="csh.CSH501.auto_allocation_ddct" modelaction="execute"/>
        <a:link id="csh_payment_auto_dt_link"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_auto_dk.lsc"/>
        <a:link id="csh501_csh_payment_req_hd_del_link" model="csh.CSH504.csh_payment_req_hd_del" modelaction="update"/>
        <a:link id="con_rd_wfl_link" url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <a:link id="csh_payment_req_ln_reject_link" model="csh.CSH504.csh_payment_req_ln_reject"
                modelaction="batch_update"/>
        <a:link id="csh_payment_req_ln_atm_reject_link" model="csh.CSH504.csh_payment_req_ln_atm_reject"
                modelaction="batch_update"/>
        <a:link id="csh_payment_post_nc_link" model="csh.CSH501.csh_payment_post_nc" modelaction="update"/>
        <a:link id="csh_payment_pay_nc_link" model="csh.CSH501.csh_payment_post_nc" modelaction="execute"/>
        <a:link id="csh_payment_bank_link" model="csh.CSH502.csh_pay_send" modelaction="update"/>
        <a:link id="csh501d_car_info_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh501d_car_info.lview"/>
        <a:link id="csh501D_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
        <link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
        <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>
59
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
stone's avatar
stone committed
60
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
Spencer Chang's avatar
Spencer Chang committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id"
                url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_id"
                url="${/request/@context_path}/downloadFile.lview"/>
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
        <a:link id="con_contract_houdu_link"
                url="${/request/@context_path}/modules/csh/CSH501/contract_houdu_query.lview"/>
        <a:link id="con_contract_houdu_readOnly_link"
                url="${/request/@context_path}/modules/csh/CSH501/contract_houdu_readOnly.lview"/>
        <a:link id="prj_project_approval_link"
                url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_query.lview"/>
        <a:link id="csh501_confirm_invoice_link_id"
                url="${/request/@context_path}/modules/acp/ACP517/acp_invoice_entrance.lview"/>
        <a:link id="get_xml" model="cont.CON501.con_change_case_submit" modelaction="execute"/>

76 77 78
       <!-- 生成Excel文件-->
        <a:link id="tre_loan_con_print_excel_link_id" url="${/request/@context_path}/modules/csh/CSH501/csh_payment_contract_export.lsc"/>

Spencer Chang's avatar
Spencer Chang committed
79 80
        <script type="text/javascript"><![CDATA[
        jQuery.noConflict();
stone's avatar
stone committed
81
        //如果头id 不为空,就使用自在定义的ds进行查询
stone's avatar
stone committed
82 83
        Leaf.onReady(function(){
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
stone's avatar
stone committed
84 85 86 87 88 89 90 91 92 93
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var payment_req_id='${/parameter/@payment_req_id}';
            if(payment_req_id){
                $(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_query_after_save/query');
                $(lnds_id).setQueryParameter("payment_req_id",payment_req_id);
                $(lnds_id).query();
                $(hdds_id).setQueryParameter("payment_req_id",payment_req_id);
                $(hdds_id).query();

            }
stone's avatar
stone committed
94
        })
Spencer Chang's avatar
Spencer Chang committed
95 96 97 98 99 100 101 102
        Ext.ux.Lightbox.register('a[ref=img]', true);

        if ('${/parameter/@payment_req_id}') {
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
        }

        var dirty_flag = 'N';
        window['${/parameter/@layout_code}_on_layout_dynamic_update'] = function (ds, record, name, value, old_value, bp_seq) {
stone's avatar
stone committed
103
            //如果更新数据,将付款日期先置为空
Spencer Chang's avatar
Spencer Chang committed
104 105 106 107 108 109 110 111 112 113 114 115 116
            var dirty_flag = 'Y';
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var hd_ds, ln_ds, lineRecords, currency_code, currency_name;
            if (hdds_id) {
                hd_ds = $(hdds_id);
                hdrecord = hd_ds.getCurrentRecord();
            }
            if (lnds_id && $L.CmpManager.get(lnds_id)) {
                ln_ds = $(lnds_id);
                lineRecords = ln_ds.getAll();
            }
            if (hdds_id && ds.id == hdds_id) {
117
                //
Spencer Chang's avatar
Spencer Chang committed
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
                if (name == 'first_payment_date') {
                    var first_payment_date = hdrecord.get('first_payment_date');
                    if (first_payment_date.getDate() != '5' && first_payment_date.getDate() != '10' && first_payment_date.getDate() != '15' && first_payment_date.getDate() != '20' && first_payment_date.getDate() != '25' && first_payment_date.getDate() != '30') {
                        Leaf.showWarningMessage('${l:HLS.PROMPT}', '为统一收款日,请选择末位为5号、10号、15号、20号、25号、30号的日期!');
                        return;
                    }
                    var first_contract_day = record.get('first_contract_day');
                    if (!record.get('first_contract_day')) {

                        first_contract_day = '${/parameter/@first_contract_day}';
                    }
                    if (first_contract_day) {
                        if (first_payment_date.getDate() != first_contract_day) {
                            Leaf.showWarningMessage('${l:HLS.PROMPT}', '为统一收款日,请选择首次支付表日期末位相同的日期!');
                            return;
                        }
                    }
                }
                if (name == 'req_date') {
                    for (var i = 0; i < lineRecords.length; i++) {
                        lineRecords[i].set('apply_pay_date', value);
                    }
                } else if (name == 'bp_id' || name == 'bp_id_n' || name == 'bp_bank_account_id' || name == 'bp_bank_account_id_n' || name == 'bp_bank_account_num' || name == 'bp_bank_account_name' || name == 'bp_name' || name == 'bp_category' || name == 'bp_category_desc') {
                    for (var j = 0; j < lineRecords.length; j++) {
                        var lineRecord = lineRecords[j];
                        if (name == 'bp_id' && first_load_flag == 'N') {
                            lineRecord.set('bp_bank_account_id', null);
                            lineRecord.set('bp_bank_account_id_n', null);
                            lineRecord.set('bp_bank_account_num', null);
                            lineRecord.set('bp_bank_account_name', null);
                        }
                        lineRecord.set(name, record.get(name));
                    }
                    first_load_flag = 'N';

                }
                if (name == 'compensatory_flag') {
                    var compensatory_flag = record.get('compensatory_flag');
                    if (compensatory_flag == 'Y') {
                        hdrecord.getField('las_compensatory_amount').setReadOnly(false);
                    } else {
                        hdrecord.getField('las_compensatory_amount').setReadOnly(true);
                        hdrecord.set('las_compensatory_amount', null);
                    }
                }
            } else if (lnds_id && lnds_id == ds.id) {
                if (name == 'amount') {
                    var amount = 0;
                    for (var m = 0; m < lineRecords.length; m++) {
                        var lineRecord = lineRecords[m];
                        currency_code = lineRecord.get('currency_code');
                        currency_name = lineRecord.get('currency_name');
                        if (hdrecord.get('currency_code') != currency_code) {
                            hdrecord.set('amount', null);
                            hdrecord.set('currency_code', null);
                            return;
                        } else {
                            current_amount = lineRecord.get('amount') || 0;
                            amount = plus(amount, current_amount);
                        }
                    }
                    hdrecord.set('amount', amount);
                    hdrecord.set('currency_code', currency_code);
                    hdrecord.set('currency_name', currency_name);
                    record.set('act_amount', minus(record.get('amount'), record.get('sum_ddct_amount') || 0));
                } else if (name == 'act_amount') {
                    hdrecord.set('sum_act_amount', plus(minus(hdrecord.get('sum_act_amount') || 0, old_value || 0), value || 0));
                }
                if (lineRecords.length == 1) {
                    if (name == 'bp_id' || name == 'bp_id_n' || name == 'bp_name' || name == 'bp_bank_account_id' || name == 'bp_bank_account_id_n' || name == 'bp_category' || name == 'bp_category_desc') {
                        hdrecord.set(name, record.get(name));
                    }
                }
            }
        };

        window['${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function (ds, record, config_records, bp_seq) {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');

            var hd_ds, lineRecords, currency_code;
            if (hdds_id) {
                hd_ds = $(hdds_id);
                hdrecord = hd_ds.getCurrentRecord();
            }
            if (record) {
                if ('${/parameter/@function_code}' == 'CSH502D') {
                    record.getField('pay_amount').setReadOnly(false);
                }
            }


            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        };

        var first_load_flag = 'N';

        window['${/parameter/@layout_code}_on_layout_dynamic_grid_add'] = function (ds, record, config_records, bp_seq) {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            if (!'${/parameter/@payment_req_id}' && hdds_id) {
                var hd_ds = $(hdds_id);
                var hd_record = hd_ds.getCurrentRecord();
                var amount = hd_record.get('amount') || 0;
                var sum_act_amount = hd_record.get('sum_act_amount') || 0;
                hd_record.set('currency_code', record.get('currency_code'));
                hd_record.set('currency_name', record.get('currency_name'));
                hd_record.set('amount', plus(amount, record.get('amount')));
                hd_record.set('sum_act_amount', plus(sum_act_amount, record.get('act_amount')));
                if (Ext.isEmpty(hd_record.get('irr')) && record.get('irr')) {
                    hd_record.set('irr', record.get('irr'));
                }
                if (Ext.isEmpty(record.get('act_amount'))) {
                    record.set('act_amount', minus(record.get('amount'), record.get('sum_ddct_amount') || 0));
                }
                if (ds.getAll().length == 1) {
                    first_load_flag = 'Y';
233
                    //
Spencer Chang's avatar
Spencer Chang committed
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
                    hdrecord.set('bp_id', record.get('bp_id'));
                    hdrecord.set('bp_id_n', record.get('bp_code'));
                    hdrecord.set('bp_name', record.get('bp_name'));
                    hdrecord.set('bp_bank_account_id', record.get('bp_bank_account_id'));
                    hdrecord.set('bp_bank_account_id_n', record.get('bp_bank_account_id_n'));
                    hdrecord.set('bp_bank_account_name', record.get('bp_bank_account_id_n'));
                    hdrecord.set('bp_bank_account_num', record.get('bp_bank_account_num'));
                    hdrecord.set('bp_category', record.get('bp_category'));
                    hdrecord.set('bp_category_desc', record.get('bp_category_desc'));
                    hdrecord.set('approval_status', 'NEW');
                    hdrecord.set('approval_status_n', '新建');
                    hdrecord.set('bank_full_name', record.get('bank_full_name'));
                    // hdrecord.set('price', record.get('price'));
                }
            }
        };

        function on_csh_payment_req_temp_ln_ds_load(ds) {
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var records = ds.getAll();

            if (!'${/parameter/@payment_req_id}' && lnds_id && '${/parameter/@business_type}' == 'PAYMENT') {
                for (var i = 0; i < records.length; i++) {
                    var record = records[i];

                    if (!record.get('apply_pay_date')) {
260 261 262
                        //添加时间为预定的每月20号
                       var pre_date= [new Date().getFullYear(),new Date().getMonth()+1,20].join('-');
                        record.set('apply_pay_date',pre_date);
Spencer Chang's avatar
Spencer Chang committed
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
                    }
                    $(lnds_id).create(Ext.apply({}, record.data));
                }
            }
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();

            // var ds_call_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
            // jQuery("div").hover(function() {
            // if (ds_call_id) {
            // var records = $(ds_call_id).getAll();
            // for (var i = 0;i < records.length;i++) {
            // var id = "#${/parameter/@layout_code}_ACY_prj_cdd_item_doc_ref_layout_grid_id__" + records[i].id;
            // if (1) {
            // jQuery(id).removeClass("grid-ckb item-ckb-u").addClass('grid-ckb item-ckb-readonly-u');
            // }
            // jQuery("div").unbind(); //移除所有
            // }
            // }
            // });

        }

        function csh_payment_req_submit_finally() {
            var win = Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function okFun() {

                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
                var hd_record = $(ds_id).getCurrentRecord();
                var payment_req_id = hd_record.get('payment_req_id');
                var line_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
293
                var line_record = $(line_ds_id).getAt(0);
Spencer Chang's avatar
Spencer Chang committed
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
                if (line_record.get('cf_item') == '52' || line_record.get('cf_item') == '509') {
                    //保证金退还Doodream审批接口  CFL-FE5D96CF-694C-4290-A22E-241FC3F6DEF0
                    var case_type = 'CFL-FE5D96CF-694C-4290-A22E-241FC3F6DEF0';
                    $('${/parameter/@layout_code}_save').disable();
                    $('${/parameter/@layout_code}_submit_approval').disable();
                    getXml(case_type, payment_req_id);
                    // else if (document_type == 'LEASEHOLD_CHAG') {
                    // case_type = '';
                    // }

                } else {
                    Leaf.request({
                        url: '${/request/@context_path}/autocrud/csh.CSH501.upd_csh_payment_sub_flag/execute',
                        para: {
                            payment_req_id: payment_req_id,
                            _status: 'execute'
                        },
                        success: function (res) {
                            Leaf.SideBar.enable = true;
                            Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            $('${/parameter/@winid}').close();
                        },
                        failure: function () {
                            Leaf.SideBar.enable = true;
                            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        error: function () {
                            Leaf.SideBar.enable = true;
                            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        scope: this
                    });
                }
            }, function cancelFun() {
                Leaf.SideBar.enable = true;
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            });
            win.on('close', function () {
                Leaf.SideBar.enable = true;
            });
        }

        function getXml(case_type, payment_req_id) {

            var req_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var req_record = $(req_ds_id).getAt(0)
            if (dirty_flag == 'Y') {
                Leaf.showMessage('${l:HLS.PROMPT}', '页面数据存在修改,请先保存再发起起案!');
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                return;
            }
            Leaf.request({
                url: $('get_xml').getUrl(),
                para: {
                    payment_req_id: payment_req_id,
                    interface_name: case_type
                },
                success: function (res) {
                    getUrl(res.result.xml)
                    //document.getElementById("doodream_iframe").contentWindow.ConnData(res.result.xml);
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
                failure: function () {
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
                error: function () {
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
                scope: this
            });

        }

        function getUrl(xml) {
            Leaf.request({
                url: '${/request/@context_path}/doodream/post/url',
                para: {
                    xml: xml
                },
                success: function (res) {
                    window.open(res.message, "", "width=940, height=650, scrollbars=yes, toolbar=no, location=no, status=no, menubar=no");
                    Leaf.SideBar.show({
                        msg: '${l:HLS.SUBMIT_SUCCESS}',
                        duration: 2000
                    });
                },
                failure: function () {
                    Leaf.SideBar.show({
                        msg: 'failure',
                        duration: 2000
                    });
                },
                error: function () {
                    Leaf.SideBar.show({
                        msg: 'error',
                        duration: 2000
                    });
                },
                scope: this
            });
        }
        //打印

        function csh501_print() {
402

Spencer Chang's avatar
Spencer Chang committed
403 404 405
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var records_l = $(lnds_id).getAll();
406
            console.log(records_l);
Spencer Chang's avatar
Spencer Chang committed
407
            var hd_record = $(hdds_id).getCurrentRecord();
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
            //add by st
            var url;
           /* url = $('tre_loan_con_print_excel_link_id').getUrl() + '?payment_req_id=' +hd_record.get('payment_req_id');
            window.open(href = url);*/
           debugger
                /*var sale_id = record[0].get('sale_id');
                var sale_code = record[0].get('sale_code');*/
                var template_name = 'payment_apply_content.xml';
               // var template_name = '1.xml';
                var file_name = '付款申请书.doc';
                var url = $('cont811_con_sale_contract_info_print_link').getUrl() + '?template_name=' + template_name + '&payment_req_id=' + hd_record.get('payment_req_id') + '&file_name=' + encodeURI(file_name);
                window.location.href = encodeURI(url);




Spencer Chang's avatar
Spencer Chang committed
424 425 426 427 428
        }


        window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function () {
            Leaf.SideBar.enable = false;
429
            //提交之前必须要保存
430 431 432 433 434 435 436
            /*  var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
              var hd_record = $(hdds_id).getCurrentRecord();
              var payment_req_id = hd_record.get('payment_req_id');
              if(payment_req_id){
                  $L.showInfoMessage("提示",'请先保存数据!');
                  return;
              }*/
Spencer Chang's avatar
Spencer Chang committed
437 438 439 440 441 442 443 444 445
            window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK'](csh_payment_req_submit_finally);

        };


        window['${/parameter/@layout_code}_print_layout_dynamic_click'] = function () {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var hd_ds = $(hdds_id),
446
                ln_ds = $(lnds_id);
Spencer Chang's avatar
Spencer Chang committed
447
            var hd_record = hd_ds.getCurrentRecord(),
448
                ln_records = ln_ds.getAll();
Spencer Chang's avatar
Spencer Chang committed
449 450
            if (ln_records.length > 0 && !ln_records[0].get('payment_req_ln_id')) {
                Leaf.showMessage('${HLS.PROMPT}', '请先保存!');
451 452 453 454
            }else{
                csh501_print();
            }
            /*else {
Spencer Chang's avatar
Spencer Chang committed
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476

                Leaf.request({
                    url: '${/request/@context_path}/autocrud/csh.CSH504.csh_payment_print/execute',
                    para: {
                        payment_req_id: hd_record.get('payment_req_id'),
                        _status: 'execute'
                    },
                    success: function (res) {
                        csh501_print();

                    },
                    sync: true,
                    failure: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    error: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                }, Leaf.Masker.unmask(Ext.getBody()));


477
            }*/
Spencer Chang's avatar
Spencer Chang committed
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
        };

        // //车辆信息
        // window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
        // var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
        // var ln_ds = $(lnds_id);
        // ln_record = ln_ds.getCurrentRecord();
        // var param = {};
        // param['function_usage'] = 'UPDATE';
        // param['contract_id'] = ln_record.get('contract_id');
        // //param['document_id'] = ln_record.get('contract_id');
        // param['function_code'] = 'CSH501D_CAR_INFO';
        // param['winid'] = 'csh501d_car_info_window';
        // param['url_title'] = '车辆信息';
        // hls_doc_get_layout_code('csh501D_get_layout_code_link_id', param, 'csh501d_car_info_link_id', null, '${/parameter/@layout_code}');


        // };

        //发票确认
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
            var contract_id = '${/parameter/@contract_id}';
            var param = {};
            param['function_code'] = 'ACP517_CONFIRM';
            param['function_usage'] = 'MODIFY';
            param['contract_id'] = contract_id;
            param['winid'] = 'csh501_confirm_invoice_link_winid';
            param['url_title'] = '发票确认';
            hls_doc_get_layout_code('csh501D_get_layout_code_link_id', param, 'csh501_confirm_invoice_link_id');
        };

        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function () {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var hd_ds = $(hdds_id),
513
                ln_ds = $(lnds_id);
Spencer Chang's avatar
Spencer Chang committed
514 515 516 517 518 519 520 521 522 523 524
            var Array = ln_ds.getSelected();
            if (Array.length < 1) {
                Leaf.showMessage('${l:PROMPT}', '${l:CHOOSE_ONE_RECORD}');
            }
            if (Array.length == ln_ds.getAll().length) {
                window['${/parameter/@layout_code}_user_button7_layout_dynamic_click']();
            } else {
                Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.DELETE_CONFIRM}', function okFun() {
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                    var hdrecord = hd_ds.getCurrentRecord();
                    for (var i = 0,
525
                             length = Array.length; i < length; i++) {
Spencer Chang's avatar
Spencer Chang committed
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
                        if (Array[i].isNew) {
                            ln_ds.removeLocal(Array[i]);
                            hdrecord.set('amount', minus(hdrecord.get('amount') || 0, Array[i].act_amount || 0));
                        }
                    }
                    if (Array.length > 0) {
                        var param = ln_ds.getJsonData(true);
                        Leaf.request({
                            url: $('csh_payment_req_ln_del_link').getUrl(),
                            para: param,
                            success: function () {
                                if (hd_ds.getCurrentRecord().get('payment_req_id')) {
                                    for (var i = 0; i < param.length; i++) {
                                        hdrecord.set('amount', minus(hdrecord.get('amount') || 0, param[i].act_amount || 0));
                                    }
                                    ln_ds.query(ln_ds.currentPage);
                                }
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            error: function () {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            failure: function () {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    } else {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    }
                });
            }
        };

        window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function () {
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var ln_ds = $(lnds_id);
            var records = ln_ds.getSelected();
            if (records.length == 0) {
                Leaf.showMessage('${l:PROMPT}', '请先选择要抵扣预付款的行明细!');
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                return;
            }

            if (!records[0].get('payment_req_ln_id')) {
                Leaf.showMessage('${l:PROMPT}', '请先保存数据!');
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                return;
            }
            var param = {};
            if ('${/parameter/@function_usage}' == 'QUERY') {
                param['function_code'] = 'CSH501_PRE_DK_READONLY';
                param['function_usage'] = 'QUERY';
            } else {
                param['function_code'] = 'CSH501_PRE_DK';
                param['function_usage'] = 'UPDATE';
            }
            param['payment_req_id'] = records[0].get('payment_req_id');
            param['winid'] = 'csh501_csh_payment_req_link_winid';
            param['url_title'] = '预付款抵扣';
            param['screen_width'] = '800';
            param['screen_height'] = '500';
            hls_doc_get_layout_code('csh501d_get_layout_code_link_id', param, 'csh_payment_prepayment_dk', lnds_id, '${/parameter/@layout_code}');
        };

        //业务核准函
        window['${/parameter/@layout_code}_user_button8_layout_dynamic_click'] = function () {
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var hd_ds = $(hdds_id).getAt(0);
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var ln_ds = $(lnds_id);
            var records = ln_ds.getAll();
            var record = records[0];
            var param = {};
            if ('${/parameter/@hzhan_flag}' == 'Y') {
                var function_usage = 'MODIFY';
                var maintain_type = 'MODIFY';
            } else if ('${/parameter/@hzhan_flag}' == 'O') {
                function_usage = 'QUERY';
                maintain_type = 'READONLY';
            }
            param['contract_id'] = record.get('contract_id');
            param['project_id'] = hd_ds.get('project_id');
            param['function_code'] = 'PRJ_NOTICE_QUERY';
            param['function_usage'] = function_usage;
            param['maintain_type'] = maintain_type;
            param['winId'] = 'prj_project_approval_link_winid';
            param['url_title'] = '核准函';
            hls_doc_get_layout_code('csh501d_get_layout_code_link_id', param, 'prj_project_approval_link', hdds_id, '${/parameter/@layout_code}');
        };

        // var first_repayment_flag = 'N';
        //支付按钮
        window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function () {
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd'),
624
                lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
Spencer Chang's avatar
Spencer Chang committed
625
            var hd_ds = $(hdds_id),
626
                ln_ds = $(lnds_id);
Spencer Chang's avatar
Spencer Chang committed
627
            var hd_record = hd_ds.getCurrentRecord(),
628
                line_records = ln_ds.getSelected();
Spencer Chang's avatar
Spencer Chang committed
629 630
            var payment_req_id = hd_record.get('payment_req_id');
            if (line_records.length == 0) {
631
                Leaf.showMessage('${l:PROMPT}', '请选择一条单据进行确认!');
Spencer Chang's avatar
Spencer Chang committed
632 633 634
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                return;
            }
stone's avatar
stone committed
635 636 637 638 639 640
            if(line_records.length>1){
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                Leaf.showMessage('${l:PROMPT}', '一次只能选择一条数据进行操作!');
                return;

            }
Spencer Chang's avatar
Spencer Chang committed
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
            var current_bp_id;
            var bp_bank_account_code;
            var bp_bank_account_num;
            var bp_bank_account_code_n;
            var bp_bank_account_id;
            var contract_id;
            for (var i = 0; i < line_records.length; i++) {
                var line_record = line_records[i];
                if (!current_bp_id && line_record.get('bp_id')) {
                    current_bp_id = line_record.get('bp_id');
                }
                // if (line_record.get('cf_item') == '5') {
                // first_repayment_flag = 'Y';
                // }
                /* if (current_bp_id && line_record.get('bp_id') && current_bp_id != line_record.get('bp_id')) {
                 Leaf.showMessage('${l:PROMPT}', '付款对象必须相同!');
                 window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                 return;
                 } */

661

stone's avatar
stone committed
662
                //支付金额为应付代理店
663 664
                var this_pay_amount=plus(line_record.get('residual_agent_amount'),line_record.get('residual_vender_amount'));
                if (this_pay_amount <=0) {
Spencer Chang's avatar
Spencer Chang committed
665 666 667 668 669 670 671 672 673 674 675 676 677 678
                    Leaf.showMessage('${l:PROMPT}', '本次支付金额为空!');
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return;
                }

                if (line_record.get('payment_status') == 'FULL') {
                    Leaf.showMessage('${l:PROMPT}', '存在已全部付款的付款行,请核查付款明细!');
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return;
                }
            }

            bp_bank_account_code = line_record.get('bp_bank_account_code');
            bp_bank_account_num = line_record.get('bp_bank_account_num');
679
            var vender_bank_account_num=line_record.get('vender_bank_account_number');
Spencer Chang's avatar
Spencer Chang committed
680 681 682 683
            bp_bank_account_name = line_record.get('bp_bank_account_name');
            bp_bank_account_code_n = line_record.get('bp_bank_account_code_n');
            bp_bank_account_id = line_record.get('bp_bank_account_id');
            contract_id = line_record.get('contract_id');
684 685 686
            line_record.set('loan_date',hd_record.get('loan_date'));
            line_record.set('hdds_id',hdds_id);
            line_record.set('lnds_id',lnds_id);
687
            line_record.set('vender_bank_account_num',vender_bank_account_num);
688
            line_record.set('winid','csh_payment_req_pay_win');
Spencer Chang's avatar
Spencer Chang committed
689 690 691
            var win = new Leaf.Window({
                id: 'csh_payment_req_pay_win',
                url: $('csh_payment_req_pay_win_link').getUrl(),
692
                params:line_record.data,
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
                /*  {
                  payment_req_id: payment_req_id,
                  winid: 'csh_payment_req_pay_win',
                  hdds_id: hdds_id,
                  lnds_id: lnds_id,
                  bp_bank_account_code: bp_bank_account_code,
                  bp_bank_account_num: bp_bank_account_num,
                  bp_bank_account_name: bp_bank_account_name,
                  bp_bank_account_code_n: bp_bank_account_code_n,
                  bp_bank_account_id: bp_bank_account_id,
                  contract_id: contract_id,
                  loan_date: hd_record.get('loan_date')
                  //first_contract_day: hd_record.get('first_contract_day')
                  // ,first_repayment_flag: first_repayment_flag
              },*/
Spencer Chang's avatar
Spencer Chang committed
708 709 710 711 712 713 714 715 716 717 718 719 720 721
                title: '${l:CSH502.CSH_PAYMENT_REQ_PAY}',
                fullScreen: true
            });
            win.on('close', function () {
                var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
                $(hdds_id).query();
            });
        };

        //保存前调用
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var check_flag = false;
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
722 723 724 725 726 727 728
            var ds_line_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');

            var total_amount_agent=0;
            var total_amount_vender=0;
            var total_apply_amount=0;
            //检验输入的数据是否符合要求
            var check_due_amount_flag=true;
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
            var line_datas=$(ds_line_id).data;
            for(var i=0;i<line_datas.length;i++){
                var line_data=line_datas[i];
                //应付我司金额
                var amount_agent=line_data.get('amount_agent');
                var amount_vender= line_data.get('amount_vender');
                var due_amount= line_data.get('due_amount');
                //首付款抵充金额
                var other_payment2=line_data.get('other_payment2');
                if(amount_agent<0||amount_vender<0){
                    $L.showErrorMessage("提示",'应付我司金额和首付款抵充金额不能为负数!');
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }

                if(plus(plus(amount_agent,amount_vender),other_payment2)!=due_amount){
                    $L.showErrorMessage("提示",'应付我司金额,委托付款金额和首付款抵充金额之后应等于应付金额!');
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }
                //本次申请金额等于委托加我司
                var this_apply_amount=plus(amount_agent,amount_vender);
                total_apply_amount=plus(total_apply_amount,this_apply_amount);
                line_data.set('amount',this_apply_amount);
                total_amount_agent=plus(total_amount_agent,amount_agent);
                total_amount_vender=plus(total_amount_vender,amount_vender);

            }
            //取消提示
            /* if(!check_due_amount_flag){
                 $L.showInfoMessage("提示",'应付金额应等于应付我司金额,委托付款金额和首付款抵充金额之和!');
             }*/
            //给头表赋值
762 763 764 765 766 767 768 769 770 771
            $(ds_id).getAt(0).set('amount_agent_total',total_amount_agent);
            $(ds_id).getAt(0).set('amount_vender_total',total_amount_vender);
            $(ds_id).getAt(0).set('amount',total_apply_amount);
            $(ds_id).getAt(0).set('company_id','${/session/@company_id}');
            $(ds_id).getAt(0).set('transaction_category','BUSINESS');
            $(ds_id).getAt(0).set('submitted_flag','N');
            $(ds_id).getAt(0).set('printed_flag','N');
            $(ds_id).getAt(0).set('document_category','PAYMENT_REQ');


772 773 774 775
            //确认保存
            var hd_record = $(ds_id).getCurrentRecord();
            var payment_req_id = hd_record.get('payment_req_id');
            //console.log( $(ds_id));
stone's avatar
stone committed
776
            // console.log( $(ds_line_id));
Spencer Chang's avatar
Spencer Chang committed
777

778 779 780 781 782 783 784 785 786 787
            if (payment_req_id) {
                Leaf.request({
                    url: $('${/parameter/@layout_code}csh511_csh_payment_req_hd_query').getUrl(),
                    para: {
                        payment_req_id: payment_req_id,
                    },
                    success: function (res) {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        if (res.result.record.submitted_flag == 'Y') {
                            Leaf.showMessage('${l:PROMPT}', '该单据已经提交');
788
                            check_flag = false;
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808
                        } else {
                            check_flag = true;
                        }

                    },
                    error: function () {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        check_flag = false;
                    },
                    failure: function () {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        check_flag = false;
                    },
                    sync: true,
                    scope: this
                });
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            } else {
                check_flag = true;
            }
Spencer Chang's avatar
Spencer Chang committed
809 810


811 812
            return check_flag||false;

Spencer Chang's avatar
Spencer Chang committed
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
        };

        //调用合同后督
        window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function () {
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');

            var ln_ds = $(lnds_id);
            var records = ln_ds.getAll();
            var record = records[0];
            if (records.length == 0) {
                Leaf.showMessage('${l:PROMPT}', '没有支付表。');
                return;
            }
            var contract_id = record.get('contract_id');
            var cdd_list_id = record.get('cdd_list_id');
            if ('${/parameter/@layout_code}' == 'CSH501D') {
                var url = $('con_contract_houdu_readOnly_link').getUrl();
            } else {
                var url = $('con_contract_houdu_link').getUrl();
            }
            // var url = $('con_contract_houdu_link').getUrl();
            var win = new Leaf.Window({
                id: 'contract_houdu_query_window',
                url: url,
                winId: 'contract_houdu_query_window_id',
                params: {
                    contract_id: contract_id,
                    cdd_list_id: cdd_list_id,
                    winId: 'contract_houdu_query_window_id'
                },
                title: '后督事项',
                fullScreen: true
            });
            win.on('close', function () {
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            });


        };
        window['${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function (ds, record, config_records, bp_seq) {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
stone's avatar
stone committed
855 856 857 858 859 860 861 862 863 864 865
            // if (!record.get('contract_number')) {
            //     record.set('contract_number', '${/parameter/@contract_number}');
            // }
            //
            // if (!record.get('first_contract_day')) {
            //     record.set('first_contract_day', '${/parameter/@first_contract_day}');
            // }
            // //record.set('contract_number', '${/parameter/@contract_number}');
            // record.set('contract_name', '${/parameter/@contract_name}');
            // record.set('division', '${/parameter/@division}');
            // record.set('division_n', '${/parameter/@division_n}');
Spencer Chang's avatar
Spencer Chang committed
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


            if (hdds_id == ds.id && record.isNew) {
                if ('${/parameter/@business_type}' == 'PAYMENT') {
                    record.set('business_type', '${/model/default_payment_document_type/record/@business_type}');
                    record.set('document_type', '${/model/default_payment_document_type/record/@document_type}');
                    record.set('document_type_n', '${/model/default_payment_document_type/record/@description}');

                    record.set('con_business_type', '${/parameter/@con_business_type}');
                    record.set('con_business_type_n', '${/parameter/@con_business_type_n}');
                    record.set('taxpayer_type', '${/parameter/@taxpayer_type}');
                    record.set('taxpayer_type_n', '${/parameter/@taxpayer_type_n}');

                    record.set('contract_id', '${/parameter/@contract_id}');

                } else if ('${/parameter/@business_type}' == 'PREPAYMENT') {
                    record.set('business_type', '${/model/default_prepayment_document_type/record/@business_type}');
                    record.set('document_type', '${/model/default_prepayment_document_type/record/@document_type}');
                    record.set('document_type_n', '${/model/default_prepayment_document_type/record/@description}');
                    record.set('contract_id', '${/parameter/@contract_id}');
                }
            }
            if (hdds_id == ds.id) {
                if ('${/parameter/@function_usage}' == 'READONLY') {

                } else {
                    var compensatory_flag = record.get('compensatory_flag');
                    if (compensatory_flag == 'Y') {
                        record.getField('las_compensatory_amount').setReadOnly(false);
                    } else {
                        record.getField('las_compensatory_amount').setReadOnly(true);
                    }
                }
            }
        };
        // // 加载时调用(grid,table,gridBox)
        // window['${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function(ds, record) {
        // var ds_call_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
        // jQuery("div").hover(function() {
        // if (ds_call_id) {
        // var records = $(ds_call_id).getAll();
        // for (var i = 0;i < records.length;i++) {
        // var id = "#${/parameter/@layout_code}_ACY_prj_cdd_item_doc_ref_layout_grid_id__" + records[i].id;
        // if (1) {
        // jQuery(id).removeClass("grid-ckb item-ckb-u").addClass('grid-ckb item-ckb-readonly-u');
        // }
        // jQuery("div").unbind(); //移除所有
        // }
        // }
        // });
        // };

        function csh504_ddct_link(record_id, name) {
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][record_id + '---' + name];
            if (record.dirty) {
                Leaf.showMessage('${l:PROMPT}', '请先保存数据!');
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                return;
            }
            var payment_req_ln_id = record.get('payment_req_ln_id'),
926 927 928
                apply_amount = record.get('amount'),
                contract_number = record.get('contract_number'),
                ref_doc_id = record.get('ref_doc_id');
Spencer Chang's avatar
Spencer Chang committed
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
            var win = new Leaf.Window({
                id: 'csh_req_ddct_link_winid',
                url: $('csh_req_ddct_link').getUrl(),
                params: {
                    apply_amount: apply_amount,
                    payment_req_id: '${/parameter/@payment_req_id}',
                    payment_req_ln_id: payment_req_ln_id,
                    contract_number: contract_number,
                    contract_id: ref_doc_id,
                    winid: 'csh_req_ddct_link_winid',
                    function_usage: '${/parameter/@function_usage}'
                },
                title: '坐扣',
                width: 1000,
                height: 500
            });
            win.on('close', function () {
                var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
                // var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
                var hd_record = $(hdds_id).getCurrentRecord();
                var payment_req_id = hd_record.get('payment_req_id');
                if (payment_req_id) {
                    $(hdds_id).setQueryParameter('payment_req_id', payment_req_id);
                } else {
                    Leaf.showMessage('${l:PROMPT}', '请先保存数据');
                    return;
                }
                $(hdds_id).query();
                // $(lnds_id).query($(lnds_id).currentPage);
            });
        }

        //保存submitsuccess调用
        window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function (ds, record, res, bp_seq) {
963
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
964 965 966 967
            dirty_flag = 'N';
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var hd_record = $(hdds_id).getCurrentRecord();
            var payment_req_id = hd_record.get('payment_req_id');
968 969 970
            //获得相应的行信息
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');

stone's avatar
stone committed
971
            $(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_query_after_save/query');
972

Spencer Chang's avatar
Spencer Chang committed
973 974 975 976 977

            var contract_id = '${/parameter/@contract_id}';
            if (payment_req_id) {
                $(hdds_id).setQueryParameter('payment_req_id', payment_req_id);
                $(hdds_id).query();
stone's avatar
stone committed
978
                $(lnds_id).setQueryParameter('payment_req_id', payment_req_id);
979 980
                $(lnds_id).query();

Spencer Chang's avatar
Spencer Chang committed
981 982
            } else {
                Leaf.showMessage('${l:PROMPT}', '请先保存数据');
983
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
984 985 986
            }

            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
987

Spencer Chang's avatar
Spencer Chang committed
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
        };

        function csh504_prepayment_dk_link(record_id, name) {
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][record_id + '---' + name];
            var payment_req_ln_id = record.get('payment_req_ln_id');
            var win = new Leaf.Window({
                id: 'csh_payment_req_prepayment_dk_detail_link_winid',
                url: $('csh_payment_req_prepayment_dk_detail_link_id').getUrl(),
                params: {
                    bp_id: record.get('bp_id'),
                    payment_req_ln_id: payment_req_ln_id,
                    payment_req_id: record.get('payment_req_id'),
                    winid: 'csh_payment_req_prepayment_dk_detail_link_winid',
                    function_usage: '${/parameter/@function_usage}'
                },
                title: '预付款抵扣明细',
                width: 650,
                height: 500
            });
            win.on('close', function () {
                var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
                $(lnds_id).query($(lnds_id).currentPage);
            });
        }

        //add by zhuxianfei

        function view_pdf(attachment_id) {
            Leaf.request({
                url: '${/request/@context_path}/autocrud/fnd.fnd_atm_attachment/query',
                para: {
                    attachment_id: attachment_id
                },
                success: function (res) {
                    var path = res.result.record.file_path;
                    path = path.substr(path.indexOf('hls_attachment'));
                    var tomcat_source = '${/parameter/@tomcat_source}';
                    var source_path = 'http://' + window.location.host + '/' + tomcat_source + '/' + path+'?type=pdf';
                    var oWin = window.open(source_path);
                },
                scope: this
            });
        }

        function upload_file(id, name, query_only) {

            var download = '${/parameter/@download}';
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            if (record.get('check_id')) {
                var url;
                if (query_only == 'Y' || download == 'Y') {
                    url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                } else {
                    url = $('${/parameter/@layout_code}${/parameter/@pre_layout}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}', '请先保存!');

            }
        }


        // //合同编号超链接
        // function open_con_contract_readonly_win(record_id, ds_id) {
        // //创建明细页面根据条件表TBL_LA11字段 function_code、bp_class匹配布局代码layout_code BCML_CONTRACT_NP_MAINTAIN、BCML_CONTRACT_ORG_MAINTAIN
        // var record = $(ds_id).findById(record_id);
        // var param = record.data;
        // param.function_code = 'CON301';
        // param.function_usage = 'QUERY';
        // param.url_title = '合同查询';
        // param.winid = 'con_rd_wfl_link_winid';
        // //param.layout_debugger_flag = 'Y';

        // hls_doc_get_layout_code('csh501d_get_layout_code_link_id', param, 'con_rd_wfl_link', ds_id, '${/parameter/@layout_code}');
        // }

        //合同编号超链接

        function open_con_contract_readonly_win(record_id, ds_id) {
1078
            //
Spencer Chang's avatar
Spencer Chang committed
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
            //创建明细页面根据条件表TBL_LA11字段 function_code、bp_class匹配布局代码layout_code BCML_CONTRACT_NP_MAINTAIN、BCML_CONTRACT_ORG_MAINTAIN
            var record = $(ds_id).findById(record_id);
            var division = record.get('division');
            if (!division) {
                division = '${/parameter/@division}';
            }
            // var param = {};
            var param = record.data;
            param.function_code = 'CON301_MODIFY';
            param.division = division;
            param.function_usage = 'QUERY';
            param.url_title = '合同查询';
            param.winid = 'con_rd_wfl_link_winid';
            //param.layout_debugger_flag = 'Y';
            //hls_doc_get_layout_code('csh501d_get_layout_code_link_id', param, 'con_rd_wfl_link', null, '${/parameter/@layout_code}');
            hls_doc_get_layout_code('csh501d_get_layout_code_link_id', param, 'con_rd_wfl_link', '', '${/parameter/@layout_code}');
        }

        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record, bp_seq) {
            var link_function = '';
            window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
            if (name == 'ddct_link') {
                link_function = 'csh504_ddct_link';
                if (record.get('payment_req_ln_id')) {
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\');">' + config_record.get('prompt') + '</a>';
                } else {
                    return '';
                }
            } else if (name == 'act_amount') {
                var act_amount = record.get('act_amount');
                return Leaf.formatMoney(act_amount);
            } else if (name == 'prepayment_dk') {
                link_function = 'csh504_prepayment_dk_link';
                if (record.get('payment_req_ln_id')) {
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\');">' + config_record.get('prompt') + '</a>';
                } else {
                    return '';
                }
            } else if (name == 'contract_number' && value) {
                return '<a href="javascript:open_con_contract_readonly_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
            }


            if (name == 'attachment') {
                link_function = 'upload_file';
                if (record.get('attach_count') == 0 || !record.get('attach_count')) {
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                } else {
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '(' + record.get('attach_count') + ')' + '</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_name = temp[0].toUpperCase();
                            var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
                            if (file_name.indexOf('.PDF') >= 0) {
                                url = url + '<a href=javascript:view_pdf(\'' + temp[1] + '\')>' + temp[0] + '</a>' + ',';
                            } else if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
                                url = url + '<a href=' + link + temp[1] + ' ref="img">' + temp[0] + '</a>' + ',';
                            } else {
                                url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                            }
                        }
                    }
                    return url;

                }
            } else if (name == 'description') {
                if (record.get('important_flag') == 'Y') {
                    return '<font color="RED">' + value + '</font>';
                }
                return value;
            }
        };

        // function rendererDay(cell, date, text, currentMonth) {
        // if (date.getDate() != '5' && date.getDate() != '10' && date.getDate() != '15' && date.getDate() != '20' && date.getDate() != '25' && date.getDate() != '30') {
        // cell.disabled = 'true';
        // }
        // return text;
        // }
        // //加载时调用(attach)
        // window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_attach_load'] = function(ds, record, config_records, bp_seq) {
        // //add by zhuxianfei 放款阶段时不可修改租赁申请的附件
        // var attach_file_type = record.get('attach_file_type');
        // if (attach_file_type == 'PROJECT') {
        // record.getField('note').setReadOnly(true);
        // }
        // };

        window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function (ds, qpara, bp_seq) {
1175 1176 1177 1178
            /* debugger
              var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
              var hd_record = $(hdds_id).getAt(0);
              qpara['payment_req_id'] = hd_record.get('payment_req_id');*/
stone's avatar
stone committed
1179
            /*if (hd_record.get('bp_id_vender_n')) {
Spencer Chang's avatar
Spencer Chang committed
1180
                qpara['bp_id_vender_n'] = hd_record.get('bp_id_vender_n');
stone's avatar
stone committed
1181
            }*/
Spencer Chang's avatar
Spencer Chang committed
1182 1183 1184 1185 1186 1187

        };

        function on_csh_payment_req_temp_ln_ds_query(ds, qpara) {
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            qpara['payment_bp_id'] = '${/parameter/@payment_bp_id}';
1188

Spencer Chang's avatar
Spencer Chang committed
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
        }


        function sumFunction(datas, name) {
            var sum = 0;
            for (var i = 0; i < datas.length; i++) {
                var r = datas[i];
                var d = r.get(name);
                var n = parseFloat(d);
                if (!isNaN(n)) {
                    sum = plus(sum, n);
                }
            }
            var total = (typeof(sum) == 'undefined' ? '' : parseFloat(sum));
            return '<font>' + Leaf.formatMoney(total) + '</font>';
        }

        window['${/parameter/@layout_code}_on_layout_dynamic_grid_select'] = function (ds, record, bp_seq) {
            if (record.get('payment_status') != 'FULL' && Ext.isEmpty(record.get('pay_amount'))) {
                record.set('pay_amount', record.get('act_amount'));
            }
        };

        window['${/parameter/@layout_code}_on_layout_dynamic_grid_unselect'] = function (ds, record, bp_seq) {
            record.set('pay_amount', '');
        };
1215

Spencer Chang's avatar
Spencer Chang committed
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
        // window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function() {
        // Leaf.showConfirm('${l:HLS.PROMPT}', '是否确定提起银行付款', function() {
        // var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
        // var hd_record = $(hdds_id).getCurrentRecord();
        // window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
        // Leaf.request({
        // url: $('csh_payment_bank_link').getUrl(),
        // para: {
        // payment_req_id: hd_record.get('payment_req_id')
        // },
        // success: function() {
        // window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        // $('${/parameter/@winid}').close();
        // },
        // error: function() {
        // window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        // },
        // failure: function() {
        // window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        // },
        // scope: this
        // });
        // });

        // };

1242 1243


Spencer Chang's avatar
Spencer Chang committed
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
        window['${/parameter/@layout_code}_upload_layout_dynamic_click'] = function () {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var hd_record = $(hdds_id).getCurrentRecord();
            var payment_req_id = hd_record.get('payment_req_id');
            if (payment_req_id) {

                var url = $('attachment_uploadFile_link').getUrl() + '?table_name=CSH_PAYMENT_REQ_HD&header_id=' + payment_req_id;
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'payment_req_uploadFile_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function () {

                    $(hdds_id).setQueryParameter('payment_req_id', payment_req_id);
                });
            } else {
                Leaf.showMessage('${l:PROMPT}', '请先保存数据');
                return;
            }

        };
        ]]></script>
1269
        <a:link id="${/parameter/@layout_code}csh511_csh_payment_req_hd_query" model="csh.CSH511.csh_payment_req_hd" modelaction="query" />
Spencer Chang's avatar
Spencer Chang committed
1270 1271 1272
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="csh_payment_req_temp_ln_ds" autoQuery="true" fetchAll="true"
1273 1274 1275 1276 1277 1278
                                     model="csh.CSH501.csh_payment_req_ln_query">
            <a:events>
                <a:event name="load" handler="on_csh_payment_req_temp_ln_ds_load"/>
                <a:event name="query" handler="on_csh_payment_req_temp_ln_ds_query"/>
            </a:events>
        </a:dataSet>
Spencer Chang's avatar
Spencer Chang committed
1279 1280 1281
        </a:dataSets>
    </a:view>
</a:screen>