<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhuxianfei
    $Date: 2018年7月16日 下午2:18:45  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure/>
    <a:view>
        <script type="text/javascript"><![CDATA[

        //锁屏
        function lock_window() {
            Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
        }

        //解屏
        function unlock_window() {
            Leaf.Masker.unmask(Ext.getBody());
        }

        //确定
        function con_confirm() {
            //
            var record = $('contract_change_result_ds').getCurrentRecord();
            var bp_id  = record.get('bp_id');
            lock_window();
            Leaf.request({
                url: '${/request/@context_path}/autocrud/cont.CON350.con350_insurance_result/update',
                para: {
                    contract_id: '${/parameter/@contract_id}',
                    bp_id: bp_id,
                    insurance_rate : record.get('insurance_rate')
                },
                success: function (res) {
                    Leaf.SideBar.show({
                        msg: '操作成功',
                        duration: 2000
                    });
                    unlock_window();
                    con_cancel();
                },
                error: function () {
                    unlock_window();

                },
                failure: function () {
                   unlock_window();

                },
                sync: true,
                scope: this
            })
            ;
        }

        //取消
        function con_cancel() {
            $('con_change_ds_ins_link_winId').close();
        }

        function changeLoad(ds){
            //
            var record = ds.getCurrentRecord();
            record.set('insurance_method','DS');
            record.set('insurance_method_n','宏菱代办');
        }

        ]]></script>
        <a:dataSets>
            <a:dataSet id="insurance_method_ds" lookupCode="INSURANCE_METHOD"/>

            <a:dataSet id="contract_change_result_ds" autoQuery="true" fetchAll="true"
                       model="cont.CON350.con350_insurance_result"
                       queryUrl="${/request/@context_path}/autocrud/cont.CON350.con350_insurance_result/query?contract_id=${/parameter/@contract_id}">
                <a:fields>
                    <a:field name="contract_number" readOnly="true"/>
                    <a:field name="bp_id_tenant_n" readOnly="true"/>
                    <a:field name="insurance_rate" required="true"/>
                    <a:field name="insurance_method"  defaultValue="DS"  readOnly="true"/>
                    <a:field name="insurance_method_n" defaultValue="宏菱代办" readOnly="true"  displayField="code_value_name"
                             options="insurance_method_ds"
                             returnField="insurance_method" valueField="code_value"/>
                    <a:field name="bp_name" lovHeight="530" lovService="cont.CON350.con350_contract_bp_lov" lovWidth="550" title="商业伙伴" required="true">
                    <a:mapping>
                        <a:map from="bp_id" to="bp_id"/>
                        <a:map from="bp_code" to="bp_code"/>
                        <a:map from="bp_name" to="bp_name"/>
                    </a:mapping>
                    </a:field>
                    <a:field name="bp_id"/>
                    <a:field name="bp_code"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="changeLoad"/>
                </a:events>name="load"
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <!--<a:screenTitle/>-->
                <a:gridButton click="con_confirm" text="确定"/>
                <a:gridButton click="con_cancel" text="取消"/>
            </a:screenTopToolbar>
            <a:grid id="cont_change_result_ds_id" bindTarget="contract_change_result_ds" width="850" height="200"
                    navBar="true">
                <a:columns>
                    <a:column name="contract_number" prompt="合同编号" width="200"/>
                    <a:column name="bp_id_tenant_n" prompt="客户名" width="200"/>
                    <a:column name="insurance_rate" prompt="保险费率" editor="nf_id" width="200"/>
                    <a:column name="insurance_method_n" prompt="投保方式"  width="200"/>
                    <a:column name="bp_name" prompt="商业伙伴"  width="200" editor="lov_id"/>
                </a:columns>
                <a:editors>
                    <a:numberField id="nf_id" allowDecimals="true" allowNegative="false" decimalPrecision="4"/>
                    <a:comboBox id="cb_id"/>
                    <a:lov id ="lov_id"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
