<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyu  
    $Date: 2016-10-9 上午11:08:11  
    $Revision: 1.0  
    $Purpose: 中介机构聘用申请
-->
<a:screen xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure/>
    <a:view>
        <a:link id="hls_bp_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="hn030d_hn_intermediary_hired_req_new_en_link_id" url="${/request/@context_path}/modules/hn/HN030/hn_intermediary_hired_req_new_en.lview"/>
        <a:link id="hn030d_hn_intermediary_hired_req_modify_link_id" url="${/request/@context_path}/modules/hn/HN030/hn_intermediary_hired_req_detail.lview"/>
        <a:link id="hn030d_hn_intermediary_hired_req_close_link_id" url="${/request/@context_path}/modules/hn/HN030/hn_intermediary_hired_req_close.lview"/>
        <script type="text/javascript"><![CDATA[
            //新增
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hn_intermediary_hired_req');
                var param = {};
                param['function_code'] = 'HN030D';
                //param['document_id'] = record.get('project_id');
                param['function_usage'] = 'UPDATE';
                //param['maintain_type'] = maintain_type;
                param['url_title'] = '中介机构聘用新增';
                param['winid'] = 'hn030d_hn_intermediary_hired_req_new_en_link';
                param['screen_height'] = '280';
                param['screen_width'] = '400';
                hls_doc_get_layout_code('hls_bp_get_layout_code_link_id', param, 'hn030d_hn_intermediary_hired_req_new_en_link_id', ds_id);
            };
            
            function open_hired_req_number_win(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var param = {};
                if (record.get('hired_req_status') == 'NEW' || record.get('hired_req_status') == 'REJECT' || record.get('hired_req_status') == 'APPROVED_RETURN' || record.get('hired_req_status') == 'CANCEL') {
                    param['function_code'] = 'HN030D_NEW';
                    param['function_usage'] = 'UPDATE';
                } else if (record.get('hired_req_status') == 'CLOSED' || record.get('hired_req_status') == 'CLOSE_APPROVING') {
                    param['function_code'] = 'HN030C_WFL';
                    param['function_usage'] = 'QUERY';
                } else {
                    param['function_code'] = 'HN030D_WFL';
                    param['function_usage'] = 'QUERY';
                }
                param['hired_req_id'] = record.get('hired_req_id');
                param['url_title'] = '中介机构聘用申请明细';
                param['winid'] = 'hn030d_chired_req_modify_winid';
                hls_doc_get_layout_code('hls_bp_get_layout_code_link_id', param, 'hn030d_hn_intermediary_hired_req_modify_link_id', ds_id);
            }
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'hired_req_number' && value) {
                    return '<a href="javascript:open_hired_req_number_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                }
                return value;
            };
            
            //终止申请
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {

                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hn_intermediary_hired_req');
                var record = $(ds_id).getSelected();

                if (record[0].get('hired_req_status') != 'APPROVED') {
                    Leaf.showMessage('${l:PROMPT}', '只有已聘用的申请才可以终止!');
                    return;
                }
                var param = {};
                param['function_code'] = 'HN030C_NEW';
                //param['document_id'] = record.get('project_id');
                param['function_usage'] = 'UPDATE';

                param['hired_req_id'] = record[0].get('hired_req_id');
                //param['maintain_type'] = maintain_type;
                param['url_title'] = '中介机构聘用终止';
                param['winid'] = 'hn030d_hn_intermediary_hired_req_close_link';
                hls_doc_get_layout_code('hls_bp_get_layout_code_link_id', param, 'hn030d_hn_intermediary_hired_req_close_link_id', ds_id);
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>