<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: niujiaqing1265 $
    $Date: 2011/11/02 05:58:20 $
    $Revision: 1.2 $
    $Purpose: 用户定义
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure><![CDATA[]]></a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
            register_customization_array_ds('${/parameter/@name}_array_ds');
            customization_array_map['${/parameter/@name}_array_ds'] = '${/parameter/@index_field}';
            
            function ${/parameter/@name}CustomizationArrayEditor(record,name){
                if(record.isNew) {
                    return '${/parameter/@name}_sys_customization_array_grid_tf';
                }else{
                    return '';
                }
            }
            
            
            function onCustomization${/parameter/@name}Update(ds,record,name,value){
                var ads = $('${/parameter/@name}_array_ds');
                var r = ads.getCurrentRecord();
                record.data['array_name']='${/parameter/@name}';
                record.data['index_field']='${/parameter/@index_field}';
                record.data['index_value']=r.get('name');
                onCustomizationUpdate(ds,record,name,value);
            }
            
            function onCustomization${/parameter/@name}Load(ds){
                var hds = $('sys_customization_query_ds');
                var head = hds.getCurrentRecord();
                var list = ds.getAll();
                for(var i=0;i<list.length;i++){
                    var r = list[i];
                    r.data['array_name']='${/parameter/@name}';
                    r.data['index_field']='${/parameter/@index_field}';
                    r.data['name'] = r.data['${/parameter/@index_field}'];
                    r.data['index_value']=r.data['name'];
                    r.data['head_id']=head.get('head_id');
                    r.data['source_file']=head.get('source_file');
                    r.data['id_value']=head.get('id_value');
                    r.data['dimension_type']=head.get('dimension_type');
                    r.data['dimension_value']=head.get('dimension_value');
                }
            }
            
            function clearCustomization${/parameter/@name}Order(){
                var array_ds = $('${/parameter/@name}_array_ds');
                if(array_ds.getAll().length > 0){
                    Leaf.showConfirm('确认','确认重置排序?',function(){
                        var hds = $('sys_customization_query_ds');
                        var head = hds.getCurrentRecord();
                        var sds = $('sys_customization_submit_ds');
                        sds.removeAll();
                        var data = {};
                        data['array_name']='${/parameter/@name}';
                        data['index_field']='${/parameter/@index_field}';
                        data['head_id']=head.get('head_id');
                        data['source_file']=head.get('source_file');
                        data['id_value']=head.get('id_value');
                        data['dimension_type']=head.get('dimension_type');
                        data['dimension_value']=head.get('dimension_value');
                        data['_cus_stauts']='clearorder';
                        data['enable_flag']='Y';
                        sds.create(data);
                        sds.submit();
                    }); 
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="${/parameter/@name}_array_ds" autoCount="false" queryDataSet="sys_customization_query_ds" queryUrl="${/request/@context_path}/modules/sys/sys_customization_array_query.lsc?array_name=${/parameter/@name}" submitUrl="${/request/@context_path}/modules/sys/sys_customization_array_delete.lsc">
                <a:fields>
                    <a:field name="array_name" defaultValue="${/parameter/@name}"/>
                    <a:field name="index_field" defaultValue="${/parameter/@index_field}"/>
                    <a:field name="_cus_stauts" defaultValue="insert"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="onCustomizationArrayAdd"/>
                    <a:event name="load" handler="onCustomization${/parameter/@name}Load"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="${/parameter/@name}_array_element_ds" autoCount="false" bindTarget="${/parameter/@name}_array_ds" bindName="pros" queryUrl="${/request/@context_path}/modules/sys/sys_customization_array_propertity_query.lsc?array_name=${/parameter/@name}&amp;index_field=${/parameter/@index_field}">
                <a:events>
                    <a:event name="update" handler="onCustomization${/parameter/@name}Update"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:hBox style="margin:5px;" padding="0">
            <a:grid bindTarget="${/parameter/@name}_array_ds" height="309" width="250">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button text="重置排序" icon="null" btnClass="grid-clear" btnStyle="background-position:0px -53px;" click="clearCustomization${/parameter/@name}Order"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="name" prompt="名称" width="150" editorFunction="${/parameter/@name}CustomizationArrayEditor" renderer="arrayNameRendere"/>
                    <a:column name="mod_type" prompt="删除" width="40" align="center" renderer="customizationDeleteRenderer"/>
                    <a:column name="sequence" prompt="排序" width="40" align="center" renderer="customizationReorderRenderer"/>
                </a:columns>
                <a:editors>
                    <a:textField id="${/parameter/@name}_sys_customization_array_grid_tf"/>
                </a:editors>
            </a:grid>
            <a:grid bindTarget="${/parameter/@name}_array_element_ds" style="margin-left:5px;" height="310" width="488">
                <a:columns>
                    <a:column name="attrib_key" prompt="名称" width="100"/>
                    <a:column name="source_value" prompt="源文件值" width="100"/>
                    <a:column name="attrib_value" prompt="设定值" width="100" editor="${/parameter/@name}_sys_customization_array_grid_tf2"/>
                    <a:column name="document" prompt="说明" width="150"/>
                </a:columns>
                <a:editors>
                    <a:textField id="${/parameter/@name}_sys_customization_array_grid_tf2"/>
                </a:editors>
            </a:grid>
        </a:hBox>
        <script type="text/javascript"><![CDATA[
            initTabQuery('${/parameter/@name}_array_ds');
        ]]></script>
    </a:view>
</a:screen>