<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <script type="text/javascript"><![CDATA[
            function dynamicHeadSave() {
                $('screen_dymaic_head_ds').submit();
            }
            
            function dynamicHeadClose() {
                $('dynamic_create_window').close();
            }
            
            function onScreenDynamicHeadSuccess(){
                dynamicHeadClose();
                $('sys_dynamic_result_ds').query();
            }
            
            function onScreenDynamicHeadUpdate(ds, record, name, value, ov){
                if(name == 'lookup_bm'){
                    record.getField('dimension_value_desc').setLovService(value)
                }
                if(name == 'dimension_code'){
                    if(value == 'SYSTEM'){
                        record.set('dimension_value','system');
                        record.set('dimension_value_desc','');
                        record.getField('dimension_value_desc').setRequired(false);
                        record.getField('dimension_value_desc').setReadOnly(true);
                    }else{
                        record.set('dimension_value','');
                        record.set('dimension_value_desc','');
                        record.getField('dimension_value_desc').setRequired(true);
                        record.getField('dimension_value_desc').setReadOnly(false);
                    }                    
                }
            }
            
            
        ]]></script>
        <a:dataSets>
            <a:dataSet id="screen_dymaic_head_ds" autoCreate="true" model="sys.SYS1090.sys_dynamic_headers">
                <a:fields>
                    <a:field name="customization_set" lovGridHeight="300" lovHeight="450" lovService="sys.sys_config_customization_head" lovWidth="350" required="true" title="设置集">
                        <a:mapping>
                            <a:map from="head_id" to="customization_header_id"/>
                            <a:map from="comments" to="customization_set"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="service_name" lovGridHeight="330" lovHeight="460" lovModel="sys.sys_service" lovWidth="450" required="true" title="PAGE_SELECT">
                        <a:mapping>
                            <a:map from="service_id" to="service_id"/>
                            <a:map from="service_name" to="service_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="dimension_type" lovGridHeight="300" lovHeight="450" lovModel="sys.SYS000.sys_config_dimension" lovWidth="500" required="true" title="维度集合">
                        <a:mapping>
                            <a:map from="dimension_code" to="dimension_code"/>
                            <a:map from="dimension_type" to="dimension_type"/>
                            <a:map from="lookup_bm" to="lookup_bm"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="dimension_value_desc" lovGridHeight="300" lovHeight="450" lovWidth="500" required="true" title="维度值">
                        <a:mapping>
                            <a:map from="id" to="dimension_value"/>
                            <a:map from="name" to="dimension_value_desc"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onScreenDynamicHeadUpdate"/>
                    <a:event name="submitsuccess" handler="onScreenDynamicHeadSuccess"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:fieldSet column="1" style="margin:10px;" title="动态配置" width="565">
                <a:lov name="customization_set" bindTarget="screen_dymaic_head_ds" prompt="个性化集" width="200"/>
                <a:hBox padding="0" prompt="页面名称">
                    <a:lov name="service_name" bindTarget="screen_dymaic_head_ds" prompt="" width="476"/>
                </a:hBox>
                <a:hBox padding="0" prompt="维度">
                    <a:lov name="dimension_type" bindTarget="screen_dymaic_head_ds" width="200"/>
                    <a:lov name="dimension_value_desc" bindTarget="screen_dymaic_head_ds" prompt="维度值" width="200"/>
                </a:hBox>
            </a:fieldSet>
        </a:screenBody>
        <a:windowToolbar>
            <a:button click="dynamicHeadSave" text="保存" width="90"/>
            <a:button click="dynamicHeadClose" text="关闭" width="90"/>
        </a:windowToolbar>
    </a:view>
</a:screen>