con_contract_query.lview 8.56 KB
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-8-1 下午02:44:52  
    $Revision: 1.0  
    $Purpose: 合同维护
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.user_id=${/session/@user_id}" model="prj.PRJ500D.sys_user_lv" rootPath="user_name_path"/>
        <s:server-script import="contract_print_path.js"><![CDATA[
           $ctx.parameter.file_path = con_print_path['con_print_path'];
           $ctx.parameter.tomcat_source = con_print_path['tomcat_source'];
       ]]></s:server-script>
    </a:init-procedure>
    <a:view>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
        <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>
        <a:link id="con505_hls_bp_master_query_link" url="${/request/@context_path}/modules/cont/CON505/hls_bp_master_query.lview"/>
        <script type="text/javascript"><![CDATA[
            Ext.ux.Lightbox.register('a[ref=img]', true);
            //报价重算 add by lpc 9874
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
                //
                // lock_current_window();
                var con_contract_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var prj_quo_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_fin_calculator_hd');
                var head_record = $(con_contract_ds).getCurrentRecord();
                var record = $(prj_quo_ds).getCurrentRecord();
                var contract_id = head_record.get('contract_id');
                var document_category = head_record.get('document_category');
                var calc_session_id = record.get('calc_session_id');
                var final_recreate_H_formula = 'Y';
                var final_recreate_L_formula = 'Y';
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/hls.HLS500.hls_fin_calculator_calc/update',
                    para: {
                        calc_session_id: calc_session_id,
                        document_id: contract_id,
                        document_category: document_category,
                        recreate_H_formula: final_recreate_H_formula,
                        recreate_L_formula: final_recreate_L_formula,
                        contract_id: contract_id
                    },
                    success: function(res) {
                        // unlock_current_window();
                        var ln_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_cashflow');
                        $(ln_ds_id).query();
                    },
                    failure: function() {
                        // unlock_current_window();
                    },
                    error: function() {
                        // unlock_current_window();
                    },
                    scope: this
                });
            };
            
            function view_pdf(attachment_id) {
                Leaf.request({
                    url: '${/request/@context_path}/autocrud/fnd.fnd_atm_attachment/query',
                    para: {
                        attachment_id: attachment_id
                    },
                    success: function(res) {
                        var path = res.result.record.file_path;
                        path = path.substr(path.indexOf('hls_attachment'));
                        var tomcat_source = '${/parameter/@tomcat_source}';
                        var source_path = 'http://' + window.location.host + '/' + tomcat_source + '/' + path;
                        var oWin = window.open(source_path);
                    },
                    scope: this
                });
            }
            
            function upload_file(id, name, query_only) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                if (record.get('check_id')) {
                    var url;
                    // if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    // } else {
                        // url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_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: 'prj500_cdd_uploadFile_screen_id',
                        width: 850,
                        height: 400
                    });
            
                    win.on('close', function() {
                        record.ds.query();
                    });
                }
            }
            
             window['${/parameter/@layout_code}_open_bp_detail_window'] = function(id, name) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var param = record.data;
                param['function_code'] = 'CON505H';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'QUERY';
                param['url_title'] = '${l:HLS212.BP_MASTER_QUERY}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con505_hls_bp_master_query_link', record.ds.id, '${/parameter/@layout_code}');
            };
            
            
            //超链接渲染
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                //
                var link_function = '';
                window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                if (name == 'attachment') {
                    link_function = 'upload_file';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + '附件上传' + '</a>';
                } else if (name == 'bp_link' && record.get('bp_id') && record.get('record_id')) {
                    link_function = '${/parameter/@layout_code}_open_bp_detail_window';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\');">' + config_record.get('prompt') + '</a>';
                } else 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])) {
                                var file_name = temp[0].toUpperCase();
                                var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
                                if (file_name.indexOf('.PDF') >= 0) {
                                    url = url + '<a href=javascript:view_pdf(\'' + temp[1] + '\')>' + temp[0] + '</a>' + ',';
                                } else if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
                                    url = url + '<a href=' + link + temp[1] + ' ref="img">' + temp[0] + '</a>' + ',';
                                } else {
                                    url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                }
                            }
                        }
                        return url;
            
                    }
                }
            };
        ]]></script>
    </a:view>
</a:screen>