<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-2-26 下午2:37:49  
    $Revision: 1.0  
    $Purpose: tabColumn
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="bmLink_tabColumn_load" model="hls.HLS030.hls_doc_layout_config_load" modelaction="execute"/>
        <a:link id="bmLink_tabColumn_reload_selected" model="hls.HLS030.hls_doc_layout_config_load" modelaction="batch_update"/>
        <a:link id="hls_doc_layout_tab_column_validation_sql_link" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_tab_column_validation_sql.lview"/>
        <a:link id="layout_batch_copy_link" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_batch_copy.lview"/>
        <script type="text/javascript"><![CDATA[
        	var tab_gird_column_index=0;
            function tabColumn_query() {
                $('tabColumnDs').query();
            }
            
            function tabColumn_save() {
                var ds = $('tabColumnDs');
                if (ds.validate()) {
                    ds.submit();
                }
            }
            
            function tabColumn_close() {
                $('hls_doc_layout_tab_column').close();
            }
            
            function tabColumn_load() {
                Leaf.request({
                    url: $('bmLink_tabColumn_load').getUrl(),
                    para: {
                        layout_code: '${/parameter/@layout_code}',
                        tab_code: '${/parameter/@tab_code}'
                    },
                    success: function(res) {
                        Leaf.SideBar.show({
                            msg: '${l:HLS.SUBMIT_SUCCESS}',
                            duration: 2000
                        });
                        $('tabColumnDs').query();
                    },
                    scope: this
                });
            }
            
            function tabColumn_reload_selected() {
                var records = $('tabColumnDs').getSelected();
            
                if (records.length == 0) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                }
            
                var datas = [];
                for (var i = 0;i < records.length;i++) {
                    datas[i] = {
                        config_id: records[i].get('config_id'),
                        layout_code: '${/parameter/@layout_code}',
                        _status: 'update'
                    };
                }
            
                Leaf.request({
                    url: $('bmLink_tabColumn_reload_selected').getUrl(),
                    para: datas,
                    success: function(res) {
                        Leaf.SideBar.show({
                            msg: '${l:HLS.SUBMIT_SUCCESS}',
                            duration: 2000
                        });
                        tabColumn_query();
                    },
                    scope: this
                });
            }
            
            function onSubmitSuccess_tabColumnDs(ds) {
                //ds.query();
            }
            
            function tabColumn_add() {
                var ds = $('tabColumnDs');
                var record = ds.create(ds.currentIndex);
                if(tab_gird_column_index==0){
	            	$('tabColumnDs_grid').showEditorByRecord(record);
	            }else{
	            	$('tabColumnDs_grid2').showEditorByRecord(record);
	            }
            }
            
            function hls_doc_layout_tab_column_select(tab,index){
	            tab_gird_column_index=index;
	        }
            
            function editorFun_tabColumnDs_grid(record, name) {
                if (record.isNew) {
                    if (name == 'column_name') {
                        return 'tabColumnDs_grid_tf_upper';
                    }
                    if (name == 'data_type_display') {
                        return 'tabColumnDs_grid_comb';
                    }
            
                }
                return '';
            }
            
            function editorFun_tabColumnDs_grid2(record, name) {
                if(name=='field_javascript')
                {
                    record.getField(name).setLovPara('record_id',record.id);
                    return 'tabColumnDs_grid_lov2';
                }
                if (record.isNew) {
                    if (name == 'column_name') {
                        return 'tabColumnDs_grid_tf_upper2';
                    }
                    if (name == 'data_type_display') {
                        return 'tabColumnDs_grid_comb2';
                    }
            
                }
                return '';
            }
            
            function tabColumn_clear() {
                $('tabColumnDs_grid').clear();
                $('tabColumnDs_grid2').clear();
            }
            
            function tabColumn_remove() {
                var ds = $('tabColumnDs');
                var records = ds.getSelected();
                if (records.length != 0) {
                    Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS030.CONFIRM_DELETE}', function() {
                        ds.remove(records);
                    });
                }
            
            }
            
            function validate_code(record, name, value) {
                var reg = /^[_0-9A-Z]*$/;
                if (!reg.test(value)) {
                    return '${l:HLS050.VALIDATOR.CHARACTER_LIMIT}' + '_0-9A-Z';
                }
                return true;
            }
            
            function hls030_sontab1_gridcellclick(grid, row, name, record) {
                record.getField('validation_sql').setLovUrl($('hls_doc_layout_tab_column_validation_sql_link').getUrl() + '?record_id=' + record.id);
            }
            function layout_batch_copy(){
                var records = $('tabColumnDs').getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                }
                new Leaf.Window({
                    id: 'hls_layout_copy_screen',
                    url: $('layout_batch_copy_link').getUrl(),
                    params: {
                        layout_code: records[0].get('layout_code'),
                        config_id: records[0].get('config_id')
                    },
                    title: '布局拷贝',
                    width: 800,
                    height: 500
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="tabColumn_alignmentDs" lookupCode="HLS050_ALIGNMENT"/>
            <a:dataSet id="tabColumn_inputModeDs" lookupCode="HLS050_INPUT_MODE"/>
            <a:dataSet id="tabColumn_enabled_status_ds" lookupCode="ENABLED_STATUS"/>
            <a:dataSet id="tabColumn_validationTypeDs" lookupCode="HLS050_VALIDATION_TYPE"/>
            <a:dataSet id="tabColumn_dataTypeDs" lookupCode="HLS050_DATA_TYPE"/>
            <a:dataSet id="para_tabColumnDs" autoCreate="true" model="hls.HLS030.hls_doc_layout_config">
                <a:fields>
                    <a:field name="column_name"/>
                    <a:field name="data_type_display" displayField="code_value_name" options="tabColumn_dataTypeDs" returnField="data_type" valueField="code_value"/>
                    <a:field name="enabled_flag_des" displayField="code_value_name" options="tabColumn_enabled_status_ds" returnField="enabled_flag" valueField="code_value"/>
                    <a:field name="enabled_flag" defaultValue="Y"/>
                    <a:field name="validation_type_display" displayField="code_value_name" options="tabColumn_validationTypeDs" returnField="validation_type" valueField="code_value"/>
                    <a:field name="input_mode_display" displayField="code_value_name" options="tabColumn_inputModeDs" returnField="input_mode" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="tabColumnDs" autoQuery="true" fetchAll="true" model="hls.HLS030.hls_doc_layout_config" queryDataSet="para_tabColumnDs" queryUrl="${/request/@context_path}/autocrud/hls.HLS030.hls_doc_layout_config/query?tab_code=${/parameter/@tab_code}&amp;layout_code=${/parameter/@layout_code}" selectable="true">
                <a:fields>
                    <a:field name="footerrenderer" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="column_name" required="true" validator="validate_code"/>
                    <a:field name="config_id"/>
                    <a:field name="tab_code" defaultValue="${/parameter/@tab_code}"/>
                    <a:field name="layout_code" defaultValue="${/parameter/@layout_code}"/>
                    <a:field name="data_type_display" displayField="code_value_name" options="tabColumn_dataTypeDs" returnField="data_type" valueField="code_value"/>
                    <a:field name="input_mode_display" displayField="code_value_name" options="tabColumn_inputModeDs" returnField="input_mode" valueField="code_value"/>
                    <a:field name="validation_type_display" displayField="code_value_name" options="tabColumn_validationTypeDs" required="true" returnField="validation_type" valueField="code_value"/>
                    <a:field name="system_flag" checkedValue="Y" defaultValue="N" readOnly="true" uncheckedValue="N"/>
                    <a:field name="display_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="copy_from_parent_tab" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="key_field_flag" checkedValue="Y" defaultValue="N" readOnly="true" uncheckedValue="N"/>
                    <a:field name="lov_return_vcode" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="zero_fill" checkedValue="TRUE" defaultValue="FALSE" uncheckedValue="FALSE"/>
                    <a:field name="allow_format" checkedValue="TRUE" defaultValue="FALSE" uncheckedValue="FALSE"/>
                    <a:field name="allow_decimal" checkedValue="TRUE" defaultValue="FALSE" uncheckedValue="FALSE"/>
                    <a:field name="percent" checkedValue="%" defaultValue="" uncheckedValue=""/>
                    <a:field name="alignment_display" displayField="code_value_name" options="tabColumn_alignmentDs" returnField="alignment" valueField="code_value"/>
                    <a:field name="validation_sql" lovHeight="430" lovWidth="580" title="HLS050.HLS_FIN_CALC_CONFIG.VALIDATION_SQL"/>
                    <a:field name="field_javascript" lovHeight="500" lovUrl="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_large_content.lview?ds_name=tabColumnDs&amp;name=field_javascript" lovWidth="850">
                        <a:mapping>
                            <a:map from="text_content" to="field_javascript"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="onSubmitSuccess_tabColumnDs"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="tabColumn_close" text="HLS.CLOSE"/>
                <a:gridButton click="tabColumn_query" text="HLS.QUERY"/>
                <a:gridButton click="tabColumn_add" text="HLS.NEW"/>
                <a:gridButton click="tabColumn_remove" text="HLS.REMOVE"/>
                <a:gridButton click="tabColumn_clear" text="HLS.CLEAR"/>
                <a:gridButton click="tabColumn_save" text="HLS.SAVE"/>
                <a:gridButton click="tabColumn_load" text="HLS050.BUTTON.LOAD"/>
                <a:gridButton click="tabColumn_reload_selected" text="HLS050.BUTTON.RELOAD"/>
                <a:gridButton click="layout_batch_copy" text="复制字段"/>
            </a:screenTopToolbar>
            <a:form column="5" labelSeparator=" ">
                <a:textField name="column_name" bindTarget="para_tabColumnDs"/>
                <a:comboBox name="data_type_display" bindTarget="para_tabColumnDs"/>
                <a:comboBox name="validation_type_display" bindTarget="para_tabColumnDs"/>
                <a:comboBox name="input_mode_display" bindTarget="para_tabColumnDs"/>
                <a:comboBox name="enabled_flag_des" bindTarget="para_tabColumnDs" prompt="HLS050.HLS_FIN_CALC_CONFIG.ENABLED_FLAG"/>
            </a:form>
            <a:tabPanel marginHeight="150" marginWidth="30">
                <a:tabs>
                    <a:tab id="hls030_sontab1_id" prompt="HLS030.HLS_DOC_LAYOUT_TAB.BASIC_INFORMATION" width="100">
                        <a:grid id="tabColumnDs_grid" bindTarget="tabColumnDs" marginHeight="200" marginWidth="50">
                            <a:columns>
                                <a:column name="column_name" autoAdjust="false" editorFunction="editorFun_tabColumnDs_grid" width="150"/>
                                <a:column name="prompt" autoAdjust="false" editor="tabColumnDs_grid_tf" width="100"/>
                                <a:column name="data_type_display" autoAdjust="false" editorFunction="editorFun_tabColumnDs_grid" width="50"/>
                                <a:column name="system_flag" autoAdjust="false" editor="tabColumnDs_grid_check" width="30"/>
                                <a:column name="enabled_flag" autoAdjust="false" editor="tabColumnDs_grid_check" width="30"/>
                                <a:column name="display_flag" autoAdjust="false" editor="tabColumnDs_grid_check" width="30"/>
                                <a:column name="display_order" align="right" autoAdjust="false" editor="tabColumnDs_grid_tf" width="40"/>
                                <a:column name="input_mode_display" autoAdjust="false" editor="tabColumnDs_grid_comb" width="60"/>
                                <a:column name="validation_type_display" autoAdjust="false" editor="tabColumnDs_grid_comb" width="60"/>
                                <a:column name="allow_decimal" autoAdjust="false" editor="tabColumnDs_grid_check" width="35"/>
                                <a:column name="precision" align="right" autoAdjust="false" editor="tabColumnDs_grid_integer_nf" width="30"/>
                                <a:column name="zero_fill" autoAdjust="false" editor="tabColumnDs_grid_check" width="30"/>
                                <a:column name="allow_format" autoAdjust="false" editor="tabColumnDs_grid_check" width="40"/>
                                <a:column name="key_field_flag" autoAdjust="false" editor="tabColumnDs_grid_check" width="60"/>
                                <a:column name="percent" align="right" autoAdjust="false" editor="tabColumnDs_grid_check" width="40"/>
                                <a:column name="alignment_display" autoAdjust="false" editor="tabColumnDs_grid_comb" width="60"/>
                                <a:column name="width" align="right" autoAdjust="false" editor="tabColumnDs_grid_integer_nf" width="35"/>
                                <a:column name="validation_sql" autoAdjust="false" editor="tabColumnDs_grid_lov" width="100"/>
                                <a:column name="default_value" autoAdjust="false" editor="tabColumnDs_grid_tf" width="60"/>
                            </a:columns>
                            <a:editors>
                                <a:textField id="tabColumnDs_grid_tf_upper" maxLength="30" typeCase="upper"/>
                                <a:textField id="tabColumnDs_grid_tf"/>
                                <a:comboBox id="tabColumnDs_grid_comb"/>
                                <a:lov id="tabColumnDs_grid_lov"/>
                                <a:checkBox id="tabColumnDs_grid_check"/>
                                <a:numberField id="tabColumnDs_grid_integer_nf" allowDecimals="false"/>
                                <a:numberField id="tabColumnDs_grid_nf" allowDecimals="false"/>
                            </a:editors>
                            <a:events>
                                <a:event name="cellclick" handler="hls030_sontab1_gridcellclick"/>
                            </a:events>
                        </a:grid>
                    </a:tab>
                    <a:tab id="hls030_sontab2_id" prompt="HLS030.HLS_DOC_LAYOUT_TAB.ADDITIONAL_INFORMATION" width="100">
                        <a:grid id="tabColumnDs_grid2" bindTarget="tabColumnDs" marginHeight="200" marginWidth="50">
                            <a:columns>
                                <a:column name="column_name" autoAdjust="false" editorFunction="editorFun_tabColumnDs_grid2" width="150"/>
                                <a:column name="prompt" autoAdjust="false" editor="tabColumnDs_grid_tf2" width="100"/>
                                <a:column name="data_type_display" autoAdjust="false" editorFunction="editorFun_tabColumnDs_grid2" width="50"/>
                                <!-- <a:column name="lower_limit" align="right" autoAdjust="false" editor="tabColumnDs_grid_nf2" width="70"/>
                                <a:column name="upper_limit" align="right" autoAdjust="false" editor="tabColumnDs_grid_nf2" width="70"/> -->
                                <a:column name="lov_return_vcode" autoAdjust="false" editor="tabColumnDs_grid_check2" width="80"/>
                                <a:column name="copy_from_parent_tab" editor="tabColumnDs_grid_check2" width="100"/>
                                <a:column name="height" editor="tabColumnDs_grid_hegiht_nf2" width="100"/>
                                <a:column name="footerrenderer" editor="tabColumnDs_grid_check2"/>
                                <a:column name="lov_cascade_para1" editor="tabColumnDs_grid_tf_upper2"/>
                                <a:column name="lov_cascade_para2" editor="tabColumnDs_grid_tf_upper2"/>
                                <a:column name="lov_cascade_para3" editor="tabColumnDs_grid_tf_upper2"/>
                                <a:column name="field_javascript" autoAdjust="false" editorFunction="editorFun_tabColumnDs_grid2" showTitle="true" width="200"/>
                            </a:columns>
                            <a:editors>
                                <a:lov id="tabColumnDs_grid_lov2"/>
                                <a:textField id="tabColumnDs_grid_tf_upper2" maxLength="30" typeCase="upper"/>
                                <a:comboBox id="tabColumnDs_grid_comb2"/>
                                <a:textField id="tabColumnDs_grid_tf2"/>
                                <a:checkBox id="tabColumnDs_grid_check2"/>
                                <a:numberField id="tabColumnDs_grid_hegiht_nf2" allowDecimals="false" allowNegative="false"/>
                                <a:numberField id="tabColumnDs_grid_nf2" allowDecimals="false"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                </a:tabs>
                <a:events>
                    <a:event name="select" handler="hls_doc_layout_tab_column_select"/>
                </a:events>
            </a:tabPanel>
        </a:screenBody>
    </a:view>
</a:screen>
