<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lpc 9874  
    $Date: 2017/11/24 13:52:40  
    $Revision: 1.0  
    $purpose: 经销商创建  创建界面    
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query model="hls.HLS303.hls_bp_agent_import_batch_id" rootPath="batch_id"/>
    </a:init-procedure>
    <a:view>
        <a:link id="bp_agent_link" url="${/request/@context_path}/modules/hls/HLS303/bp_agent_create.lview"/>
        <a:link id="import_save_link" model="hls.HLS303.save_data" modelaction="update"/>
        <a:link id="import_upload_link" url="${/request/@context_path}/modules/hls/HLS303/bp_agent_import_upload.lview"/>
        <script type="text/javascript"><![CDATA[
            function view() {
                parent._input_window.close();
            }
            
            // function loadData() {
                //
                // var win = new Leaf.Window({
                    // url: $('import_upload_link').getUrl(),
                    // params: {
                        // 'winid': ${/parameter/@winid},
                        // 'bp_id': ${/parameter/@bp_id},
                        // 'batch_id': ${/model/batch_id/record/@batch_id}
                    // },
                    // title: '导入',
                    // width: 420,
                    // height: 275
                // });
            // }
            
            function submitData() {

                var param = {};
                param['batch_id'] = ${/session/@session_id};
                param['bp_id'] = ${/parameter/@bp_id};
                Leaf.request({
                    url: $('import_save_link').getUrl(),
                    para: param,
                    success: function() {
                        Leaf.SideBar.show({
                            msg: '提交操作成功！',
                            duration: 2000
                        });
                        view();
                        //$('${/parameter/@winid}').close();
                    },
                    scope: this
                });
            }
        ]]></script>
        <a:dataSet id="modality_ds" lookupCode="AGENT_REBATE_MODALITY"/>
        <a:dataSets>
            <a:dataSet id="sale_ds" autoQuery="true" model="hls.HLS303.hls_bp_master_agent_sl_temp" queryUrl="${/request/@context_path}/autocrud/hls.HLS303.hls_bp_master_agent_sl_temp/query?batch_id=${/model/batch_id/record/@batch_id}"/>
        </a:dataSets>
        <a:dataSets>
            <a:dataSet id="rebate_ds" autoQuery="true" model="hls.HLS303.hls_bp_master_agent_rb_temp" queryUrl="${/request/@context_path}/autocrud/hls.HLS303.hls_bp_master_agent_rb_temp/query?batch_id=${/model/batch_id/record/@batch_id}">
                <a:field name="modality_n" displayField="code_value_name" options="modality_ds" readOnly="true" returnField="modality" valueField="code_value"/>
                <a:field name="modality"/>
            </a:dataSet>
        </a:dataSets>
        <a:dataSets>
            <a:dataSet id="loan_ds" autoQuery="true" model="hls.HLS303.hls_bp_master_agent_la_temp" queryUrl="${/request/@context_path}/autocrud/hls.HLS303.hls_bp_master_agent_la_temp/query?batch_id=${/model/batch_id/record/@batch_id}&amp;document_type=LOAN"/>
        </a:dataSets>
        <a:dataSets>
            <a:dataSet id="agent_loan_ds" autoQuery="true" model="hls.HLS303.hls_bp_master_agent_la_temp" queryUrl="${/request/@context_path}/autocrud/hls.HLS303.hls_bp_master_agent_la_temp/query?batch_id=${/model/batch_id/record/@batch_id}&amp;document_type=AGENT_LOAN"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <!-- <a:toolbarButton click="loadData" text="PROMPT.LOADDATA" width="80"/> -->
                <a:toolbarButton click="submitData" text="PROMPT.SUBMIT" width="80"/>
            </a:screenTopToolbar>
            <a:grid id="sale_grid" bindTarget="sale_ds" marginHeight="150" marginWidth="10" navBar="true">
                <a:columns>
                    <a:column name="statement_date" align="center" prompt="报表日期" width="120"/>
                    <a:column name="wholesale_task" align="center" prompt="批售任务" width="120"/>
                    <a:column name="wholesale_real_sales" align="center" prompt="批售实际" width="120"/>
                    <a:column name="wholesale_amount" align="center" prompt="批售金额（万元）" renderer="Leaf.formatMoney" width="180"/>
                    <a:column name="retail_task" align="center" prompt="零售任务" width="150"/>
                    <a:column name="retail_real_sales" align="center" prompt="零售实际" width="180"/>
                    <a:column name="retail_amount" align="center" prompt="零售金额（万元）" renderer="Leaf.formatMoney" width="180"/>
                    <a:column name="repair_sum" align="center" prompt="累计维修台数" width="180"/>
                    <a:column name="repair_amount" align="center" prompt="累计维修金额（万元）" renderer="Leaf.formatMoney" width="180"/>
                </a:columns>
            </a:grid>
            <a:grid id="rebate_grid" bindTarget="rebate_ds" marginHeight="150" marginWidth="10" navBar="true">
                <a:columns>
                    <a:column name="quarter" align="center" prompt="季度" width="120"/>
                    <a:column name="rebate_amount_vat" align="center" prompt="返利金额（含税）" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="modality_n" align="center" prompt="形式（现金/车辆）" width="120"/>
                    <a:column name="amount" align="center" prompt="金额（万元）" renderer="Leaf.formatMoney" width="180"/>
                    <a:column name="rebate_date" align="center" prompt="时间 " width="150"/>
                    <a:column name="note" align="center" prompt="备注" width="180"/>
                </a:columns>
            </a:grid>
            <a:grid id="loan_grid" bindTarget="loan_ds" marginHeight="150" marginWidth="10" navBar="true">
                <a:columns>
                    <a:column name="financial_org_name" align="center" prompt="金融机构名称" width="120"/>
                    <a:column name="credit_limit" align="center" prompt="授信额度（万元）" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="loan_amount" align="center" prompt="借款金额（万元）" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="loan_date_from" align="center" prompt="借款日期从" renderer="Leaf.formatDate" width="180"/>
                    <a:column name="loan_date_to" align="center" prompt="借款日期到" renderer="Leaf.formatDate" width="150"/>
                    <a:column name="loan_use" align="center" prompt="借款用途" width="180"/>
                    <a:column name="guarantee_condition" align="center" prompt="担保条件" width="180"/>
                </a:columns>
            </a:grid>
            <a:grid id="agent_loan_grid" bindTarget="agent_loan_ds" marginHeight="150" marginWidth="10" navBar="true">
                <a:columns>
                    <a:column name="bank_name" align="center" prompt="银行名" width="120"/>
                    <a:column name="credit_limit" align="center" prompt="授信额度（万元）" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="loan_amount" align="center" prompt="借款金额（万元）" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="loan_date_from" align="center" prompt="借款日期从" renderer="Leaf.formatDate" width="180"/>
                    <a:column name="loan_date_to" align="center" prompt="借款日期到" renderer="Leaf.formatDate" width="150"/>
                    <a:column name="loan_use" align="center" prompt="借款用途" width="180"/>
                    <a:column name="deposit_ratio" align="center" prompt="保证金比例" width="180"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
