<?xml version="1.0" encoding="UTF-8"?>

<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:view>
        <script type="text/javascript"><![CDATA[
        function agent_query_query() {
            $('agent_query_grid_ds').query();
        }

        function agent_query_reset(){
            $('agent_query_form_ds').reset();
        }

        function agent_query_export() {
            $('source_to_grid')._export();
        }

        function aut_authority_list_validate_query(ds, qpara) {
            qpara['authority_flag'] = 'Y';
            qpara['trx_category'] = 'BP';
            qpara['master_type'] = 'BP';
            qpara['trx_id'] = 't1.bp_id';

        }

        ]]></script>

        <a:dataSets>
            <a:dataSet id="hls211_bp_class_ds" lookupCode="HLS211_BP_CLASS"/>
            <a:dataSet id="agent_query_form_ds">
                <a:fields>
                    <a:field name="bp_class"/>
                    <a:field name="bp_class_n" displayField="code_value_name" options="hls211_bp_class_ds" returnField="bp_class" valueField="code_value"/>
                    <a:field name="bp_code" autoComplete="true" lovGridHeight="350" lovHeight="500" lovService="cont.CON1230.con_bp_query" lovWidth="500" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_code" to="bp_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_name"/>
                    <a:field name="bp_code_lately" lovGridHeight="330" lovHeight="470" lovLabelWidth="120" lovService="cont.CON1230.con_bp_agent_query" lovWidth="700" title="代理商">
                        <a:mapping>
                            <a:map from="bp_code_lately" to="bp_code_lately"/>
                            <a:map from="bp_agent_name" to="bp_agent_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_agent_name"/>
                    <a:field name="__async__"  defaultValue="Y" prompt="异步导出"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="agent_query_grid_ds"
                       model="cont.CON1230.con_agent_query"
                       queryDataSet="agent_query_form_ds" selectable="true" selectionModel="single">
                <a:events>
                    <a:event  name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>

        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="agent_query_query" text="查询"/>
                <a:gridButton click="agent_query_reset" text="重置"/>
                <a:gridButton click="agent_query_export" text="导出"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="200" marginWidth="100" title="查询条件">
                <a:lov name="bp_code" bindTarget="agent_query_form_ds" prompt="客户编号" />
                <a:textField name="bp_name" bindTarget="agent_query_form_ds" prompt="客户名称"/>
                <a:lov name="bp_code_lately" bindTarget="agent_query_form_ds" prompt="代理商编号" />
                <a:comboBox name="bp_class_n" bindTarget="agent_query_form_ds" prompt="客户类型" />
                <a:numberField name="sum_quantity_terminate_from" bindTarget="agent_query_form_ds" prompt="已融资设备台数从" allowDecimals="false"/>
                <a:numberField name="sum_quantity_terminate_to" bindTarget="agent_query_form_ds" prompt="已融资设备台数到" allowDecimals="false"/>
                <a:numberField name="sum_quantity_from" bindTarget="agent_query_form_ds" prompt="融资中设备台数从" allowDecimals="false"/>
                <a:numberField name="sum_quantity_to" bindTarget="agent_query_form_ds" prompt="融资中设备台数到" allowDecimals="false"/>
                <a:numberField name="sum_finance_amount_from" bindTarget="agent_query_form_ds" prompt="融资总金额从" />
                <a:numberField name="sum_finance_amount_to" bindTarget="agent_query_form_ds" prompt="融资总金额到" />
                <a:numberField name="financing_amount_from" bindTarget="agent_query_form_ds" prompt="融资中金额从" />
                <a:numberField name="financing_amount_to" bindTarget="agent_query_form_ds" prompt="融资中金额到" />
                <a:datePicker name="min_lease_execution_date_from" bindTarget="agent_query_form_ds" prompt="第一台融资开始时间从" />
                <a:datePicker name="min_lease_execution_date_to" bindTarget="agent_query_form_ds" prompt="第一台融资开始时间到" />
                <a:numberField name="principal_total_from" bindTarget="agent_query_form_ds" prompt="逾期本金从" />
                <a:numberField name="principal_total_to" bindTarget="agent_query_form_ds" prompt="逾期本金到" />
                <!--<a:numberField name="sys_level_lately" bindTarget="agent_query_form_ds" prompt="最后一次AS评分等级" />-->
            </a:form>
            <a:grid id="source_to_grid" bindTarget="agent_query_grid_ds" navBar="true" height="400" marginWidth="100">
                <a:columns>
                    <a:column name="bp_code_lately" prompt="代理商编号(最近)" width="120"/>
                    <a:column name="bp_name_lately"  prompt="代理商名称(最近)" width="120"/>
                    <a:column name="contract_number_lately" prompt="合同编号(最近)" />
                    <a:column name="bp_code" prompt="客户编号"/>
                    <a:column name="bp_name"  prompt="客户名称" width="100" />
                    <a:column name="bp_class_n"  prompt="客户类型" width="100" />
                    <a:column name="sys_level_lately"  prompt="最后一次AS评分等级" width="150" />
                    <a:column name="bs_level"  prompt="执行中合同BS等级最差分数" width="200" />
                    <a:column name="sum_quantity_terminate"  prompt="已融资设备总台数" width="150" />
                    <a:column name="sum_quantity"  prompt="融资中设备台数" width="150" />
                    <a:column name="min_lease_execution_date"  prompt="第一台融资开始时间" width="150" renderer="Leaf.formatDate"/>
                    <a:column name="max_calc_date"  prompt="最后一台融资结束日期" width="150" renderer="Leaf.formatDate"/>
                    <a:column name="sum_finance_amount"  prompt="融资总金额" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="sum_received_amount"  prompt="已还融资金额" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="financing_amount"  prompt="融资中金额" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="principal_total"  prompt="逾期本金" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="interest_total"  prompt="逾期利息" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="overdue_total"  prompt="罚息" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="no_principal_total"  prompt="未到期本金" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="no_interest_total"  prompt="未到期利息" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="received_penalty"  prompt="已收罚息合计" width="100" renderer="Leaf.formatMoney"/>
                    <a:column name="contact_information"  prompt="客户联系方式" width="100" />
                    <a:column name="deduct_bank"  prompt="付款类型" width="100" />
                    <a:column name="overdue_times"  prompt="逾期期数合计" width="100" />
                    <a:column name="max_overdue_times"  prompt="最大逾期期数" width="100" />
                    <a:column name="mailing_address"  prompt="客户地址" width="300"/>
                    <a:column  name="is_excellent_customer_n" prompt="优秀客户" width="100" />
                    <a:column  name="excellent_customer_remark" prompt="优秀客户备注" width="100" />
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>