<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zyx 
    $Date: 2016-12-13 下午3:12:06
    $Revision: 1.0  
    $Purpose: 公告定义
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" dynamiccreateenabled="true" trace="true">
    <a:init-procedure><![CDATA[
	]]></a:init-procedure>
    <a:view>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <script type="text/javascript"><![CDATA[
	        //新增时调用(grid,table,gridBox)
	        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_add'] = function(ds, record, config_records, bp_seq) {
	            if ((ds.id).indexOf('hls_notice_definition') != -1) {
	                //开始时间校验

	                if (ds.fields.start_date) {
	                    ds.fields.start_date.pro.validator = start_date_validate;
	                }
	                //结束时间校验
	                if (ds.fields.end_date) {
	                    ds.fields.end_date.pro.validator = end_date_validate;
	                }
	            }
	        };
	        
	        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function(ds, record, config_records, bp_seq) {
            	if ((ds.id).indexOf('hls_notice_definition') != -1) {
	                //开始时间校验

	                if (ds.fields.start_date) {
	                    ds.fields.start_date.pro.validator = start_date_validate;
	                }
	                //结束时间校验
	                if (ds.fields.end_date) {
	                    ds.fields.end_date.pro.validator = end_date_validate;
	                }
	            }
         	};
	        
	        function start_date_validate(record, name, value) {
				var end_date = record.get('end_date');
				if(value > end_date){
				    return '开始时间不能晚于结束时间';
				}     
	            return true;
	        }
	            
	        function end_date_validate(record, name, value) {
				var start_date = record.get('start_date');   
				if(start_date > value){
				    return '开始时间不能晚于结束时间';
				}     
	            return true;
	        }
           window['${/parameter/@bp_seq}${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record, bp_seq) {
                var link_function = '';
                var hls_notice_definition_id = record.get('hls_notice_definition_id');
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                if (name == 'attachment') {
                    return '<a href="javascript:attachment_window_open(\'' + hls_notice_definition_id + '\',\'' + record.id + '\',\'' + record.ds.id + '\');">' + '附件' + '</a>';
                }
            };
            
            function attachment_window_open(hls_notice_definition_id,record_id,ds_id){

            	url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id').getUrl() + '?table_name=HLS_NOTICE_DEFINITION&header_id=' + hls_notice_definition_id;
            	wd = new Leaf.Window({
                	id: 'attachment_up_window',
                	url: url,
                	title: '附件上传',
                	height: 350,
                	width: 850
            	});
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
