<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ZLF  
    $Date: 2015-1-2 上午9:53:03  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure><![CDATA[
		
	]]></a:init-procedure>
    <a:view>
        <a:link id="branch_node_edit_link" url="${/request/@context_path}/modules/hls/HLS600/hls_branch_node_edit.lview"/>
        <a:link id="normal_node_edit_link" url="${/request/@context_path}/modules/hls/HLS600/hls_normal_node_edit.lview"/>
        <a:link id="node_verify_sql_link" url="${/request/@context_path}/modules/hls/HLS600/hls_branch_verify_sql.lview"/>
        <script type="text/javascript"><![CDATA[
			function hls600_reset() {
			    $('hls600_document_node_query_ds').reset();
			}
			
			function hls600_query() {
			    $('hls600_document_node_result_ds').query();
			}
			
			function hls600_save() {
			    if($('hls600_document_node_result_ds').validate()) {
			    	$('hls600_document_node_result_ds').submit();
			    }
			}
			
			function node_edit_renderer(value, record, name) {
			    var node_type = record.get('node_type');
			    if(node_type == 'NORMAL') {
			        return '<a href="javascript:winOpen_normal_node_edit(' + record.get('node_id') + ',\'' + node_type + '\')">编辑节点</a>';
			    }else if(node_type == 'BRANCH') {
			        return '<a href="javascript:winOpen_branch_node_edit(' + record.get('node_id') + ',\'' + node_type + '\')">编辑节点</a>';
			    }
			}
			
			function winOpen_normal_node_edit(node_id ,node_type) {
                var win = new Leaf.Window({
                    id: 'normal_node_edit_window',
                    url: $('normal_node_edit_link').getUrl(),
                    params: {
                    	node_id:node_id,
                    	node_type : node_type,
                    	workflow_id:'${/parameter/@workflow_id}'
                    },
                    title: '编辑节点',
                    fullScreen: true
                });
                win.on('close', function() {
                    refresh_nodeDs();
                });
                
            }
            
            function winOpen_branch_node_edit(node_id ,node_type) {
                var win = new Leaf.Window({
                    id: 'branch_node_edit_window',
                    url: $('branch_node_edit_link').getUrl(),
                    params: {
                    	node_id:node_id,
                    	node_type : node_type,
                    	workflow_id:'${/parameter/@workflow_id}'
                    },
                    title: '编辑节点',
                    fullScreen: true
                });
                win.on('close', function() {
                    refresh_nodeDs();
                });
                
            }
            
            function document_node_addHandler(ds,record,index) {
                record.set('node_type','NORMAL');
                record.set('node_type_desc','普通节点');
            }
            
            function verify_sql_renderer(value, record, name) {
		        if (!value){
                	return '<a  href="javascript:verify_sql_window_open(' + record.id +',\'' + name + '\')">' + '验证SQL' + '</a>';
                }else{
                    return '<a  href="javascript:verify_sql_window_open(' + record.id +',\'' + name + '\')">' + '<font color="#FF9900">验证SQL</font>' + '</a>';
                }
			}
			
			function verify_sql_window_open(id,name) {           
                var win = new Leaf.Window({
                    id: 'verify_sql_his_id',
                    params: {
                        record_id: id,
                        ds_name: 'hls600_document_node_result_ds',
                        name: name,
            
                        winId: 'verify_sql_his_id'
                    },
                    url: $('node_verify_sql_link').getUrl(),
                    title: '验证SQL',
                    width: 600,
                    height: 430,
                    draggable: true
                });
            }
		]]></script>
        <a:dataSets>
            <a:dataSet id="hls_document_node_type_ds" lookupCode="HLS_DOCUMENT_NODE_TYPE"/>
            <a:dataSet id="yes_or_no_ds" lookupCode="YES_NO"/>
            <a:dataSet id="hls600_document_node_query_ds">
                <a:fields>
                    <a:field name="node_desc"/>
                    <a:field name="node_type_desc" displayField="code_value_name" options="hls_document_node_type_ds" returnField="node_type" valueField="code_value"/>
                    <a:field name="enabled_flag"/>
                    <a:field name="enabled_flag_desc" displayField="code_value_name" options="yes_or_no_ds" returnField="enabled_flag" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls600_document_node_result_ds" autoPageSize="true" autoQuery="true" model="hls.HLS600.hls_document_node" queryDataSet="hls600_document_node_query_ds" selectable="true">
                <a:fields>
                    <a:field name="node_desc"/>
                    <a:field name="node_type"/>
                    <a:field name="node_type_desc" displayField="code_value_name" options="hls_document_node_type_ds" required="true" returnField="node_type" valueField="code_value"/>
                    <a:field name="enabled_flag" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="enabled_flag_desc" displayField="code_value_name" options="yes_or_no_ds" returnField="enabled_flag" valueField="code_value"/>
                    <a:field name="approved_sql"/>
                    <a:field name="condition_sql1"/>
                    <a:field name="condition_sql2"/>
                    <a:field name="condition_sql3"/>
                    <a:field name="condition_sql4"/>
                    <a:field name="condition_sql5"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="document_node_addHandler"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hls600_reset" text="重置"/>
                <a:gridButton click="hls600_query" text="HLS.QUERY"/>
                <a:gridButton click="hls600_save" text="保存"/>
            </a:screenTopToolbar>
            <a:form Width="500" column="2" title="查询条件">
                <a:textField name="node_desc" bindTarget="hls600_document_node_query_ds" prompt="节点描述"/>
                <!-- <a:comboBox name="node_type_desc" bindTarget="hls600_document_node_query_ds" prompt="节点类型"/> -->
                <a:comboBox name="enabled_flag_desc" bindTarget="hls600_document_node_query_ds" prompt="是否启用"/>
            </a:form>
            <a:grid id="hls_document_node_result_grid" bindTarget="hls600_document_node_result_ds" marginHeight="180" marginWidth="60" navBar="true">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button type="delete"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="node_seq" align="right" editor="nodeDs_grid_editor_nf_integer" prompt="节点序号" width="100"/>
                    <a:column name="node_desc" editor="nodeDs_grid_editor_tf" prompt="节点描述" width="200"/>
                    <a:column name="node_type_desc" align="center" prompt="节点类型" width="100"/>
                    <a:column name="enabled_flag" editor="nodeDs_grid_editor_check" prompt="启用标志" width="120"/>
                    <a:column name="approved_sql" align="center" autoAdjust="false" prompt="验证通过SQL" renderer="verify_sql_renderer" width="120"/>
                    <a:column name="condition_sql1" align="center" autoAdjust="false" prompt="条件SQL1" renderer="verify_sql_renderer" width="120"/>
                    <a:column name="condition_sql2" align="center" autoAdjust="false" prompt="条件SQL2" renderer="verify_sql_renderer" width="120"/>
                    <a:column name="condition_sql3" align="center" autoAdjust="false" prompt="条件SQL3" renderer="verify_sql_renderer" width="120"/>
                    <a:column name="condition_sql4" align="center" autoAdjust="false" prompt="条件SQL4" renderer="verify_sql_renderer" width="120"/>
                    <a:column name="condition_sql5" align="center" autoAdjust="false" prompt="条件SQL5" renderer="verify_sql_renderer" width="120"/>
                </a:columns>
                <a:editors>
                    <a:numberField id="nodeDs_grid_editor_nf_integer" allowDecimals="false" allowNegative="false"/>
                    <a:textField id="nodeDs_grid_editor_tf"/>
                    <a:comboBox id="nodeDs_grid_editor_comb"/>
                    <a:checkBox id="nodeDs_grid_editor_check"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
