<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-8-28 下午04:33:38  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="hls030_doc_layout_tab_button_proc_link" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_lab_button_proc.lview"/>
        <a:link id="hls030_doc_layout_tab_button_load_link" model="hls.HLS030.hls_doc_layout_tab_button" modelaction="execute"/>
        <!-- <a:link id="hls030_doc_layout_tab_button_reload_link" model="hls.HLS030.hls_doc_layout_tab_button" modelaction="batch_update"/> -->
        <a:link id="hls_doc_layout_tab_btn_detail_javascript_link" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_tab_button_javascript.lview"/>
        <a:link id="hls_doc_layout_tab_button_reload_link" model="hls.HLS030.hls_doc_layout_tab_button_reload" modelaction="batch_update"/>
        <script type="text/javascript"><![CDATA[
            function hls030_tab_button_detail_close() {
                $('hls030_tab_function_result_ds').query();
                $('hls030_doc_layout_tab_button_detail_window').close();
            }
            
            function hls030_tab_button_detail_grid_query() {
                $('hls030_tab_button_detail_ds').query();
            }
            
            function hls030_tab_button_detail_grid_load() {
                Leaf.request({
                    url: $('hls030_doc_layout_tab_button_load_link').getUrl(),
                    para: {
                        function_code: '${/parameter/@function_code}',
                        layout_code: '${/parameter/@layout_code}',
                        tab_code: '${/parameter/@tab_code}'
                    },
                    success: function() {
                        hls030_tab_button_detail_grid_query();
                    },
                    scope: this
                });
            }
            
            function hls030_tab_button_detail_grid_reload() {
                var records = $('hls030_tab_button_detail_ds').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] = {
                        layout_code: '${/parameter/@layout_code}',
                        tab_code: '${/parameter/@tab_code}',
                        function_code: '${/parameter/@function_code}',
                        button_code: records[i].get('button_code'),
                        _status: 'insert'
                    };
                }
            
                Leaf.request({
                    url: $('hls_doc_layout_tab_button_reload_link').getUrl(),
                    para: datas,
                    success: function(res) {
                        Leaf.SideBar.show({
                            msg: '${l:HLS.SUBMIT_SUCCESS}',
                            duration: 2000
                        });
                        hls030_tab_button_detail_grid_query();
                    },
                    scope: this
                });
            }
            
            function hls030_tab_button_detail_grid_remove()
            {
            	$('hls030_tab_button_detail_grid').remove();
            }
            
            function hls030_tab_button_proc_update(record_id) {
                var record = $('hls030_tab_button_detail_ds').findById(record_id);
                new Leaf.Window({
                    id: 'hls030_doc_layout_lab_button_proc_window',
                    url: $('hls030_doc_layout_tab_button_proc_link').getUrl(),
                    params: {
                        layout_code: '${/parameter/@layout_code}',
                        tab_code: '${/parameter/@tab_code}',
                        function_code: record.get('function_code'),
                        button_code: record.get('button_code')
                    },
                    title: '${l:HLS031.PROCEDURE_EDIT}',
                    height: 450,
                    width: 600
                });
            }
            
            function hls030_tab_button_detail_grid_render(value, record, name) {
                if (record.get('system_flag') == 'N') {
                return '<a href="javascript:hls030_tab_button_proc_update(\'' + record.id + '\')">${l:HLS031.PROCEDURE_EDIT}</a>';
                }
            }
            
            function hls030_tab_btn_js_ef(record,name)
            {
                if(record.get('system_flag')=='N')
                {
                    
                }else{
                    return '';
                }
            }
            
            function hls030_button_grid_cc(gird,row,name,record)
            {
                record.getField('javascript').setLovUrl($('hls_doc_layout_tab_btn_detail_javascript_link').getUrl() + '?record_id=' + record.id);
          		record.getField('javascript').setTitle('JS脚本');
          
                if (name == 'javascript') {
                    if (record.get('system_flag') == 'Y') {
                        record.getField(name).setReadOnly(true);
                    } else if (record.get('system_flag') == 'N') {
                        record.getField(name).setReadOnly(false);
                    }
                }
            }
            
            function button_code_ef(record,name){
                if(record.isNew){
                    return 'hls030_tab_button_detail_grid_tf_id';
                }
                return '';
            }
            
            function hls030_tab_button_detail_ds_add(ds,record){
                record.set('function_code','${/parameter/@function_code}');
                record.set('layout_code','${/parameter/@layout_code}');
                record.set('tab_code','${/parameter/@tab_code}');
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls030_enabled_status_ds" lookupCode="ENABLED_STATUS"/>
            <a:dataSet id="hls030_tab_button_detail_query_ds">
                <a:fields>
                    <a:field name="function_code" defaultValue="${/parameter/@function_code}" readOnly="true"/>
                    <a:field name="function_name" defaultValue="${/parameter/@function_name}" readOnly="true"/>
                    <a:field name="layout_code" defaultValue="${/parameter/@layout_code}" prompt="HLS030.HLS_DOC_LAYOUT.LAYOUT_CODE" readOnly="true"/>
                    <a:field name="layout_desc" defaultValue="${/parameter/@layout_desc}" prompt="HLS.DESCRIPTION" readOnly="true"/>
                    <a:field name="tab_code" defaultValue="${/parameter/@tab_code}" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_CODE" readOnly="true"/>
                    <a:field name="tab_desc" defaultValue="${/parameter/@tab_desc}" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_DESC" readOnly="true"/>
                    <a:field name="button_code"/>
                    <a:field name="prompt"/>
                    <a:field name="enabled_flag_des" displayField="code_value_name" options="hls030_enabled_status_ds" returnField="enabled_flag" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls030_tab_button_detail_ds" autoPageSize="true" autoQuery="true" model="hls.HLS030.hls_doc_layout_tab_button" queryDataSet="hls030_tab_button_detail_query_ds" selectable="true">
                <a:fields>
                    <a:field name="button_code" required="true"/>
                    <a:field name="prompt" required="true"/>
                    <a:field name="save_data_first" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="system_flag" checkedValue="Y" 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="javascript" lovHeight="430" lovWidth="580"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="hls030_tab_button_detail_ds_add"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:toolbarButton click="hls030_tab_button_detail_close" text="HLS.CLOSE" width="80"/>
                <a:gridButton bind="hls030_tab_button_detail_grid" type="add" width="80"/>
                <a:gridButton bind="hls030_tab_button_detail_grid" type="save" width="80"/>
                <a:toolbarButton click="hls030_tab_button_detail_grid_query" text="HLS.QUERY" width="80"/>
                <a:toolbarButton click="hls030_tab_button_detail_grid_load" text="HLS031.BUTTON.LOAD" width="80"/>
                <a:toolbarButton click="hls030_tab_button_detail_grid_reload" text="HLS031.BUTTON.RELOAD" width="80"/>
                <a:toolbarButton click="hls030_tab_button_detail_grid_remove" text="HLS.REMOVE" width="80"/>
            </a:screenTopToolbar>
            <a:form>
                <a:hBox labelSeparator=" " labelWidth="100">
                    <a:textField name="function_code" bindTarget="hls030_tab_button_detail_query_ds" prompt="SYS8010.SYS_FUNCTION.FUNCTION_CODE" typeCase="upper"/>
                    <a:textField name="function_name" bindTarget="hls030_tab_button_detail_query_ds" prompt="SYS8010.SYS_FUNCTION.FUNCTION_NAME"/>
                </a:hBox>
                <a:hBox labelSeparator=" " labelWidth="100">
                    <a:textField name="layout_code" bindTarget="hls030_tab_button_detail_query_ds"/>
                    <a:textField name="layout_desc" bindTarget="hls030_tab_button_detail_query_ds"/>
                    <a:textField name="tab_code" bindTarget="hls030_tab_button_detail_query_ds" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_CODE"/>
                    <a:textField name="tab_desc" bindTarget="hls030_tab_button_detail_query_ds" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_DESC"/>
                </a:hBox>
                <a:hBox labelSeparator=" " labelWidth="100">
                    <a:textField name="button_code" bindTarget="hls030_tab_button_detail_query_ds" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.BUTTON_CODE" typeCase="upper"/>
                    <a:textField name="prompt" bindTarget="hls030_tab_button_detail_query_ds" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.PROMPT"/>
                    <a:comboBox name="enabled_flag_des" bindTarget="hls030_tab_button_detail_query_ds" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.ENABLED_FLAG"/>
                </a:hBox>
            </a:form>
            <a:grid id="hls030_tab_button_detail_grid" bindTarget="hls030_tab_button_detail_ds" marginHeight="220" marginWidth="60">
                <a:columns>
                    <a:column name="display_order" align="right" autoAdjust="false" editor="hls030_tab_button_detail_grid_nf_id" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.DISPLAY_ORDER" width="50"/>
                    <a:column name="button_code" autoAdjust="false" editorFunction="button_code_ef" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.BUTTON_CODE" width="150"/>
                    <a:column name="prompt" autoAdjust="false" editor="hls030_tab_button_detail_grid_tf_id" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.PROMPT" width="150"/>
                    <a:column name="system_flag" autoAdjust="false" editor="hls030_tab_button_detail_grid_ck_id" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.SYSTEM_FLAG" width="60"/>
                    <a:column name="enabled_flag" autoAdjust="false" editor="hls030_tab_button_detail_grid_ck_id" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.ENABLED_FLAG" width="60"/>
                    <a:column name="display_flag" autoAdjust="false" editor="hls030_tab_button_detail_grid_ck_id" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.DISPLAY_FLAG" width="60"/>
                    <a:column name="save_data_first" autoAdjust="false" editor="hls030_tab_button_detail_grid_ck_id" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.SAVE_DATA_FIRST" width="100"/>
                    <a:column name="calc_btn" align="center" autoAdjust="false" prompt="HLS031.PROCEDURE_EDIT" renderer="hls030_tab_button_detail_grid_render" width="100"/>
                    <a:column name="javascript" autoAdjust="false" editor="hls030_tab_button_detail_grid_lov_id" prompt="HLS031.HLS_DOC_LAYOUT_BUTTON.JAVASCRIPT" width="300"/>
                </a:columns>
                <a:editors>
                    <a:numberField id="hls030_tab_button_detail_grid_nf_id" allowDecimals="false" allowNegative="false"/>
                    <a:textField id="hls030_tab_button_detail_grid_tf_id"/>
                    <a:checkBox id="hls030_tab_button_detail_grid_ck_id"/>
                    <a:lov id="hls030_tab_button_detail_grid_lov_id"/>
                </a:editors>
                <a:events>
                    <a:event name="cellclick" handler="hls030_button_grid_cc"/>
                </a:events>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
