<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang 
    $Date: 2015年12月8日 下午2:50:21  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="ins550t_ins_insurance_create_cashflow_link_id" model="ins.INS550.ins_insurance_create_cashflow" modelaction="batch_update"/>
        <script type="text/javascript"><![CDATA[
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var cf_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ins_insurance_cf_item');
                var records = $('${/parameter/@ds_id}').getSelected();
                if (records.length) {
                    var cf_records = $(cf_ds_id).getSelected();
                    if (cf_records.length) {
                        var sava_data = [];
                        for (var i = 0;i < cf_records.length;i++) {
                            var cf_record = cf_records[i];
                            for (var j = 0;j < records.length;j++) {
                                var record = records[j];
                                sava_data.push({
                                    claims_id: record.get('claims_id'),
                                    _status: 'update',
                                    cf_item: cf_record.get('cf_item'),
                                    cf_type: cf_record.get('cf_type')
                                });
                            }
                        }
                        Leaf.showConfirm('${l:PROMPT}', '是否确认生成现金流?', function() {
                            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                            Leaf.request({
                                url: $('ins550t_ins_insurance_create_cashflow_link_id').getUrl(),
                                para: sava_data,
                                success: function(res) {
                                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                    parent.Leaf.SideBar.enable = true;
                                    parent.Leaf.SideBar.show({
                                        msg: '已生成现金流',
                                        duration: 2000
                                    });
                                    $('${/parameter/@winid}').close();
                                },
                                failure: function() {
                                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                },
                                error: function() {
                                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                },
                                scope: this
                            });
                        }, function() {
                            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        });
            
                    } else {
                        Leaf.showMessage('${l:PROMPT}', '请先选择现金流项目!');
                    }
                }
            };
        ]]></script>
    </a:view>
</a:screen>