<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hand  
    $Date: 2016-4-26 下午3:25:17  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="wfl_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="wfl_prj_chance_create_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_maintain.lview"/>
        <a:link id="con_content_storage_apply_id" url="${/request/@context_path}/modules/cont/CON555B/con_contract_storage_apply.lview"/>
        <script type="text/javascript"><![CDATA[
			function query_con_contract_storage_v_result_ds(){
				$('con_contract_storage_v_result_ds').query();
			}
			function reset_con_contract_storage_v_query_ds(){
				$('con_contract_storage_v_query_ds').reset();
			}
			
			function con555_con_contract_archive(record_id) {
                var record = $('con_contract_storage_v_result_ds').findById(record_id);
            
                con555_contractMaintainDs_grid_update2(record.get('contract_id'), record.get('cdd_list_id'));
                // if ($('con_contract_v_for_query_result_ds').getCurrentRecord()) {
                // var record = $('con_contract_v_for_query_result_ds').getCurrentRecord();
                // con555_contractMaintainDs_grid_update2(record.get('contract_id'), record.get('cdd_list_id'));
                // }
            }
            
            function con555_contractMaintainDs_grid_update2(contract_id, cdd_list_id) {
                var url = $('con_content_storage_apply_id').getUrl();
                var win = new Leaf.Window({
                    id: 'con_contract_content_window',
                    url: url,
                    params: {
                        contract_id: contract_id,
                        cdd_list_id: cdd_list_id
                    },
                    title: '归档入库',
                    fullScreen: true
                });
                win.on('close', function() {
                    $('con_contract_storage_v_result_ds').query();
                });
            }
            
            function con555_render_contractMaintainDs_grid(value, record, name) {
                if (name == 'contract_number') {
            
                    return '<a href="javascript:con555_con_contract_archive(' + record.id + ');">' + value + '</a>';
                    //return '<a href="javascript:con555_contractMaintainDs_grid_update(' + record.id + ');">' + value + '</a>';
            
                }
            }
            
             function on_base_ds_project_number_render(value, record, name) {
            
                return '<a href="javascript:do_open_prj(\'' + record.ds.id + '\')" >' + value + '</a>';
            }
            
            function do_open_prj(ds_id) {
            
                var record = $(ds_id).getCurrentRecord();
                record.set('function_code', 'PRJ501W');
                record.set('function_usage', 'QUERY');
                record.set('document_category', 'PROJECT');
                record.data['url_title'] = '租赁申请查询';
                record.data['window_open_flag'] = 'Y';
                record.data['show_history_flag'] = 'Y';
                var param = record.data;
                hls_doc_get_layout_code('wfl_con_contract_get_layout_code_link_id', param, 'wfl_prj_chance_create_link');
            }
			
		]]></script>
        <a:dataSets>
            <a:dataSet id="con_contract_storage_v_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="contract_number"/>
                    <a:field name="project_number"/>
                    <a:field name="bp_name"/>
                    <a:field name="express_number"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_storage_v_result_ds" autoQuery="true" model="cont.CON555B.con_contract_storage_v" queryDataSet="con_contract_storage_v_query_ds" selectable="true">
                <a:fields>
                    <a:field name="contract_id"/>
                    <a:field name="calc_session_id"/>
                    <a:field name="contract_number"/>
                    <a:field name="project_number"/>
                    <a:field name="project_id"/>
                    <a:field name="bp_name"/>
                    <a:field name="business_type_desc"/>
                    <a:field name="division_desc"/>
                    <a:field name="bp_class_desc"/>
                    <a:field name="invoice_agent_desc"/>
                    <a:field name="lease_item_amount"/>
                    <a:field name="cdd_list_id"/>
                    <a:field name="archive_status"/>
                    <a:field name="archive_status_n"/>
                    <a:field name="express_date"/>
                    <a:field name="express_company"/>
                    <a:field name="express_number"/>
                    <a:field name="express_province"/>
                    <a:field name="express_province_n"/>
                    <a:field name="express_city"/>
                    <a:field name="express_city_n"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="query_con_contract_storage_v_result_ds" text="查询"/>
                <a:gridButton click="" text="退回"/>
                <a:gridButton click="convenience_archive" text="补档"/>
                <a:gridButton click="storage_archive" text="归档入库"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="100" marginWidth="30" title="资料归档查询">
                <a:textField name="contract_number" bindTarget="con_contract_storage_v_query_ds" prompt="合同编号"/>
                <a:textField name="project_number" bindTarget="con_contract_storage_v_query_ds" prompt="申请编号"/>
                <a:textField name="bp_name" bindTarget="con_contract_storage_v_query_ds" prompt="承租人"/>
                <a:textField name="express_number" bindTarget="con_contract_storage_v_query_ds" prompt="邮寄单号"/>
            </a:form>
            <a:grid id="grid_id" bindTarget="con_contract_storage_v_result_ds" marginHeight="230" marginWidth="30" navBar="true">
                <a:toolBar>
                    <a:button type="excel"/>
                    <a:button type="clear"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="contract_number" prompt="合同编号" renderer="con555_render_contractMaintainDs_grid" width="160"/>
                    <a:column name="project_number" prompt="申请编号" renderer="on_base_ds_project_number_render" width="100"/>
                    <!--  <a:column name="employee_name" prompt="承租人" width="100"/> -->
                    <a:column name="bp_name" prompt="承租人" width="100"/>
                    <a:column name="business_type_desc" prompt="业务类型" width="100"/>
                    <!-- <a:column name="division" prompt="产品线" width="100"/> -->
                    <a:column name="division_desc" prompt="产品线" width="100"/>
                    <a:column name="bp_class_desc" prompt="客户类别" width="100"/>
                    <a:column name="invoice_agent_desc" prompt="代理商" width="100"/>
                    <a:column name="lease_item_amount" prompt="租赁物总价" width="100"/>
                    <a:column name="express_date" prompt="邮寄时间" renderer="Leaf.formatDate" width="100"/>
                    <a:column name="express_company" prompt="邮寄公司" width="100"/>
                    <a:column name="archive_status_n" prompt="归档状态" width="60"/>
                    <a:column name="express_number" prompt="邮寄编号" width="80"/>
                    <a:column name="express_province_n" prompt="邮寄城市" width="100"/>
                    <a:column name="express_city_n" prompt="邮寄省份" width="100"/>
                </a:columns>
            </a:grid>
            <a:hBox/>
        </a:screenBody>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
