gld_account_hierarchy_details.lview 10.1 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyi2652 $
    $Date: 2010/11/01 01:43:06 $
    $Revision: 1.2 $
    $Purpose: “科目层次定义”模块中,grid中的“子科目”页面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query autoCount="false" fetchAll="true" model="gld.gld_account_set_sub_fieldset" rootPath="fieldset"/>
    </a:init-procedure>
    <a:view>
        <a:screen-include screen="modules/hls/hls_common_javascript.lview"/>
        <a:link id="gld_account_hierarchy_tree_link" url="${/request/@context_path}/modules/gld/public/gld_account_hierarchy_tree.lview"/>
        <a:link id="gld_account_hierarchy_details_arrange_link" model="db.gld_account_pkg.refresh_account_hierarchy" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[

            function saveFuncgtion() {
                var ds=$('hierarchyDetailDs');
                var new_records = ds.getNewRecords();
                
                var all_records = ds.getAll();
                var p_error = 0;
                var v_error = 0;
                if (new_records.length > 0) {
                    for (var i = 0;i < new_records.length;i++) {
                        var new_from = new_records[i].get('from_account_code');
                        var new_to = new_records[i].get('to_account_code');
                        if (parseInt(new_from) > parseInt(new_to)) {
                            Leaf.showInfoMessage('${l:PROMPT}', '${l:GLD_ACCOUNT_CODE.VERIFIED}');
                        } else {
                            for (var j = 0;j < all_records.length;j++) {
                                if (all_records[j].isNew == false) {
            
                                    var old_from = all_records[i].get('from_account_code');
                                    var old_to = all_records[i].get('to_account_code');
                                    if (parseInt(new_to) < parseInt(old_from) || parseInt(new_from) < parseInt(old_from)) {
                                        p_error = p_error + 1;
                                    } else if ((parseInt(old_from) < parseInt(new_to) && parseInt(new_to) < parseInt(old_to)) || (parseInt(old_from) < parseInt(new_from) && parseInt(new_from) < parseInt(old_to))) {
                                        v_error = v_error + 1;
                                    }
                                }
                            }
                        }
                    }
                } else {
                    for (var i = 0;i < all_records.length;i++) {
                        if (all_records[i].dirty == true) {
                            var new_from = all_records[i].get('from_account_code');
                            var new_to = all_records[i].get('to_account_code');
                            for (var j = 0;j < all_records.length;j++) {
                                if (all_records[j].dirty == false) {
                                    var old_from = all_records[j].get('from_account_code');
                                    var old_to = all_records[j].get('to_account_code');
                                    if (parseInt(new_to) < parseInt(old_from) || parseInt(new_from) < parseInt(old_from)) {
                                        p_error = p_error + 1;
                                    } else if ((parseInt(old_from) < parseInt(new_to) && parseInt(new_to) < parseInt(old_to)) || (parseInt(old_from) < parseInt(new_from) && parseInt(new_from) < parseInt(old_to))) {
                                        v_error = v_error + 1;
                                    }
                                }
                            }
                        }
            
                    }
                }
	            if (p_error > 0)
	            {
	                Leaf.showInfoMessage('${l:PROMPT}', '${l:GLD_ACCOUNT_CODE.INTERVAL}');
	            }
	            else if (v_error > 0)
	            {
	                Leaf.showInfoMessage('${l:PROMPT}', '${l:GLD_ACCOUNT_CODE.OVERLAPPING}');
	            }
	            else
	            {
	                for (var i = 0;i < all_records.length;i++)
	                {
	                    var old_from = all_records[i].get('from_account_code');
	                    var old_to = all_records[i].get('to_account_code');
	                }
	                if (parseInt(old_from) > parseInt(old_to)) {
	                    Leaf.showInfoMessage('${l:PROMPT}', '${l:GLD_ACCOUNT_CODE.VERIFIED}');
	                }
	                else
	                {
	                    $('hierarchyDetailDs').submit();
	                }
	            }
            }
            
            
            function hierarchyArrange() {
                var ds = $('head_hierarchyDetailDs');
                var record = ds.getCurrentRecord();
            
                Leaf.request({
                    url: $('gld_account_hierarchy_details_arrange_link').getUrl(),
                    para: record.data,
                    success: function() {
                        Leaf.showMessage('${l:PROMPT}', '${l:FND_DIMENSION_VALUES.OPR_SUC}');
                    },
                    scope: this
                });
            }
            
            function viewTree()
            {
                new Leaf.Window({
                    id: 'tree_window',
                    url: $('gld_account_hierarchy_tree_link').getUrl(),
                    params:{
                    	// account_set_id:'${/model/fieldset/record/@account_set_id}'
                    	account_set_id:'${/parameter/@account_set_id}'
                    },
                    title: '${l:FND_COMPANY_HIERARCHY.VIEW_HIERARCHY}',
                    height: 570,
                    width: 550
                });
            }
            
            function setinitdata(ds, record, index) {
                record.set('account_set_id', '${/parameter/@account_set_id}');
                record.set('parent_account_id', '${/parameter/@account_id}');
            }
            
        	function gld_public_account_tetails_grid_add(){
                $('hierarchyDetailDs_grid').showEditorByRecord($('hierarchyDetailDs').create());
            }
            
            function gld_public_account_tetails_grid_clear(){
                $('hierarchyDetailDs_grid').clear();
            }
            
            function gld_public_account_tetails_grid_remove(){
                $('hierarchyDetailDs_grid').remove();
            }
            
            function gld_public_account_tetails_grid_submit() {
                var result_ds = $('hierarchyDetailDs');
                if (result_ds.validate()) {
                    result_ds.submit();
                }
            }
            
        ]]></script>
        <a:dataSets>
            <a:dataSet id="head_hierarchyDetailDs" model="gld.gld_account_set_sub_fieldset">
                <a:datas dataSource="/model/fieldset"/>
            </a:dataSet>
            <a:dataSet id="hierarchyDetailDs" autoCount="true" autoQuery="true" fetchAll="false" model="gld.gld_account_hierarchy" notification="有数据没有保存" queryDataSet="head_hierarchyDetailDs" queryUrl="${/request/@context_path}/autocrud/gld.gld_account_hierarchy/query?ORDER_FIELD=sub_account_code&amp;parent_account_id=${/parameter/@account_id}" selectable="true">
                <a:fields>
                    <a:field name="account_set_id" defaultValue="${/parameter/@account_set_id}"/>
                    <a:field name="parent_account_id" defaultValue="${/parameter/@account_id}"/>
                    <a:field name="sub_account_code" validator="hlsCommon_validateCode"/>
                    <a:field name="from_account_code" validator="hlsCommon_validateCode"/>
                    <a:field name="to_account_code" validator="hlsCommon_validateCode"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="setinitdata"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="gld_public_account_tetails_grid_add" text="HLS.NEW"/>
                <a:gridButton click="gld_public_account_tetails_grid_remove" text="HLS.REMOVE"/>
                <a:gridButton click="gld_public_account_tetails_grid_clear" text="HLS.CLEAR"/>
                <a:gridButton click="saveFuncgtion" text="HLS.SAVE"/>
                <a:gridButton click="viewTree" text="FND_COMPANY_HIERARCHY.VIEW_HIERARCHY"/>
                <a:gridButton click="hierarchyArrange" text="REGULATE_HIERARCHY"/>
            </a:screenTopToolbar>
            <a:fieldSet column="2" width="552">
                <a:textField name="account_set_code" bindTarget="head_hierarchyDetailDs" prompt="GLD_ACCOUNT_SETS.ACCOUNT_CODE" readOnly="true"/>
                <a:textField name="account_set_name" bindTarget="head_hierarchyDetailDs" readOnly="true"/>
                <a:textField name="account_code" bindTarget="head_hierarchyDetailDs" prompt="GLD_ACCOUNTS.ACCOUNT_CODE" readOnly="true"/>
                <a:textField name="account_description" bindTarget="head_hierarchyDetailDs" prompt="FND_CALENDAR.DESCRIPTION" readOnly="true"/>
            </a:fieldSet>
            <a:grid id="hierarchyDetailDs_grid" bindTarget="hierarchyDetailDs" height="330" navBar="true" width="550">
                <a:columns>
                    <a:column name="sub_account_code" align="center" editor="hierarchyDetailDs_grid_tf_upper" prompt="GLD_ACCOUNTS.ACCOUNT_CODE" width="200"/>
                    <a:column name="from_account_code" align="center" editor="hierarchyDetailDs_grid_tf" prompt="GLD_ACCOUNT_SETS.ACCOUNT_CODE_FROM" width="150"/>
                    <a:column name="to_account_code" align="center" editor="hierarchyDetailDs_grid_tf" prompt="GLD_ACCOUNT_SETS.ACCOUNT_CODE_TO" width="150"/>
                </a:columns>
                <a:editors>
                    <a:textField id="hierarchyDetailDs_grid_tf" typeCase="upper"/>
                    <a:textField id="hierarchyDetailDs_grid_tf_upper" typeCase="upper"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>