<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author:  Yimeng
    $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.cus_hls_specify_define" rootPath="hls_specify_define_info"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_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}_con543_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_con543_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="con_batch_dl_link_id" url="${/request/@context_path}/modules/cont/CON505/con_atm_batch_dl.lsc"/>
        <a:link id="con543_submit_link" model="cont.CON543.cus_con_sign_submit" modelaction="execute"/>
        <a:link id="con543_con_contract_update_print_detail_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update_print_detail.lview"/>
        <a:link id="cus_prj_secify_approver_link" url="${/request/@context_path}/modules/prj/PRJ501N/cus_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}_con543_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}_con543_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}_con543_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    } else {
                        url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con543_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 = $('con_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 = 'http://199.10.10.65:8180/reportapp/preview?__report=reports/contract/OTHER_CONTRACT.rptdesign&__format=pdf&contract_id=' + ${/parameter/@contract_id};
                window.open(birturl);
            };
            
            function con543_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: 'cus_prj_secify_approver_screen',
                    url: $('cus_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: $('con543_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() {
                                con543_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: $('con543_con_contract_update_print_detail_link_id').getUrl(),
                    title: '${l:CON505.CON_CONTENT_PRINT}',
                    width: 900,
                    height: 450
                });
            }
            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: $('con543_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 specify_code = '${/parameter/@specify_code}'||'PROJECT_DOC_APPROVER';
                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: 'cus_prj_secify_approver_screen',
	                    url: $('cus_prj_secify_approver_link').getUrl(),
	                    params: {
	                        document_id: document_id,
	                        specify_code: specify_code
	                    },
	                    title: title,
	                    width: 550,
	                    heigh: 650,
	                    closeable:false
	                });
	                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>
