<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-1-3 下午02:33:27  
    $Revision: 1.0  
    $Purpose: 回访报告维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="fc.company_id=${/session/@company_id}" fetchAll="true" model="fnd.fnd_companies" rootPath="default_company_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="prj_chance_con_contract_update_link_id" url="${/request/@context_path}/modules/nanshan_all_layout.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con801_attach_download_link" url="${/request/@context_path}/downloadFile.lview"/>
        <script type="text/javascript"><![CDATA[
            
        	function con_visit_report_hds_query(){
    	    	$('con_visit_report_hds_result_ds').query();
        	}
        	
        	function con_visit_report_hds_reset(){
        	    $('con_visit_report_hds_query_ds').reset();
        	}
        	
    		function con_visit_report_hds_save() {
    		    $('con_visit_report_hds_result_ds').submit();
    		}
    		
    		function con_visit_report_hds_remove(){
    		    $('con_visit_report_hds_grid').remove();
    		}
    		function con_visit_report_hds_new(){
    		    var record = $('con_visit_report_hds_temp_ds').getCurrentRecord();
                    record.set('function_code','CON801');
	                record.set('function_usage', 'CREATE');
	                record.set('document_category', 'VISIT_REPORT');
	                record.set('batch_id','${/parameter/@batch_id}');
	                record.set('save_path', 'CHANCE_REPROT_PATH');
	                record.set('default_value_dsid', 'con_visit_report_hds_temp_ds');
	                record.data['url_title']='资产检查报告维护';
	                var param = record.data;
	                hls_doc_get_layout_code('con_contract_get_layout_code_link_id',param,'prj_chance_con_contract_update_link_id','con_visit_report_hds_result_ds');
    		    
    		}
    		
    		function visit_detail_renderer(value,record,name){
    		    var visit_report_id = record.get('visit_report_id');
    		    if(!Ext.isEmpty(visit_report_id) && name === 'visit_detail'){
    		        return '<a href="javascript:open_detail_window('+record.id+')">'+'${l:PROMPT.DETAIL}'+'</a>';
    		    }else if(name === 'visit_report_desc'){
    		        return '<a href="javascript:open_detail_window('+record.id+')">'+value+'</a>';
    		    }
    		}
    		
    		function open_detail_window(id){
    			var current_record = $('con_visit_report_hds_result_ds').findById(id);
                var param = current_record.data;
                if(current_record.get('wfl_status') !== 'NEW' && current_record.get('wfl_status') !== 'REJECT'){
                    param['function_usage'] = 'QUERY';
                    param['function_code'] = 'CON801F';
                }else{
                    param['function_code'] = 'CON801';
                    param['function_usage'] = 'MODIFY';
                }
                param['save_path'] = 'CHANCE_REPROT_PATH';
                param['document_id'] = current_record.get('visit_report_id');
                param['maintain_type'] = 'VISIT_REPORT';
                param['url_title'] = '${l:CON801.VISIT_REPORT_MODIFY}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'prj_chance_con_contract_update_link_id', 'con_visit_report_hds_result_ds');
            }
    		
    		
    		function attach_detail(){
    		    var batch_id = '${/parameter/@batch_id}';
    		    var url = $('con801_attach_download_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
                });
    		}
		]]></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=VISIT_REPORT&amp;function_code=CON801"/>
        <a:dataSets>
            <a:dataSet id="con_visit_method_ds" lookupCode="CON_VISIT_METHOD"/>
            <a:dataSet id="con_visit_result_ds" lookupCode="CON_VISIT_RESULT"/>
            <a:dataSet id="con_visit_report_hds_temp_ds" autoCreate="true">
                <a:fields>
                    <a:field name="company_id" defaultValue="${/model/default_company_path/record/@company_id}"/>
                    <a:field name="company_id_n" defaultValue="${/model/default_company_path/record/@company_full_name}"/>
                    <a:field name="owner_user_id"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_visit_report_hds_query_ds">
                <a:fields>
                    <a:field name="visit_report_desc"/>
                    <a:field name="tenant_id"/>
                    <a:field name="bp_name" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="500">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_id" to="tenant_id"/>
                        </a:mapping>
                    </a:field>
                    <!-- <a:field name="batch_id" defaultValue="${@batch_id}"/> -->
                    <a:field name="batch_id" defaultValue="${/parameter/@batch_id}"/>
                    <a:field name="visit_method"/>
                    <a:field name="visit_method_desc" displayField="code_value_name" options="con_visit_method_ds" returnField="visit_method" valueField="code_value"/>
                    <a:field name="visit_date"/>
                    <a:field name="visit_result"/>
                    <a:field name="visit_result_desc" displayField="code_value_name" options="con_visit_result_ds" returnField="visit_result" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_visit_report_hds_result_ds" autoQuery="true" model="cont.CON801.con_visit_report_hds" pageSize="15" queryDataSet="con_visit_report_hds_query_ds" selectable="true">
                <a:fields>
                    <a:field name="document_category" defaultValue="VISIT_REPORT"/>
                    <a:field name="visit_report_desc"/>
                    <a:field name="tenant_id"/>
                    <a:field name="bp_name" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov?bp_category=TENANT" lovWidth="500">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_id" to="tenant_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="batch_id" defaultValue="${/parameter/@batch_id}"/>
                    <a:field name="visit_method"/>
                    <a:field name="visit_method_desc" displayField="code_value_name" options="con_visit_method_ds" returnField="visit_method" valueField="code_value"/>
                    <a:field name="visit_date"/>
                    <a:field name="visit_result"/>
                    <a:field name="visit_result_desc" displayField="code_value_name" options="con_visit_result_ds" returnField="visit_result" valueField="code_value"/>
                </a:fields>
                <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:toolbarButton className="item-rbtn-blue print" click="attach_detail" text="检查报告"/>
            </a:screenTopToolbar>
            <a:grid id="con_visit_report_hds_grid" Height="280" bindTarget="con_visit_report_hds_result_ds" marginWidth="100" navBar="true">
                <a:columns>
                    <!-- <a:column name="visit_report_desc" lock="true" prompt="CON801.VISIT_REPORT_DESC" renderer="visit_detail_renderer" width="250"/> -->
                    <a:column name="bp_name" lock="true" prompt="HLS.TENANT_CODE" width="200"/>
                    <a:column name="visit_date" prompt="检查日期" renderer="Leaf.formatDate" width="80"/>
                    <a:column name="visit_method_desc" align="center" prompt="检查方式"/>
                    <!--  <a:column name="wfl_status_n" align="center" prompt="状态" width="80"/> -->
                    <a:column name="visit_detail" align="center" prompt="检查明细" renderer="visit_detail_renderer" width="80"/>
                    <a:column name="check_result_desc" align="left" prompt="检查结果说明" width="450"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
