<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyu  
    $Date: 2015-12-06 下午14:57:33  
    $Revision: 1.0  
    $Purpose: 批量借款合同调息
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="batch_adjust_detail_link" url="${/request/@context_path}/modules/cont/CON801Q/con_visit_report_hds.lview"/>
        <a:link id="con801_attach_upload_link" url="${/request/@context_path}/downloadFile.lview"/>
        <script type="text/javascript"><![CDATA[
            function query_bacth_adjust_hd() {
                $('bacth_adjust_hd_ds').query();
            }
            
            function open_detail(value, record, name) {
                if (record.isNew) {
                    return '';
                } else {
                    var batch_id = record.get('batch_id');
                    if(name == 'detail'){
                        return '<a href="javascript:showDetail(' + value + ', '+batch_id+' );">' + '明细'+ '</a>';
                    }
                    
                    
                }
            
            }
            
            function showDetail(batch_hd_id ,batch_id) {
                new Leaf.Window({
                    id: 'batch_adjust_detail_winid',
                    url: $('batch_adjust_detail_link').getUrl(),
                    params: {
                        batch_hd_id: batch_hd_id,
                        batch_id :batch_id ,
                        win_id: 'batch_adjust_detail_winid'
                    },
                    title: '资产检查',
                    fullScreen: true
                }).on('close', function() {
                    $('bacth_adjust_hd_ds').query();
                });
            }
            
         
            function batch_adjust_grid_query(){
                $('bacth_adjust_hd_ds').query();
            }
            
           
            
            function attach_upload_win(batch_id){
                var url = $('con801_attach_upload_link').getUrl() + '?table_name=SDIC_CON_VISIT_REPORT_BATCH&header_id='+batch_id;
                new Leaf.Window({
                    url: url,
                    title: '附件下载',
                    id: 'con_visit_hd_win',
                    width: 850,
                    height: 400
                });
	      }
            
            function open_attach(value,record,name){
                if(!Ext.isEmpty(record.get('batch_id'))||!record.isNew){
	              return '<a href="javascript:attach_upload_win('+record.get('batch_id')+')">'+'附件下载'+'</a>';
	          }
            }
            
        ]]></script>
        <a:dataSets>
            <a:dataSet id="approval_status_ds" lookupCode="CON801_WFL_STATUS"/>
            <a:dataSet id="bacth_adjust_hd_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="batch_number"/>
                    <a:field name="batch_name"/>
                    <a:field name="batch_description"/>
                    <a:field name="status"/>
                    <a:field name="status_n" displayField="code_value_name" options="approval_status_ds" returnField="status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="bacth_adjust_hd_ds" autoPageSize="true" autoQuery="true" model="cont.CON801Q.sdic_con_visit_report_batch" queryDataSet="bacth_adjust_hd_query_ds">
                <a:fields>
                    <a:field name="batch_id"/>
                    <a:field name="batch_name"/>
                    <a:field name="batch_number"/>
                    <a:field name="batch_description"/>
                    <a:field name="visit_date"/>
                    <a:field name="status"/>
                    <a:field name="status_n" displayField="code_value_name" options="approval_status_ds" returnField="status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="batch_adjust_grid_query" text="查询"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="100" marginWidth="100" title="查询">
                <a:textField name="batch_number" bindTarget="bacth_adjust_hd_query_ds" prompt="编号"/>
                <a:comboBox name="status_n" bindTarget="bacth_adjust_hd_query_ds" prompt="审批状态"/>
                <a:textField name="batch_name" bindTarget="bacth_adjust_hd_query_ds" prompt="名称"/>
                <a:textField name="batch_description" bindTarget="bacth_adjust_hd_query_ds" prompt="描述"/>
            </a:form>
            <a:grid id="batch_adjust_grid" Height="440" bindTarget="bacth_adjust_hd_ds" marginWidth="100" navBar="true">
                <a:columns>
                    <a:column name="batch_number" align="center" prompt="编号" width="170"/>
                    <a:column name="batch_name" prompt="名称" width="250"/>
                    <a:column name="batch_description" prompt="描述"/>
                    <a:column name="status_n" align="center" prompt="审批状态"/>
                    <a:column name="visit_date" align="center" prompt="检查日期" renderer="Leaf.formatDate"/>
                    <a:column name="detail" align="center" prompt="明细" renderer="open_detail" width="170"/>
                    <a:column name="batch_attach" align="center" prompt="检查报告" renderer="open_attach" width="100"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
