<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyu  
    $Date: 2015-12-19 下午21:32:11  
    $Revision: 1.0  
    $Purpose: 集团资金计划基础表（季度）
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.hd_id=${/parameter/@hd_id}" fetchAll="true" model="sdic.SDIC2020.sdic_fin_plan_rpt_quarter_hd" rootPath="hd_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="sdic2020_ln_create_link" model="sdic.SDIC2020.sdic_fin_plan_rpt_quarter_ln" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
        	function sdic2020_ln_return(){
         	    $('${/parameter/@win_id}').close();
         	}
         	
         	function sdic2020_ln_create(){
         	    var record=$('sdic2020_hd_query_ds').getCurrentRecord();
         	    var status =record.get('status');
         	    if (status != 'NEW'){
         	        Leaf.showMessage('${l:PROMPT}', '只有新建状态的报表才能生成！');
                     return;
         	    } else{
         	        Leaf.request({
                    url: $('sdic2020_ln_create_link').getUrl(),
                    para: {
                        hd_id:record.get('hd_id')
                    },
                    success: function(res) {
                        Leaf.Masker.unmask(Ext.getBody()); //解锁
                        $('sdic2020_ln_result_ds').query();
                    },
                    failure: function() {
                        Leaf.Masker.unFmask(Ext.getBody());
                    },
                    error: function() {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });
         	    }
         	}
         	
         	function first_level(code) {
                var codes = {
                    'A8': true,
                    'A11': true,
                    'A83': true,
                    'A149': true,
                    'A150': true,
                    'A151': true
                };
                if (codes[code]) {
                    return true;
                } else {
                    return false;
                }
            }
            
            function second_level(code) {
                var codes = {
                    'A12': true,
                    'A16': true,
                    'A84': true,
                    'A89': true
                };
                if (codes[code]) {
                    return true;
                } else {
                    return false;
                }
            }
            
            function third_level(code) {
                var codes = {
                    'A26': true,
                    'A31': true,
                    'A36': true,
                    'A43': true,
                    'A48': true,
                    'A50': true,
                    'A58': true,
                    'A60': true,
                    'A61': true,
                    'A62': true,
                    'A63': true,
                    'A64': true,
                    'A65': true,
                    'A66': true,
                    'A67': true,
                    'A98': true,
                    'A106': true,
                    'A111': true,
                    'A118': true,
                    'A119': true,
                    'A120': true,
                    'A121': true,
                    'A122': true,
                    'A123': true,
                    'A124': true,
                    'A125': true,
                    'A141': true,
                    'A142': true,
                    'A143': true,
                    'A146': true
                };
                if (codes[code]) {
                    return true;
                } else {
                    return false;
                }
            }
            
            function firth_level(code) {
                var codes = {
                    'A13': true,
                    'A14': true,
                    'A17': true,
                    'A18': true,
                    'A27': true,
                    'A28': true,
                    'A29': true,
                    'A30': true,
                    'A32': true,
                    'A33': true,
                    'A34': true,
                    'A35': true,
                    'A37': true,
                    'A38': true,
                    'A39': true,
                    'A40': true,
                    'A44': true,
                    'A45': true,
                    'A46': true,
                    'A47': true,
                    'A49': true,
                    'A51': true,
                    'A52': true,
                    'A71': true,
                    'A72': true,
                    'A73': true,
                    'A74': true,
                    'A75': true,
                    'A76': true,
                    'A78': true,
                    'A79': true,
                    'A80': true,
                    'A81': true,
                    'A85': true,
                    'A86': true,
                    'A90': true,
                    'A91': true,
                    'A99': true,
                    'A100': true,
                    'A101': true,
                    'A102': true,
                    'A107': true,
                    'A108': true,
                    'A109': true,
                    'A110': true,
                    'A112': true,
                    'A113': true,
                    'A114': true,
                    'A115': true,
                    'A129': true,
                    'A130': true,
                    'A131': true,
                    'A132': true,
                    'A133': true,
                    'A134': true,
                    'A136': true,
                    'A137': true,
                    'A138': true,
                    'A139': true,
                    'A147': true
                };
                if (codes[code]) {
                    return true;
                } else {
                    return false;
                }
            }
            
            function render_line(record) {
                var item_code = record.get('item_code');
                if (first_level(item_code)) {
                    return 'font-weight:bold;';
                } 
                else if (second_level(item_code)) {
                    return 'color:#0000FF;';
                } else if (third_level(item_code)) {
                    return 'color:#0000FF;font-weight:bold;';
                } else if (firth_level(item_code)) {
                    return 'color:#FF0000;';
                }
            }
		]]></script>
        <a:dataSets>
            <a:dataSet id="sdic2020_hd_query_ds" autoCreate="true">
                <a:datas dataSource="/model/hd_path"/>
                <a:fields>
                    <a:field name="hd_id"/>
                    <a:field name="plan_year_n" readOnly="true"/>
                    <a:field name="plan_month_n" readOnly="true"/>
                    <a:field name="plan_frequency_n" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="sdic2020_ln_result_ds" autoQuery="true" fetchAll="true" model="sdic.SDIC2020.sdic_fin_plan_rpt_quarter_ln" queryDataSet="sdic2020_hd_query_ds"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="sdic2020_ln_return" text="HLS.RETURN"/>
                <a:gridButton click="sdic2020_ln_create" text="生成报表"/>
                <a:gridButton bind="sdic2020_ln_result_grid_id" type="excel"/>
            </a:screenTopToolbar>
            <a:form column="3" labelSeparator=" " marginWidth="150" title="基本信息">
                <a:textField name="plan_year_n" bindTarget="sdic2020_hd_query_ds" prompt="年份"/>
                <a:textField name="plan_month_n" bindTarget="sdic2020_hd_query_ds" prompt="月份"/>
                <a:textField name="plan_frequency_n" bindTarget="sdic2020_hd_query_ds" prompt="填报周期"/>
            </a:form>
            <a:grid id="sdic2020_ln_result_grid_id" bindTarget="sdic2020_ln_result_ds" marginHeight="180" marginWidth="150" navBar="true" rowRenderer="render_line" showRowNumber="true">
                <a:columns>
                    <a:column name="item_description" prompt="项目" width="400"/>
                    <a:column name="first_quarter_data" align="right" prompt="一季度计划数" renderer="Leaf.formatMoney" width="150"/>
                    <a:column name="second_quarter_data" align="right" prompt="二季度实际数" renderer="Leaf.formatMoney" width="150"/>
                    <a:column name="third_quarter_data" align="right" prompt="三季度计划数" renderer="Leaf.formatMoney" width="150"/>
                    <a:column name="forth_quarter_data" align="right" prompt="四季度计划数" renderer="Leaf.formatMoney" width="150"/>
                    <a:column name="current_year_plan_data" align="right" prompt="本年计划数" renderer="Leaf.formatMoney" width="150"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
        <script type="text/javascript"><![CDATA[
            // function load_complete() {
                // var grid_id = $('sdic2020_ln_result_grid_id');
                // var plan_month = $('sdic2020_hd_query_ds').getCurrentRecord().get('plan_month');
                // if (plan_month == '01' || plan_month == '02' || plan_month == '03') {
                    // grid_id.hideColumn('second_quarter_data');
                    // grid_id.hideColumn('third_quarter_data');
                    // grid_id.hideColumn('forth_quarter_data');
                // } else if (plan_month == '04' || plan_month == '05' || plan_month == '06') {
                    // grid_id.hideColumn('first_quarter_data');
                    // grid_id.hideColumn('third_quarter_data');
                    // grid_id.hideColumn('forth_quarter_data');
                // } else if (plan_month == '07' || plan_month == '08' || plan_month == '09') {
                    // grid_id.hideColumn('first_quarter_data');
                    // grid_id.hideColumn('second_quarter_data');
                    // grid_id.hideColumn('forth_quarter_data');
                // } else if (plan_month == '10' || plan_month == '11' || plan_month == '12') {
                    // grid_id.hideColumn('first_quarter_data');
                    // grid_id.hideColumn('second_quarter_data');
                    // grid_id.hideColumn('third_quarter_data');
                // }
            // }
            // load_complete();
        ]]></script>
    </a:view>
</a:screen>
