<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-12-7 下午03:33:05  
    $Revision: 1.0  
    $Purpose: 合同保险维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true">
    <a:view>
        <a:link id="con_contract_insurance_year_link" model="cont.CON511.con_contract_insurance_year" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            function con_contract_insurance_new() {
                $('con_contract_insurance_gird').showEditorByRecord($('con_contract_insurance_result').create());
            }
            
            function con_contract_insurance_save() {
                $('con_contract_insurance_result').submit();
            }
            
            function con511_contract_insurance_query() {
                $('con_contract_insurance_result').query();
            }
            
            function con_contract_insurance_reset() {
                $('con_contract_insurance_query').reset();
            }
            
            function con_contract_insurance_update(ds, record, name, value, oldvalue) {
                var year;
                if (name == 'insurance_date_from') {
                    if (!Ext.isEmpty(record.get('insurance_date_from'))) {
                        params = {
                            'insurance_date_from': record.get('insurance_date_from')
                        };
                        Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
                        Leaf.request({
                            url: $('con_contract_insurance_year_link').getUrl(),
                            para: params,
                            success: function(res) {
                                Leaf.Masker.unmask(Ext.getBody());
                                if (res) {
                                    record.set('year_seq', res.result.period_year);
                                }
                            },
                            failure: function() {
                                Leaf.Masker.unmask(Ext.getBody());
                            },
                            error: function() {
                                Leaf.Masker.unmask(Ext.getBody());
                            },
                            scope: this
                        });
                    }
                }
            }
            
            function con_contract_insurance_remove() {
            
                $('con_contract_insurance_gird').remove();
            }
            
            function con_contract_insurance_rf(record, name) {
                if (record.isNew) {
                    return 'con_contract_insurance_lov';
                } else {
                    return '';
                }
            }
        ]]></script>
        <a:dataSets>
            <!-- <a:dataSet id="insurance_company_ds" lookupCode="CON511_INSURANCE_COMPANY"/> -->
            <a:dataSet id="con_contract_insurance_query">
                <a:fields>
                    <a:field name="contract_number" lovGridHeight="350" lovHeight="550" lovService="cont.CON511.con_contract_for_lov?document_type=PRJCON" lovWidth="500">
                        <a:mapping>
                            <a:map from="contract_id" to="contract_id"/>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                            <a:map from="project_name" to="project_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_name"/>
                    <a:field name="insurance_policy_no"/>
                    <a:field name="insurance_date_from"/>
                    <a:field name="insurance_date_to"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_insurance_result" autoPageSize="true" autoQuery="true" model="cont.CON511.con_contract_insurance" queryDataSet="con_contract_insurance_query" selectable="true">
                <a:fields>
                    <a:field name="contract_number" lovGridHeight="350" lovHeight="550" lovService="cont.CON511.con_contract_for_lov?document_type=PRJCON" lovWidth="500" required="true">
                        <a:mapping>
                            <a:map from="contract_id" to="contract_id"/>
                            <a:map from="contract_number" to="contract_number"/>
                            <a:map from="contract_name" to="contract_name"/>
                            <a:map from="project_name" to="project_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="insurance_date_from" required="true"/>
                    <a:field name="insurance_date_to" required="true"/>
                    <a:field name="insurance_amount" required="true"/>
                    <a:field name="fact_insurance_amount" required="true"/>
                    <a:field name="year_seq" required="true"/>
                    <a:field name="insurance_policy_no" required="true"/>
                    <a:field name="insurance_company"/>
                    <!-- <a:field name="insurance_company_desc" displayField="code_value_name" options="insurance_company_ds" returnField="insurance_company" valueField="code_value"/> -->
                </a:fields>
                <a:events>
                    <a:event name="update" handler="con_contract_insurance_update"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="con511_contract_insurance_query" text="HLS.QUERY"/>
                <a:gridButton click="con_contract_insurance_reset" text="HLS.RESET"/>
                <a:gridButton click="con_contract_insurance_new" text="HLS.NEW"/>
                <a:gridButton click="con_contract_insurance_remove" text="HLS.REMOVE"/>
                <a:gridButton click="con_contract_insurance_save" text="HLS.SAVE"/>
            </a:screenTopToolbar>
            <a:form column="5" labelWidth="100" title="HLS.QUERY_TITLE">
                <a:lov name="contract_number" bindTarget="con_contract_insurance_query" prompt="HLS.CONTRACT_NUMBER" width="150"/>
                <a:textField name="contract_name" bindTarget="con_contract_insurance_query" prompt="HLS.CONTRACT_NAME" width="200"/>
                <a:datePicker name="insurance_date_from" bindTarget="con_contract_insurance_query" prompt="投保时间从"/>
                <a:datePicker name="insurance_date_to" bindTarget="con_contract_insurance_query" prompt="投保时间到"/>
                <a:textField name="insurance_policy_no" bindTarget="con_contract_insurance_query" prompt="CON511.INSURANCE_POLICY_NO"/>
            </a:form>
            <a:grid id="con_contract_insurance_gird" bindTarget="con_contract_insurance_result" marginHeight="200" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="contract_number" editorFunction="con_contract_insurance_rf" prompt="HLS.CONTRACT_NUMBER" width="150"/>
                    <a:column name="contract_name" prompt="HLS.CONTRACT_NAME" width="200"/>
                    <a:column name="project_name" prompt="HLS.PROJECT_NAME" width="200"/>
                    <a:column name="insurance_amount" align="right" editor="con_contract_insurance_nf" prompt="CON511.INSURANCE_AMOUNT" renderer="Leaf.formatMoney"/>
                    <a:column name="fact_insurance_amount" align="right" editor="con_contract_insurance_nf" prompt="CON511.FACT_INSURANCE_AMOUNT" renderer="Leaf.formatMoney"/>
                    <a:column name="insurance_date_from" editor="con_contract_insurance_dp" prompt="CON511.INSURANCE_DATE_FROM" renderer="Leaf.formatDate"/>
                    <a:column name="insurance_date_to" editor="con_contract_insurance_dp" prompt="CON511.INSURANCE_DATE_TO" renderer="Leaf.formatDate"/>
                    <a:column name="year_seq" align="right" editor="year_seq_nf" prompt="CON511.YEAR_SEQ" width="60"/>
                    <!-- <a:column name="insurance_company_desc" editor="con_contract_insurance_ccb" prompt="CON511.INSURANCE_COMPANY" width="150"/> -->
                    <a:column name="insurance_company" editor="con_contract_insurance_tf" prompt="CON511.INSURANCE_COMPANY" width="150"/>
                    <a:column name="insurance_policy_no" editor="con_contract_insurance_tf" prompt="CON511.INSURANCE_POLICY_NO" width="150"/>
                    <a:column name="insurance_description" editor="con_contract_insurance_tf" prompt="HLS.COMMENT" width="200"/>
                </a:columns>
                <a:editors>
                    <a:lov id="con_contract_insurance_lov"/>
                    <a:numberField id="con_contract_insurance_nf"/>
                    <a:numberField id="year_seq_nf" allowDecimals="false" allowFormat="false" allowNegative="false"/>
                    <a:datePicker id="con_contract_insurance_dp"/>
                    <a:textField id="con_contract_insurance_tf"/>
                    <a:comboBox id="con_contract_insurance_ccb"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
