csh_payment_req.lview 33.4 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
<?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 fetchAll="true" model="csh.CSH501.get_loan_flag" rootPath="loan_flag_path"/>
    </a:init-procedure>
    <a:view>
26 27
        <a:link id="csh_payment_req_word_print_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_word_print.lsc"/>
niminmin's avatar
niminmin committed
28 29
        <a:link id="csh501d_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
30
        <a:link id="update_csh_payment_hd_info_link" model="csh.CSH501.csh_payment_req_get_num" modelaction="execute"/>
Spencer Chang's avatar
Spencer Chang committed
31 32 33
        <a:link id="con_rd_wfl_link" url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
        <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>
34
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
Spencer Chang's avatar
Spencer Chang committed
35
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
niminmin's avatar
niminmin committed
36 37 38
        <!-- 生成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
39 40
        <script type="text/javascript"><![CDATA[
        jQuery.noConflict();
niminmin's avatar
niminmin committed
41
        var con_business_type='${/parameter/@con_business_type}'||'${/model/loan_flag_path/record/@business_type}'||'LEASE';
42
        //工作流审批界面校验发票状态
43
        if ('${/parameter/@source_type}' == 'WFL_Y') {
44 45 46
            zjwfl5110_ApproveChecker_add('zjwfl5110_submit', function (type) {
                var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
                // if ('${/parameter/@re_param}' == 'node1') {
niminmin's avatar
niminmin committed
47
                if (type == 'agree'&&con_business_type == 'LEASE') {
niminmin's avatar
niminmin committed
48 49
                    var records = $(lnds_id).getAll();
                    for (var i = 0; i < records.length; i++) {
50 51
                        if (records[i].get('billing_status_n') != '全部开票' || records[i].get('invoice_status_n') != '已确认') {
                            $L.showErrorMessage("提示", '请选择开票状态为全部开票,发票状态为已确认的现金流!');
niminmin's avatar
niminmin committed
52 53 54 55 56 57
                            return false;
                        }
                    }
                    return true;
                } else return true;
                // }
58 59
            });
        }
niminmin's avatar
niminmin committed
60 61 62 63 64 65 66
        function get_current_amount(amt) {
            if (!Ext.isEmpty(amt)) {
                return parseFloat(amt).toFixed(2);
            } else {
                return 0;
            }
        }
stone's avatar
stone committed
67
        //如果头id 不为空,就使用自在定义的ds进行查询
niminmin's avatar
niminmin committed
68
        Leaf.onReady(function () {
niminmin's avatar
niminmin committed
69 70 71
            if ('${/parameter/@source_type}' == 'WFL') {
                document.getElementById('${/parameter/@layout_code}_save').style.display = "none";
            }
stone's avatar
stone committed
72
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
stone's avatar
stone committed
73
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
niminmin's avatar
niminmin committed
74 75
            var payment_req_id = '${/parameter/@payment_req_id}';
            if (payment_req_id) {
stone's avatar
stone committed
76
                $(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_query_after_save/query');
niminmin's avatar
niminmin committed
77
                $(lnds_id).setQueryParameter("payment_req_id", payment_req_id);
stone's avatar
stone committed
78
                $(lnds_id).query();
niminmin's avatar
niminmin committed
79
                $(hdds_id).setQueryParameter("payment_req_id", payment_req_id);
stone's avatar
stone committed
80 81
                $(hdds_id).query();
            }
niminmin's avatar
niminmin committed
82 83 84 85 86 87 88 89
            if (con_business_type == 'LEASE') {
                $('CSH501D_PAYMENT_REQ_DETAIL_G_csh_payment_req_ln_layout_grid_id').hideColumn('amount_tenant');
                $('CSH501D_PAYMENT_REQ_DETAIL_G_csh_payment_req_ln_layout_grid_id').hideColumn('tenant_bank_account_number');
                $('CSH501D_PAYMENT_REQ_DETAIL_G_csh_payment_req_ln_layout_grid_id').hideColumn('tenant_bank_account_number_n');
                $('CSH501D_PAYMENT_REQ_DETAIL_G_csh_payment_req_ln_layout_grid_id').hideColumn('tenant_bank_account_name');
//CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_AMOUNT_TENANT_TOTAL_prompt
                document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_AMOUNT_TENANT_TOTAL_prompt').style.display = 'none';
                document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_AMOUNT_TENANT_TOTAL').style.display = 'none';
Spencer Chang's avatar
Spencer Chang committed
90

niminmin's avatar
niminmin committed
91 92 93 94
            }
            // var elements=document.querySelector('td[title="SBO反馈信息"]');
            // elements.remove();
        });
Spencer Chang's avatar
Spencer Chang committed
95 96 97 98 99
        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
100
            //如果更新数据,将付款日期先置为空
niminmin's avatar
niminmin committed
101
            dirty_flag = 'Y';
Spencer Chang's avatar
Spencer Chang committed
102 103 104 105 106 107 108 109 110 111 112
            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();
            }
niminmin's avatar
niminmin committed
113 114 115 116 117 118 119 120
            if (lnds_id && lnds_id == ds.id) {
                if (name == 'amount_vender' || name == 'amount_agent') {
                    var due_amount =get_current_amount(record.get('due_amount'));
                    if (value < 0) {
                        Leaf.showMessage('${l:HLS.PROMPT}', '所填金额应大于等于0!');
                        setTimeout(function () {
                            record.set(name, null);
                        }, 5);
Spencer Chang's avatar
Spencer Chang committed
121 122
                        return;
                    }
niminmin's avatar
niminmin committed
123 124 125 126 127
                    if (value > due_amount) {
                        $L.showErrorMessage("提示", '所填金额不能大于应付金额!');
                        setTimeout(function () {
                            record.set(name, null);
                        }, 5);
Spencer Chang's avatar
Spencer Chang committed
128 129

                    }
niminmin's avatar
niminmin committed
130 131 132 133
                } else if (name == 'repur_con_ddct_amt') {
                    var repur_con_amt = get_current_amount(record.get('repur_con_amt'));
                    var other_payment2 = get_current_amount(record.get('other_payment2'));
                    var amount_vender = get_current_amount(record.get('amount_vender'));
niminmin's avatar
niminmin committed
134 135 136 137 138 139 140 141
                    if (value < 0 || value == NaN || value == undefined) {
                        Leaf.showMessage('${l:HLS.PROMPT}', '回购租金抵冲金额应大于等于0!');
                        setTimeout(function () {
                            record.set('repur_con_ddct_amt', 0);
                        }, 5);
                        return;
                    }
                    if (value > repur_con_amt) {
niminmin's avatar
niminmin committed
142
                        $L.showErrorMessage("提示", '回购租金抵冲金额不能大于回购租金剩余金额!');
niminmin's avatar
niminmin committed
143 144 145
                        setTimeout(function () {
                            record.set('repur_con_ddct_amt', 0);
                        }, 5);
Spencer Chang's avatar
Spencer Chang committed
146 147 148 149 150 151 152
                    }
                }
            }
        };

        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');
niminmin's avatar
niminmin committed
153
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
Spencer Chang's avatar
Spencer Chang committed
154 155 156 157 158 159 160 161 162 163
            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);
                }
            }
niminmin's avatar
niminmin committed
164 165 166 167 168 169 170 171 172 173 174
            if (con_business_type == 'LEASE') {
                if (ds.id == ds_id) {
                    var records = $(ds_id).getAll();
                    for (i = 0; i < records.length; i++) {
                        records[i].getField('amount_tenant').setRequired(false);
                        records[i].getField('tenant_bank_account_number').setRequired(false);
                        records[i].getField('tenant_bank_account_number_n').setRequired(false);
                        records[i].getField('tenant_bank_account_name').setRequired(false);
                    }
                }
            }
gzj34291's avatar
gzj34291 committed
175
            var lnds_records = $(ds_id).getAll();
176
			if (con_business_type == 'LEASEBACK'){
177 178 179 180 181 182 183 184 185 186 187
                debugger
                if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'){
                    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
                    var records = $(ds_id).getAll();
                    for (i = 0; i < records.length; i++) {
                        records[i].getField('tenant_bank_account_number').setRequired(false);
                        records[i].getField('tenant_bank_account_number_n').setRequired(false);
                        records[i].getField('tenant_bank_account_name').setRequired(false);
                    }
                }
            }
188 189 190 191 192 193 194 195 196
            var lnds_records = $(ds_id).getAll();
            if (ds.id == ds_id) {
                for (var i = 0; i < lnds_records.length; i++) {
                    if (lnds_records[i].get('division') == '70' || lnds_records[i].get('division') == '92') {
                        lnds_records[i].getField('tenant_bank_account_number').setRequired(false);
                        lnds_records[i].getField('tenant_bank_account_number_n').setRequired(false);
                    }
                }
            }
Spencer Chang's avatar
Spencer Chang committed
197 198 199 200 201 202 203 204 205 206 207 208
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        };

        var first_load_flag = 'N';

        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')) {
209
                        //添加时间为预定的每月20号
niminmin's avatar
niminmin committed
210 211
                        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
212 213
                    }
                    $(lnds_id).create(Ext.apply({}, record.data));
niminmin's avatar
niminmin committed
214 215 216 217 218 219 220
                    if (con_business_type == 'LEASE') {
                        var ln_record = $(lnds_id).getCurrentRecord();
                        ln_record.getField('amount_tenant').setRequired(false);
                        ln_record.getField('tenant_bank_account_number').setRequired(false);
                        ln_record.getField('tenant_bank_account_number_n').setRequired(false);
                        ln_record.getField('tenant_bank_account_name').setRequired(false);
                    }
221 222 223 224 225
                    var ln_record = $(lnds_id).getCurrentRecord();
                    if (ln_record.get('division') == '70'){
                        ln_record.getField('tenant_bank_account_number').setRequired(false);
                        ln_record.getField('tenant_bank_account_number_n').setRequired(false);
                    }
Spencer Chang's avatar
Spencer Chang committed
226 227
                }
            }
gzj34291's avatar
gzj34291 committed
228
            if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'||'${/parameter/@division}' ==92||'${/parameter/@division}' =='北京卡家' ){
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
                debugger
                if (con_business_type == 'LEASEBACK'){
                    var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
                    var records = $(ds_id).getAll();
                    for (i = 0; i < records.length; i++) {
                        records[i].getField('tenant_bank_account_number').setRequired(false);
                        records[i].getField('tenant_bank_account_number_n').setRequired(false);
                        records[i].getField('tenant_bank_account_name').setRequired(false);
                    }
                }
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
                var records = $(ds_id).getAll();
                for (i = 0; i < records.length; i++) {
                    if (records[i].getField('amount_agent')) {
                        records[i].set('amount_agent', 0);
                    };
                    if (records[i].getField('amount_vender')) {
                        records[i].set('amount_vender',records[i].get('finance_amount'));
                    };
                }
            }
Spencer Chang's avatar
Spencer Chang committed
250 251 252 253
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        }

        function csh_payment_req_submit_finally() {
niminmin's avatar
niminmin committed
254
            Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function okFun() {
Spencer Chang's avatar
Spencer Chang committed
255 256 257 258 259
                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');
260
                var line_record = $(line_ds_id).getAt(0);
niminmin's avatar
niminmin committed
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
                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
                });
stone's avatar
stone committed
286
                // }
Spencer Chang's avatar
Spencer Chang committed
287 288 289 290 291
            }, function cancelFun() {
                Leaf.SideBar.enable = true;
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            });
        }
niminmin's avatar
niminmin committed
292

Spencer Chang's avatar
Spencer Chang committed
293 294
        //打印
        function csh501_print() {
295

Spencer Chang's avatar
Spencer Chang committed
296 297
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var hd_record = $(hdds_id).getCurrentRecord();
298

stone's avatar
stone committed
299
            var url_l = $('csh_payment_req_word_print_link_id').getUrl() + '?document_id=' + hd_record.get('payment_req_id') + '&document_table=CSH_PAYMENT_REQ&file_path=${/parameter/@file_path}&batch_flag=Y&source_type=COMMON';
300
            window.open(href = url_l, target = "_self");
Spencer Chang's avatar
Spencer Chang committed
301 302 303 304 305 306 307 308 309 310 311 312
        }

        window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function () {
            Leaf.SideBar.enable = false;
            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),
313
                ln_ds = $(lnds_id);
Spencer Chang's avatar
Spencer Chang committed
314
            var hd_record = hd_ds.getCurrentRecord(),
315
                ln_records = ln_ds.getAll();
Spencer Chang's avatar
Spencer Chang committed
316 317
            if (ln_records.length > 0 && !ln_records[0].get('payment_req_ln_id')) {
                Leaf.showMessage('${HLS.PROMPT}', '请先保存!');
niminmin's avatar
niminmin committed
318
            } else {
319 320
                csh501_print();
            }
Spencer Chang's avatar
Spencer Chang committed
321 322
        };
        //保存前调用
niminmin's avatar
niminmin committed
323
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function (ds, record) {
Spencer Chang's avatar
Spencer Chang committed
324 325 326
            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');
327
            var ds_line_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
niminmin's avatar
niminmin committed
328 329
            if ($(ds_line_id).data.length <= 0) {
                $L.showErrorMessage("错误", '无付款记录,不可提交审批!');
stone's avatar
stone committed
330
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
niminmin's avatar
niminmin committed
331
                check_flag = false;
stone's avatar
stone committed
332 333
                return;
            }
niminmin's avatar
niminmin committed
334 335 336
            var total_amount_agent = 0;
            var total_amount_vender = 0;
            var total_apply_amount = 0;
niminmin's avatar
niminmin committed
337
            var total_amount_tenant=0;
338
            //检验输入的数据是否符合要求
niminmin's avatar
niminmin committed
339 340 341
            var check_due_amount_flag = true;
            var line_datas = $(ds_line_id).data;
            var head_record = $(ds_id).getAt(0);
stone's avatar
stone committed
342
            //高空作业车个数
niminmin's avatar
niminmin committed
343 344 345
            var gk_contract_num = 0;
            for (var i = 0; i < line_datas.length; i++) {
                var line_data = line_datas[i];
346
                //应付我司金额
niminmin's avatar
niminmin committed
347 348 349 350
                var amount_agent = get_current_amount(line_data.get('amount_agent'));
                //应付厂商金额(
                var amount_vender = get_current_amount(line_data.get('amount_vender'));
                var due_amount = get_current_amount(line_data.get('due_amount'));
niminmin's avatar
niminmin committed
351 352
                var bp_bank_account_id = line_data.get('bp_bank_account_id');
                var vender_bank_account_id = line_data.get('vender_bank_account_id');
353
                //首付款抵充金额
niminmin's avatar
niminmin committed
354 355 356 357 358
                var other_payment2 = get_current_amount(line_data.get('other_payment2'));
                //回购抵充金额
                var repur_con_ddct_amt = get_current_amount(line_data.get('repur_con_ddct_amt'));
                //应付承租人金额
                var amount_tenant = get_current_amount(line_data.get('amount_tenant'));
niminmin's avatar
niminmin committed
359 360
                if (amount_agent < 0 || amount_vender < 0) {
                    $L.showErrorMessage("提示", '应付我司金额和首付款抵冲金额不能为负数!');
361 362 363
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }
stone's avatar
stone committed
364
                //买断机合同 个数
niminmin's avatar
niminmin committed
365 366
                if (amount_vender == 0 || '${/parameter/@division}' == 30) {
                    gk_contract_num = gk_contract_num + 1;
stone's avatar
stone committed
367
                }
368
                //根据金额判断代理店和厂商不能为空
niminmin's avatar
niminmin committed
369
                if (amount_agent > 0 && !bp_bank_account_id) {
370

niminmin's avatar
niminmin committed
371
                    $L.showErrorMessage("提示", '请选择代理店账号信息!');
372 373 374
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }
niminmin's avatar
niminmin committed
375
                if (amount_vender > 0 && !vender_bank_account_id) {
376

niminmin's avatar
niminmin committed
377
                    $L.showErrorMessage("提示", '请选择委托付款金额不为0的厂商账号信息!');
378 379 380
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }
niminmin's avatar
niminmin committed
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
                if (con_business_type == 'LEASE') {
                    if (plus(plus(plus(amount_agent, amount_vender), other_payment2), repur_con_ddct_amt) != due_amount) {
                        $L.showErrorMessage("提示", '应付我司金额,委托付款金额,首付款抵冲金额和回购租金抵冲金额之和应等于应付金额!',null,500,300);
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        return false;
                    }
                } else if (con_business_type == 'LEASEBACK') {
                    var entrusted_amount = get_current_amount(line_data.get('entrusted_amount'));
                    if (plus(plus(amount_agent, amount_vender),repur_con_ddct_amt) != entrusted_amount) {
                        $L.showErrorMessage("提示", '应付代理店金额、应付厂商金额、回购租金抵冲金额合计不等于合同签约时承租人所填写委托付款金额,请重新填写!',null,500,300);
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        return false;
                    }
                    if (plus(plus(plus(plus(amount_agent, amount_vender), other_payment2), repur_con_ddct_amt), amount_tenant) != due_amount) {
                        $L.showErrorMessage("提示", '应付我司金额,委托付款金额,应付承租人金额,首付款抵冲金额和回购租金抵冲金额之和应等于应付金额!',null,500,300);
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        return false;
                    }
399
                }
niminmin's avatar
niminmin committed
400 401 402

                //本次申请金额等于委托加我司加应付承租人金额
                var this_apply_amount = plus(plus(amount_agent, amount_vender),amount_tenant);
niminmin's avatar
niminmin committed
403 404 405 406
                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);
niminmin's avatar
niminmin committed
407
                total_amount_tenant = plus(total_amount_tenant, amount_tenant);
408
            }
niminmin's avatar
niminmin committed
409 410 411 412
            if (gk_contract_num < line_datas.length && gk_contract_num != 0) {
                $L.showErrorMessage("提示", '买断机合同(即厂商的付款金额为0)不可与其他正常合同同时进行付款申请支付');
                return false;
            }
413
            //给头表赋值
niminmin's avatar
niminmin committed
414 415
            $(ds_id).getAt(0).set('amount_agent_total', total_amount_agent);
            $(ds_id).getAt(0).set('amount_vender_total', total_amount_vender);
niminmin's avatar
niminmin committed
416
            $(ds_id).getAt(0).set('amount_tenant_total', total_amount_tenant);
niminmin's avatar
niminmin committed
417 418 419 420 421 422
            $(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');
niminmin's avatar
niminmin committed
423
            //$(ds_id).getAt(0).set('currency_code', 'CNY');
424 425 426 427 428 429 430 431 432 433 434
            //确认保存
            var hd_record = $(ds_id).getCurrentRecord();
            var payment_req_id = hd_record.get('payment_req_id');
            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']();
435
                        if (res.result.record.submitted_flag == 'Y' && '${/parameter/@source_type}' != 'WFL_Y') {
436
                            Leaf.showMessage('${l:PROMPT}', '该单据已经提交');
437
                            check_flag = false;
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
                        } 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;
            }
niminmin's avatar
niminmin committed
458
            return check_flag || false;
Spencer Chang's avatar
Spencer Chang committed
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
        };

        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');
            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);
                    }
                }
            }
        };
        //保存submitsuccess调用
        window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function (ds, record, res, bp_seq) {
496
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
497 498 499 500
            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');
501 502 503
            //获得相应的行信息
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');

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

Spencer Chang's avatar
Spencer Chang committed
506 507 508

            var contract_id = '${/parameter/@contract_id}';
            if (payment_req_id) {
509 510 511 512 513
                //更新头信息
                Leaf.Masker.mask(Ext.getBody(), '正在保存中。。。');
                Leaf.request({
                    url: $('update_csh_payment_hd_info_link').getUrl(),
                    para: {
niminmin's avatar
niminmin committed
514
                        payment_req_id: payment_req_id
515 516 517 518
                    },
                    success: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                        $(hdds_id).setQueryParameter('payment_req_id', payment_req_id);
niminmin's avatar
niminmin committed
519 520
                        $(hdds_id).query();
                    },
521 522 523 524 525 526 527 528 529
                    failure: function () {
                        Leaf.Masker.unmask(detail_mask);
                    },
                    error: function () {
                        Leaf.Masker.unmask(detail_mask);
                    },
                    scope: this
                });

stone's avatar
stone committed
530
                $(lnds_id).setQueryParameter('payment_req_id', payment_req_id);
531 532
                $(lnds_id).query();

Spencer Chang's avatar
Spencer Chang committed
533 534
            } else {
                Leaf.showMessage('${l:PROMPT}', '请先保存数据');
535
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
536 537 538
            }

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

Spencer Chang's avatar
Spencer Chang committed
540 541 542 543
        };

        //合同编号超链接
        function open_con_contract_readonly_win(record_id, ds_id) {
544
            //
Spencer Chang's avatar
Spencer Chang committed
545 546 547 548 549 550 551 552
            //创建明细页面根据条件表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;
niminmin's avatar
niminmin committed
553
            param.function_code = 'CON3200Q';
Spencer Chang's avatar
Spencer Chang committed
554 555
            param.division = division;
            param.function_usage = 'QUERY';
niminmin's avatar
niminmin committed
556 557
            param.maintain_type = 'QUERY';
            param.url_title = '${l:CON301.CONTRACT_DETAIL}';
Spencer Chang's avatar
Spencer Chang committed
558 559 560 561 562 563 564 565 566
            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;
niminmin's avatar
niminmin committed
567
            if (name == 'contract_number' && value) {
Spencer Chang's avatar
Spencer Chang committed
568 569 570 571 572 573 574 575 576
                return '<a href="javascript:open_con_contract_readonly_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
            }
        };
        window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function (ds, qpara, bp_seq) {
        };

        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}';
577

Spencer Chang's avatar
Spencer Chang committed
578
        }
niminmin's avatar
niminmin committed
579

Spencer Chang's avatar
Spencer Chang committed
580
        ]]></script>
niminmin's avatar
niminmin committed
581 582
        <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
583 584 585
        <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"
niminmin's avatar
niminmin committed
586 587 588 589 590 591
                       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
592 593 594
        </a:dataSets>
    </a:view>
</a:screen>