csh_payment_req.lview 55.4 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2
<?xml version="1.0" encoding="UTF-8"?>
<!--
3 4 5 6
    $Author: gaoyang
    $Date: 2015-1-27 上午09:27:36
    $Revision: 1.0
    $Purpose:
Spencer Chang's avatar
Spencer Chang committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-->
<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"/>
24
		<a:model-query fetchAll="true" model="csh.CSH501.get_vender_bank_info" rootPath="vender_account_path"/>
Spencer Chang's avatar
Spencer Chang committed
25 26
    </a:init-procedure>
    <a:view>
27 28
        <a:link id="csh_payment_req_word_print_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_word_print.lsc"/>
29 30 31
		<a:link id="csh_payment_req_bo_pdf_print_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_bo_pdf_print.lsc"/>
	    <a:link id="csh_batch_pdf_dl_link_id" url="${/request/@context_path}/modules/csh/CSH501/csh_atm_batch_dl.lsc"/>
niminmin's avatar
niminmin committed
32 33
        <a:link id="csh501d_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
34
        <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
35 36 37
        <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"/>
38
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
Spencer Chang's avatar
Spencer Chang committed
39
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
niminmin's avatar
niminmin committed
40 41 42
        <!-- 生成Excel文件-->
        <a:link id="tre_loan_con_print_excel_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_contract_export.lsc"/>
43
		<a:link id="csh_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
44
        <a:link id="csh_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
Spencer Chang's avatar
Spencer Chang committed
45 46
        <script type="text/javascript"><![CDATA[
        jQuery.noConflict();
niminmin's avatar
niminmin committed
47
        var con_business_type='${/parameter/@con_business_type}'||'${/model/loan_flag_path/record/@business_type}'||'LEASE';
48
		var is_constru_unit='${/parameter/@is_constru_unit}' || 'N';
49
        var is_buyout='${/parameter/@is_buyout}' || 'N';
50
        //工作流审批界面校验发票状态
51
        if ('${/parameter/@source_type}' == 'WFL_Y') {
52 53 54
            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
55
                if (type == 'agree'&&con_business_type == 'LEASE') {
niminmin's avatar
niminmin committed
56 57
                    var records = $(lnds_id).getAll();
                    for (var i = 0; i < records.length; i++) {
58 59
                        if (records[i].get('billing_status_n') != '全部开票' || records[i].get('invoice_status_n') != '已确认') {
                            $L.showErrorMessage("提示", '请选择开票状态为全部开票,发票状态为已确认的现金流!');
niminmin's avatar
niminmin committed
60 61 62 63 64 65
                            return false;
                        }
                    }
                    return true;
                } else return true;
                // }
66 67
            });
        }
niminmin's avatar
niminmin committed
68 69 70 71 72 73 74
        function get_current_amount(amt) {
            if (!Ext.isEmpty(amt)) {
                return parseFloat(amt).toFixed(2);
            } else {
                return 0;
            }
        }
stone's avatar
stone committed
75
        //如果头id 不为空,就使用自在定义的ds进行查询
niminmin's avatar
niminmin committed
76
        Leaf.onReady(function () {
niminmin's avatar
niminmin committed
77 78 79
            if ('${/parameter/@source_type}' == 'WFL') {
                document.getElementById('${/parameter/@layout_code}_save').style.display = "none";
            }
stone's avatar
stone committed
80
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
stone's avatar
stone committed
81
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
niminmin's avatar
niminmin committed
82 83
            var payment_req_id = '${/parameter/@payment_req_id}';
            if (payment_req_id) {
stone's avatar
stone committed
84
                $(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_query_after_save/query');
niminmin's avatar
niminmin committed
85
                $(lnds_id).setQueryParameter("payment_req_id", payment_req_id);
stone's avatar
stone committed
86
                $(lnds_id).query();
niminmin's avatar
niminmin committed
87
                $(hdds_id).setQueryParameter("payment_req_id", payment_req_id);
stone's avatar
stone committed
88 89
                $(hdds_id).query();
            }
niminmin's avatar
niminmin committed
90 91 92 93 94 95 96 97
            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
98

niminmin's avatar
niminmin committed
99 100 101 102
            }
            // var elements=document.querySelector('td[title="SBO反馈信息"]');
            // elements.remove();
        });
Spencer Chang's avatar
Spencer Chang committed
103 104 105 106 107
        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
108
            //如果更新数据,将付款日期先置为空
niminmin's avatar
niminmin committed
109
            dirty_flag = 'Y';
Spencer Chang's avatar
Spencer Chang committed
110 111
            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');
gzj34291's avatar
gzj34291 committed
112 113 114 115 116
            hd_ds = $(hdds_id);
            var  hdrecord = hd_ds.getCurrentRecord();
            var bank_account_name = hdrecord.get('third_bp_id_n');
            var vender_bank_account_id = hdrecord.get('t_bank_account_id');
            var bank_account_num = hdrecord.get('t_bank_account_num');
Spencer Chang's avatar
Spencer Chang committed
117 118
            var hd_ds, ln_ds, lineRecords, currency_code, currency_name;
            if (hdds_id) {
gzj34291's avatar
gzj34291 committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
                if((name == 't_bank_account_name'||name == 't_bank_account_name_n') && !Ext.isEmpty(hdrecord.get('t_bank_account_name_n')) && !Ext.isEmpty(hdrecord.get('third_bp_id_n'))){
                    var records = $(lnds_id).getAll();
                    for (var i = 0; i < records.length; i++) {
                        records[i].set('vender_bank_account_number', bank_account_num);
                        records[i].set('vender_bank_account_number_n', bank_account_num);
                        records[i].set('vender_bank_account_name', bank_account_name);
                        records[i].set('vender_bank_account_id', vender_bank_account_id);
                        records[i].getField('vender_bank_account_number').setReadOnly(true);
                        records[i].getField('vender_bank_account_number_n').setReadOnly(true);
                    }
                }
                if((name == 'third_bp_id'||name == 'third_bp_id_n') && (Leaf.isEmpty(record.get('document_number_t')) || bank_account_name=='')){
                    var records = $(lnds_id).getAll();
                    hdrecord.set('t_bank_account_num',null);
                    hdrecord.set('t_bank_branch_name',null);
                    hdrecord.set('t_bank_full_name',null);
                    hdrecord.set('t_bank_account_id',null);
                    for (var i = 0; i < records.length; i++) {
                        records[i].getField('vender_bank_account_number').setReadOnly(false);
                        records[i].getField('vender_bank_account_number_n').setReadOnly(false);
                    }
                }

Spencer Chang's avatar
Spencer Chang committed
142 143 144 145 146
            }
            if (lnds_id && $L.CmpManager.get(lnds_id)) {
                ln_ds = $(lnds_id);
                lineRecords = ln_ds.getAll();
            }
niminmin's avatar
niminmin committed
147 148 149 150 151 152 153 154
            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
155 156
                        return;
                    }
niminmin's avatar
niminmin committed
157 158 159 160 161
                    if (value > due_amount) {
                        $L.showErrorMessage("提示", '所填金额不能大于应付金额!');
                        setTimeout(function () {
                            record.set(name, null);
                        }, 5);
Spencer Chang's avatar
Spencer Chang committed
162 163

                    }
niminmin's avatar
niminmin committed
164 165 166 167
                } 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
168 169 170 171 172 173 174 175
                    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
176
                        $L.showErrorMessage("提示", '回购租金抵冲金额不能大于回购租金剩余金额!');
niminmin's avatar
niminmin committed
177 178 179
                        setTimeout(function () {
                            record.set('repur_con_ddct_amt', 0);
                        }, 5);
Spencer Chang's avatar
Spencer Chang committed
180 181
                    }
                }
182 183 184 185 186 187 188 189 190 191 192 193 194
                //add by 18938 承租人金额为0时 承租人账户信息为可输
                if(is_constru_unit == 'Y'){
                    if(name == 'amount_tenant'){
                        if(record.get('amount_tenant') == 0){
                            record.getField('tenant_bank_account_number').setRequired(false);
                            record.getField('tenant_bank_account_number_n').setRequired(false);
                        }else{
                            record.getField('tenant_bank_account_number').setRequired(true);
                            record.getField('tenant_bank_account_number_n').setRequired(true);
                        }
                    }
                }
                //end
Spencer Chang's avatar
Spencer Chang committed
195 196 197 198
            }
        };

        window['${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function (ds, record, config_records, bp_seq) {
199
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
niminmin's avatar
niminmin committed
200
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
Spencer Chang's avatar
Spencer Chang committed
201 202 203 204 205
            var hd_ds, lineRecords, currency_code;
            if (hdds_id) {
                hd_ds = $(hdds_id);
                hdrecord = hd_ds.getCurrentRecord();
            }
gzj34291's avatar
gzj34291 committed
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
            if (ds.id == ds_id) {
                var handrecord = $(hdds_id).getCurrentRecord();
                if (!Ext.isEmpty(handrecord)) {
                    var bank_account_name = handrecord.get('third_bp_id_n');
                    if (!Ext.isEmpty(hdrecord.get('third_bp_id_n'))) {
                        var records = $(ds_id).getAll();
                        for (var i = 0; i < records.length; i++) {
                            records[i].getField('vender_bank_account_number').setReadOnly(true);
                            records[i].getField('vender_bank_account_number_n').setReadOnly(true);
                        }
                    }
                }
            }


Spencer Chang's avatar
Spencer Chang committed
221 222 223 224 225
            if (record) {
                if ('${/parameter/@function_code}' == 'CSH502D') {
                    record.getField('pay_amount').setReadOnly(false);
                }
            }
niminmin's avatar
niminmin committed
226 227 228 229 230 231 232 233 234 235 236
            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
237
            var lnds_records = $(ds_id).getAll();
238 239
			if (con_business_type == 'LEASEBACK'){
                if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'||'${/parameter/@division}' ==93||'${/parameter/@division}' =='新业务-厂商担保'){
240 241 242 243 244 245 246 247
                    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);
                    }
                }
248 249 250 251 252 253 254 255 256 257 258 259 260
                //add by 18938
                if(is_constru_unit == 'Y'){
                    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].get('is_buyout') == 'Y'){
                                //买断机 应付承租人金额为必填项 应付我司金额为只读项且默认为0
                                records[i].getField('amount_tenant').setRequired(true);
                                records[i].getField('amount_agent').setReadOnly(true);
                            }else{
                                //非买断机 应付承租人金额为只读项,默认为0,承租人账号为非必填 应付我司金额为只读项且默认为0 委托付款金额为必填项(界面已配置)
                                records[i].getField('amount_tenant').setReadOnly(true);
                                records[i].getField('amount_agent').setReadOnly(true);
261
                            }
262 263 264 265
							if(records[i].get('amount_tenant') > 0){
							  records[i].getField('tenant_bank_account_number').setRequired(true);
							  records[i].getField('tenant_bank_account_number_n').setRequired(true);
							}
266 267 268 269 270
                    }
                }
            }
            //非虚拟店 应付承租人金额非必填且未只读
            if(is_constru_unit != 'Y'){
271
               var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
272 273 274 275 276
                var records = $(ds_id).getAll();
                for (i = 0; i < records.length; i++) {
                        records[i].getField('amount_tenant').setRequired(false);
                        records[i].getField('amount_tenant').setReadOnly(true);
                        if(con_business_type == 'LEASEBACK'){
277 278 279 280 281
                             if (records[i].get('division') =='91'||records[i].get('division') =='93'){
                             records[i].getField('tenant_bank_account_number').setRequired(false);
                             records[i].getField('tenant_bank_account_number_n').setRequired(false);
                            }else{
							records[i].getField('tenant_bank_account_number').setRequired(true);
282
                            records[i].getField('tenant_bank_account_number_n').setRequired(true);
283
						  }
284 285
                        }
                }
286
            }
287 288 289 290 291 292 293 294 295
            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
296 297 298 299 300 301
            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) {
302
          	var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
Spencer Chang's avatar
Spencer Chang committed
303 304 305 306 307
            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')) {
308
                        //添加时间为预定的每月20号
niminmin's avatar
niminmin committed
309 310
                        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
311
                    }
312 313 314 315 316 317 318 319 320 321
					if (record.get('division') == '93'){
					 if (!record.get('vender_bank_account_number')||!record.get('vender_bank_account_name')) {
                      records[i].set('vender_bank_account_number', '${/model/vender_account_path/record/@vender_bank_account_number}');
                      records[i].set('vender_bank_account_number_n', '${/model/vender_account_path/record/@vender_bank_account_number}');
                      records[i].set('vender_bank_full_name', '${/model/vender_account_path/record/@vender_bank_full_name}');
                      records[i].set('vender_bank_account_name','${/model/vender_account_path/record/@vender_bank_account_name}');
                      records[i].set('vender_bank_account_id', '${/model/vender_account_path/record/@vender_bank_account_id}');

                     }
					}
Spencer Chang's avatar
Spencer Chang committed
322
                    $(lnds_id).create(Ext.apply({}, record.data));
niminmin's avatar
niminmin committed
323 324 325 326 327 328 329
                    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);
                    }
330 331 332 333 334
                    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
335 336
                }
            }
337
            if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'||'${/parameter/@division}' ==92||'${/parameter/@division}' =='北京心诚' ){
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
                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'));
                    };
                }
            }
358 359 360 361 362 363 364 365 366 367
            //add by 18938
            if(is_constru_unit == 'Y'){
                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++) {
                        if(is_buyout == 'Y'){
                             //买断机 应付承租人金额为必填项 应付我司金额为只读项且默认为0 承租人账号必填
                              records[i].getField('amount_tenant').setRequired(true);
                              records[i].getField('amount_agent').setReadOnly(true);
368

369 370 371 372
                        }else{
                            //非买断机 应付承租人金额为只读项,默认为0,承租人账号为非必填 应付我司金额为只读项且默认为0 委托付款金额为必填项(界面已配置)
                              records[i].getField('amount_tenant').setReadOnly(true);
                              records[i].getField('amount_agent').setReadOnly(true);
373

374
                        }
375 376 377 378
                        if(records[i].get('amount_tenant') > 0){
                          records[i].getField('tenant_bank_account_number').setRequired(true);
                          records[i].getField('tenant_bank_account_number_n').setRequired(true);
                        }
379 380 381 382 383 384 385 386 387
                    }
                }
            }else{
                //非虚拟店 应付承租人金额非必填且未只读
                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('amount_tenant').setRequired(false);
                        records[i].getField('amount_tenant').setReadOnly(true);
388 389 390 391 392 393 394 395 396
							  if(con_business_type == 'LEASEBACK'){
							   if ('${/parameter/@division}' ==91||'${/parameter/@division}' =='神钢建机'||'${/parameter/@division}' ==93||'${/parameter/@division}' =='新业务-厂商担保'){
								 records[i].getField('tenant_bank_account_number').setRequired(false);
								 records[i].getField('tenant_bank_account_number_n').setRequired(false);
							    }else{
									records[i].getField('tenant_bank_account_number').setRequired(true);
									records[i].getField('tenant_bank_account_number_n').setRequired(true);
							    }
							}
397 398 399
                 }
            }
            //end
Spencer Chang's avatar
Spencer Chang committed
400 401 402 403
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        }

        function csh_payment_req_submit_finally() {
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
            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');
            var line_record = $(line_ds_id).getAt(0);
            var line_record_all = $(line_ds_id).getAll();
            var flag = false;
            for (var j = 0; j < line_record_all.length; j++) {
            	if(	line_record_all[j].get('division')=='93' && line_record_all[j].get('amount_vender') == 0 && line_record_all[j].get('is_buyout')=='N'){
            	  flag = true;
            	  break;
            	}
            }
           if(flag){
            Leaf.showConfirm('${l:HLS.PROMPT}', '是否买断机为否,请确认全部支付代理店!', function okFun() {
                 Leaf.request({
niminmin's avatar
niminmin committed
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
                    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
445
                // }
Spencer Chang's avatar
Spencer Chang committed
446 447 448 449
            }, function cancelFun() {
                Leaf.SideBar.enable = true;
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            });
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
         }else{
           Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function okFun() {
           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']();
      });
         }
Spencer Chang's avatar
Spencer Chang committed
483
        }
niminmin's avatar
niminmin committed
484

Spencer Chang's avatar
Spencer Chang committed
485 486 487 488
        //打印
        function csh501_print() {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var hd_record = $(hdds_id).getCurrentRecord();
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516
            if(hd_record.get('con_division')=='93'){
			//新业务-厂商付款请求书打印
			// 锁屏
            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
          	Leaf.request({
				url: $('csh_payment_req_bo_pdf_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',
				success: function() {
					// 下载
					var doc_code = '付款请求书';
					var url_l = $('csh_batch_pdf_dl_link_id').getUrl() + '?document_id=' + hd_record.get('payment_req_id') + '&document_table=CSH_PAYMENT_REQ&batch_flag=Y&doc_code=' + encodeURI(doc_code) + '&fnd_atm_flag=Y';
				 	window.open(href = url_l, target = "_self");
					Leaf.Masker.unmask(Ext.getBody());
				},
				error: function() {
					Leaf.Masker.unmask(Ext.getBody());
				},
				failure: function() {
					Leaf.Masker.unmask(Ext.getBody());
				},
				scope: this
			});
			}else{
			 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';
             window.open(href = url_l, target = "_self");

			}

			}
517

Spencer Chang's avatar
Spencer Chang committed
518 519 520 521 522 523 524 525 526 527 528

        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),
529
                ln_ds = $(lnds_id);
Spencer Chang's avatar
Spencer Chang committed
530
            var hd_record = hd_ds.getCurrentRecord(),
531
                ln_records = ln_ds.getAll();
Spencer Chang's avatar
Spencer Chang committed
532 533
            if (ln_records.length > 0 && !ln_records[0].get('payment_req_ln_id')) {
                Leaf.showMessage('${HLS.PROMPT}', '请先保存!');
niminmin's avatar
niminmin committed
534
            } else {
535 536
                csh501_print();
            }
Spencer Chang's avatar
Spencer Chang committed
537 538
        };
        //保存前调用
niminmin's avatar
niminmin committed
539
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function (ds, record) {
Spencer Chang's avatar
Spencer Chang committed
540
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
541
          	var check_flag = false;
Spencer Chang's avatar
Spencer Chang committed
542
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
543
            var ds_line_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
niminmin's avatar
niminmin committed
544 545
            if ($(ds_line_id).data.length <= 0) {
                $L.showErrorMessage("错误", '无付款记录,不可提交审批!');
stone's avatar
stone committed
546
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
niminmin's avatar
niminmin committed
547
                check_flag = false;
stone's avatar
stone committed
548 549
                return;
            }
niminmin's avatar
niminmin committed
550 551 552
            var total_amount_agent = 0;
            var total_amount_vender = 0;
            var total_apply_amount = 0;
niminmin's avatar
niminmin committed
553
            var total_amount_tenant=0;
554
            //检验输入的数据是否符合要求
niminmin's avatar
niminmin committed
555 556 557
            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
558
            //高空作业车个数
niminmin's avatar
niminmin committed
559
            var gk_contract_num = 0;
gzj34291's avatar
gzj34291 committed
560 561 562 563 564 565 566
            if(!Ext.isEmpty(head_record.get('t_bank_account_id'))){
                for (var i = 0; i < line_datas.length; i++) {
                    var line_data = line_datas[i];
                    line_data.set('vender_bank_account_id',head_record.get('t_bank_account_id'));
                }
            }

niminmin's avatar
niminmin committed
567 568
            for (var i = 0; i < line_datas.length; i++) {
                var line_data = line_datas[i];
569
                //应付我司金额
niminmin's avatar
niminmin committed
570 571 572 573
                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
574 575
                var bp_bank_account_id = line_data.get('bp_bank_account_id');
                var vender_bank_account_id = line_data.get('vender_bank_account_id');
576
                //首付款抵充金额
niminmin's avatar
niminmin committed
577 578 579 580 581
                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'));
582 583
                //设备款 add by 18938
                var lease_item_amount = get_current_amount(line_data.get('lease_item_amount'));
niminmin's avatar
niminmin committed
584 585
                if (amount_agent < 0 || amount_vender < 0) {
                    $L.showErrorMessage("提示", '应付我司金额和首付款抵冲金额不能为负数!');
586 587 588
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }
stone's avatar
stone committed
589
                //买断机合同 个数
niminmin's avatar
niminmin committed
590 591
                if (amount_vender == 0 || '${/parameter/@division}' == 30) {
                    gk_contract_num = gk_contract_num + 1;
stone's avatar
stone committed
592
                }
593
                //根据金额判断代理店和厂商不能为空
niminmin's avatar
niminmin committed
594
                if (amount_agent > 0 && !bp_bank_account_id) {
595

niminmin's avatar
niminmin committed
596
                    $L.showErrorMessage("提示", '请选择代理店账号信息!');
597 598 599
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }
niminmin's avatar
niminmin committed
600
                if (amount_vender > 0 && !vender_bank_account_id) {
601

niminmin's avatar
niminmin committed
602
                    $L.showErrorMessage("提示", '请选择委托付款金额不为0的厂商账号信息!');
603 604 605
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    return false;
                }
niminmin's avatar
niminmin committed
606 607 608 609 610 611
                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;
                    }
612 613 614 615 616 617 618 619
                    //add by 18938
                    if(is_constru_unit == 'Y'){
                        if(plus(plus(other_payment2, amount_vender), repur_con_ddct_amt) != lease_item_amount){
                            $L.showErrorMessage("提示", '首付款抵扣金额,委托付款金额,回购租金抵冲金额之和应等于设备款!',null,500,300);
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
niminmin's avatar
niminmin committed
620 621
                } else if (con_business_type == 'LEASEBACK') {
                    var entrusted_amount = get_current_amount(line_data.get('entrusted_amount'));
622 623 624 625 626
                    if (plus(plus(amount_agent, amount_vender),repur_con_ddct_amt) != entrusted_amount && is_constru_unit != 'Y') {
                        $L.showErrorMessage("提示", '应付代理店金额、应付厂商金额、回购租金抵冲金额合计不等于合同签约时承租人所填写委托付款金额,请重新填写!',null,500,300);
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        return false;
                    }
niminmin's avatar
niminmin committed
627 628 629 630 631
                    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;
                    }
632 633 634 635 636 637 638 639 640
                    //add by 18938
                    if(is_constru_unit == 'Y'){
                        if(plus(plus(plus(other_payment2, amount_tenant), amount_vender), repur_con_ddct_amt) != lease_item_amount){
                            $L.showErrorMessage("提示", '首付款抵扣金额,应付承租人金额,委托付款金额,回购租金抵冲金额之和应等于设备款!',null,500,300);
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    //end
641
                }
642 643 644 645 646 647 648 649
			    //新业务厂商全部支付给代理店且买断机为否,增加弱校验 18083
                 /*if (amount_vender == 0 && line_data.get('division') == '93' && line_data.get('is_buyout')=='N') {
                   $L.showConfirm('提示','是否买断机为否,请确认全部支付代理店!', function () {
                   window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
				   return true;
                                         });
                   $L.showInfoMessage('提示', '是否买断机为否,请确认全部支付代理店!');
                 }*/
niminmin's avatar
niminmin committed
650 651 652

                //本次申请金额等于委托加我司加应付承租人金额
                var this_apply_amount = plus(plus(amount_agent, amount_vender),amount_tenant);
niminmin's avatar
niminmin committed
653 654 655 656
                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
657
                total_amount_tenant = plus(total_amount_tenant, amount_tenant);
658
            }
niminmin's avatar
niminmin committed
659 660 661 662
            if (gk_contract_num < line_datas.length && gk_contract_num != 0) {
                $L.showErrorMessage("提示", '买断机合同(即厂商的付款金额为0)不可与其他正常合同同时进行付款申请支付');
                return false;
            }
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
           //add by 18938
           if(is_constru_unit == 'Y'){
                if(con_business_type == 'LEASEBACK'){
                    if(plus(plus(total_amount_agent, total_amount_vender), total_amount_tenant) != total_apply_amount){
                        $L.showErrorMessage("提示", '应付代理店总金额,应付厂商总金额,应付承租人总金额之和应等于申请总金额!',null,500,300);
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        return false;
                    }
                }else{
                    if(plus(total_amount_agent, total_amount_vender) != total_apply_amount){
                        $L.showErrorMessage("提示", '应付代理店总金额,应付厂商总金额之和应等于申请总金额!',null,500,300);
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        return false;
                    }
                }
           }
           //end
680
            //给头表赋值
niminmin's avatar
niminmin committed
681 682
            $(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
683
            $(ds_id).getAt(0).set('amount_tenant_total', total_amount_tenant);
niminmin's avatar
niminmin committed
684 685 686 687 688 689
            $(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
690
            //$(ds_id).getAt(0).set('currency_code', 'CNY');
691 692 693 694 695 696 697 698 699 700 701
            //确认保存
            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']();
702
                        if (res.result.record.submitted_flag == 'Y' && '${/parameter/@source_type}' != 'WFL_Y') {
703
                            Leaf.showMessage('${l:PROMPT}', '该单据已经提交');
704
                            check_flag = false;
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
                        } 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
725
            return check_flag || false;
Spencer Chang's avatar
Spencer Chang committed
726 727 728
        };

        window['${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function (ds, record, config_records, bp_seq) {
729
          	var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
Spencer Chang's avatar
Spencer Chang committed
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
            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}');
                }
            }
748
			var head_record = $(hdds_id).getAt(0);
Spencer Chang's avatar
Spencer Chang committed
749 750 751 752 753 754 755 756 757 758 759
            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);
                    }
                }
gzj34291's avatar
gzj34291 committed
760 761 762 763 764 765 766
                if(head_record.get('con_division') == '30' || head_record.get('con_division') == '50'||'${/parameter/@division}' == '50' || '${/parameter/@division}' == '30'){
                    //  record.getField('third_bp_id').setRequired(true);
                    //  record.getField('third_bp_id_n').setRequired(true);
                    // record.getField('t_bank_account_name').setRequired(true);
                    //record.getField('t_bank_account_name_n').setRequired(true);

                }else{
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
                    if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID')){
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID_prompt').style.display = 'none';
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID').style.display = 'none';
                    }
                    if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NAME')){
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NAME_prompt').style.display = 'none';
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NAME').style.display = 'none';
                    }
                    if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NUM')){
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NUM_prompt').style.display = 'none';
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NUM').style.display = 'none';
                    }
                    if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME')){
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME_prompt').style.display = 'none';
                        document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME').style.display = 'none';
                    }
783 784

                 }
785 786
                //add by 18938
                if(is_constru_unit == 'Y'){
787

788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
                        if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID')){
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID_prompt').style.display = 'block';
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_THIRD_BP_ID').style.display = 'block';
                        }
                        if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NAME')){
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NAME_prompt').style.display = 'block';
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NAME').style.display = 'block';
                        }
                        if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NUM')){
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NUM_prompt').style.display = 'block';
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_ACCOUNT_NUM').style.display = 'block';
                        }
                        if(document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME')){
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME_prompt').style.display = 'block';
                            document.getElementById('CSH501D_PAYMENT_REQ_HD_CSH_PAYMENT_REQ_HD_T_BANK_FULL_NAME').style.display = 'block';
                        }
804

805 806
                }
                //end
807

Spencer Chang's avatar
Spencer Chang committed
808 809 810 811
            }
        };
        //保存submitsuccess调用
        window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function (ds, record, res, bp_seq) {
812
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
813 814 815 816
            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');
817 818
            //获得相应的行信息
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
819
            var cdd_file_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hl_cm_cdd_file_list');
stone's avatar
stone committed
820
            $(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_query_after_save/query');
821

Spencer Chang's avatar
Spencer Chang committed
822 823 824

            var contract_id = '${/parameter/@contract_id}';
            if (payment_req_id) {
825 826 827 828 829
                //更新头信息
                Leaf.Masker.mask(Ext.getBody(), '正在保存中。。。');
                Leaf.request({
                    url: $('update_csh_payment_hd_info_link').getUrl(),
                    para: {
niminmin's avatar
niminmin committed
830
                        payment_req_id: payment_req_id
831 832 833 834
                    },
                    success: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                        $(hdds_id).setQueryParameter('payment_req_id', payment_req_id);
niminmin's avatar
niminmin committed
835 836
                        $(hdds_id).query();
                    },
837 838 839 840 841 842 843 844 845
                    failure: function () {
                        Leaf.Masker.unmask(detail_mask);
                    },
                    error: function () {
                        Leaf.Masker.unmask(detail_mask);
                    },
                    scope: this
                });

stone's avatar
stone committed
846
                $(lnds_id).setQueryParameter('payment_req_id', payment_req_id);
847
                $(lnds_id).query();
848 849
				//保存成功,刷新附件数据  18083 2023/12/28
				$(cdd_file_id).setQueryParameter('payment_req_id', payment_req_id);
850
                $(cdd_file_id).query();
851

Spencer Chang's avatar
Spencer Chang committed
852 853
            } else {
                Leaf.showMessage('${l:PROMPT}', '请先保存数据');
854
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
855 856 857
            }

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

Spencer Chang's avatar
Spencer Chang committed
859 860 861 862
        };

        //合同编号超链接
        function open_con_contract_readonly_win(record_id, ds_id) {
863
            //
Spencer Chang's avatar
Spencer Chang committed
864 865 866 867 868 869 870 871
            //创建明细页面根据条件表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
872
            param.function_code = 'CON3200Q';
Spencer Chang's avatar
Spencer Chang committed
873 874
            param.division = division;
            param.function_usage = 'QUERY';
niminmin's avatar
niminmin committed
875 876
            param.maintain_type = 'QUERY';
            param.url_title = '${l:CON301.CONTRACT_DETAIL}';
Spencer Chang's avatar
Spencer Chang committed
877 878 879 880 881 882
            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}');
        }

883
	  function upload_csh_file(id,name,record_id,item_code) {
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902
         var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
        if (item_code=='INVOICE') {
         var url = $('csh_uploadFile_id').getUrl() + '?table_name=INVOICE&header_id=' + record_id;
        }else if(item_code=='PAYMENT_REQUEST_LETTER'){
         var url = $('csh_uploadFile_id').getUrl() + '?table_name=PAYMENT_REQUEST_LETTER&header_id=' + record_id;
        }else if(item_code=='OTHERS'){
         var url = $('csh_uploadFile_id').getUrl() + '?table_name=OTHERS&header_id=' + record_id;
       }
         var win = new Leaf.Window({
            url: url,
            title: '${l:HLS.SUPPORTING_DOCUMENT}',
            id: 'csh_attachment_uploadFile_id',
            width: 850,
            height: 400
            });
          win.on('close', function () {
            record.ds.query();
        });

903
       }
904

905
        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record, bp_seq) {
Spencer Chang's avatar
Spencer Chang committed
906 907
            var link_function = '';
            window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
niminmin's avatar
niminmin committed
908
            if (name == 'contract_number' && value) {
Spencer Chang's avatar
Spencer Chang committed
909
                return '<a href="javascript:open_con_contract_readonly_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
910
            }else if (name == 'attachment'){
911
               return '<a href=javascript:upload_csh_file(\''+record.id+'\',\''+ name + '\',\'' +record.get('payment_req_id')+'\',\'' + record.get('item_code')+'\')>附件上传</a>';
912 913 914 915 916 917 918 919 920 921 922

             } 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();
18083's avatar
18083 committed
923
                     if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
924 925 926 927 928 929 930 931 932 933
                         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;

         }

Spencer Chang's avatar
Spencer Chang committed
934 935 936 937 938 939 940 941
            }
        };
        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}';
942

Spencer Chang's avatar
Spencer Chang committed
943
        }
niminmin's avatar
niminmin committed
944

Spencer Chang's avatar
Spencer Chang committed
945
        ]]></script>
niminmin's avatar
niminmin committed
946 947
        <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
948 949 950
        <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
951 952 953 954 955 956
                       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
957 958 959
        </a:dataSets>
    </a:view>
</a:screen>