<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure><![CDATA[
        
    ]]></a:init-procedure>
    <a:view>
        <a:link id="${/parameter/@layout_code}_hls_fin_doc_quotation_link_id" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_doc_quotation.lsc"/>
        <a:link id="${/parameter/@layout_code}_hls_fin_calculator_update_link_id" url="${/request/@context_path}/modules/hls/HLS500N/hls_fin_calculator_update_n.lview"/>
        <a:link id="${/parameter/@layout_code}_hls_fin_calculator_readonly_link_id" url="${/request/@context_path}/modules/hls/HLS500/hls_fin_calculator_readonly.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_con500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_con500_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_con500_prj_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="content_download_link_id" url="${/request/@context_path}/modules/cont/CON505/con_atm_batch_dl.lsc"/>
        <a:link id="prj_chance_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="hls_bp_master_modify_link" url="${/request/@context_path}/modules/hls/HLS214N/hls_bp_master_modify.lview"/>
        <script type="text/javascript"><![CDATA[
            /*add by syj
             //desc:该页面为国资项目所有非树类的工作流审批动态页面
             */
            
            function check_releated_layout(releated_table) {
                var str = '${/parameter/@layout_code}';
                //商机
                if (str.indexOf(releated_table) >= 0) {
                    return true;
                } else {
                    return false;
                }
            }
            
            function quote_link(type, record_id) {
                var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
                var prj_quotation_record = $(prj_quotation_ds_id).findById(record_id);
                var calc_recreate_L_formula;
                var saveData = [];
                if (type == 'quote') {
                    url = $('${/parameter/@layout_code}_hls_fin_calculator_update_link_id').getUrl();
                } else {
                    url = $('${/parameter/@layout_code}_hls_fin_calculator_readonly_link_id').getUrl();
                    new Leaf.Window({
                        id: '${/parameter/@layout_code}_hls_fin_calc_readonly_link_winid',
                        params: {
                            document_id: '${/parameter/@document_id}',
                            document_category: '${/parameter/@document_category}',
                            maintain_type: 'READONLY',
                            calc_session_id: prj_quotation_record.get('calc_session_id'),
                            winId: '${/parameter/@layout_code}_hls_fin_calc_readonly_link_winid',
                            global_flag: 'Y',
                            calc_type: 'CLASSIC_CALCULATOR'
                        },
                        url: url,
                        fullScreen: true,
                        draggable: true
                    });
                    return;
                }
            }
            
            function quote_link_contract(type, record_id) {
                var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
                var prj_quotation_record = $(prj_quotation_ds_id).findById(record_id);
                var saveData = [];
                if (type == 'readOnly') {
                    url = $('${/parameter/@layout_code}_hls_fin_calculator_readonly_link_id').getUrl();
                    new Leaf.Window({
                        id: '${/parameter/@layout_code}_hls_fin_calc_readonly_link_winid',
                        params: {
                            document_id: '${/parameter/@document_id}',
                            document_category: '${/parameter/@document_category}',
                            maintain_type: 'READONLY',
                            calc_session_id: prj_quotation_record.get('calc_session_id'),
                            winId: '${/parameter/@layout_code}_hls_fin_calc_readonly_link_winid',
                            global_flag: 'Y',
                            calc_type: 'CLASSIC_CALCULATOR'
                        },
                        url: url,
                        fullScreen: true,
                        draggable: true
                    });
                    return;
                }
            }
            
            window['${/parameter/@layout_code}_con500_cdd_attachtment_upload'] = function(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/@tree_code}_con500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    } else {
                        url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con500_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}_con_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}_con500_accessory_download'] = function(id, name, query_only) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var url = $('content_download_link_id').getUrl() + '?content_id=' + record.get('content_id') + '&contract_id=' + record.get('contract_id') + '&content_type=' + record.get('content_type');
                window.open(url, '_self');
            };
            //文本附件
            window['${/parameter/@layout_code}_con500_attachment_upload'] = function(id, name, query_only) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var url;
                if (query_only === 'Y') {
                    url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con500_cdd_downloadFile_id').getUrl() + '?table_name=CON_CONTRACT_CONTENT_V&header_id=' + record.get('content_id');
                } else {
                    url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con500_cdd_uploadFile_id').getUrl() + '?table_name=CON_CONTRACT_CONTENT_V&header_id=' + record.get('content_id');
                }
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: '${/parameter/@layout_code}${/parameter/@tree_code}_con500_cdd_uploadFile_win_id',
                    width: 850,
                    height: 400
                });
            };
            //modify by liuguocai5900
            //文本附件
            window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function(id, name, query_only) {

                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var ds_id_record = $(ds_id).getCurrentRecord();
                var project_id = ds_id_record.get('project_id');
                var pj_instance_id = ds_id_record.get('wfl_instance_id');
                var url;
                if (query_only === 'Y') {
                    url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con500_prj_cdd_downloadFile_id').getUrl() + '?table_name=ZJ_WFL_APPROVE_RECORD&header_id=' + pj_instance_id;
                } else {
                    url = $('${/parameter/@layout_code}${/parameter/@tree_code}_con500_prj_cdd_downloadFile_id').getUrl() + '?table_name=ZJ_WFL_APPROVE_RECORD&header_id=' + pj_instance_id;
                }
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: '${/parameter/@layout_code}${/parameter/@tree_code}_con500_prj_cdd_uploadFile_win_id',
                    width: 850,
                    height: 400
                });
            };
            
            
            
            window['${/parameter/@layout_code}_open_bp_win'] = function(id, name, query_only) {
                var prj_chance_bp_record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var param = prj_chance_bp_record.data;
                param['document_id'] = prj_chance_bp_record.get('bp_id');
                param['cond_para2'] = prj_chance_bp_record.get('bp_type');
                param['function_code'] = 'HLS306';
                param['function_usage'] = 'QUERY';
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
                hls_doc_get_layout_code('prj_chance_get_layout_code_link_id', param, 'hls_bp_master_modify_link', null, '${/parameter/@layout_code}', '${/parameter/@winid}');
            };
            
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record, bp_seq) {
                window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                var ds_id = record.ds.id;
                if (name == 'attachment') {
                    link_function = '${/parameter/@layout_code}_con500_cdd_attachtment_upload';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + 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])) {
                                url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                            }
                        }
                        return url;
            
                    }
                } else if (name.indexOf('quote') >= 0) {
                    if (check_releated_layout('CHANCE')) {
                        return '<a href="javascript:quote_link(\'' + 'readOnly' + '\',\'' + record.id + '\')">报价查看</a>';
                    } else if (check_releated_layout('CONTRACT')) {
                        return '<a href="javascript:quote_link_contract(\'' + 'readOnly' + '\',\'' + record.id + '\')">报价查看</a>';
                    }
                } else if (name === 'accessory') { // 文本正本
                    link_function = '${/parameter/@layout_code}_con500_accessory_download';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                } else if (name === 'attachment_upload') { // 文本附件
                    link_function = '${/parameter/@layout_code}_con500_attachment_upload';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                } else if (name === 'more') {
                    link_function = '${/parameter/@layout_code}_open_bp_win';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">明细</a>';
                }
            };
            
            //保存时选择签字授权人,校验附件“签字授权书”上传  modify  by liuguocai5900
            window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function(ds, record, res) {
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();

                var contract_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                $('${/parameter/@layout_code}_virtual_ds').setSubmitParameter('document_id', $(contract_id).getAt(0).get('contract_id'));
                $('${/parameter/@layout_code}_virtual_ds').setSubmitParameter('document_category', 'CONTRACT_SIGN_CHECK');
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>