<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:  nyl 
    $Date: 2014-8-4 下午01:58:31  
    $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="ins_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="ins500_get_valid_to_link_id" model="ins.INS500U.hls_import_interface" modelaction="execute"/>
        <a:link id="ins_insurance_create_cashflow_link_id" url="${/request/@context_path}/modules/ins/INS550/ins_insurance_create_cashflow.lview"/>
        <script type="text/javascript"><![CDATA[
            //加载时调用(grid,table,gridBox)
            window['${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function(ds, record, config_records, bp_seq) {
                // var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ins_insurance_policy');
                // if (ds.id == ds_id) {
                // var records = $(ds_id).getAll();
                // if (!records.length) {
                // return;
                // }
                // for (var i = 0;i < records.length;i++) {
                // //已确认的不可编辑
                // if (records[i].data['insured_flag'] == 'Y') {
                // records[i].getField('valid_from').setReadOnly(true);
                // // records[i].getField('policy_number').setReadOnly(true);
                // }
                // }
                // }
            };
            
            //保存
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ins_insurance_claims_policy');
                if (ds_id) {
                    var records = $(ds_id).getSelected();
                    if (records.length) {
                        var param = {};
                        param['function_code'] = 'INS550T';
                        param['function_usage'] = 'CREATE';
                        param['url_title'] = '生成现金流';
                        param['ds_id'] = ds_id;
                        param['screen_width'] = '800';
                        param['screen_height'] = '400';
                        hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'ins_insurance_create_cashflow_link_id', ds_id, '${/parameter/@layout_code}');
                    } else {
                        Leaf.showMessage('${l:PROMPT}', '请先选择理赔记录!');
                    }
                }
            };
            
            //更新时调用
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ins_insurance_policy');
                var prj_quotation_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
            
            
                // if (ds.id == ds_id && name == 'valid_from') {
                // quotation_record = $(prj_quotation_id).getCurrentRecord();
                // var valid_from = record.get('valid_from');
            
                // if (valid_from) {
                // Leaf.request({
                // url: $('ins500_get_valid_to_link_id').getUrl(),
                // para: {
                // project_id: quotation_record.get('project_id'),
                // quotation_id :quotation_record.get('quotation_id'),
                // valid_from: valid_from
                // },
                // success: function(res) {
            
                // record.set('valid_to', res.result.valid_to);
            
                // },
                // sync: true,
                // scope: this
                // });
                // } else {
                // record.set('valid_from', null);
                // record.set('valid_to', null);
                // }
                // }
            
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>