<?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"/>
        <script type="text/javascript"><![CDATA[
        	
        	grid_data_is_read_only = false;
        	
            function ds_load(){
                var ds = $('con_visit_report_hds_result_ds');
                if(ds.getAt(0)){
                    var rec = ds.getAt(0);
                    var status = rec.get('wfl_status_n');
                    if(status == '审批中' || status =="审批通过"){
                        grid_data_is_read_only = true;
                    }
                }
                
            }
        	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() {
    		    // if(grid_data_is_read_only){
    		        // Leaf.showMessage('${l:PROMPT}', '只有新建或审批拒绝的报告才能修改！');
    		        // return ;
    		    // }
    		    // $('con_visit_report_hds_result_ds').submit();
    		// }
    		
    		// function con_visit_report_hds_remove(){
    		    // if(grid_data_is_read_only){
    		        // Leaf.showMessage('${l:PROMPT}', '只有新建或审批拒绝的报告才能删除！');
    		        // return ;
    		    // }
    		    // $('con_visit_report_hds_grid').remove();
    		// }
    		// function con_visit_report_hds_new(){
    		    // if(grid_data_is_read_only){
    		        // Leaf.showMessage('${l:PROMPT}', '只有新建或审批拒绝的报告才能新增！');
    		        // return ;
    		    // }
    		    // 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;
                    param['function_usage'] = 'QUERY';
                    param['function_code'] = 'CON801F';
                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 con810_close(){
    		$('${/parameter/@win_id}').close();
    	}
    		
		]]></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="${/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:event name="load" handler="ds_load"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:toolbarButton click="con810_close" text="HLS.CLOSE"/>
                <a:gridButton id="btn_query" click="con_visit_report_hds_query" text="HLS.QUERY"/>
                <!-- <a:gridButton id="btn_reset" click="con_visit_report_hds_reset" text="HLS.RESET"/> -->
                <!--                 <a:gridButton id="btn_new" click="con_visit_report_hds_new" text="HLS.NEW"/>
                <a:gridButton id="btn_remove" click="con_visit_report_hds_remove" text="HLS.REMOVE"/>
                <a:gridButton id="btn_save" click="con_visit_report_hds_save" text="HLS.SAVE"/> -->
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="120" marginWidth="30" title="HLS.QUERY_TITLE">
                <a:textField name="visit_report_desc" bindTarget="con_visit_report_hds_query_ds" prompt="CON801.VISIT_REPORT_DESC"/>
                <a:lov name="bp_name" bindTarget="con_visit_report_hds_query_ds" prompt="HLS.TENANT_CODE">
                    <a:events>
                        <a:event name="focus" handler="function(object){on_std_focus(object,&apos;BP&apos;)}"/>
                    </a:events>
                </a:lov>
                <a:comboBox name="visit_method_desc" bindTarget="con_visit_report_hds_query_ds" prompt="检查方式"/>
                <a:datePicker name="visit_date" bindTarget="con_visit_report_hds_query_ds" prompt="检查日期"/>
            </a:form>
            <a:grid id="con_visit_report_hds_grid" bindTarget="con_visit_report_hds_result_ds" marginHeight="200" marginWidth="30" 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>
