<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxign5129  
    $Date: 2014-11-24 下午07:01:12  
    $Revision: 1.0  
    $Purpose: 文档借阅
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" 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="yonda_document_lend_record_add_link" url="${/request/@context_path}/modules/cont/CON556/yonda_document_lend_record_add.lview"/>
        <a:link id="con_contract_modify_link" url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <script type="text/javascript"><![CDATA[
            function yonda_document_lend_record_add() {
                var add_win = new Leaf.Window({
                    id: 'yonda_document_lend_record_add_win',
                    params: {
                        'winid': 'yonda_document_lend_record_add_win'
                    },
                    url: $('yonda_document_lend_record_add_link').getUrl(),
                    fullScreen: true
                });
                add_win.on('close', function() {
                    $('yonda_document_lend_record_hd_ds').query();
                });
            }
            
            function yonda_document_lend_record_save() {
                $('yonda_document_lend_record_ln_ds').submit();
            }
            
            function yonda_document_lend_record_query() {
                $('yonda_document_lend_record_hd_ds').query();
            }
            
            function yonda_document_lend_record_reset() {
                $('con_contract_query_ds').reset();
            }
            
            //index发生改变，重新查询
            
            function yonda_document_lend_record_hd_ds_indexchange(ds, record) {
                $('yonda_document_lend_record_ln_ds').setQueryParameter('contract_id', record.get('contract_id'));
                $('yonda_document_lend_record_ln_ds').setQueryParameter('lend_header_id', record.get('lend_header_id'));
                $('yonda_document_lend_record_ln_ds').query();
            }
            
            function open_contract_win(record_id) {
                var record = $('yonda_document_lend_record_hd_ds').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');
            }
            
            function contract_number_renderer(value, record, name) {
                if (record.get('contract_id')) {
                    return '<a href="javascript:open_contract_win(' + record.id + ')">' + value + '<a>';
                }
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="con_contract_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="lend_header_id" defaultValue="${/parameter/@lend_header_id}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="yonda_document_lend_record_hd_ds" autoPageSize="true" autoQuery="true" model="cont.CON556.yonda_document_lend_record_hd" queryDataSet="con_contract_query_ds">
                <a:fields>
                    <a:field name="contract_number"/>
                </a:fields>
                <a:events>
                    <a:event name="indexchange" handler="yonda_document_lend_record_hd_ds_indexchange"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="yonda_document_lend_record_ln_ds" fetchAll="true" model="cont.CON556.yonda_document_lend_record_ln">
                <a:fields>
                    <a:field name="contract_number"/>
                    <a:field name="lend_flag" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="return_flag" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="return_date"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar/>
            <a:grid bindTarget="yonda_document_lend_record_hd_ds" height="200" marginWidth="80" navBar="true">
                <a:columns>
                    <a:column name="contract_number" prompt="合同编号" renderer="contract_number_renderer" width="150"/>
                    <a:column name="contract_name" prompt="合同名称" width="200"/>
                    <a:column name="borrower_name" prompt="借阅人名称" width="80"/>
                    <a:column name="borrower_phone" prompt="借阅人电话" width="100"/>
                    <a:column name="bp_name" prompt="承租人名称" width="200"/>
                    <!-- <a:column name="bp_type_desc" prompt="承租人类型" width="100"/> -->
                    <!-- <a:column name="lease_channel_desc" prompt="商业模式" width="100"/> -->
                    <a:column name="borrower_date" prompt="档案借出日期" renderer="Leaf.formatDate" width="100"/>
                    <!-- <a:column name="status_desc" prompt="状态" /> -->
                    <a:column name="ref_v01" prompt="出借理由" width="200"/>
                </a:columns>
            </a:grid>
            <a:grid id="yonda_document_lend_record_ln_grid" bindTarget="yonda_document_lend_record_ln_ds" marginHeight="450" marginWidth="80" navBar="true">
                <a:columns>
                    <a:column name="cdd_item_desc" prompt="文档名称" width="600"/>
                    <a:column name="lend_flag" prompt="是否借出" width="80"/>
                    <!-- <a:column name="return_flag" prompt="是否归还" width="80"/> -->
                    <!-- <a:column name="return_date" editor="yonda_document_lend_record_ln_grid_dp" prompt="归还日期" renderer="Leaf.formatDate" width="120"/> -->
                </a:columns>
                <a:editors>
                    <a:datePicker id="yonda_document_lend_record_ln_grid_dp"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
