<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:  nyl
    $Date: 2014-11-27 下午01:58:31  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.specify_code=&apos;PROJECT_DOC_APPROVER&apos;" model="cont.CON543.lsh_hls_specify_define" rootPath="hls_specify_define_info"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con545_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_con545_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_con545_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="con545_batch_dl_link_id" url="${/request/@context_path}/modules/cont/CON505/con_atm_batch_dl.lsc"/>
        <a:link id="con545_submit_link" model="cont.CON543.lsh_con_sign_submit" modelaction="execute"/>
        <a:link id="con545_cdd_update_link" model="cont.CON543.lsh_hls_contract_review_info" modelaction="batch_update"/>
        <a:link id="con545_con_contract_update_print_detail_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update_print_detail.lview"/>
        <a:link id="con545_prj_secify_approver_link" url="${/request/@context_path}/modules/prj/PRJ501N/lsh_hls_specify_approver.lview"/>
        <script type="text/javascript"><![CDATA[
        
  
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                if (name == 'attach_file_name') {
                    if (value != null) {
                        var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                        var str = value.split(';;');
                        var url = '';
                        for (var i = 0;i < str.length;i++) {
                            var temp = str[i].split('--');
                            if (!Leaf.isEmpty(temp[0])) {
                                url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                            }
                        }
                        return url;
            
                    }
                } else if (name == 'attachment') {
                    link_function = '${/parameter/@layout_code}_con545_cdd_attachtment_upload';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\',\'' + record.ds.id + '\');">' + config_record.get('prompt') + '</a>';
                } else if (name == 'file') {
                    link_function = '${/parameter/@layout_code}_downloadfile_link';
                    var content_id = record.get('content_id');
                    var content_print_flag = record.get('content_print_flag');
                    if (content_id && content_print_flag == 'Y') {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + content_id + '\');">' + config_record.get('prompt') + '</a>';
                    } else {
                        return;
                    }
                }
                 
            };
            
            function unlock_tree_window() {
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            }
            
            function lock_tree_window() {
                window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            }
            
            window['${/parameter/@layout_code}_con545_cdd_attachtment_upload'] = function(id, name, query_only, ds_id) {
                var record = $(ds_id).findById(id);
                if (record.get('check_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con545_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    } else {
                        url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con545_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    }
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: '${/parameter/@layout_code}${/parameter/@tree_code}_prj500_cdd_uploadFile_screen_id',
                        width: 850,
                        height: 400
                    });
            
                    win.on('close', function() {
                        record.ds.query();
                    });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
                }
            };
            window['${/parameter/@layout_code}_downloadfile_link'] = function(content_id) {
                var url = $('con545_batch_dl_link_id').getUrl() + '?content_id=' + content_id + '&contract_id=' + '${/parameter/@contract_id}';
                window.open(url, '_self');
            };
            
            
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                birturl = '${/request/@context_path}/reports?__report=reports/contract/OTHER_CONTRACT.rptdesign&__format=pdf&contract_id=' + ${/parameter/@contract_id};
                window.open(birturl);
            };
            
            function con545_window_close() {
                $('hls_doc_get_layout_code_winid').close();
            }
            
            window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
                var document_id = ${/parameter/@contract_id};
                var document_table = 'CON_CONTRACT';
                var title = '${/model/hls_specify_define_info/record/@description}';
                var win = new Leaf.Window({
                    id: 'lsh_prj_secify_approver_screen',
                    url: $('con545_prj_secify_approver_link').getUrl(),
                    params: {
                        document_id: document_id,
                        specify_code: 'PROJECT_DOC_APPROVER'
                    },
                    title: title,
                    width: 550,
                    heigh: 650
                });
                win.on('close', function() {
                    ajax_flag = 'Y';
            
                    /* parent.Leaf.SideBar.enable = true;
                     parent.Leaf.SideBar.show({
                     msg: '${l:HLS.SUBMIT_SUCCESS}',
                     duration: 2000
                     }); */
                    Leaf.Masker.mask(Ext.getBody(), '${l:HLS.EXECUTING}');
            
                    Leaf.request({
                        url: $('con545_submit_link').getUrl(),
                        para: {
                            document_id: document_id,
                            document_table: document_table
                        },
                        success: function(res) {
                            Leaf.Masker.unmask(Ext.getBody());
            
            
                            Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.SUBMIT_SUCCESS}', function() {
                                con545_window_close();
                            });
            
                        },
                        failure: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function() {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                });
            };
            
            
            
            function con505_con_contract_content_print() {
                var records = $('con505_contract_result_ds').getSelected();
                if (records.length != 1) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                }
                var record = records[0];
                new Leaf.Window({
                    id: 'con_contract_update_print_detail_winid',
                    params: {
                        contract_id: record.get('contract_id'),
                        document_category: record.get('document_category'),
                        business_type: record.get('business_type'),
                        winid: 'con_contract_update_print_detail_winid'
                    },
                    url: $('con545_con_contract_update_print_detail_link_id').getUrl(),
                    title: '${l:CON505.CON_CONTENT_PRINT}',
                    width: 900,
                    height: 450
                });
            }
            
            //保存前调用
            window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var cdd_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
                var records = $(cdd_ds).getAll();
                //con545_cdd_update_link
                if ('${/parameter/@layout_code}' == 'CON_CONTEXT_CONFIRM_1') {
                    for (var i = 0;i < records.length;i++) {
            
            
                        var note2 = records[i].get('note2') == undefined ? '' : records[i].get('note2');
            
                        var note = records[i].get('note') == undefined ? '' : records[i].get('note');
            
                        if (note2 == '') {
                            records[i].set('note2', note);
                            records[i].set('note', '');
            
                        }
                        records[i].set('_status', 'update');
                    }
            
                }
                var check_flag = true;
                return check_flag;
            };
            
            
            
            window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var cdd_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
                var record = $(ds_id).getAt(0);
                var win = new Leaf.Window({
                    id: 'con_contract_update_print_detail_winid',
                    params: {
                        contract_id: record.get('contract_id'),
                        document_category: record.get('document_category'),
                        business_type: record.get('business_type'),
                        content_type: 'AUDIT',
                        winid: 'con_contract_update_print_detail_winid'
                    },
                    url: $('con545_con_contract_update_print_detail_link_id').getUrl(),
                    title: '${l:CON505.CON_CONTENT_PRINT}',
                    width: 900,
                    height: 450
                });
                win.addListener('close', function() {
                    if (cdd_ds) {
                        $(cdd_ds).query();
                    }
                });
            };
            
        
            
            
            function zjwfl_before_approve_procedure(out_type) {
                var document_id = '${/parameter/@contract_id}';
                var appoint_check = '${/parameter/@appoint_check}';
                var params;
                out_type = 'no_win';
                var out_object = 'out_object';
                if (appoint_check) {
                    var document_table = 'CON_CONTRACT';
                    var title = '${/model/hls_specify_define_info/record/@description}';
                    var win = new Leaf.Window({
                        id: 'lsh_prj_secify_approver_screen',
                        url: $('con545_prj_secify_approver_link').getUrl(),
                        params: {
                            document_id: document_id,
                            specify_code: 'PROJECT_DOC_APPROVER'
                        },
                        title: title,
                        width: 550,
                        heigh: 650
                    });
                    out_type = 'win';
                    out_object = win;
                }
            
                params = {
                    out_type: out_type,
                    out_object: out_object
                };
                return params;
            }
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
