<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Spencer 3893
    $Date: 2019-9-19
    $Revision: 1.0  
    $Purpose: 提前结清创建入口
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <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_et_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="con_et_change_link" url="${/request/@context_path}/modules/cont/CON_ET001/con_early_termination_et_detail.lview"/>
        <a:link id="con_et_create_change_link" model="cont.CON_ET001.create_change_req" modelaction="execute"/>
        <script type="text/javascript"><![CDATA[
            function contractQueryScreen_query() {
                $('contractQueryScreen_mainDs').query();
            }
            
            function contractQueryScreen_reset() {
                $('contractQueryScreen_paraDs').reset();
            }
            
            function contractQueryScreen_add() {
                //$('et_create').disable(); //按钮不可用
                var records = $('contractQueryScreen_mainDs').getSelected();
                var record = records[0],
                    contract_id = record.get('contract_id');
                Leaf.showConfirm('特别注意', '<span style="color: #ff0000; ">该操作将导致合同在回购期间无法进行后续操作，请谨慎操作！！！如果需要取消提前结清，请一定点击取消按钮！！！</span>', function () {
                    var ccr_document_type = 'ET_CHAG';
                    Leaf.Masker.mask(Ext.getBody());
                    Leaf.request({
                        url: $('con_et_create_change_link').getUrl(),
                        para: {
                            simulation_flag: 'N',
                            contract_id: contract_id,
                            req_type: ccr_document_type
                        },
                        success: function (res) {
                         //   $('et_create').enable(); //按钮启用
                            var param = record.data;
                            param['change_req_id'] = res.result.change_req_id;
                            param['contract_id'] = res.result.change_req_id;
                            param['source_contract_id'] = contract_id;
                            //param['layout_debugger_flag'] = 'Y';
                            param['function_code'] = 'CON_ET002';
                            param['url_title'] = '提前结清创建';
                            param['function_usage'] = 'MODIFY';
                            param['maintain_type'] = 'UPDATE';
                            param['document_type'] = ccr_document_type;
                            param['winid'] = 'con_et002_detail_winid';
                            hls_doc_get_layout_code('con_et_get_layout_code_link_id', param, 'con_et_change_link', 'contractQueryScreen_mainDs');
                        },
                        failure: function () {
                            Leaf.Masker.unmask(Ext.getBody());
                         //   $('et_create').enable(); //按钮启用
                        },
                        error: function () {
                            Leaf.Masker.unmask(Ext.getBody());
                          //  $('et_create').enable(); //按钮启用
                        },
                        scope: this
                    });
                }, function () {
                   // $('et_create').enable(); //按钮启用
                }, 300, 150);
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=CONTRACT&amp;function_code=CON_ET001"/>
        <a:dataSets>
            <a:dataSet id="yes_or_no_ds" lookupCode="YES_NO"/>
            <a:dataSet id="contract_status_ds" lookupCode="CON500_CONTRACT_STATUS"/>
            <a:dataSet id="hls_division_ds">
                <a:datas dataSource="/model/hls_division_path"/>
            </a:dataSet>
            <a:dataSet id="contractQueryScreen_paraDs">
                <a:fields>
                    <a:field name="contract_number" typeCase="upper"/>
                    <a:field name="contract_name"/>
                    <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="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:fields>
            </a:dataSet>
            <a:dataSet id="contractQueryScreen_mainDs" autoQuery="true" fetchAll="false" model="cont.CON_ET001.con_early_termination_query" pageSize="14" queryDataSet="contractQueryScreen_paraDs" selectable="true" selectionModel="single">
                <a:fields>
                    <a:field name="et_type_dis" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="cont.CON701.hls_document_type_for_et_lov" lovWidth="500" prompt="提前结清类型" readOnly="true" required="true">
                        <a:mapping>
                            <a:map from="document_type" to="et_type"/>
                            <a:map from="document_type_desc" to="et_type_dis"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="termination_date" datatype="date" required="true"/>
                    <a:field name="overdue_status" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="trial" 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 id="et_create" click="contractQueryScreen_add" text="HLS.CREATE"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="100" marginWidth="40" title="HLS.QUERY_TITLE">
                <a:textField name="contract_number" bindTarget="contractQueryScreen_paraDs" prompt="合同编号"/>
                <a:textField name="contract_name" bindTarget="contractQueryScreen_paraDs" prompt="合同名称"/>
                <a:lov name="bp_name" bindTarget="contractQueryScreen_paraDs" prompt="承租人名称"/>
<!--                <a:lov name="bp_agent" bindTarget="contractQueryScreen_paraDs" prompt="代理店"/>-->
                <a:comboBox name="division_n" bindTarget="contractQueryScreen_paraDs" prompt="租赁物"/>
<!--                <a:textField name="received_times" bindTarget="contractQueryScreen_paraDs" prompt="已还款期数"/>-->
<!--                <a:comboBox name="contract_status_desc" bindTarget="contractQueryScreen_paraDs" prompt="合同状态"/>-->
<!--                <a:comboBox name="overdue_status_desc" bindTarget="contractQueryScreen_paraDs" prompt="是否逾期"/>-->
            </a:form>
            <a:grid id="contractQueryScreen_mainDs_grid" bindTarget="contractQueryScreen_mainDs" marginHeight="230" marginWidth="40" navBar="true">
                <a:columns>
                    <a:column name="contract_number" prompt="合同编号" width="120" align="left"/>
                    <a:column name="contract_name" 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="status_desc" prompt="合同状态" width="120" align="center"/>
<!--                    <a:column name="overdue_status" prompt="是否逾期" width="100" align="center"/>-->
                </a:columns>
            </a:grid>
        </a:screenBody>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
