<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:view>
        <a:link id="con_bad_debts_confirmed_calc_id" model="cont.CON8000.con_bad_debts_confirmed_query"
                modelaction="update"/>
        <a:link id="${/parameter/@layout_code}con_contract_query_link"
                url="${/request/@context_path}/modules/cont/CON3200/con_re_incept_modify.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
        <script type="text/javascript"><![CDATA[
        // 退出按钮
        function con_bad_debts_confirmed_reset() {
            $('con_bad_debts_confirmed_query_ds').reset();
        }

        function con_bad_debts_confirmed_query() {
            if ($('con_bad_debts_confirmed_query_ds').validate()) {
                var headers_ds = $('con_bad_debts_confirmed_query_ds');
                var record = headers_ds.getAt(0);
                Leaf.Masker.mask(Ext.getBody(), '正在统计并查询,请稍等...');
                Leaf.request({
                    url: $('con_bad_debts_confirmed_calc_id').getUrl(),
                    para: {
                        end_date: record.get('end_date')
                    },
                    success: function (res) {
                        Leaf.Masker.unmask(Ext.getBody());
                        $('con_bad_debts_confirmed_result_ds').query();
                        $('con_bad_debts_confirmed_sum_ds').query();

                    },
                    failure: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    error: function () {
                        Leaf.Masker.unmask(Ext.getBody());
                    },
                    scope: this
                });
            }
        }
        function CON620_render_contract_dun_grid(value, record, name) {
            if (name == 'contract_number') {
                    return '<a href="javascript:contract_detail_link(' + record.id + ',\'' + record.ds.id + '\');">' + value + '</a>';
            }
        }
            function contract_detail_link(record_id,ds_id) {
            var record = $(ds_id).findById(record_id);
            var param = record.data;
                param['document_id'] = record.get('contract_id');
            param['function_usage'] = 'QUERY';
            param['function_code'] = 'CON3200Q';
            param['maintain_type'] = 'QUERY';
            param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';

            //hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', null);
            hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, '${/parameter/@layout_code}con_contract_query_link', ds_id);
        }

        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="con_bad_debts_confirmed_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="period_name" lovGridHeight="100" lovHeight="100"
                             lovService="cont.CON8000.gld_periods"
                             lovWidth="500" required="true" title="GLD_PERIODS.PERIOD_NAME" prompt="期间">
                        <a:mapping>
                            <a:map from="period_name" to="period_name"/>
                            <a:map from="end_date" to="end_date"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="end_date"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_bad_debts_confirmed_result_ds" autoPageSize="true"
                       model="cont.CON8000.con_bad_debts_confirmed_query"
                       queryDataSet="con_bad_debts_confirmed_query_ds"
            />
            <a:dataSet id="con_bad_debts_confirmed_sum_ds" autoPageSize="true"
                       model="cont.CON8000.con_bad_debts_confirmed_sum_query"
                       queryDataSet="con_bad_debts_confirmed_query_ds"
            />
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="con_bad_debts_confirmed_reset" text="HLS.RESET"/>
                <a:gridButton click="con_bad_debts_confirmed_query" text="HLS.QUERY"/>
            </a:screenTopToolbar>
            <a:form column="1" labelWidth="130" marginWidth="50">
                <a:lov name="period_name" prompt="期间"
                       bindTarget="con_bad_debts_confirmed_query_ds" renderer="Leaf.formatDate"/>
            </a:form>
            <a:tabPanel marginHeight="100" marginWidth="50">
                <a:tabs>
                    <a:tab prompt="解约回购合同计提对象金额" width="190">
                        <a:grid id="con_bad_debts_confirmed_result_id" bindTarget="con_bad_debts_confirmed_result_ds"
                                marginHeight="150" marginWidth="238" navBar="true">
                            <a:columns>
                                <a:column name="contract_number" prompt="合同编号" width="200" align="center"  renderer="CON620_render_contract_dun_grid"/>
                                <a:column name="bp_id_tenant_name" prompt="承租人名称" width="230" align="center"/>
                                <a:column name="principal_due_sum" prompt="本金应收金额合计" renderer="Leaf.formatMoney"
                                          width="125" align="right"/>
                                <a:column name="principal_received_sum" prompt="本金已收金额合计" renderer="Leaf.formatMoney"
                                          width="125" align="right"/>
                                <a:column name="over_due_max_days" prompt="最大逾期天数"
                                          width="120" align="center"/>
                                <a:column name="confirmed_amount" prompt="计提对象金额" renderer="Leaf.formatMoney"
                                          width="120" align="right"/>
                                <a:column name="confirmed_rate" prompt="计提率"
                                          width="120" align="right"/>
                            </a:columns>
                        </a:grid>
                    </a:tab>
                    <a:tab prompt="解约回购坏账计提合计" width="180">
                        <a:grid id="con_bad_debts_confirmed_sum_id" bindTarget="con_bad_debts_confirmed_sum_ds"
                                marginHeight="150" marginWidth="238" navBar="true">
                            <a:columns>
                                <a:column name="confirmed_types_desc" prompt="债券状况" width="250" align="center"/>
                                <a:column name="customer_count" prompt="计提对象客户数" width="250" align="center"/>
                                <a:column name="confirmed_amount" prompt="计提对象金额"  renderer="Leaf.formatMoney" width="250" align="right"/>
                                <a:column name="confirmed_rate" prompt="计提率" width="250" align="right"/>
                                <a:column name="confirmed_sum_amount" prompt="计提金额" align="right"
                                          renderer="Leaf.formatMoney"/>
                            </a:columns>
                        </a:grid>
                    </a:tab>
                </a:tabs>
            </a:tabPanel>
        </a:screenBody>
    </a:view>
</a:screen>