<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Icon  
    $Date: 2014-11-3 下午3:11:24  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure><![CDATA[
		
	]]></a:init-procedure>
    <a:view>
        <a:link id="attachment_desc_link" url="${/request/@context_path}/modules/csh/CSH507/csh_attachment_query.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_contract_query_link_id" url="${/request/@context_path}/modules/cont/CON505/con_contract_query.lview"/>
        <script type="text/javascript"><![CDATA[
            function csh507_payment_reset() {
                $('csh_payment_apply_query_ds').reset();
            }
            
            function csh507_payment_query() {
                $('csh_payment_apply_result_ds').query();
            }
            
            function csh507_payment_confirm() {
                var records = $('csh_payment_apply_result_ds').getSelected();
                if (records.length < 1) {
                    Leaf.showMessage('${l:PROMPT}', '请至少选择一条记录');
                    return;
                }
                Leaf.showConfirm('提示', '是否确认?', function() {
                    for (var i = 0;i < records.length;i++) {
                        records[i].set('_status', 'update', false);
                    }
                    $('csh_payment_apply_result_ds').submitSelected('${/request/@context_path}/autocrud/csh.CSH507.csh_payment_confirm_query/batch_update');
                });
            }
            
            function csh_payment_submitsuccess(ds) {
                $('csh_payment_apply_query_ds').reset();
                $('csh_payment_apply_result_ds').query();
            }
            
            function attachment_desc_renderer(val, rec, name) {
                return '<a href=javascript:open_upload_window(' + rec.get('contract_id') + ',' + rec.get('cdd_list_id') + ')>查看附件</a>';
            }
            
            function open_upload_window(contract_id, cdd_list_id) {
                var url = $('attachment_desc_link').getUrl();
                var win = new Leaf.Window({
                    id: 'con_contract_content_window',
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    params: {
                        contract_id: contract_id,
                        cdd_list_id: cdd_list_id,
                        winId: 'con_contract_content_window'
                    },
                    fullScreen: true
                });
                win.on('close', function() {});
            }
            
            function contract_info_renderer(value, record, name) {
                if (name == 'contract_number' && value) {
                    return '<a href="javascript:open_contract_win(\'' + record.id + '\')">' + value + '</a>';
                }
            }
            
            function open_contract_win( record_id) {
                var record = $('csh_payment_apply_result_ds').findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON301_INTER';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'UPDATE';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_query_link_id', 'csh_payment_apply_result_ds');
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
        <a:dataSets>
            <a:dataSet id="csh_payment_apply_query_ds">
                <a:fields>
                    <a:field name="contract_number_from"/>
                    <a:field name="contract_number_to"/>
                    <a:field name="req_date_from"/>
                    <a:field name="req_date_to"/>
                    <a:field name="bp_code_from" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code_from"/>
                            <a:map from="bp_name" to="bp_code_desc_from"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="bp_code_to" lovGridHeight="350" lovHeight="500" lovService="basic.hls_bp_master_v_for_lov" lovWidth="500">
                        <a:mapping>
                            <a:map from="bp_code" to="bp_code_to"/>
                            <a:map from="bp_name" to="bp_code_desc_to"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="amount_from"/>
                    <a:field name="amount_to"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="csh_payment_apply_result_ds" autoPageSize="true" autoQuery="true" model="csh.CSH507.csh_payment_confirm_query" queryDataSet="csh_payment_apply_query_ds" selectable="true">
                <a:events>
                    <a:event name="submitsuccess" handler="csh_payment_submitsuccess"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="csh507_payment_reset" text="HLS.RESET"/>
                <a:gridButton click="csh507_payment_query" text="HAP_QUERY"/>
                <a:gridButton click="csh507_payment_confirm" text="确认"/>
                <!-- <a:gridButton click="csh502_payment_close" text="HLS.CLOSE"/> -->
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="100" title="查询条件">
                <a:textField name="contract_number_from" bindTarget="csh_payment_apply_query_ds" prompt="合同编号从" width="150"/>
                <a:textField name="contract_number_to" bindTarget="csh_payment_apply_query_ds" prompt="合同编号到" width="150"/>
                <a:datePicker name="req_date_from" bindTarget="csh_payment_apply_query_ds" prompt="起租日从" width="150"/>
                <a:datePicker name="req_date_to" bindTarget="csh_payment_apply_query_ds" prompt="起租日到" width="150"/>
                <a:lov name="bp_code_from" bindTarget="csh_payment_apply_query_ds" prompt="CSH502.CSH_PAYMENT_OBJ_FROM" width="150"/>
                <a:lov name="bp_code_to" bindTarget="csh_payment_apply_query_ds" prompt="CSH502.CSH_PAYMENT_OBJ_TO" width="150"/>
                <a:numberField name="amount_from" bindTarget="csh_payment_apply_query_ds" prompt="车款从" width="150"/>
                <a:numberField name="amount_to" bindTarget="csh_payment_apply_query_ds" prompt="车款到" width="150"/>
                <!-- <a:textField name="submitted_flag" bindTarget="csh_payment_req_query_ds" prompt="CSH502.CSH_SUBMIT_STATE" width="150"/> -->
                <!-- <a:checkBox name="closed_flag" bindTarget="csh_payment_req_query_ds" prompt="CSH502.CSH_CLOSED_FLAG" width="70"/> -->
            </a:form>
            <a:grid id="csh_payment_apply_grid" bindTarget="csh_payment_apply_result_ds" marginHeight="230" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="contract_number" prompt="合同编号" renderer="contract_info_renderer" width="150"/>
                    <a:column name="contract_name" prompt="合同名称" width="150"/>
                    <a:column name="inception_of_lease" align="center" prompt="起租日" renderer="Leaf.formatDate" width="150"/>
                    <a:column name="bp_code" prompt="付款对象" width="150"/>
                    <a:column name="bp_name" prompt="对象名称" width="150"/>
                    <a:column name="lease_item_amount" align="right" prompt="车款" renderer="Leaf.formatMoney" width="100"/>
                    <a:column name="other_fee3" align="right" prompt="购置税" renderer="Leaf.formatMoney" width="100"/>
                    <a:column name="insurance_fee" align="right" prompt="保险费" renderer="Leaf.formatMoney" width="100"/>
                    <a:column name="pay_req_print_status_des" prompt="打印状态" width="100"/>
                    <a:column name="attachment_desc" align="center" prompt="查看附件" renderer="attachment_desc_renderer" width="100"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>