<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-7-25 上午10:54:35  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query model="basic.sys_session_info" rootPath="con201_session_info"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con202_basic_clause_select_save_link" url="${/request/@context_path}/modules/cont/CON202/con_basic_clause_select_save.lsc"/>
        <script type="text/javascript"><![CDATA[
            function con202_basic_clause_select_result_ds_Onselect(ds, record, all) {
                if (!all) {
                    var parent_clause_id = record.get('clause_id'),
                    	records = ds.getAll();
                    for (var i = 0,length = records.length;i < length;i++) {
                        if (records[i].get('parent_clause_id') == parent_clause_id) {
                            ds.select(records[i]);
                        }
                    }
                }
            }
            
            function con202_basic_clause_select_result_ds_Onunselect(ds, record, all) {
                if (!all) {
                    var parent_clause_id = record.get('clause_id'),
                    	records = ds.getAll();
                    for (var i = 0,length = records.length;i < length;i++) {
                        if (records[i].get('parent_clause_id') == parent_clause_id) {
                            ds.unSelect(records[i]);
                        }
                    }
                }
            }

            
            function con202_basic_clause_select_confirm() {
                var records = $('con202_basic_clause_select_result_ds').getSelected();
                for (var i = 0;i < records.length;i++) {
                    records[i].set('templet_id', '${/parameter/@templet_id}');
                    records[i].set('_status', 'insert');
                }
                $('con202_basic_clause_select_result_ds').setSubmitParameter('templet_id', '${/parameter/@templet_id}');
                if (!Leaf.isEmpty('${/parameter/@parent_line_id}')) {
                    $('con202_basic_clause_select_result_ds').setSubmitParameter('parent_line_id', '${/parameter/@parent_line_id}');
                }
                $('con202_basic_clause_select_result_ds').submitSelected($('con202_basic_clause_select_save_link').getUrl());
            }
            
            function con202_basic_clause_select_result_ds_submitsuccess(ds) {
                $('con202_clause_templet_line_result_ds').query();
                $('con202_basic_clause_select_window').close();
            }
            
            function con202_basic_clause_select_close() {
                $('con202_basic_clause_select_window').close();
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con202_basic_clause_select_mplet_usage_ds" lookupCode="MPLET_USAGE"/>
            <a:dataSet id="con202_basic_clause_select_approval_status_ds" lookupCode="CON_TERMS_APPROVE_STATUS"/>
            <a:dataSet id="con202_basic_clause_select_enabled_status_ds" lookupCode="ENABLED_STATUS"/>
            <a:dataSet id="con202_basic_clause_select_query_ds">
                <a:fields>
                    <a:field name="clause_usage" defaultValue="${/parameter/@clause_usage}"/>
                    <a:field name="enabled_flag" defaultValue="Y"/>
                    <a:field name="approval_status" defaultValue="APPROVED"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con202_basic_clause_select_result_ds" autoCount="false" autoQuery="true" fetchAll="true" model="cont.CON201.con_basic_clause" queryDataSet="con202_basic_clause_select_query_ds" selectable="true">
                <a:fields>
                    <a:field name="clause_code" required="true"/>
                    <a:field name="description" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="select" handler="con202_basic_clause_select_result_ds_Onselect"/>
                    <a:event name="unselect" handler="con202_basic_clause_select_result_ds_Onunselect"/>
                    <a:event name="submitsuccess" handler="con202_basic_clause_select_result_ds_submitsuccess"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="con202_basic_clause_select_close" text="HLS.CLOSE" width="80"/>
                <a:gridButton click="con202_basic_clause_select_confirm" text="PROMPT.OK" width="80"/>
            </a:screenTopToolbar>
            <a:treeGrid id="con202_basic_clause_select_functionTreeGrid" bindTarget="con202_basic_clause_select_result_ds" expandField="expand_flag" height="360" idField="clause_id" parentField="parent_clause_id" sequenceField="order_seq" showCheckBox="false" width="465">
                <a:columns>
                    <a:column name="clause_code" prompt="CON201.CON_BASIC_CLAUSE.CLAUSE_CODE" width="260"/>
                    <a:column name="description" prompt="CON201.CON_BASIC_CLAUSE.CLAUSE_CODE" width="150"/>
                </a:columns>
            </a:treeGrid>
        </a:screenBody>
    </a:view>
</a:screen>
