<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lpc 9874
    $Date: $
    $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="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_contract_modify_link" url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <a:link id="car_modify_special_link" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_create.lview"/>
        <a:link id="con_contract_storage_apply_link" url="${/request/@context_path}/modules/cont/CON570/con_contract_storage_apply.lview"/>
        <a:link id="con_contract_storage_apply_readOnly_link" url="${/request/@context_path}/modules/cont/CON570/con_contract_storage_apply_readOnly.lview"/>
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
        <style type="text/css"><![CDATA[
        .SelectBG{
            background-color:#FFC0CB;
            }
    ]]></style>
        <script type="text/javascript"><![CDATA[
            jQuery.noConflict();
            
            var isLoaded = 'N';
            //	set单元格颜色  load事件无法实现效果
            
            var check_isload = setInterval(function() {
                if (isLoaded == 'N') {
                    var ids = $('${/parameter/@layout_code}_G_CONTRACT_CONTENT_RESULT_con_contract_ds');
                    var idsRecord = ids.getAll();
                    for (var i = 0;i < idsRecord.length;i++) {
                        var rowData = idsRecord[i];
                        if (rowData.get('archive_remind') == 'Y') { //如果归档提醒大于42天，则背景色置红显示
                            tr_id = '#${/parameter/@layout_code}_G_CONTRACT_CONTENT_RESULT_con_contract_layout_grid_id-u-' + rowData.id;
                            jQuery(tr_id).removeClass("row-selected").addClass('SelectBG');
                        }
                    }
                } else {
                    clearInterval(check_isload);
                }
            }, 1000);
            
            //加载时调用(grid,table,gridBox)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function(ds, record, config_records, bp_seq) {
                // var ids = $('${/parameter/@layout_code}_G_CONTRACT_CONTENT_RESULT_con_contract_ds');
                // var idsRecord = ids.getAll();
            
                // for (var i = 0;i < idsRecord.length;i++) {
            
                // var rowData = idsRecord[i];
                // if (1) { //如果归档提醒大于42天，则背景色置红显示
                //
                // tr_id = '#${/parameter/@layout_code}_G_CONTRACT_CONTENT_RESULT_con_contract_layout_grid_id-u-' + rowData.id;
                // jQuery(tr_id).removeClass("row-selected").addClass('SelectBG');
                // }
                // }
            };
            
            function open_contract_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON301'; /* param['function_usage'] = 'QUERY'; */
                param['maintain_type'] = 'UPDATE';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', null);
            }
            
            function open_project_Window(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var param = {};
                param['company_id'] = record.get('company_id');
                param['project_id'] = record.get('project_id');
                param['function_code'] = 'PRJ502D';
                param['function_usage'] = 'QUERY';
                param['bp_class'] = record.get('bp_class');
                param['maintain_type'] = 'QUERY';
                /*  param['window_open_flag'] = 'Y';
                 param['show_history_flag'] = 'Y'; */
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_special_link', ds_id, '${/parameter/@layout_code}');
            }
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'contract_number' && value) {
                    return '<a href="javascript:open_contract_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                }
                if (name == 'project_number' && value) {
                    return '<a href="javascript:open_project_Window(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                }
                return value;
            };
            
            
            //归档
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var records = $('CONTRACT_CONTENT_ENTRANCE_G_CONTRACT_CONTENT_RESULT_con_contract_ds').getSelected();
                // if (records.length != 1) {
                // Leaf.showMessage('${l:HLS.PROMPT}', '请选择一个合同进行归档操作！');
                // return;
                // }
                if (records[0].get('archive_status') == '30'||records[0].get('archive_status') == '20') {
                    var url = $('con_contract_storage_apply_readOnly_link').getUrl();
                } else {
                    var url = $('con_contract_storage_apply_link').getUrl();
                }
                var contract_id = records[0].get('contract_id');
                var cdd_list_id = records[0].get('cdd_list_id');
                var win = new Leaf.Window({
                    id: 'con_contract_storage_apply_window',
                    url: url,
                    params: {
                        contract_id: contract_id,
                        cdd_list_id: cdd_list_id
                    },
                    title: '资料收集',
                    fullScreen: true
                });
                win.on('close', function() {
                    // $('con_contract_v_for_query_result_ds').query();
                });
            };
            window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
            
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON501"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
