<?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="hls_doc_layout_column_lov_validation_link" url="${/request/@context_path}/modules/hls/HLS030N/hls_doc_layout_column_lov_validation.lview"/>
        <a:link id="layout_batch_copy_link" url="${/request/@context_path}/modules/hls/HLS030N/hls_doc_layout_batch_copy.lview"/>
        <a:link id="field_javascript_link" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_large_content.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 field_javascript_window_open(id) {
                var win = new Leaf.Window({
                    id: 'field_javascript_id',
                    params: {
                        record_id: id,
                        ds_name: 'tabColumnDs',
                        name: 'field_javascript',
            
                        winId: 'con_contract_insurance_his_id'
                    },
                    url: $('field_javascript_link').getUrl(),
                    title: '域脚本',
                    width: 900,
                    height: 500,
                    draggable: true
                });
            }
            
            function clob_validation_sql_window_open(id) {
            
                var win = new Leaf.Window({
                    id: 'clob_validation_sql_his_id',
                    params: {
                        record_id: id,
                        ds_name: 'tabColumnDs',
                        name: 'clob_validation_sql',
            
                        winId: 'clob_validation_sql_his_id'
                    },
                    url: $('hls_doc_layout_tab_column_validation_sql_link').getUrl(),
                    title: '验证SQL',
                    width: 600,
                    height: 430,
                    draggable: true
                });
            }
            
            function field_render(value, record, name) {
                if (name == 'field_javascript') {
                    return '<a  href="javascript:field_javascript_window_open(' + record.id + ')">' + '域脚本' + '</a>';
                } else if (name == 'clob_validation_sql') {
                    if (!value){
                    	return '<a  href="javascript:clob_validation_sql_window_open(' + record.id + ')">' + '验证SQL' + '</a>';
                    }else{
                        return '<a  href="javascript:clob_validation_sql_window_open(' + record.id + ')">' + '<font color="#FF9900">验证SQL</font>' + '</a>';
                    }
                }
            }
            
            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') {
                    if (record.get('data_type_display')) {
                        return '';
                    } else {
                        return 'tabColumnDs_grid_comb';
                    }
                }
            }
            
            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('clob_validation_sql').setLovUrl($('hls_doc_layout_tab_column_validation_sql_link').getUrl() + '?record_id=' + record.id);
            }
            
            function validation_type_display_detail_link(value, record, name) {
                if (record.get('config_id') && record.get('validation_type') == 'LOV_D') {
                    return '<a href="javascript:winOpen_lov_validation(\'' + record.get('layout_code') + '\',\'' + record.get('tab_code') + '\',\'' + record.get('config_id') + '\',\'' + record.get('column_name') + '\',\'' + record.get('prompt') + '\');">' + '列配置' + '</a>';
                }
            }
            
            function winOpen_lov_validation(layout_code, tab_code, config_id, column_name, prompt) {
            
                new Leaf.Window({
                    id: 'hls_doc_layout_tab_column_lov_validation',
                    url: $('hls_doc_layout_column_lov_validation_link').getUrl(),
                    params: {
                        layout_code: layout_code,
                        tab_code: tab_code,
                        config_id: config_id,
                        column_name: column_name,
                        prompt: prompt
                    },
                    title: column_name + '(' + layout_code + '.' + tab_code + ')',
                    width: 700,
                    height: 430
                });
            }
            
            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'),
                        tab_code   : records[0].get('tab_code')
                    },
                    title: '批量修改',
                    width: 1100,
                    height: 600
                });
            }
        ]]></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="tabColume_Yes_No_ds" lookupCode="YES_NO"/>
            <a:dataSet id="tabColumn_hls030n_grid_order_type_ds" lookupCode="HLS030N_GRID_ORDER_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="switchcard_tab_code" lovGridHeight="300" lovHeight="450" lovService="hls.HLS030.hls_doc_layout_tab_lov?layout_code=${/parameter/@layout_code}&amp;enabled_flag=Y" lovWidth="500">
                        <a:mapping>
                            <a:map from="tab_code" to="switchcard_tab_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="base_tab_code" lovGridHeight="300" lovHeight="450" lovService="hls.HLS030.hls_doc_layout_tab_lov?layout_code=${/parameter/@layout_code}&amp;enabled_flag=Y" lovWidth="500">
                        <a:mapping>
                            <a:map from="tab_code" to="base_tab_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="grid_order_type_display" displayField="code_value_name" options="tabColumn_hls030n_grid_order_type_ds" returnField="grid_order_type" valueField="code_value"/>
                    <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="underline" checkedValue="Y" defaultValue="N" uncheckedValue="N"/>
                    <a:field name="field_bak_flag" checkedValue="Y" defaultValue="N" 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="clob_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:field name="ignore_required" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="lov_width"/>
                    <a:field name="lov_height"/>
                </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="210" 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="80"/>
                                <a:column name="validation_type_display_detail" align="center" autoAdjust="false" prompt="LOV列配置" renderer="validation_type_display_detail_link" width="80"/>
                                <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="underline" autoAdjust="false" editor="tabColumnDs_grid_check" prompt="下划线" width="40"/>
                                <a:column name="field_bak_flag" autoAdjust="false" editor="tabColumnDs_grid_check" prompt="备份标志" width="55"/>
                                <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="clob_validation_sql" align="center" autoAdjust="false" renderer="field_render" width="66"/>
                                <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="210" 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="ignore_required" align="center" editor="tabColumnDs_grid_check2" prompt="忽略保存必输"/>
                                <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="field_group" align="right" editor="tabColumnDs_grid_hegiht_nf2" prompt="字段组" width="50"/>
                                <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="lov_width" align="right" editor="tabColumnDs_grid_hegiht_nf2" prompt="lov宽度" width="55"/>
                                <a:column name="lov_height" align="right" editor="tabColumnDs_grid_hegiht_nf2" prompt="lov高度" width="55"/>
                                <a:column name="grid_order_seq" align="right" editor="tabColumnDs_grid_hegiht_nf2" prompt="结果集排序" width="66"/>
                                <a:column name="grid_order_type_display" align="center" editor="tabColumnDs_grid_comb2" prompt="排序类型" width="55"/>
                                <a:column name="base_tab_code" editor="tabColumnDs_grid_lov2" prompt="源组件" width="150"/>
                                <a:column name="switchcard_tab_code" editor="tabColumnDs_grid_lov2" prompt="卡片组件" width="150"/>
                                <a:column name="field_javascript" align="center" autoAdjust="false" renderer="field_render" showTitle="true" width="57"/>
                            </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>
