<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gonglu  
    $Date: 2014-4-21 下午2:16:03  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="trailer_attachment_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <script type="text/javascript"><![CDATA[
            function receipt_attachment_upload(val, rec, name) {
                return '<a href=javascript:open_upload_window(' + rec.get('ast_car_trailer_id') + ')>附件上传</a>';
            }
            
            function open_upload_window(record_id) {
                if (Leaf.isEmpty(record_id)) {
                    Leaf.showMessage('提示', '请先保存再上传附件!');
                    return;
                }
                var url = $('trailer_attachment_uploadFile_id').getUrl() + '?table_name=AST_CAR_TRAILER&header_id=' + record_id;
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'trailer_uploadFile_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {});
            }
            
            function submitsuccessHandler(ds, res) {
                ds.query();
            }
            
            function ast_car_trailer_grid_id_renderer(value, record, name) {
                if (name == 'trail_wfl_status_desc') {
                    var trail_wfl_status = record.get('trail_wfl_status');
                    if (trail_wfl_status == 'SUBMIT') {
                        return '<div style="color:grey">' + value + '<div>';
                    } else if (trail_wfl_status == 'REJECT') {
                        return '<div style="color:red">' + value + '<div>';
                    } else if (trail_wfl_status == 'APPROVED') {
                        return '<div style="color:blue">' + value + '<div>';
                    }
                    return value;
                }
                return value;
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="ast_car_trailer_result_ds" autoPageSize="true" model="ast.AST505.ast_car_trailer" selectable="true">
                <a:fields>
                    <a:field name="ast_car_trailer_id"/>
                    <a:field name="item_detail_id"/>
                    <a:field name="trailer_date"/>
                    <a:field name="trailer_place"/>
                    <a:field name="trailer_partner"/>
                    <a:field name="trailer_fee"/>
                    <a:field name="trailer_result"/>
                    <a:field name="disposal_scheme"/>
                    <a:field name="trailer_reason"/>
                    <a:field name="trail_wfl_status"/>
                    <a:field name="trail_fee_status"/>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="submitsuccessHandler"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:grid id="ast_car_trailer_grid_id" bindTarget="ast_car_trailer_result_ds" height="160" marginWidth="30" navBar="true">
            <a:columns>
                <a:column name="trailer_date" editor="ast_car_trailer_dp" prompt="拖车时间" renderer="Leaf.formatDate" width="100"/>
                <a:column name="trailer_place" editor="ast_car_trailer_tf" prompt="拖车地点" width="180"/>
                <a:column name="trail_wfl_status_desc" align="center" prompt="拖车申请状态" renderer="ast_car_trailer_grid_id_renderer" width="100"/>
                <a:column name="trail_fee_status_desc" align="center" prompt="拖车费用状态" width="100"/>
                <a:column name="estimate_amount" prompt="拖车预估费用" renderer="Leaf.formatMoney" width="100"/>
                <a:column name="trailer_fee" align="right" editor="ast_car_trailer_nf" prompt="拖车费用" renderer="Leaf.formatMoney" width="100"/>
                <a:column name="trail_other_fee" editor="ast_car_trailer_nf" prompt="其他费用" renderer="Leaf.formatMoney" width="100"/>
                <a:column name="trailer_reason" editor="ast_car_trailer_tf" prompt="拖车原因" width="120"/>
                <a:column name="trailer_partner" editor="ast_car_trailer_tf" prompt="拖车合作方" width="100"/>
                <a:column name="trailer_result" editor="ast_car_trailer_tf" prompt="拖车结果" width="180"/>
                <a:column name="disposal_scheme" editor="ast_car_trailer_tf" prompt="处置方案" width="180"/>
                <a:column align="center" prompt="附件上传" renderer="receipt_attachment_upload" width="80"/>
            </a:columns>
            <a:editors>
                <a:numberField id="ast_car_trailer_nf"/>
                <a:textField id="ast_car_trailer_tf"/>
                <a:datePicker id="ast_car_trailer_dp"/>
            </a:editors>
        </a:grid>
        <a:hBox/>
    </a:view>
</a:screen>