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

<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="csh.CSH1010.csh1010_deposit_distinguish" rootPath="csh1010_deposit_distinguish_ds"/>
        <a:model-query fetchAll="true" model="csh.CSH1010.csh_deposit_positive" rootPath="csh1010_deposit_positive_ds"/>
        <a:model-query fetchAll="true" model="cont.CON1240.con_get_period" rootPath="sys_default_time"/>
    </a:init-procedure>
    <a:view>
        <script type="text/javascript"><![CDATA[
        function csh_deposit_query() {
            $('source_to_grid_ds').query();
            $('csh_deposit_form_ds_sum').query();
        }

        function csh_deposit_reset(){
            $('csh_deposit_form_ds').reset();
        }

        function csh_deposit_export() {
            $('source_to_grid')._export(null,'客户保证金明细');
        }
        function aut_authority_list_validate_query(ds, qpara) {
            qpara['authority_flag'] = 'Y';
            qpara['contract_ref_content_flag'] = 'Y';
            qpara['trx_category'] = 'CONTRACT';
            qpara['trx_id'] = 't1.contract_id';

        }
        ]]></script>

        <a:dataSets>
            <a:dataSet id="status_ds" lookupCode="CON500_CONTRACT_STATUS"/>
            <a:dataSet id="csh1010_deposit_distinguish_ds">
                <a:datas dataSource="/model/csh1010_deposit_distinguish_ds"/>
            </a:dataSet>
            <a:dataSet id="csh1010_deposit_positive_ds">
                <a:datas dataSource="/model/csh1010_deposit_positive_ds"/>
            </a:dataSet>
            <a:dataSet id="csh_deposit_form_ds" autoQuery="true"  >
                <a:fields>
                    <a:field name="deposit_distinguish" displayField="deposit_distinguish" options="csh1010_deposit_distinguish_ds"
                             returnField="deposit_distinguish" valueField="deposit_distinguish"/>
                    <a:field name="deposit_positive" displayField="deposit_positive" options="csh1010_deposit_positive_ds"
                             returnField="deposit_positive_n" valueField="number" defaultValue="大于0"/>
                    <a:field name="deposit_positive_n" defaultValue="1"/>
                    <a:field name="write_off_date" defaultValue="${/model/sys_default_time/record/@now_date}"/>
                    <a:field name="contract_status_n" displayField="code_value_name" options="status_ds" returnField="status"
                             valueField="code_value"/>
                    <a:field name="contract_status"/>
                    <a:field name="__async__"  defaultValue="Y" prompt="异步导出"/>
                </a:fields>
            </a:dataSet>

            <a:dataSet id="csh_deposit_form_ds_sum" autoQuery="false" queryDataSet="csh_deposit_form_ds" model="csh.CSH1010.csh_deposit_agent_sum">
            </a:dataSet>

            <a:dataSet id="source_to_grid_ds" autoQuery="false" model="csh.CSH1010.csh_deposit_agent_query" queryDataSet="csh_deposit_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="csh_deposit_query" text="查询"/>
                <a:gridButton click="csh_deposit_reset" text="重置"/>
                <a:gridButton click="csh_deposit_export" text="导出"/>
            </a:screenTopToolbar>
            <a:form column="4" marginWidth="100" title="查询条件">
                <a:textField name="contract_number" bindTarget="csh_deposit_form_ds" prompt="合同号" />
                <a:textField name="bp_name" bindTarget="csh_deposit_form_ds" prompt="客户名称" />
                <a:textField name="bp_agent_name" bindTarget="csh_deposit_form_ds" prompt="代理商名称" />
                <a:comboBox name="deposit_distinguish" bindTarget="csh_deposit_form_ds" prompt="保证金类型" />
                <a:comboBox name="deposit_positive" bindTarget="csh_deposit_form_ds" prompt="保证金是否大于0" />
                <a:comboBox name="contract_status_n" bindTarget="csh_deposit_form_ds" prompt="合同状态" />
                <a:datePicker name="write_off_date" bindTarget="csh_deposit_form_ds" prompt="基准日期"/>
                <a:numberField name="balance_amount_sum" bindTarget="csh_deposit_form_ds_sum" prompt="保证金余额总和" editable="false" renderer="Leaf.formatMoney"/>
            </a:form>
            <a:grid id="source_to_grid" bindTarget="source_to_grid_ds" navBar="true" height="400" marginWidth="100">
                <a:columns>
                    <a:column name="contract_number" align="center" prompt="合同号" width="150"/>
                    <a:column name="bp_code" align="center" prompt="客户编码" width="150"/>
                    <a:column name="bp_name" align="center" prompt="客户名称" width="150"/>
                    <a:column name="bp_agent_code" align="center" prompt="代理商编码" width="150"/>
                    <a:column name="bp_agent_name" align="center" prompt="代理商名称" width="150"/>
                    <a:column name="deposit_distinguish"  prompt="保证金区分" align="center" />
                    <a:column name="deposit" align="center" prompt="收取金额" width="150" renderer="Leaf.formatMoney"/>
                    <a:column name="deduction_amount" align="center" prompt="核销租金" width="150" renderer="Leaf.formatMoney"/>
                    <a:column name="refund_amount" align="center" prompt="退款金额" width="150" renderer="Leaf.formatMoney"/>
                    <a:column name="balance_amount" align="center" prompt="保证金余额" width="150" renderer="Leaf.formatMoney"/>
                    <a:column name="contract_status_n" align="center" prompt="合同状态" width="150" />
                    <a:column name="et_date" align="center" prompt="结清日期" width="150" renderer="Leaf.formatDate"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>