<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhuxianfei
    $Date: 2017年11月23日 下午1:34:27  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <!-- <a:link id="bp_credit_details_window" url="${/request/@context_path}/modules/cont/CON403/con403_contract_credit_details.lview"/> -->
        <a:link id="hls700_credit_ln_update_link" model="hls.HLS700.hls_bp_master_credit_detail" modelaction="batch_update"/>
        <script type="text/javascript"><![CDATA[
            function hls700_credit_detail_add() {
                $('hls700_credit_detail_grid_ds').showEditorByRecord($('hls700_credit_detail_result_ds').create());
                            
            }
            
            function hls700_credit_detail__query() {
                $('hls700_credit_detail_result_ds').query();
            }
            
            
            function hls700_credit_detail_render(value, record, name) {
            
                return '<a href="javascript:hls700_grid_update(' + record.get('bp_credit_hd_id') + ')">分配</a>';
            }
            
            
            
            function credit_detail_exit() {
                // var con_record = $('hls700_credit_detail_result_ds').getAll();
                // for (var i = 0;i < con_record.length;i++) {
                    // if (con_record[i].dirty == true) {
                        // Leaf.showMessage('提示', '界面数据已更改，请先保存');
                        // return;
                    // }
                // }
                $('bp_credit_details_window').close();
            }
            
            
            function hls700_credit_detail_save() {
                var ds = $('hls700_credit_detail_result_ds');
                var records = ds.getAll();
                if (ds.validate()) {
                    var param_list = [];
                    var param = {};
                    for (var i = 0;i < records.length;i++) {
                        param = {
                            'bp_credit_line_id': records[i].get('bp_credit_line_id'),
                            'bp_credit_hd_id': ${/parameter/@bp_credit_hd_id},
                            'bp_id':${/parameter/@bp_id},
                            'credit_number': records[i].get('credit_number'),
                            'credit_total_amount': records[i].get('credit_total_amount'),
                            'open_amount': records[i].get('open_amount'),
                            'credit_date_from': records[i].get('credit_date_from'),
                            'credit_date_to': records[i].get('credit_date_to'),
                            'enable_flag': records[i].get('enable_flag'),
                            '_status': 'update'
                        };
                        param_list.push(param);
                    }
                    Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
                    Leaf.request({
                        url: $('hls700_credit_ln_update_link').getUrl(),
                        para: param_list,
                        success: function(res) {
                            Leaf.Masker.unmask(Ext.getBody());
                            Leaf.SideBar.show({
                                msg: '保存成功',
                                duration: 2000
                            });
                            $('hls700_credit_detail_result_ds').query();
                        },
                        failure: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hls700_credit_detail_query_ds"/>
            <a:dataSet id="hls700_credit_detail_result_ds" autoPageSize="true" autoQuery="true" fetchAll="true" model="hls.HLS700.hls_bp_master_credit_detail" queryUrl="${/request/@context_path}/autocrud/hls.HLS700.hls_bp_master_credit_detail/query?bp_credit_hd_id=${/parameter/@bp_credit_hd_id}" selectable="true" selectionModel="single">
                <a:fields>
                    <!--   <a:field name="bp_name" lovHeight="500" defaultValue="31483"  lovService="hls.HLS700.hls700_bp_master_lov" lovWidth="700" required="true" title="商业伙伴选择">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id"/>
                            <a:map from="bp_code" to="bp_code"/>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_category_n" to="bp_category_n"/>
                        </a:mapping>
                    </a:field> -->
                    <a:field name="bp_name" defaultValue="${/parameter/@bp_name}" readOnly="true"/>
                    <a:field name="contract_number" lovHeight="500" lovService="hls.HLS700.con_contract_for_lov" lovWidth="500" title="合同选择">
                        <a:mapping>
                            <a:map from="contract_id" to="contract_id"/>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="credit_number"/>
                    <a:field name="credit_total_amount"/>
                    <a:field name="open_amount"/>
                    <a:field name="credit_date_from"/>
                    <a:field name="credit_date_to"/>
                    <a:field name="enable_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hls700_credit_useinfo_result_ds" autoPageSize="true" autoQuery="true" model="hls.HLS700.hls_bp_master_credit_useinfo" queryUrl="${/request/@context_path}/autocrud/hls.HLS700.hls_bp_master_credit_useinfo/query?bp_credit_hd_id=${/parameter/@bp_credit_hd_id}" selectable="true" selectionModel="single"><![CDATA[
               
            ]]></a:dataSet>
            <a:dataSet id="hls700_credit_used_detail_result_ds" autoPageSize="true" autoQuery="true" model="hls.HLS700.hls_bp_master_credit_detail"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hls700_credit_detail_add" text="HLS.NEW"/>
                <a:gridButton click="hls700_credit_detail_save" text="HLS.SAVE"/>
                <a:gridButton click="credit_detail_exit" text="HLS.EXIT"/>
            </a:screenTopToolbar>
            <a:tabPanel marginHeight="200" marginWidth="30">
                <a:tabs>
                    <a:tab prompt="额度明细" width="110">
                        <a:grid id="hls700_credit_detail_grid_ds" bindTarget="hls700_credit_detail_result_ds" marginHeight="240" marginWidth="60" navBar="true">
                            <a:columns>
                                <a:column name="bp_name" editor="creditDs_grid_detail_editor_tf" prompt="商业伙伴名称" width="280"/>
                                <a:column name="credit_number" editor="creditDs_grid_detail_editor_tf" prompt="授信合同编号" width="200"/>
                                <a:column name="credit_total_amount" align="right" editor="creditDs_grid_detail_editor_tx" prompt="授信总额度" renderer="Leaf.formatMoney" width="150"/>
                                <a:column name="credit_date_from" editor="creditDs_grid_detail_editor_dp" prompt="授信期限从" renderer="Leaf.formatDate" width="120"/>
                                <a:column name="credit_date_to" editor="creditDs_grid_detail_editor_dp" prompt="授信期限到" renderer="Leaf.formatDate" width="120"/>
                                <a:column name="open_amount" align="right" editor="creditDs_grid_detail_editor_tx" prompt="开额额度" renderer="Leaf.formatMoney"/>
                                <a:column name="enable_flag" editor="creditDs_grid_detail_editor_cb" prompt="启用标志"/>
                            </a:columns>
                            <a:editors>
                                <!--  <a:currencyField id="creditDs_grid_detail_editor_tx"/> -->
                                <a:numberField id="creditDs_grid_detail_editor_tx"/>
                                <a:datePicker id="creditDs_grid_detail_editor_dp"/>
                                <a:lov id="creditDs_grid_detail_editor_lov"/>
                                <a:checkBox id="creditDs_grid_detail_editor_cb"/>
                                <a:textField id="creditDs_grid_detail_editor_tf"/>
                            </a:editors>
                        </a:grid>
                    </a:tab>
                    <a:tab prompt="额度使用详情" width="110">
                        <a:grid id="hls700_credit_detail_grid_ds_02" bindTarget="hls700_credit_useinfo_result_ds" marginHeight="270" marginWidth="60" navBar="true">
                            <a:columns>
                                <a:column name="contract_number" align="center" prompt="支付表编号" width="220"/>
                                <a:column name="business_type_n" align="center" prompt="业务类型" width="120"/>
                                <a:column name="bp_id_tenant_n" align="center" prompt="承租人名称" width="200"/>
                                <a:column name="contract_status_n" align="center" prompt="支付表状态" width="180"/>
                                <a:column name="delivery_total" align="right" prompt="投放总额" renderer="Leaf.formatMoney" width="200"/>
                                <a:column name="total_rental" align="right" prompt="租金回收总额" renderer="Leaf.formatMoney" width="200"/>
                                <a:column name="use_amount" align="right" prompt="使用额度金额" renderer="Leaf.formatMoney" width="200"/>
                                <a:column name="overdue_status_n" align="center" prompt="是否逾期" width="100"/>
                                <a:column name="release_date" align="center" prompt="放款时间" renderer="Leaf.formatDate"/>
                            </a:columns>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
        </a:screenBody>
    </a:view>
</a:screen>
