<?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="yonda_document_lend_record_adds_link" url="${/request/@context_path}/modules/cont/CON556/yonda_document_lend_record_adds.lview"/>
        <a:link id="yonda_document_lend_record_add_links" url="${/request/@context_path}/modules/cont/CON556/yonda_document_lend_record_add_links.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 record=$('con_document_lend_record_hd_query_result_ds').getCurrentRecord();
                   // var lend_header_id=record.get('lend_header_id');
                    // // var status = record.get('status');
                // var add_win = new Leaf.Window({
                    // id: 'yonda_document_lend_record_adds_win',
                    // params: {
                        // 'winid': 'yonda_document_lend_record_adds_win',
                        // 'button_type': 'new',
                        // lend_header_id: lend_header_id
                    // },
                    // url: $('yonda_document_lend_record_adds_link').getUrl(),
                    // fullScreen: true
                // });
                // add_win.on('close', function() {
                    // $('con_document_lend_record_hd_query_result_ds').query();
                // });
            // }
            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',
                        'button_type': 'new'
                    },
                    url: $('yonda_document_lend_record_adds_link').getUrl(),
                    fullScreen: true
                });
                add_win.on('close', function() {
                    $('con_document_lend_record_hd_query_result_ds').query();
                });
            }
            
            function yonda_document_lend_record_save() {
                $('yonda_document_lend_record_ln_ds').submit();
                //var record = $('yonda_document_lend_record_ln_ds').getCurrentRecord()
                //var returnDateField = record.getMeta().getField("return_date");
                //returnDateField.setReadOnly(true);
            }
            
            function yonda_document_lend_record_query() {
                $('con_document_lend_record_hd_query_result_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>';
                }
            }
            
            function return_date_readOnly(record, name) {
            
                var returnDateField = record.getMeta().getField(name);
                if (record.get('return_flag') == 'N') returnDateField.setReadOnly(false);
                else returnDateField.setReadOnly(true);
                return "yonda_document_lend_record_ln_grid_dp";
            }
            
            function lend_record_hd_indexchange(ds, record) {
                var lend_header_id = record.get('lend_header_id');
                $('con_contract_lend_ds').setQueryParameter('lend_header_id', lend_header_id);
                $('con_contract_lend_ds').query();
            
            }
            
            function document_lend_record_maintenance(lend_header_id) {
                // var record=$('con_document_lend_record_hd_query_result_ds').getCurrentRecord();
                // var lend_header_id=record.get('lend_header_id');
                var add_win = new Leaf.Window({
                    id: 'yonda_document_lend_record_add_win',
                    params: {
                        'winid': 'yonda_document_lend_record_add_win',
                        lend_header_id: lend_header_id
                    },
                    url: $('yonda_document_lend_record_add_link').getUrl(),
                    fullScreen: true
                });
                add_win.on('close', function() {
                    $('con_document_lend_record_hd_query_result_ds').query();
                });
            }
            
             function document_lend_record_maintenances(lend_header_id) {

                // var record=$('con_document_lend_record_hd_query_result_ds').getCurrentRecord();
                // var lend_header_id=record.get('lend_header_id');
                var add_win = new Leaf.Window({
                    id: 'yonda_document_lend_record_add_wins',
                    params: {
                        'winid': 'yonda_document_lend_record_add_wins',
                        lend_header_id: lend_header_id
                    },
                    url: $('yonda_document_lend_record_add_links').getUrl(),
                    fullScreen: true
                });
                add_win.on('close', function() {
                    $('con_document_lend_record_hd_query_result_ds').query();
                });
            }
            
            function borrower_number_renderer(value, record, name) {
                if (name == 'borrower_number') {
                    var lend_header_id = record.get('lend_header_id');
                    var status_n=record.get('status_n');
                    //var status = record.get('status');
                   // if (status == 'NEW' || Ext.isEmpty(status)) {
                     //   return '<a href="javascript:document_lend_record_maintenance(' + lend_header_id + ');">' + value + '</a>';
            
                   // }
                   // return value;
                   if(status_n=='审批完成' || status_n=='审批中'){
                        return '<a href="javascript:document_lend_record_maintenances(' + lend_header_id + ');">' + value + '</a>';
                   }
                   return '<a href="javascript:document_lend_record_maintenance(' + lend_header_id + ');">' + value + '</a>';;
                }
            
            }
             function borrower_date_renderer(value, record, name) {
              var  status_n= record.get('status_n');
              var date=new Date();
                if (status_n=='审批中' && Leaf.formatDate(date)>Leaf.formatDate(value)) {
                    return "<font color='red'>" + Leaf.formatDate(value)+ "</font>";
              // return "<div style='background-color:#FF0000'>" + Leaf.formatDate(value)+ "</div>";
                }
                return Leaf.formatDate(value);
            
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=LEND&amp;function_code=CON556"/>
        <a:dataSets>
            <a:dataSet id="status_ds" lookupCode="CON556_WFL_STATUS"/>
            <a:dataSet id="borrow_type_query_ds" lookupCode="BORROW_TYPE"/>
            <a:dataSet id=""/>
            <a:dataSet id="return_flag_ds">
                <a:datas>
                    <a:record name="是" code="Y"/>
                    <a:record name="否" code="N"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="con_contract_query_ds">
                <a:fields>
                    <a:field name="borrower_number"/>
                    <a:field name="borrower_date_from"/>
                    <a:field name="borrower_date_to"/>
                    <!--                     <a:field name="status_desc" displayField="code_value_name" options="status_ds" returnField="status" valueField="code_value"/>
 -->
                    <a:field name="borrower_name"/>
                    <a:field name="status"/>
                    <a:field name="status_n" displayField="code_value_name" options="status_ds" returnField="status" valueField="code_value"/>
                    <a:field name="borrow_type"/>
                    <a:field name="borrow_type_n" displayField="code_value_name" options="borrow_type_query_ds" returnField="borrow_type" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_document_lend_record_hd_query_result_ds" autoQuery="true" model="cont.CON556.con_document_lend_record_hd_query" queryDataSet="con_contract_query_ds" selectable="true" selectionModel="single">
                <a:fields>
                    <a:field name="lend_header_id"/>
                    <a:field name="borrower_name"/>
                    <a:field name="borrower_phone"/>
                    <a:field name="borrower_date"/>
                    <a:field name="lender_name"/>
                    <a:field name="ref_v01"/>
                    <a:field name="ref_v02"/>
                    <a:field name="ref_v03"/>
                    <a:field name="ref_v04"/>
                    <a:field name="ref_v05"/>
                    <a:field name="ref_n01"/>
                    <a:field name="ref_n02"/>
                    <a:field name="ref_n03"/>
                    <a:field name="ref_n04"/>
                    <a:field name="ref_n05"/>
                    <a:field name="ref_d01"/>
                    <a:field name="ref_d02"/>
                    <a:field name="ref_d03"/>
                    <a:field name="ref_d04"/>
                    <a:field name="ref_d05"/>
                    <a:field name="status"/>
                    <a:field name="borrow_status"/>
                    <a:field name="instance_id"/>
                    <a:field name="express_number_out"/>
                    <a:field name="express_company_out"/>
                    <a:field name="express_address_out"/>
                    <a:field name="doc_out_time"/>
                    <a:field name="express_number_in"/>
                    <a:field name="express_company_in"/>
                    <a:field name="express_address_in"/>
                    <a:field name="doc_in_time"/>
                    <a:field name="email"/>
                    <a:field name="borrower_number"/>
                    <a:field name="borrow_type_n"/>
                    <a:field name="status_n"/>
                </a:fields>
                <a:events>
                    <a:event name="indexchange" handler="lend_record_hd_indexchange"/>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </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="docu_number"/>
                    <a:field name="chest_number"/>
                    <a:field name="doc_type"/>
                    <a:field name="contract_id"/>
                    <a:field name="doc_type_n"/>
                    <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:dataSet id="con_contract_lend_ds" autoQuery="true" queryUrl="${/request/@context_path}/autocrud/cont.CON556.con_contract_document_lend_record_ln/query" selectable="true">
                <a:fields>
                    <a:field name="contract_id"/>
                    <a:field name="contract_number"/>
                    <a:field name="contract_name"/>
                    <a:field name="bp_name"/>
                    <!--   <a:field name="bp_type_desc"/> -->
                    <a:field name="hls_lease_channel_desc"/>
                    <a:field name="reg_status"/>
                    <a:field name="archive_status"/>
                    <a:field name="business_type_desc"/>
                    <a:field name="invoice_agent_desc"/>
                    <a:field name="docu_number_reg"/>
                    <a:field name="docu_numberr_archive"/>
                    <a:field name="bp_class_desc"/>
                    <a:field name="archive_status_n"/>
                    <a:field name="reg_status_n"/>
                    <a:field name="division_desc"/>
                    <a:field/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="yonda_document_lend_record_add" text="HLS.NEW"/>
                <a:gridButton click="yonda_document_lend_record_save" text="HLS.SAVE"/>
                <a:gridButton click="yonda_document_lend_record_query" text="HLS.QUERY"/>
                <a:gridButton click="yonda_document_lend_record_reset" text="HLS.RESET"/>
                <!--  <a:gridButton click="document_lend_record_maintenance" text="维护"/> -->
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="120" marginWidth="30" title="查询条件">
                <a:textField name="borrower_number" bindTarget="con_contract_query_ds" prompt="调阅编号"/>
                <a:textField name="borrower_name" bindTarget="con_contract_query_ds" prompt="申请人"/>
                <a:datePicker name="borrower_date_from" bindTarget="con_contract_query_ds" prompt="预计归还日期从"/>
                <a:datePicker name="borrower_date_to" bindTarget="con_contract_query_ds" prompt="预计归还日期到"/>
                <a:comboBox name="status_n" bindTarget="con_contract_query_ds" prompt="工作流状态"/>
                <a:comboBox name="borrow_type_n" bindTarget="con_contract_query_ds" prompt="调阅类型"/>
            </a:form>
            <a:grid bindTarget="con_document_lend_record_hd_query_result_ds" height="270" marginWidth="30" navBar="true">
                <a:toolBar>
                    <a:button type="excel"/>
                    <a:button type="clear"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="borrower_number" prompt="调阅编号" renderer="borrower_number_renderer" width="150"/>
                    <a:column name="borrower_name" prompt="申请人" width="100"/>
                    <a:column name="borrower_phone" prompt="申请人联系方式" width="120"/>
                    <a:column name="borrower_date" prompt="预计归还时间" renderer="borrower_date_renderer" width="100"/>
                    <a:column name="lender_name_n" prompt="出借人" width="100"/>
                    <a:column name="ref_v01" prompt="出借理由" width="210"/>
                    <a:column name="ref_v02" prompt="邮寄地址" width="170"/>
                    <a:column name="borrow_type_n" prompt="调阅类型" width="100"/>
                    <a:column name="email" prompt="邮箱" width="140"/>
                    <a:column name="status_n" prompt="工作流"/>
                    <!--  <a:column name="instance_id" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.INSTANCE_ID" width="100"/>
                    <a:column name="express_number_out" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.EXPRESS_NUMBER_OUT" width="100"/>
                    <a:column name="express_company_out" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.EXPRESS_COMPANY_OUT" width="100"/>
                    <a:column name="express_address_out" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.EXPRESS_ADDRESS_OUT" width="100"/>
                    <a:column name="doc_out_time" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.DOC_OUT_TIME" width="100"/>
                    <a:column name="express_number_in" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.EXPRESS_NUMBER_IN" width="100"/>
                    <a:column name="express_company_in" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.EXPRESS_COMPANY_IN" width="100"/>
                    <a:column name="express_address_in" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.EXPRESS_ADDRESS_IN" width="100"/>
                    <a:column name="doc_in_time" prompt="YONDA_DOCUMENT_LEND_RECORD_HD.DOC_IN_TIME" width="100"/>
                     -->
                </a:columns>
            </a:grid>
            <a:grid bindTarget="con_contract_lend_ds" height="180" marginWidth="30" navBar="true">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button type="clear"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="contract_number" prompt="合同编号" width="200"/>
                    <!--   <a:column name="contract_name" prompt="合同名称" width="200"/> -->
                    <a:column name="bp_name" prompt="承租人名称" width="100"/>
                    <a:column name="invoice_agent_desc" prompt="代理商" width="100"/>
                    <a:column name="business_type_desc" prompt="业务类型" width="100"/>
                    <a:column name="division_desc" prompt="产品线" width="100"/>
                    <a:column name="bp_class_desc" prompt="客户类别" width="100"/>
                    <!--  <a:column name="bp_type_desc" prompt="承租人类型" width="120"/> -->
                    <a:column name="hls_lease_channel_desc" prompt="商业模式" width="120"/>
                    <!--    <a:column name="contract_id" prompt="承租人类型" width="120"/> -->
                    <!--   <a:column name="reg_status" prompt="文件类型" width="100"/>
                     <a:column name="archive_status" prompt="文件类型" width="100"/> -->
                    <a:column name="docu_numberr_archive" prompt="合同箱编号" width="120"/>
                    <a:column name="archive_status_n" prompt="合同归档状态" width="120"/>
                    <a:column name="reg_status_n" prompt="登记证归档状态" width="120"/>
                    <a:column name="docu_number_reg" prompt="登记证箱编号" width="120"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
