<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Robert8900
    $Date: 2018-8-15 08:33
    $Revision: 1.0  
    $Purpose:  中途偿还维护入口页面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="basic.hls_division_for_lov" rootPath="hls_division_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_contrac_et_update_link" url="${/request/@context_path}/modules/cont/CON702/con_contract_et_update.lview"/>
        <a:link id="con_contract_et_cancel_link" model="cont.CON611.con_contract_rp_cancel" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
            function contractQueryScreen_query() {
                $('contract_et_Screen_mainDs').query();
            }

            function contractQueryScreen_reset() {
                $('contract_et_Screen_paraDs').reset();
            }

            function winOpen_update(et_agreement_id, contract_id, et_agreement_status) {
                var function_usage, utl_title;
            
                if (et_agreement_status == 'NEW') {
                    utl_title = '中途偿还维护';
                    function_usage = 'UPDATE';
                } else {
                    function_usage = 'QUERY';
                    utl_title = '中途偿还查询';
                }
            
                var win = new Leaf.Window({
                    id: 'con_contrac_et_update_window',
                    url: $('con_contrac_et_update_link').getUrl(),
                    params: {
                        et_agreement_id: et_agreement_id,
                        contract_id: contract_id,
                        winId: 'con_contrac_et_update_window',
                        function_usage: function_usage
                    },
                    title: utl_title,
                    fullScreen: true
                });
                win.on('close', function() {
                    contractQueryScreen_query();
                });
            }
            
            function contractQueryScreen_maintance() {
                var record = $('contract_et_Screen_mainDs').getCurrentRecord();
                winOpen_update(record.get('et_agreement_id'), record.get('contract_id'), record.get('et_agreement_status'));
            }
            
            function cancel() {
                var record = $('contract_et_Screen_mainDs').getCurrentRecord();
                var et_agreement_id = record.get('et_agreement_id');

                Leaf.showConfirm('${l:HLS.PROMPT}', '确定要取消？', function() {
                    Leaf.Masker.mask(Ext.getBody());
                    Leaf.request({
                        url: $('con_contract_et_cancel_link').getUrl(),
                        para: {
                            et_agreement_id: et_agreement_id
                        },
                        success: function(args) {
                            Leaf.SideBar.show({
                                msg: '取消成功',
                                duration: 2000
                            });
                            Leaf.Masker.unmask(Ext.getBody());
                            $('contract_et_Screen_mainDs').query();
                        },
                        failure: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                });
            }

     
        ]]></script>
        <a:dataSets>
            <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON702"/>
            <a:dataSet id="yes_or_no_ds" lookupCode="YES_NO"/>
            <a:dataSet id="contract_status_ds" lookupCode="CON500_CONTRACT_STATUS"/>
            <a:dataSet id="document_type_ds">
                <a:datas dataSource="/model/document_type"/>
            </a:dataSet>
            <a:dataSet id="document_type_for_et_ds">
                <a:datas dataSource="/model/document_type_for_et"/>
            </a:dataSet>
            <a:dataSet id="document_category_ds">
                <a:datas dataSource="/model/document_category"/>
            </a:dataSet>
            <a:dataSet id="et_profile_ds">
                <a:datas dataSource="/model/et_profile"/>
            </a:dataSet>
            <a:dataSet id="hls_division_ds">
                <a:datas dataSource="/model/hls_division_path"/>
            </a:dataSet>
            <a:dataSet id="et_agreement_status_ds" lookupCode="CON_ET_STATUS"/>
            <a:dataSet id="contract_et_Screen_paraDs">
                <a:fields>
                    <a:field name="document_type_desc" displayField="document_type_desc" options="document_type_ds" returnField="document_type" valueField="document_type"/>
                    <a:field name="document_category_desc" displayField="description" options="document_category_ds" returnField="document_category" valueField="document_category"/>
                    <a:field name="employee_id"/>
                    <a:field name="employee_code" lovGridHeight="300" lovHeight="450" lovService="basic.hls_salesman_assign_v_for_lov" lovWidth="500" title="PRJ501.PRJ_contract.EMPLOYEE_NAME">
                        <a:mapping>
                            <a:map from="employee_id" to="employee_id"/>
                            <a:map from="employee_name" to="employee_name"/>
                            <a:map from="employee_code" to="employee_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="contract_number" typeCase="upper"/>
                    <a:field name="date_from"/>
                    <a:field name="date_to"/>
                    <a:field name="bp_id_tenant"/>
                    <a:field name="bp_name" lovGridHeight="330" lovHeight="470" lovLabelWidth="120" lovService="cont.CON701.hls_bp_master_v_all_lov?bp_category=TENANT" lovWidth="700" title="承租人">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id_tenant"/>
                            <a:map from="bp_name" to="bp_name"/>
                        </a:mapping>
                    </a:field>
                    <!--代理商-->
                    <a:field name="bp_id_agent_level1"/>
                    <a:field name="bp_agent" lovGridHeight="330" lovHeight="470" lovLabelWidth="120" lovService="cont.CON701.hls_bp_master_v_all_lov?bp_category=AGENT" lovWidth="700" title="代理商">
                        <a:mapping>
                            <a:map from="bp_id" to="bp_id_agent_level1"/>
                            <a:map from="bp_name" to="bp_agent"/>
                        </a:mapping>
                    </a:field>
                    <!--产品线-->
                    <a:field name="division_n" displayField="description" options="hls_division_ds" returnField="division" valueField="division"/>
                    <a:field name="project_number" title="申请编号" typeCase="upper"/>
                    <a:field name="user_desc" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="basic.sys_user_for_lov" lovWidth="500" prompt="AUT_TRX_USER_AUTHORIZE.USER_ID" title="员工选择">
                        <a:mapping>
                            <a:map from="description" to="user_desc"/>
                            <a:map from="user_id" to="user_id"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="overdue_status"/>
                    <a:field name="overdue_status_desc" displayField="code_value_name" options="yes_or_no_ds" returnField="overdue_status" valueField="code_value"/>
                    <a:field name="contract_status"/>
                    <a:field name="contract_status_desc" displayField="code_value_name" options="contract_status_ds" returnField="contract_status" valueField="code_value"/>
                    <a:field name="et_agreement_status"/>
                    <a:field name="et_agreement_status_desc" displayField="code_value_name" options="et_agreement_status_ds" returnField="et_agreement_status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="contract_et_Screen_mainDs" autoQuery="true" model="cont.CON702.con_contract_et_hd_maintain_query" pageSize="12" queryDataSet="contract_et_Screen_paraDs" queryUrl="${/request/@context_path}/autocrud/cont.CON702.con_contract_et_hd_maintain_query/query?status_filter=Y" selectable="true" selectionModel="single">
                <a:fields>
                    <a:field name="overdue_status" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="lease_execution_date" datatype="date"/>
                </a:fields>
                <a:events>
                    <a:event name="query" handler="aut_authority_list_validate_query"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="contractQueryScreen_query" text="HLS.QUERY"/>
                <a:gridButton click="contractQueryScreen_reset" text="HLS.RESET"/>
                <a:gridButton click="cancel" text="HLS.CANCLE"/>
                <a:gridButton click="contractQueryScreen_maintance" text="维护"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="110" marginWidth="40" title="HLS.QUERY_TITLE">
                <a:textField name="contract_number" bindTarget="contract_et_Screen_paraDs" prompt="合同编号"/>
                <a:lov name="bp_name" bindTarget="contract_et_Screen_paraDs" prompt="承租人名称"/>
                <a:lov name="bp_agent" bindTarget="contract_et_Screen_paraDs" prompt="代理商名称"/>
                <a:comboBox name="division_n" bindTarget="contract_et_Screen_paraDs" prompt="产品线"/>
                <a:textField name="received_times" bindTarget="contract_et_Screen_paraDs" prompt="已还款期数"/>
                <a:comboBox name="contract_status_desc" bindTarget="contract_et_Screen_paraDs" prompt="合同状态"/>
                <a:datePicker name="lease_execution_date_from" bindTarget="contract_et_Screen_paraDs" prompt="执行日期从"/>
                <a:datePicker name="lease_execution_date_to" bindTarget="contract_et_Screen_paraDs" prompt="执行日期到"/>
                <a:comboBox name="overdue_status_desc" bindTarget="contract_et_Screen_paraDs" prompt="是否逾期"/>
                <a:comboBox name="et_agreement_status_desc" bindTarget="contract_et_Screen_paraDs" prompt="中途偿还单据状态"/>
                <a:datePicker name="creation_date_from" bindTarget="contract_et_Screen_paraDs" prompt="中途偿还创建日期从"/>
                <a:datePicker name="creation_date_to" bindTarget="contract_et_Screen_paraDs" prompt="中途偿还创建日期到"/>
            </a:form>
            <a:grid id="contract_et_Screen_mainDs_grid" bindTarget="contract_et_Screen_mainDs" marginHeight="260" marginWidth="40" navBar="true">
                <a:columns>
                    <a:column name="et_agreement_number" prompt="中途偿还编号" width="120" align="left"/>
                    <a:column name="contract_number"  prompt="合同编号" width="120" align="left"/>
                    <a:column name="bp_name" prompt="承租人名称" width="200" align="left"/>
                    <a:column name="bp_agent" prompt="代理商名称" width="200" align="left"/>
                    <a:column name="division_n" prompt="产品线" width="120" align="left"/>
                    <a:column name="received_times" prompt="已还款期数" width="80" align="right"/>
                    <a:column name="contract_status_desc" prompt="合同状态" width="120" align="center"/>
                    <a:column name="lease_execution_date" prompt="执行日期" renderer="Leaf.formatDate" width="120" align="center"/>
                    <a:column name="overdue_status" prompt="是否逾期" width="100" align="center"/>
                    <a:column name="et_agreement_status_desc" align="center" prompt="中途偿还单据状态" width="120"/>
                    <a:column name="creation_date" align="center" prompt="中途偿还创建日期" renderer="Leaf.formatDate" width="120"/>
                    <a:column name="created_by_n" align="center" prompt="创建人" width="120"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
