<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangyu  
    $Date: 2016-12-20 上午10:20:13  
    $Revision: 1.0  
    $Purpose: 项目报告上会流程入口界面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="prj501c_project_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="prj501c_project_modify_link" url="${/request/@context_path}/modules/prj/PRJ501N/prj_project_create_tree_n.lview"/>
        <a:link id="hn_project_consideration_submit_link" model="prj.PRJ501C.hn_project_meeting_submit" modelaction="execute"/>
        <a:link id="hn_project_approve_return_link" model="prj.PRJ501C.hn_project_meeting_submit" modelaction="update"/>
        <a:link id="prj501c_project_detail_link" url="${/request/@context_path}/modules/prj/PRJ600/prj_project_maintain_wfl.lview"/>
        <script type="text/javascript"><![CDATA[
            function open_project_modify_win(record_id, ds_id) {
                var record = $(ds_id).findById(record_id);
                var maintain_type = 'UPDATE';
                var function_usage = 'MODIFY';
                var function_code = 'PRJ501D';
                var param = record.data;
                var project_status = record.get('project_status');
                if (project_status == 'APPROVING') {
                maintain_type = 'READONLY';
                function_usage = 'QUERY';
                function_code = 'PRJ505';
                }
            
                param['document_id'] = record.get('project_id');
                param['function_code'] = function_code;
                param['function_usage'] = function_usage;
                param['maintain_type'] = maintain_type;
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                //param['layout_debugger_flag']='Y';
                param['cond_para2'] = record.get('hn_industry_classification');
                param['wf_function_code'] = '${/parameter/@function_code}';
                hls_doc_get_layout_code('prj501c_project_get_layout_code_link_id', param, 'prj501c_project_modify_link', ds_id);
                // var record = $(ds_id).findById(record_id);
                // new Leaf.Window({
                    // title: '项目明细',
                    // id: 'prj501c_project_detail_win',
                    // url: $('prj501c_project_detail_link').getUrl(),
                    // params: {
                        // project_id: record.get('project_id'),
                        // show_opinion: 'N',
                        // show_upload: 'N',
                        // print_flag: 'N',
                        // conditions_flag: 'N',
                        // show_upload_grid: 'N',
                        // hn_industry_classification: record.get('hn_industry_classification'),
                        // winid: 'prj501c_project_detail_win'
                    // },
                    // fullScreen: true
                // });
            }
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'project_number' && value) {
                    return '<a href="javascript:open_project_modify_win(\'' + record.id + '\',\'' + record.ds.id + '\')">' + value + '</a>';
                }
                return value;
            };
            
            //同意提请上会
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_result_ds = $(ds_id);
                var records = prj_project_result_ds.getSelected();
                var record = records[0];
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                } else if (record.get('prj_wfl_status') !== 'PRJ_REVIEWED' && record.get('prj_wfl_status') !== 'PRJ_RETURN') {
                    Leaf.showErrorMessage('提示', '只有评审通过的项目或者审批退回的项目才允许提请上会!');
                    return;
                } else if (record.get('risk_action_type') !== 'agree') {
                    Leaf.showErrorMessage('提示', '项目评审风控部意见为不同意,如需上会请行使职权!');
                    return;
                } else {
                    Leaf.showConfirm('提示', '你确定要提交<font color="red">' + record.get('project_name') + '</font>到上会流程吗?', function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                        Leaf.request({
                            url: $('hn_project_consideration_submit_link').getUrl(),
                            para: {
                                project_id: record.get('project_id')
                            },
                            success: function(res) {
                                parent.Leaf.SideBar.enable = true;
                                parent.Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                prj_project_result_ds.query(prj_project_result_ds.currentPage);
                            },
                            error: function(res) {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            faliure: function() {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }, null, 400);
                }
            };
            
            //行使分管副总职权上会
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_result_ds = $(ds_id);
                var records = prj_project_result_ds.getSelected();
                var record = records[0];

                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                } else if (record.get('prj_wfl_status') !== 'PRJ_REVIEWED' && record.get('prj_wfl_status') !== 'PRJ_RETURN') {
                    Leaf.showErrorMessage('提示', '只有评审通过的项目或者审批退回的项目才允许提请上会!');
                    return;
                } else if (record.get('risk_action_type') == 'agree') {
                    Leaf.showErrorMessage('提示', '项目评审已通过,无需行使职权,直接提请上会即可!');
                    return;
                } else {
                    Leaf.showConfirm('提示', '你确定要提交<font color="red">' + record.get('project_name') + '</font>到上会流程吗?', function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                        Leaf.request({
                            url: $('hn_project_consideration_submit_link').getUrl(),
                            para: {
                                project_id: record.get('project_id')
                            },
                            success: function(res) {
                                parent.Leaf.SideBar.enable = true;
                                parent.Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                prj_project_result_ds.query(prj_project_result_ds.currentPage);
                            },
                            error: function(res) {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            faliure: function() {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }, null, 400);
                }
            };
            
            //退回提交人
            window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_result_ds = $(ds_id);
                var records = prj_project_result_ds.getSelected();
                var record = records[0];
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                } else if (record.get('prj_wfl_status') !== 'PRJ_REVIEWED' && record.get('prj_wfl_status') !== 'PRJ_RETURN') {
                    Leaf.showErrorMessage('提示', '该项目已经在上会流程中,不能退回提交人!');
                    return;
                } else {
                    Leaf.showConfirm('提示', '你确定要把<font color="red">' + record.get('project_name') + '</font>退回给提交人吗?', function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                        Leaf.request({
                            url: $('hn_project_approve_return_link').getUrl(),
                            para: {
                                project_id: record.get('project_id'),
                                instance_id: record.get('wfl_instance_id_2')
                            },
                            success: function(res) {
                                parent.Leaf.SideBar.enable = true;
                                parent.Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                prj_project_result_ds.query(prj_project_result_ds.currentPage);
                            },
                            error: function(res) {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            faliure: function() {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }, null, 400);
                }
            };
            
            //业务经理提交审批
            window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var prj_project_result_ds = $(ds_id);
                var records = prj_project_result_ds.getSelected();
                var record = records[0];
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                } else if (record.get('prj_wfl_status') !== 'PRJ_REVIEWED' && record.get('prj_wfl_status') !== 'PRJ_RETURN') {
                    Leaf.showErrorMessage('提示', '只有评审通过的项目或者审批退回的项目才允许提请上会!');
                    return;
                } else {
                    Leaf.showConfirm('提示', '你确定要提交<font color="red">' + record.get('project_name') + '</font>到上会流程吗?', function() {
                        window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
                        Leaf.request({
                            url: $('hn_project_consideration_submit_link').getUrl(),
                            para: {
                                project_id: record.get('project_id')
                            },
                            success: function(res) {
                                parent.Leaf.SideBar.enable = true;
                                parent.Leaf.SideBar.show({
                                    msg: '${l:HLS.SUBMIT_SUCCESS}',
                                    duration: 2000
                                });
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                prj_project_result_ds.query(prj_project_result_ds.currentPage);
                            },
                            error: function(res) {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            faliure: function() {
                                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }, null, 400);
                }
            };
            
            window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            
                if (ds == $(ds_id)) {
                    aut_authority_list_validate_query(ds, qpara);
            
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=PROJECT&amp;function_code=PRJ501"/>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>