<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: nyl  
    $Date: 2015-02-14 下午04:17:08  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:c="leaf.application.action" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc">
    <a:init-procedure>
        <a:model-query autoCount="false" fetchAll="true" model="cont.CON565.con_contract_province" rootPath="item_column"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
            function query_con_contract_terminate_query_ds() {
 
                $('con_contract_terminate_result_ds').query();
            }
            
            function reset_con_contract_terminate_result_ds() {
                $('con_contract_terminate_query_ds').reset();
            
            }
            
            function onload(ds) {
             
                var records = $('con_contract_terminate_result_ds').getAll();
                var columns_records = $('con_contract_terminat_columns_ds').getAll();
               
                for (var i = 0;i < records.length;i++) {
                    for(var j = 0;j < columns_records.length;j++){
                        if(columns_records[j].get('termination_date') == records[i].get('termination_date')){
                          records[i].set(columns_records[j].get('province_id'), columns_records[j].get('quantity'));  
                        }
                    }
                    
                }
             records[i].set('####','');
            }
            
            function onRenderFunction(value, record, name) {
            
                if (name != 'total_quantity') {
                    return record.get('quantity');
                }
                return value;
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con_contract_terminate_query_ds">
                <a:fields>
                    <a:field name="from_termination_date"/>
                    <a:field name="to_termination_date"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_terminat_columns_ds" autoQuery="true" loadData="true" model="cont.CON565.con_contract_terminat_columns" queryDataSet="con_contract_terminate_query_ds"/>
            <a:dataSet id="con_contract_terminate_result_ds" autoCount="true" autoQuery="true" loadData="true" model="cont.CON565.con_contract_terminate_for_vender" pageSize="100" queryDataSet="con_contract_terminate_query_ds">
                <a:fields>
                    <a:placeHolder id="dynamicLineFieldsItem"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="onload"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form column="4" marginWidth="100" title="查询条件">
                <a:comboBox name="from_termination_date" bindTarget="con_contract_terminate_query_ds" prompt="月份从"/>
                <a:comboBox name="to_termination_date" bindTarget="con_contract_terminate_query_ds" prompt="月份至"/>
            </a:form>
            <a:hBox>
                <a:button click="query_con_contract_terminate_query_ds" text="查询"/>
                <a:button click="reset_con_contract_terminate_result_ds" text="重置"/>
            </a:hBox>
            <a:grid id="grid_id" bindTarget="con_contract_terminate_result_ds" height="300" marginWidth="100" navBar="true">
                <a:toolBar>
                    <a:button type="excel"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="termination_date" align="center" prompt="结束月份"/>
                    <a:placeHolder id="dynamicLineColumnItem"/>
                    <a:column name="total_quantity" prompt="合计"/>
                </a:columns>
                <a:editors>
                    <a:numberField allowDecimals="true" allowFormat="true" allowNegative="true"/>
                </a:editors>
            </a:grid>
            <a:hBox/>
        </a:screenBody>
    </a:view>
    <a:view-config>
        <c:create-config targetId="dynamicLineFieldsItem">
            <p:loop source="/model/item_column">
                <c:process-config>
                    <a:field name="${@province_id}" prompt="${@province_id_tenant_n}"/>
                </c:process-config>
            </p:loop>
        </c:create-config>
        <c:create-config targetId="dynamicLineColumnItem">
            <p:loop source="/model/item_column">
                <c:process-config>
                    <a:column name="${@province_id}" align="center" width="80"/>
                </c:process-config>
            </p:loop>
        </c:create-config>
    </a:view-config>
</a:screen>
