<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:   zhangxing5129
    $Date: 2014-6-10 下午04:01:46  
    $Revision: 1.0  
    $Purpose: 模板分组定义
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="prj_cdd_item_tplt_multi_link" url="${/request/@context_path}/modules/hls/HLS220/prj_cdd_item_tplt_multi.lview"/>
        <a:link id="prj_cdd_item_tab_group_link" url="${/request/@context_path}/modules/hls/HLS220/prj_cdd_item_tab_group.lview"/>
        <script type="text/javascript"><![CDATA[
            function prj_cdd_item_tplt_group_define_back() {
                $('${/parameter/@winid}').close();
            }
            
            function cdd_item_ef(record, name) {
                if (record.isNew) {
                    return 'tplt_ln_lov';
                }
                return '';
            }
            
            function tplt_ln_multi_add() {
                var templet_head_id = '${/parameter/@templet_head_id}';
                if (templet_head_id) {
                    new Leaf.Window({
                        id: 'hls220_tplt_multi_win',
                        url: $('prj_cdd_item_tplt_multi_link').getUrl(),
                        params: {
                            winid: 'hls220_tplt_multi_win',
                            templet_head_id: templet_head_id
                        },
                        width: 650,
                        height: 550
                    });
                }
            }
            
            
            function prj_cdd_item_tplt_group_define_save() {
                $('prj_cdd_item_tplt_tab_group_ds').submit();
            }
            
            function tplt_group_ef(record, name) {
                if (Ext.isEmpty(record.get('tab_group_id'))) {
                    return 'tplt_group_tf';
                }
                return '';
            }
            
            function prj_cdd_item_tplt_tab_group_add(ds, record, index) {
               
                var current_record = $('prj_cdd_item_tab_group_query_ds').getCurrentRecord();
                if (!Ext.isEmpty(current_record) && current_record.get('tab_group_id')) {
                    record.set('tab_group_id', current_record.get('tab_group_id'));
                }else{
                    return false;
                }
            }
            
            function prj_cdd_item_tplt_group_define_add_group(){
                new Leaf.Window({
                    id:'prj_cdd_item_tab_group_win',
                    url:$('prj_cdd_item_tab_group_link').getUrl(),
                    params:{
                        'winid':'prj_cdd_item_tab_group_win'
                    },
                    width:650,
                    height:520
                });
            }
            
            function prj_cdd_item_tab_group_query_ds_update(ds,record,name,value,oldvalue){
                $('prj_cdd_item_tplt_tab_group_ds').query();
            }
            
            function prj_cdd_item_tab_group_query_ds_load(ds){
                $('prj_cdd_item_tplt_tab_group_ds').query();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="prj_cdd_item_tab_group_query_ds" autoQuery="true" model="hls.HLS220.prj_cdd_item_tab_group">
                <a:fields>
                    <a:field name="tab_group_id"/>
                    <a:field name="tab_group" lovGridHeight="400" lovHeight="530" lovService="hls.HLS220.prj_cdd_item_tab_group?enabled_flag=Y" lovWidth="480">
                        <a:mapping>
                            <a:map from="tab_group_id" to="tab_group_id"/>
                            <a:map from="tab_group" to="tab_group"/>
                            <a:map from="tab_group_name" to="tab_group_name"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="prj_cdd_item_tab_group_query_ds_update"/>
                    <a:event name="load" handler="prj_cdd_item_tab_group_query_ds_load"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="prj_cdd_item_tplt_tab_group_ds" fetchAll="true" model="hls.HLS220.prj_cdd_item_tplt_tab_group" queryDataSet="prj_cdd_item_tab_group_query_ds" queryUrl="${/request/@context_path}/autocrud/hls.HLS220.prj_cdd_item_tplt_tab_group/query?templet_header_id=${/parameter/@templet_head_id}" selectable="true">
                <a:fields>
                    <a:field name="templet_header_id" defaultValue="${/parameter/@templet_head_id}"/>
                    <a:field name="cdd_item" lovGridHeight="350" lovHeight="500" lovLabelWidth="100" lovService="hls.HLS220.prj_cdd_item_templet_for_lov?templet_head_id=${/parameter/@templet_head_id}" lovWidth="600" required="true">
                        <a:mapping>
                            <a:map from="cdd_item" to="cdd_item"/>
                            <a:map from="description" to="cdd_item_desc"/>
                            <a:map from="templet_head_name" to="templet_header_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="seq_num"/>
                    <a:field name="tab_group_id"/>
                    <a:field name="cdd_item_desc"/>
                    <a:field name="important_flag" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="prj_cdd_item_tplt_tab_group_add"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="prj_cdd_item_tplt_group_define_back" text="HLS.BACK"/>
                <a:gridButton click="prj_cdd_item_tplt_group_define_save" text="HLS.SAVE"/>
                <a:gridButton click="prj_cdd_item_tplt_group_define_add_group" text="分组管理"/>
            </a:screenTopToolbar>
            <a:form column="2" title="选择分组">
                <a:lov name="tab_group" bindTarget="prj_cdd_item_tab_group_query_ds" prompt="分组编号"/>
                <a:textField name="tab_group_name" bindTarget="prj_cdd_item_tab_group_query_ds" prompt="分组名称" readOnly="true" width="200"/>
            </a:form>
            <a:grid bindTarget="prj_cdd_item_tplt_tab_group_ds" marginHeight="180" marginWidth="30" navBar="true">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button type="clear"/>
                    <a:button type="delete"/>
                    <a:button click="tplt_ln_multi_add" icon="${/request/@context_path}/images/entity.png" text="批量新增"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="cdd_item" editorFunction="cdd_item_ef" prompt="资料编码" width="250"/>
                    <a:column name="cdd_item_desc" prompt="资料描述" width="250"/>
                    <a:column name="seq_num" align="right" editor="tplt_ln_nf" prompt="排序" width="50"/>
                    <a:column name="important_flag" editor="tplt_ln_cb" prompt="重要字段" width="50"/>
                    <a:column name="enabled_flag" align="center" editor="tplt_ln_cb" prompt="启用" width="50"/>
                </a:columns>
                <a:editors>
                    <a:checkBox id="tplt_ln_cb"/>
                    <a:lov id="tplt_ln_lov"/>
                    <a:numberField id="tplt_ln_nf" allowDecimals="false"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
