<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2014-11-18 上午10:40:15  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:view>
        <a:link id="attach_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <script type="text/javascript"><![CDATA[
            function insurance_endorse_close(){
                $('${/parameter/@winId}').close();
            }
            
            function insurance_endorse_save(){
                $('insurance_endorse_ds').submit();
            }
            
            function one_insurance_endorse_ds_query(ds){
                ds.query();
            }
            
            function insurance_endorse_add(){
                   var ds = $( 'insurance_endorse_ds');
                var record = ds.create(ds.currentIndex);
                $( 'grid_one').showEditorByRecord(record);
                
            }
            
            function one_insurance_endorse_ds_add(ds,record,index){
                var ast_car_insurance_id='${/parameter/@ast_car_insurance_id}';
                record.set('ast_car_insurance_id',ast_car_insurance_id);
            }
            
            function endorse_attach_upload(val, rec, name){
            return '<a href=javascript:open_upload_endorse_window(' + rec.get('insurance_endorse_id') + ')>附件上传</a>';
            }
            
            function open_upload_endorse_window(record_id){
                 if (Leaf.isEmpty(record_id)) {
                    Leaf.showMessage('提示', '请先保存再上传附件！');
                    return;
                }
                var url = $('attach_uploadFile_id').getUrl() + '?table_name=AST_CAR_INSURANCE_ENDORSE&header_id=' + record_id;
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'endorse_uploadFile_id',
                    width: 850,
                    height: 400
                });
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="insurance_endorse_ds" autoQuery="true" model="cont.CON762.con_car_insurance_endorse" queryUrl="${/request/@context_path}/autocrud/cont.CON762.con_car_insurance_endorse/query?ast_car_insurance_id=${/parameter/@ast_car_insurance_id}">
                <a:fields>
                    <a:field name="endorse_number" required="true"/>
                    <a:field name="ast_car_insurance_id"/>
                </a:fields>
                <a:events>
                    <a:event name="add" handler="one_insurance_endorse_ds_add"/>
                    <a:event name="submitsuccess" handler="one_insurance_endorse_ds_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="insurance_endorse_close" text="退出"/>
                <a:gridButton click="insurance_endorse_save" text="保存"/>
                <a:gridButton click="insurance_endorse_add" text="新增"/>
            </a:screenTopToolbar>
            <a:grid id="grid_one" bindTarget="insurance_endorse_ds" height="300" navBar="true" width="675">
                <a:columns>
                    <a:column name="endorse_number" editor="tx_ed" prompt="批单编号" width="150"/>
                    <a:column name="insure_name" editor="tx_ed" prompt="投保人" width="150"/>
                    <a:column name="first_beneficiary" editor="tx_ed" prompt="第一受益人" width="150"/>
                    <a:column name="endorse_fee" align="right" editor="num_ed" prompt="批单费用" renderer="Leaf.formatMoney" width="120"/>
                    <a:column align="center" prompt="附件" renderer="endorse_attach_upload" width="100"/>
                </a:columns>
                <a:editors>
                    <a:textField id="tx_ed"/>
                    <a:numberField id="num_ed" allowDecimals="true" allowFormat="true" decimalPrecision="2"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
