prj_project_statement_note.lview 21.5 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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm  
    $Date: 2013-10-2 上午10:10:21  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <!-- <a:model-query defaultWhereClause="t1.project_id =${/parameter/@project_id}" fetchAll="true" model="prj.PRJ501.prj_project_v" rootPath=""/> -->
        <!-- <a:model-query defaultWhereClause="is_show =&apos;Y&apos;" fetchAll="true" model="prj.PRJ509.prj_fsn_config" queryOrderBy="order_seq" rootPath="dataset_submit_list"/> -->
        <!-- <a:model-query defaultWhereClause="is_show =&apos;Y&apos;" fetchAll="true"  model="prj.PRJ509.prj_fsn_config"  rootPath="dataset_submit_list"/> --><![CDATA[
        
        
        
   
    ]]></a:init-procedure>
    <a:view package="leaf.ui.std" template="default">
        <a:link id="prj_project_statement_note_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_project_statement_note.lview"/>
        <a:link id="prj_project_statement_note_selected_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_project_statement_note_selected.lview"/>
        <a:link id="get_config_link" model="prj.PRJ509.prj_fsn_config_selected" modelaction="query"/>
        <a:link id="prj_fsn_curr_ast_tab_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_curr_ast_tab.lview"/>
        <a:link id="prj_fsn_non_curr_ast_tab_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_non_curr_ast_tab.lview"/>
        <a:link id="prj_fsn_curr_liab_tab_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_curr_liab_tab.lview"/>
        <a:link id="prj_fsn_non_curr_liab_tab_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_non_curr_liab_tab.lview"/>
        <a:link id="prj_fsn_equity_tab_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_equity_tab.lview"/>
        <a:link id="prj_fsn_income_statement_tab_link" url="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_income_statement_tab.lview"/>
        <a:link id="prj_fsn_excel_id" url="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_excel_output.lview"/>
        <div/>
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
        <script type="text/javascript"><![CDATA[
            var fin_statement_id='';//, fiscal_year_change_flag = 'N';
            //共用
            //计算营业收入及成本(产品) :主营业务毛利
            function calculate_main_biz_profit(record) {
                var array = new Array();
                var main_biz_profit = 0;
                array[0] = record.get('main_biz_income');
                array[1] = -record.get('main_biz_cost');
                for (var i = 0;i < array.length;i++) {
                    if (array[i] == 'NAN' || array[i] == 'undefined' || array[i] == null || array[i] == '' || isNaN(array[i])) {
                        array[i] = 0;
                    }
                    main_biz_profit = plus(main_biz_profit, array[i]);
                }
            
                record.set('main_biz_profit', main_biz_profit);
            }
            
            function calculate_balance(record) {
                var array = new Array();
                var balance = 0;
                array[0] = record.get('opening_bal');
                array[1] = record.get('current_acquisition');
                array[2] = record.get('transfer_from_cip');
                array[3] = -record.get('fixed_ast_disposal');
                array[4] = -record.get('current_depreciation');
                array[5] = -record.get('provision_impairment');
                for (var i = 0;i < array.length;i++) {
                    if (array[i] == 'NAN' || array[i] == 'undefined' || array[i] == null || array[i] == '' || isNaN(array[i])) {
                        array[i] = 0;
                    }
                    balance = plus(balance, array[i]);
                }
                record.set('balance', balance);
            }
            
            function calculate_intgbl_ast_balance(record) {
                var array = new Array();
                var balance = 0;
                array[0] = record.get('opening_bal');
                array[1] = record.get('current_acquisition');
                array[2] = -record.get('intangible_ast_disposal');
                array[3] = -record.get('current_amortization');
                array[4] = -record.get('provision_impairment');
                for (var i = 0;i < array.length;i++) {
                    if (array[i] == 'NAN' || array[i] == 'undefined' || array[i] == null || array[i] == '' || isNaN(array[i])) {
                        array[i] = 0;
                    }
                    balance = plus(balance, array[i]);
                }
                record.set('balance', balance);
            }
            
            function calculate_totals(datas, name) {
                var sum = 0;
                for (var i = 0;i < datas.length;i++) {
                    var r = datas[i];
                    var d = r.get(name);
                    var n = parseFloat(d);
                    if (!isNaN(n)) {
                        sum = plus(sum, n);
                    }
                }
                var total = (typeof(sum) == 'undefined' ? '' : parseFloat(sum));
                return total;
            }
            
            function sumFunction_desc(datas, name) {
                var total;
                if (name == 'item_detail_desc') {
                    total = '${l:PRJ509.TOTAL}';
                    return '<font>' + total + '</font>';
                } else if (name == 'ratio') {
                    return '<font>' + Leaf.formatMoney(1) + '</font>';
                }
                
            }
            
            function sumFunction(datas, name) {
                var total = calculate_totals(datas, name);
                return '<font>' + Leaf.formatMoney(total) + '</font>';
            }
            
            
            function beforeremove_grid(ds, records) {
                for (var i = 0;i < records.length;i++) {
                    if (records[i].get('item_detail') == 'TOTAL') {
                        return false;
                    }
                }
            }
            
            function update_calculate_totals(total_record, lineRecords, name) {
                var current_amount, amount, i, lineRecord;
                amount = 0;
                for (i = 0;i < lineRecords.length;i++) {
                    lineRecord = lineRecords[i];
                    if (lineRecord.get('item_detail') == 'TOTAL') {
                        break;
                    }
                    current_amount = lineRecord.get(name);
                    if (current_amount == 'NAN' || current_amount == 'undefined' || current_amount == null || current_amount == '') {
                        current_amount = 0;
                    }
                    amount = plus(amount, current_amount);
                }
                total_record.set(name, amount);
            }
            
            
            function update_calculate_ratio(dataSet, records, name) {
                for (var i = 0;i < records.length;i++) {
            
                    var total = calculate_totals(records, name);
                    var ratio = div(records[i].get(name), total);
                    if (isNaN(ratio)) {
                        records[i].set('ratio', '');
                    } else {
                        records[i].set('ratio', ratio);
                    }
                }
            }
            
            function onUpdate_item_detail_common(dataSet, record, name, value, oldValue) {
                var lineRecords = dataSet.getAll();
                var total_record = dataSet.find('item_detail', 'TOTAL');
                var ratio_flag = Ext.isDefined(record.fields['ratio']);
                if (name == 'balance') {
                    if (ratio_flag) {
                        update_calculate_ratio(dataSet, lineRecords, 'balance');
                    }
                } else if (name == 'current_amt') {
                    if (ratio_flag) {
                        update_calculate_ratio(dataSet, lineRecords, 'current_amt');
                    }
                } else if (name == 'income_from_oper') {
                    if (ratio_flag) {
                        update_calculate_ratio(dataSet, lineRecords, 'income_from_oper');
                    }
                } else if (name == 'main_biz_income' || name == 'main_biz_cost') {
                    calculate_main_biz_profit(record);
                } else if (name == 'transfer_from_cip' || name == 'fixed_ast_disposal' || name == 'current_depreciation') {
            
                    calculate_balance(record);
                } else if (name == 'intangible_ast_disposal' || name == 'current_amortization') {
                    calculate_intgbl_ast_balance(record);
                } else if (name == 'opening_bal' || name == 'current_acquisition' || name == 'provision_impairment') {
                    var id = dataSet.id;
                    if (id == 'fixed_ast_ds') {
            
                        calculate_balance(record);
                    } else {
                        calculate_intgbl_ast_balance(record);
                    }
                }
            
            }
            
            
            
            function remove_item_detail_common(dataSet, record, index) {
                var lineRecords = dataSet.getAll();
                var item_detail = record.get('item_detail');
                var total_record = dataSet.find('item_detail', 'TOTAL');
                var ratio_flag = Ext.isDefined(record.fields['ratio']);
                if (Ext.isDefined(record.fields['balance'])) {
                    if (ratio_flag) {
                        update_calculate_ratio(dataSet, lineRecords, 'balance');
                    }
                }if (Ext.isDefined(record.fields['current_amt'])) {
                    if (ratio_flag) {
                        update_calculate_ratio(dataSet, lineRecords, 'current_amt');
                    }
                }if (Ext.isDefined(record.fields['income_from_oper'])) {
            
                    if (ratio_flag) {
                        update_calculate_ratio(dataSet, lineRecords, 'income_from_oper');
                    }
                }
            }
            
            function grid_add(id, ds) {
                var index_flag = ds.indexOf('prj_fsn');
                var fsn_item_name;
                var order_seq;
                var dataSet = $(ds);
                var records = dataSet.getAll();
                if (records.length == 0) {
                    if (index_flag == -1) {
                        fsn_item_name = ds.substring(0, ds.length - 3).toUpperCase();
                    } else {
                        fsn_item_name = ds.substring(8, ds.length - 3).toUpperCase();
                    }
            
                    Leaf.request({
                        url: $('get_config_link').getUrl(),
                        para: {
                            fin_statement_id: fin_statement_id,
                            fsn_item: fsn_item_name
                        },
                        success: function(args) { 
                            var record = args.result.record;
                            if (!record) {
                                Leaf.showWarningMessage('', '${l:PRJ509.DATA_NOT_BACK}', null, 200, 100);
                                return;
                            }
                            var data = {
                                order_seq: 1,
                                fin_statement_id: record.fin_statement_id,
                                config_id: record.config_id,
                                fsn_item: record.fsn_item
                            };
                            $(id).showEditorByRecord($(ds).create(data));
                        },
                        scope: this
                    });
                } else {
                    var record = dataSet.getAt(records.length - 1);
                    order_seq = record.get('order_seq');
                    var data = {
                        order_seq: order_seq + 1,
                        fin_statement_id: record.get('fin_statement_id'),
                        config_id: record.get('config_id'),
                        fsn_item: record.get('fsn_item')
                    };
                    $(id).showEditorByRecord($(ds).create(data));
                }
            }
            
            function noteQueryScreen_save() {
                Leaf.Masker.mask(parent.document.documentElement, '${l:HLS.SAVING}');
                $('QueryScreen_paraDs').submit();
             
            }
            
            function submitsuccess_paraDs(ds,res){
                Leaf.Masker.unmask(parent.document.documentElement);
            }
            
            function stetement_note_back() {
                if ('${/parameter/@winid}') {
                (parent == top ? self : parent)['$']('${/parameter/@winid}').close();}
                else{
                    history.go(-1);
                }
            }
            function rsc303_handle_changeRate_back() {
                (parent == top ? self : parent)['$']('${/parameter/@winid}').close();
            }
            
            
            
            function noteQueryScreen_add() {
                if (Ext.isEmpty(fin_statement_id)) {
                    
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:PRJ509.CHOOSE_DATE}');
                } else {
                    new Leaf.Window({
                        id: 'prj_project_statement_note_selected_window',
                        url: $('prj_project_statement_note_selected_link').getUrl(),
                        params: {
                            fin_statement_id: fin_statement_id,
                            winid: 'prj_project_statement_note_selected_window'
                        },
                        title: '${l:PRJ509.REPORT_SELECTION}',
            
                        width: 800,
                        height: 500
                    });
                }
            }
            
            
            function statement_note_select_back() {
                $('prj_project_statement_note_selected_window').close();
            }
            
            
            function grid_remove(grid, ds) {
                var dataSet = $(ds);
                var gridObject = $(grid);
                var lineRecords = dataSet.getSelected();
                for (var i = 0;i < lineRecords.length;i++) {
                    if (Ext.isEmpty(lineRecords[i].get('item_detail'))) {
                        dataSet.remove(lineRecords[i]);
                    }
                }
            
            }
            
            
            //重新获取tab的ref
            
            function get_tab_link(tab, fin_statement_id) {
                var ref0 = $('prj_fsn_curr_ast_tab_link').getUrl() + '?fin_statement_id=' + fin_statement_id + '&fsn_type=CURR_AST';
                var ref1 = $('prj_fsn_non_curr_ast_tab_link').getUrl() + '?fin_statement_id=' + fin_statement_id + '&fsn_type=NON_CURR_AST';
                var ref2 = $('prj_fsn_curr_liab_tab_link').getUrl() + '?fin_statement_id=' + fin_statement_id + '&fsn_type=CURR_LIAB';
                var ref3 = $('prj_fsn_non_curr_liab_tab_link').getUrl() + '?fin_statement_id=' + fin_statement_id + '&fsn_type=NON_CURR_LIAB';
                var ref4 = $('prj_fsn_equity_tab_link').getUrl() + '?fin_statement_id=' + fin_statement_id + '&fsn_type=EQUITY';
                var ref5 = $('prj_fsn_income_statement_tab_link').getUrl() + '?fin_statement_id=' + fin_statement_id + '&fsn_type=INCOME_STATEMENT';
                // tab.items[0].ref = ref0;
                // tab.items[1].ref = ref1;
                // tab.items[2].ref = ref2;
                // tab.items[3].ref = ref3;
                // tab.items[4].ref = ref4;
                // tab.items[5].ref = ref5;
            	tab.setURL(0,ref0);
            	tab.setURL(1,ref1);
            	tab.setURL(2,ref2);
            	tab.setURL(3,ref3);
            	tab.setURL(4,ref4);
            	tab.setURL(5,ref5);
            }
            
            // var tab_loaded_data = [];
            
            // function set_tab_loaded_data(index) {
                // tab_loaded_data.push({
                    // index: true
                // });
            // }
            
            function onUpdate_paraDs(dataSet, record, name, value, oldValue) {
                if (name == 'fiscal_year') {
                    fin_statement_id = record.get('fin_statement_id');
            
                    // if (value != oldValue) {
                        // fiscal_year_change_flag = 'Y';
                    // }
                    var obj = $('tabPanel_id');
            
                    get_tab_link(obj, fin_statement_id);
                    // var ref0 = $('prj_fsn_curr_ast_tab_link').getUrl() + '?fin_statement_id=' + fin_statement_id + '&fsn_type=CURR_AST';
                    // tab_loaded_data = [];
                    // set_tab_loaded_data(0);
                    // $('tabPanel_id').reloadTab(0, ref0);
                }

            }
            
            
            // function beforeselect_tab(tab, index) {
                // if (fiscal_year_change_flag == 'Y' && !tab_loaded_data[index]) {
                    // set_tab_loaded_data(index);
                    // $('tabPanel_id').reloadTab(index, tab.items[index].ref);
                    // return false;
                // } else {
                    // return true;
                // }
            // }
            
            function do_excel() {
                var url = $('prj_fsn_excel_id').getUrl()+ '?fin_statement_id=' + fin_statement_id;
               //window.open(url);
               window.location.href=url;
                
                
            }
          
        ]]></script>
        <a:dataSets>
            <a:dataSet id="QueryScreen_paraDs" autoQuery="true" model="prj.PRJ509.prj_project_statement_note_query" queryUrl="${/request/@context_path}/autocrud/prj.PRJ509.prj_project_statement_note_query/query?bp_id=${/parameter/@bp_id}" submitUrl="${/request/@context_path}/modules/prj/PRJ509/prj_fsn_submit.lsc">
                <a:fields>
                    <a:field name="project_number" readOnly="true"/>
                    <a:field name="project_name" readOnly="true"/>
                    <a:field name="bp_code" readOnly="true"/>
                    <a:field name="bp_name" readOnly="true"/>
                    <a:field name="rsc_fin_statement_id_desc"/>
                    <a:field name="fiscal_year" lovGridHeight="300" lovHeight="450" lovLabelWidth="120" lovService="prj.PRJ509.prj_project_statement_fiscal_year_lov?bp_id=${/parameter/@bp_id}" lovWidth="550" prompt="HLS.BP_CODE" title="PRJ509.FISCAL_YEAR">
                        <a:mapping>
                            <a:map from="fin_statement_id" to="fin_statement_id"/>
                            <a:map from="fin_statement_templet_name" to="fin_statement_templet_name"/>
                            <a:map from="fiscal_year" to="fiscal_year"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="onUpdate_paraDs"/>
                    <a:event name="submitsuccess" handler="submitsuccess_paraDs"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="stetement_note_back" text="HLS.BACK"/>
                <a:gridButton click="noteQueryScreen_add" text="PRJ509.SHOW_PROJECT"/>
                <a:gridButton click="noteQueryScreen_save" text="HLS.SAVE"/>
                <a:gridButton click="do_excel" text="HLS.WORD_EXPORT"/>
            </a:screenTopToolbar>
            <a:form column="3" labelWidth="120" marginWidth="30" title="PRJ509.REPORT">
                <a:lov name="project_number" bindTarget="QueryScreen_paraDs" prompt="HLS.PROJECT_NUMBER"/>
                <a:textField name="project_name" bindTarget="QueryScreen_paraDs" prompt="HLS.PROJECT_NAME"/>
                <a:lov name="fiscal_year" bindTarget="QueryScreen_paraDs" prompt="PRJ509.FISCAL_YEAR"/>
                <a:lov name="bp_code" bindTarget="QueryScreen_paraDs" prompt="HLS.BP_CODE"/>
                <a:textField name="bp_name" bindTarget="QueryScreen_paraDs" prompt="HLS.BP_NAME"/>
            </a:form>
            <a:tabPanel id="tabPanel_id" marginHeight="180" marginWidth="30">
                <a:tabs>
                    <a:tab prompt="PRJ509.CURR_AST" width="110"><![CDATA[
                       
                    ]]></a:tab>
                    <a:tab prompt="PRJ509.NON_CURR_AST" width="110"><![CDATA[
                        
                    ]]></a:tab>
                    <a:tab prompt="PRJ509.CURR_LIAB" width="110"><![CDATA[
                        
                    ]]></a:tab>
                    <a:tab prompt="PRJ509.NON_CURR_LIAB" width="110"><![CDATA[
                        
                    ]]></a:tab>
                    <a:tab prompt="PRJ509.EQUITY" width="110"><![CDATA[
                        
                    ]]></a:tab>
                    <a:tab prompt="PRJ509.INCOME_STATEMENT" width="110"><![CDATA[
                        
                    ]]></a:tab>
                </a:tabs>
                <!-- <a:events>
                    <a:event name="beforeselect" handler="beforeselect_tab"/>
                </a:events> -->
            </a:tabPanel>
        </a:screenBody>
    </a:view>
</a:screen>