<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qianming  
    $Date: 2015-9-4 下午9:36:52  
    $Revision: 1.0  
    $Purpose: 公共模版维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="uploadFile_link_id" url="${/request/@context_path}/uploadFile.lview"/>
        <script type="text/javascript"><![CDATA[
        	function bgfl_common_template_query(){
        	    $('bgfl_common_template_result_ds').query();
        	}
        	function bgfl_common_template_reset(){
        	    $('bgfl_common_template_query_ds').reset();
        	}
        	function bgfl_common_template_edit_func(record,name){
        	    if(name === 'template_code' && record.isNew){
        	        return 'grid_id_textField_id';
        	    }
        	}
        	function open_upload_window(template_id){
        	    new Leaf.Window({
                    url: $('uploadFile_link_id').getUrl(),
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    params: {
                        'table_name': 'BGFL_COMMON_TEMPLATE',
                        'header_id': template_id
                    },
                    width: 850,
                    height: 400
                });
        	}
        	function bgfl_common_template_render_func(value,record,name){
        	    if(name === 'template_files' && !record.isNew){
        	        return '<a href="javascript:open_upload_window('+record.get('template_id')+')">上传</a>';
        	    }
        	}
		]]></script>
        <a:dataSets>
            <a:dataSet id="bgfl_common_template_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="template_code"/>
                    <a:field name="function_id"/>
                    <a:field name="function_name" lovGridHeight="305" lovHeight="450" lovService="fnd.FND6000.sys_function_v" lovWidth="600">
                        <a:mapping>
                            <a:map from="function_id" to="function_id"/>
                            <a:map from="function_name" to="function_name"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="bgfl_common_template_result_ds" autoPageSize="true" autoQuery="true" model="fnd.FND6000.bgfl_common_template" queryDataSet="bgfl_common_template_query_ds" selectable="true">
                <a:fields>
                    <a:field name="template_id"/>
                    <a:field name="template_code" required="true"/>
                    <a:field name="description" required="true"/>
                    <a:field name="function_id"/>
                    <a:field name="function_code" lovGridHeight="305" lovHeight="450" lovService="fnd.FND6000.sys_function_v" lovWidth="600" required="true">
                        <a:mapping>
                            <a:map from="function_id" to="function_id"/>
                            <a:map from="function_code" to="function_code"/>
                            <a:map from="function_name" to="function_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="function_name"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="bgfl_common_template_query" text="HLS.QUERY"/>
                <a:gridButton click="bgfl_common_template_reset" text="HLS.RESET"/>
                <a:gridButton bind="grid_id" type="add"/>
                <a:gridButton bind="grid_id" type="delete"/>
                <a:gridButton bind="grid_id" type="save"/>
            </a:screenTopToolbar>
            <a:form column="4" marginWidth="45" title="HLS.QUERY_TITLE">
                <a:textField name="template_code" bindTarget="bgfl_common_template_query_ds" prompt="模版编码"/>
                <a:textField name="description" bindTarget="bgfl_common_template_query_ds" prompt="模版描述"/>
                <a:lov name="function_name" bindTarget="bgfl_common_template_query_ds" prompt="所属功能"/>
                <a:comboBox name="enabled_flag_n" bindTarget="bgfl_common_template_query_ds" prompt="是否启用"/>
            </a:form>
            <a:grid id="grid_id" bindTarget="bgfl_common_template_result_ds" marginHeight="160" marginWidth="45" navBar="true">
                <a:columns>
                    <a:column name="template_code" editorFunction="bgfl_common_template_edit_func" prompt="模版编码" width="100"/>
                    <a:column name="description" editor="grid_id_textField_id" prompt="模版描述" width="300"/>
                    <a:column name="function_code" align="center" editor="grid_id_lov_id" prompt="所属功能编码" width="100"/>
                    <a:column name="function_name" prompt="所属功能名称" width="180"/>
                    <a:column name="template_files" align="center" prompt="模版" renderer="bgfl_common_template_render_func" width="80"/>
                    <a:column name="enabled_flag" align="center" editor="grid_id_checkBox_id" prompt="是否启用" width="60"/>
                </a:columns>
                <a:editors>
                    <a:textField id="grid_id_textField_id"/>
                    <a:lov id="grid_id_lov_id"/>
                    <a:checkBox id="grid_id_checkBox_id"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>