<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2015-11-13 下午03:23:39  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="con_flt_int_rate_req_batch_detail_link_id" url="${/request/@context_path}/modules/cont/CON771/con_flt_int_rate_req_batch_detail.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_hls_link_render_record'] = {};
            //超链接渲染
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record, bp_seq) {
                var link_function = '';
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                if (name == 'batch_number' && value) {
                    link_function = 'on_batch_detail_window';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\');">' + value + '</a>';
                }
            };
            
            function on_batch_detail_window(record_id, name) {
                var record = window['${/parameter/@bp_seq}${/parameter/@layout_code}_hls_link_render_record'][record_id + '---' + name];
                var param = record.data;
                param['function_code'] = 'CON771D';
                param['function_usage'] = 'QUERY';
                param['url_title'] = '利率浮动明细';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_flt_int_rate_req_batch_detail_link_id', record.ds.id, '${/parameter/@layout_code}');
            }
            
            //加载时调用(grid,table,gridBox)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function(ds, qpara, bp_seq) {
                setListInterval();
            };
            
            function ListSetFieldColor(record_id, field_color) {
                var grid_id = '${/parameter/@layout_code}_CON_RESULT_con_flt_int_rate_req_batch_layout_grid_id';
                var name = 'batch_status_n';
                if (Ext.get(grid_id) && $(grid_id).findColByName(name)) {
                    Ext.get(grid_id).select('tr[_row=' + record_id + '] td[dataindex=' + name + ']').setStyle({
                        background: field_color
                    });
                }
            }
            
            function setListInterval() {
                var btnListInterval = setInterval(function() {
                    var line_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_flt_int_rate_req_batch');
                    var records = $(line_ds).getAll();
                    var field_color = null;
                    if (records.length) {
                        clearInterval(btnListInterval);
                        btnListInterval = null;
                        for (var i = 0;i < records.length;i++) {
                            var record = records[i];
                            var batch_status = record.get('batch_status');
                            if (batch_status == 'IN_CALCULATE' || batch_status == 'IN_CONFIRM') {
                                field_color = 'yellow';
                            } else {
                                if (batch_status == 'ERROR_CALCULATE' || batch_status == 'ERROR_CONFIRM') {
                                    field_color = 'red';
                                } else if (batch_status == 'CONFIRM') {
                                    field_color = 'green';
                                }
                            }
                            ListSetFieldColor(record.id, field_color);
                        }
                    }
                }, 200);
            }
            
            var btnGridInterval = setInterval(function() {
                var line_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_flt_int_rate_req_batch');
                $(line_ds_id).query($(line_ds_id).currentPage);
            
            }, 10000);
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
