<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: chenlingfeng
    $Date: 2017-8-2 上午11:14:17
    $Revision: 1.0
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="document_category=&apos;INVESTMENT_BUSINESS&apos;" fetchAll="true" model="basic.hls_document_type_for_lov" rootPath="hls_document_type_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="hn1210_hn_invest_app_approval_print_link" url="${/request/@context_path}/modules/hn/HN1210/hn_invest_app_approval_print.lsc"/>
        <a:link id="hn1210_hn_invest_app_create_entrance_link" url="${/request/@context_path}/modules/hn/HN1210/hn_invest_app_create_detail.lview"/>
        <a:link id="hn1210_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <script type="text/javascript"><![CDATA[
            function hn1210_query() {
                $('hn1210_hn_invest_app_query_result_ds').query();
            }
            
            function hn1210_reset() {
                $('hn1210_hn_invest_app_query_ds').reset();
            }
            
            function hn1210_add() {
                var ds_id = 'hn1210_hn_invest_app_query_result_ds';
                var param = {};
                param['function_code'] = 'HN1210D';
                param['function_usage'] = 'CREATE';
                param['url_title'] = '投资业务申请';
                hls_doc_get_layout_code('hn1210_get_layout_code_link_id', param, 'hn1210_hn_invest_app_create_entrance_link', ds_id);
            }
            
            function hn1210_export() {
                $('hn1210_hn_invest_app_query_grid')._export();
            }
            
            function hn1210_invest_open_detail(id) {
                var ds_id = 'hn1210_hn_invest_app_query_result_ds';
                var record = $(ds_id).findById(id);
                var param = record.data;
                param['function_code'] = 'HN1210D';
                param['function_usage'] = 'MODIFY';
                if (record.get('wfl_status') == 'APPROVING' || record.get('wfl_status') == 'APPROVED') {
                    param['function_code'] = 'HN1210WFL';
                    param['function_usage'] = 'QUERY';
                }
                if ('${/session/@user_id}' != record.get('owner_user_id')){
                      param['function_code'] = 'HN1210WFL';
                    param['function_usage'] = 'QUERY';
                }
            
                param['url_title'] = '投资业务申请';
                param['invest_id'] = record.get('invest_id');
                param['winid'] = 'hn1210_hn_invest_app_detail_winid';
                hls_doc_get_layout_code('hn1210_get_layout_code_link_id', param, 'hn1210_hn_invest_app_create_entrance_link', ds_id);
            
            }
            
            function hn1210_invest_number_renderer(value, record, name) {
                if (name == 'invest_number') {
                    return '<a href="javascript:hn1210_invest_open_detail(' + record.id + ')">' + value + '</a>';
                }
            }
            
            function hn1210_print() {
                var url = $('hn1210_hn_invest_app_approval_print_link').getUrl();
                var records = $('hn1210_hn_invest_app_query_result_ds').getSelected();
                var param;
                var record = records[0];
                if (record) {

                    if (record.get('wfl_status') == 'APPROVED') {
                        param = '?invest_id=' + record.get('invest_id');
                        param = param+'&cdd_list_id=' + record.get('cdd_list_id');
                        param = param+'&instance_id=' + record.get('wfl_instance_id');
                        param = param+'&templt_name=hn_invest_app_approval.xml';
                        url = url + param;
                        window.open(url);
                    } else {
                        Leaf.showMessage('提示','无法打印未审批通过的单据');
                    }
                }
            
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="hn_common_wfl_status_ds" lookupCode="HN_COMMON_WFL_STATUS"/>
            <a:dataSet id="investment_business_doc_type_ds">
                <a:datas dataSource="/model/hls_document_type_path"/>
            </a:dataSet>
            <a:dataSet id="hn1210_hn_invest_app_query_ds" autoCreate="true">
                <a:fields>
                    <a:field name="invest_number"/>
                    <a:field name="invest_name"/>
                    <a:field name="document_type"/>
                    <a:field name="document_type_n" displayField="description" options="investment_business_doc_type_ds" returnField="document_type" valueField="document_type"/>
                    <a:field name="wfl_status"/>
                    <a:field name="wfl_status_desc" displayField="code_value_name" options="hn_common_wfl_status_ds" returnField="wfl_status" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="hn1210_hn_invest_app_query_result_ds" autoPageSize="true" autoQuery="true" model="hn.HN1210.hn_invest_app_query" queryDataSet="hn1210_hn_invest_app_query_ds" selectable="true" selectionModel="single"/>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="hn1210_reset" text="重置"/>
                <a:gridButton click="hn1210_query" text="HLS.QUERY"/>
                <a:gridButton click="hn1210_add" text="新增"/>
                <a:gridButton click="hn1210_export" text="导出"/>
                <a:gridButton click="hn1210_print" text="打印审批单"/>
            </a:screenTopToolbar>
            <a:form column="4" labelWidth="120" marginWidth="30" title="查询条件">
                <a:textField name="invest_number" bindTarget="hn1210_hn_invest_app_query_ds" prompt="投资业务编号"/>
                <a:textField name="invest_name" bindTarget="hn1210_hn_invest_app_query_ds" prompt="投资业务名称"/>
                <a:comboBox name="document_type_n" bindTarget="hn1210_hn_invest_app_query_ds" prompt="业务类型"/>
                <a:comboBox name="wfl_status_desc" bindTarget="hn1210_hn_invest_app_query_ds" prompt="审批状态"/>
            </a:form>
            <a:grid id="hn1210_hn_invest_app_query_grid" bindTarget="hn1210_hn_invest_app_query_result_ds" marginHeight="200" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="invest_number" prompt="投资业务编号" renderer="hn1210_invest_number_renderer"/>
                    <a:column name="invest_name" prompt="投资业务名称"/>
                    <a:column name="document_type_n" prompt="业务类型"/>
                    <a:column name="transaction_type" prompt="交易品种"/>
                    <a:column name="transaction_direction_n" prompt="交易方向"/>
                    <a:column name="amount_quantity" prompt="金额/数量"/>
                    <a:column name="owner_user_id_n" prompt="经办人"/>
                    <a:column name="wfl_status_n" prompt="审批状态"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>