csh_payment_op_req.lview 23.7 KB
Newer Older
18083's avatar
18083 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: trd
    $Date: 2023-9-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>
        <a:link id="csh_payment_req_op_word_print_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_req_op_word_print.lsc"/>
        <a:link id="csh501d_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
        <a:link id="update_csh_payment_hd_info_link" model="csh.CSH501.csh_payment_req_get_num" modelaction="execute"/>
        <a:link id="con_rd_wfl_link" url="${/request/@context_path}/modules/prj/PRJ2000/purchase_order_deteail.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"/>
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
        <!-- 生成Excel文件-->
        <a:link id="tre_loan_con_print_excel_link_id"
                url="${/request/@context_path}/modules/csh/CSH501/csh_payment_contract_export.lsc"/>
        <script type="text/javascript"><![CDATA[
        jQuery.noConflict();

        function get_current_amount(amt) {
            if (!Ext.isEmpty(amt)) {
                return parseFloat(amt).toFixed(2);
            } else {
                return 0;
            }
        }
        //如果头id 不为空,就使用自在定义的ds进行查询
        Leaf.onReady(function () {
            if ('${/parameter/@source_type}' == 'WFL') {
                document.getElementById('${/parameter/@layout_code}_save').style.display = "none";
            }
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var payment_req_id = '${/parameter/@payment_req_id}';
            if (payment_req_id) {
                $(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_op_query_after_save/query');
                $(lnds_id).setQueryParameter("payment_req_id", payment_req_id);
                $(lnds_id).query();
                $(hdds_id).setQueryParameter("payment_req_id", payment_req_id);
                $(hdds_id).query();
            }
                });
        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) {
            //如果更新数据,将付款日期先置为空
             debugger;
             dirty_flag = 'Y';
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            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');
            var bank_full_name = hdrecord.get('t_bank_full_name');
             var hd_ds, ln_ds, lineRecords, currency_code, currency_name;
            if (hdds_id) {
            if((name == 't_bank_account_name'||name == 't_bank_account_name_n'||name == 't_bank_full_name'||name == 't_bank_account_id') && !Ext.isEmpty(hdrecord.get('t_bank_account_name_n')) && !Ext.isEmpty(hdrecord.get('third_bp_id_n'))&& !Ext.isEmpty(hdrecord.get('t_bank_full_name'))&& !Ext.isEmpty(hdrecord.get('t_bank_account_id'))){
                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].set('vender_bank_full_name', bank_full_name);
                    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);
                }
            }

        }

            if (lnds_id && $L.CmpManager.get(lnds_id)) {
                ln_ds = $(lnds_id);
                lineRecords = ln_ds.getAll();
            }
            if (lnds_id && lnds_id == ds.id) {
                if (name == 'amount') {
                    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);
                        return;
                    }
                    if (value > due_amount) {
                        $L.showErrorMessage("提示", '所填金额不能大于应付金额!');
                        setTimeout(function () {
                            record.set(name, null);
                        }, 5);

                    }
                    //设置本次抵扣金额
                    //var insurance_fee_ddct = minus(due_amount,value);
                    record.set('insurance_fee_ddct',minus(due_amount,value));

                }
              if (name == 'insurance_fee_ddct') {
                  var insurance_fee =get_current_amount(record.get('insurance_fee'));
                   if (value > insurance_fee) {
                      $L.showErrorMessage("提示", '厂商质保金抵扣金额不能大于厂商质保金!');
                      setTimeout(function () {
                          record.set(name, insurance_fee);
                      }, 5);

                  }

              }
          }
        };

        window['${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function (ds, record, config_records, bp_seq) {
            var hdds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            var hd_ds, lineRecords, currency_code;
            if (hdds_id) {
                hd_ds = $(hdds_id);
                hdrecord = hd_ds.getCurrentRecord();
            }
             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];
                    $(lnds_id).create(Ext.apply({}, record.data));
                }
            }
              window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        }

        function csh_payment_req_submit_finally() {
              Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function okFun() {
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
                var hd_record = $(ds_id).getCurrentRecord();
                var payment_req_id = hd_record.get('payment_req_id');
                var line_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
                var line_record = $(line_ds_id).getAt(0);
                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']();
            });
        }

        //打印
        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();

            var url_l = $('csh_payment_req_op_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");
        }



        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),
                ln_ds = $(lnds_id);
            var hd_record = hd_ds.getCurrentRecord(),
                ln_records = ln_ds.getAll();
            if (ln_records.length > 0 && !ln_records[0].get('payment_req_ln_id')) {
                Leaf.showMessage('${HLS.PROMPT}', '请先保存!');
            } else {
                csh501_print();
            }
        };



        //保存前调用
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function (ds, record) {
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var check_flag = false;
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
            var ds_line_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');
            if ($(ds_line_id).data.length <= 0) {
                $L.showErrorMessage("错误", '无付款记录,不可提交审批!');
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                check_flag = false;
                return;
            }
             var total_apply_amount = 0;
             var total_amount_vender = 0;
             var this_apply_amount=0;
             var lease_item_amount=0;
             var total_insurance_fee_ddct=0;
            //检验输入的数据是否符合要求
            var check_due_amount_flag = true;
            var line_datas = $(ds_line_id).data;
            var head_record = $(ds_id).getAt(0);
            for (var i = 0; i < line_datas.length; i++) {
                var line_data = line_datas[i];
                  //付厂商金额
                 var amount_vender = get_current_amount(line_data.get('amount'));
                 //采购总额
                 var this_apply_amount = get_current_amount(line_data.get('due_amount'));
                 var lease_item_amount = get_current_amount(line_data.get('lease_item_amount'));
                 var insurance_fee_ddct = get_current_amount(line_data.get('insurance_fee_ddct'));
                 total_apply_amount = plus(total_apply_amount, this_apply_amount);
                 total_amount_vender = plus(total_amount_vender, amount_vender);
                 total_insurance_fee_ddct = plus(total_insurance_fee_ddct, insurance_fee_ddct);
            }
             if(plus(total_insurance_fee_ddct, total_amount_vender) != total_apply_amount){
                $L.showErrorMessage("提示", '本次申请金额与厂商质保金抵扣金额和应等于申请总金额!',null,500,300);
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                return false;
            }

            //给头表赋值
            $(ds_id).getAt(0).set('amount_vender_total', total_amount_vender);
            $(ds_id).getAt(0).set('amount', total_amount_vender);
            $(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');
            //$(ds_id).getAt(0).set('currency_code', 'CNY');
            //确认保存
            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']();
                        if (res.result.record.submitted_flag == 'Y' && '${/parameter/@source_type}' != 'WFL_Y') {
                            Leaf.showMessage('${l:PROMPT}', '该单据已经提交');
                            check_flag = false;
                        } 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;
            }
            return check_flag || false;
        };

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

        };
        //保存submitsuccess调用
        window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function (ds, record, res, bp_seq) {
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            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');
            //获得相应的行信息
            var lnds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_ln');

            $(lnds_id).setQueryUrl('${/request/@context_path}/autocrud/csh.CSH501.csh_payment_req_ln_op_query_after_save/query');


            var contract_id = '${/parameter/@contract_id}';
            if (payment_req_id) {
                //更新头信息
                Leaf.Masker.mask(Ext.getBody(), '正在保存中。。。');
                Leaf.request({
                    url: $('update_csh_payment_hd_info_link').getUrl(),
                    para: {
                        payment_req_id: payment_req_id
                    },
                    success: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                        $(hdds_id).setQueryParameter('payment_req_id', payment_req_id);
                        $(hdds_id).query();
                    },
                    failure: function () {
                        Leaf.Masker.unmask(detail_mask);
                    },
                    error: function () {
                        Leaf.Masker.unmask(detail_mask);
                    },
                    scope: this
                });

                $(lnds_id).setQueryParameter('payment_req_id', payment_req_id);
                $(lnds_id).query();

            } else {
                Leaf.showMessage('${l:PROMPT}', '请先保存数据');
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            }

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

        };

        //采购单编号超链接
        function open_pur_project_readonly_win(record_id, ds_id) {
             var record = $(ds_id).findById(record_id);
             var project_id=record.get('project_id');
            var param = record.data;
            param.function_code = 'PRJ2000D_WFL';
            param.function_usage = 'QUERY';
            param.maintain_type = 'READONLY';
            param.url_title = '采购申请单维护';
            param['project_id'] = project_id;
            hls_doc_get_layout_code('csh501d_get_layout_code_link_id', param, 'con_rd_wfl_link', '', '${/parameter/@layout_code}');
        }

        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record, bp_seq) {
            var link_function = '';
            window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
            if (name == 'project_number' && value) {
                return '<a href="javascript:open_pur_project_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}';

        }

        ]]></script>
        <a:link id="${/parameter/@layout_code}csh511_csh_payment_req_hd_query" model="csh.CSH511.csh_payment_req_hd"
                modelaction="query"/>
        <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"
                       model="csh.CSH501.csh_payment_req_op_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>
        </a:dataSets>
    </a:view>
</a:screen>