<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: ZLF 
    $Date: 2014-11-18 上午11:07:38  
    $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_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <script type="text/javascript"><![CDATA[
            function summaryRenderer(datas, name) {
                var sum = 0;
                for (var i = 0;i < datas.length;i++) {
                    record = datas[i];
                    var t_1 = record.get(name);
                    var t_2 = parseFloat(t_1);
                    if (!isNaN(t_2)) {
                        sum += t_2;
                    }
                }
                return '<font color="red">' + Leaf.formatNumber(sum, 2) + '</font>';
            }
            
            function attachment_uploadFile() {

                if (!'${/parameter/@change_req_id}') {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存！');
                    return;
                }
                var url = $('attachment_downloadFile_id').getUrl() + '?table_name=CON_CONTRACT_CHANGE_REQ&header_id=' + '${/parameter/@change_req_id}';
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'uploadFile_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {});
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="contract_change_req_status_ds_2" lookupCode="CON_CHANGE_REQ_STATUS"/>
            <a:dataSet id="con_contract_change_req_head_ds" autoQuery="true" model="cont.CON748.con_contract_change_req" queryUrl="${/request/@context_path}/autocrud/cont.CON748.con_contract_change_req/query?change_req_id=${/parameter/@change_req_id}">
                <a:fields>
                    <a:field name="status_desc" displayField="code_value_name" options="contract_change_req_status_ds_2" returnField="req_status" valueField="code_value"/>
                    <a:field name="description" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_change_req_line_ds" autoQuery="true" model="cont.CON748.con_contract_change_req_detail" queryUrl="${/request/@context_path}/autocrud/cont.CON748.con_contract_change_req_detail/query?change_req_id=${/parameter/@change_req_id}" selectable="true"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="attachment_uploadFile" text="附件上传"/>
            </a:screenTopToolbar>
            <a:form marginWidth="50" title="查询条件">
                <a:hBox>
                    <a:textField name="change_req_number" bindTarget="con_contract_change_req_head_ds" prompt="申请编号" readOnly="true"/>
                    <a:datePicker name="req_date" bindTarget="con_contract_change_req_head_ds" prompt="申请日期从" readOnly="true"/>
                    <a:textField name="contract_name" bindTarget="con_contract_change_req_head_ds" prompt="合同名称" readOnly="true"/>
                    <a:textField name="contract_number" bindTarget="con_contract_change_req_head_ds" prompt="合同编号" readOnly="true"/>
                    <a:comboBox name="req_status_desc" bindTarget="con_contract_change_req_head_ds" prompt="申请状态" readOnly="true"/>
                </a:hBox>
                <a:hBox>
                    <a:textArea name="description" bindTarget="con_contract_change_req_head_ds" prompt="变更原因" width="380"/>
                </a:hBox>
            </a:form>
            <a:grid id="con_contract_change_req_line_grid" bindTarget="con_contract_change_req_line_ds" marginHeight="400" marginWidth="50" navBar="true">
                <a:columns>
                    <a:column name="cf_item_desc" align="center" prompt="HLS.CF_ITEM_DESC" width="120"/>
                    <a:column name="times" align="center" prompt="HLS.TIMES" width="100"/>
                    <a:column name="rental_amount" align="right" prompt="CON305.ACC_AMOUNT" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="due_date" align="center" prompt="HLS.DUE_DATE" renderer="Leaf.formatDate" width="120"/>
                    <a:column name="overdue_max_days" align="right" prompt="CON747.OVERDUE_MAX_DAYS" width="120"/>
                    <a:column name="due_amount" align="right" prompt="CON305.ACC_AMOUNT" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="received_amount" align="right" prompt="已收金额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="unreceived_amount" align="right" prompt="未收金额" renderer="Leaf.formatMoney" width="120"/>
                    <a:column name="derate_amount" align="right" footerRenderer="summaryRenderer" prompt="本次减免金额" renderer="Leaf.formatMoney" width="100"/>
                    <a:column name="change_penalty_amount" align="right" editor="line_nf" prompt="减免后应收金额" renderer="Leaf.formatMoney" width="120"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
