<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Calvin  
    $Date: 2017年11月22日18:21:48
    $Revision: 1.0  
    $Purpose:发起清收页面 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="cont.CON632.get_batch_id" rootPath="batch_id_path"/>
        <!-- <a:model-query fetchAll="true" model="cont.CON632.get_col_count" rootPath="col_count_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="con632_update_col_link" url="${/request/@context_path}/modules/cont/CON632/con_collection_insert_tmp.lsc"/>
        <a:link id="con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="car_modify_special_link" url="${/request/@context_path}/modules/prj/PRJ500N/prj_project_create.lview"/>
        <a:link id="con_contract_modify_link" url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
        <a:link id="${/parameter/@layout_code}_col_detail_link" url="${/request/@context_path}/modules/cont/CON632/con_collection_phone_detail.lview"/>
        <a:link id="${/parameter/@layout_code}_submit_approval_link" model="cont.CON632.con_collection_callback_wfl" modelaction="update"/>
        <a:link id="${/parameter/@layout_code}_insert_management_link" url="${/request/@context_path}/modules/cont/CON632/con_collection_insert_management.lsc"/>
        <a:link id="${/parameter/@layout_code}_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}_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"/>
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
        <a:link id="get_col_count_link" model="cont.CON632.get_col_count" modelaction="update"/>
        <a:link id="update_assign_user_link" model="cont.CON632.update_assign_user" 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[
            jQuery.noConflict();
            Ext.ux.Lightbox.register('a[ref=img]', true);
            //锁屏
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window'] = function() {
                var detail_mask;
                if ('${/parameter/@winid}') {
                    if (parent.$L.CmpManager.get('${/parameter/@winid}')) {
                        detail_mask = parent.$('${/parameter/@winid}').wrap;
                        parent.Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    } else {
                        detail_mask = $('${/parameter/@winid}').wrap;
                        Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                    }
                } else {
                    detail_mask = Ext.getBody();
                    Leaf.Masker.mask(detail_mask, '${l:HLS.EXECUTING}');
                }
            };
            //解屏
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window'] = function() {
                var detail_mask;
                if ('${/parameter/@winid}') {
                    if (parent.$L.CmpManager.get('${/parameter/@winid}')) {
                        detail_mask = parent.$('${/parameter/@winid}').wrap;
                        parent.Leaf.Masker.unmask(detail_mask);
                    } else {
                        detail_mask = $('${/parameter/@winid}').wrap;
                        Leaf.Masker.unmask(detail_mask);
                    }
                } else {
                    detail_mask = Ext.getBody();
                    Leaf.Masker.unmask(detail_mask);
                }
                if (Ext.get(document.documentElement)) {
                    $L.Masker.unmask(Ext.get(document.documentElement));
                }
            };
            
            function check_releated_layout(releated_table) {
                var str = '${/parameter/@layout_code}';
                //商机
                if (str.indexOf(releated_table) >= 0) {
                    return true;
                } else {
                    return false;
                }
            }
            
            //提交审批
            window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
                //
                //提交先保存
                window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_collection_callback');
                var lease_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
                // window['${/parameter/@layout_code}_not_ignore_required_flag'] = true;
                var record = $(ds_id).getCurrentRecord();
                var contract_ds_id = $('${/parameter/@layout_code}_G_CAR_hls_bp_master_ds');
                var contract_records = contract_ds_id.getSelected();
                if (record.get('wfl_status') == 'REJECT') {
                    var param = {};
                    var datas = [];
                    var saveData = [];
                    var batch_id = ${/model/batch_id_path/record/@batch_id};
                    for (var j = 0;j < contract_records.length;j++) {
                        saveData.push({
                            'contract_lease_item_id': contract_records[j].get('contract_lease_item_id'),
                            'callback_id': record.get('callback_id'),
                            'batch_id': batch_id,
                            '_status': 'insert'
                        });
                    }
                    param['details'] = saveData;
                    Leaf.request({
                        url: $('con632_update_col_link').getUrl(),
                        para: param,
                        success: function() {},
                        failure: function() {},
                        error: function() {},
                        scope: this
                    });
                    //
                    for (var i = 0;i < contract_records.length;i++) {
                        var callback_flag = contract_records[i].get('callback_flag');
                        // var real_callback_flag = contract_records[i].get('real_callback_flag');
                        if (contract_records[i].get('contract_lease_item_id')) {
                            var obj = {};
                            obj['callback_id'] = record.get('callback_id');
                            obj['contract_lease_item_id'] = contract_records[i].get('contract_lease_item_id');
                            obj['callback_flag'] = callback_flag;
                            // obj['real_callback_flag'] = real_callback_flag;
                            obj['_status'] = 'update';
                            datas[i] = obj;
                        }
                    }
                    // if (!callback_flag && !real_callback_flag) {
                    // Leaf.showMessage('${l:HLS.PROMPT}', '请至少选择一个清收状态!');
                    // } else {
                    Leaf.showConfirm('${l:HLS.PROMPT}', '确认提交?', function() {
                        //插入待处置清单表
                        Leaf.request({
                            url: $('${/parameter/@layout_code}_insert_management_link').getUrl(),
                            para: datas,
                            success: function() {
                                //启动工作流
                                Leaf.request({
                                    url: $('${/parameter/@layout_code}_submit_approval_link').getUrl(),
                                    para: {
                                        callback_id: record.get('callback_id')
                                    },
                                    success: function(res) {
                                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                        $('${/parameter/@winid}').close();
                                        Leaf.SideBar.show({
                                            msg: '操作成功',
                                            duration: 2000
                                        });
                                    },
                                    failure: function() {
                                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                    },
                                    error: function() {
                                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                    },
                                    scope: this
                                });
                            },
                            failure: function() {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            error: function() {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    });
                } else {
                    if (contract_records.length == 0) {
                        Leaf.showMessage('提示', '请至少选择一条租赁物!');
                        return;
                    } else {
                        var param = {};
                        var datas = [];
                        var saveData = [];
                        var batch_id = ${/model/batch_id_path/record/@batch_id};
                        for (var j = 0;j < contract_records.length;j++) {
                            saveData.push({
                                'contract_lease_item_id': contract_records[j].get('contract_lease_item_id'),
                                'callback_id': record.get('callback_id'),
                                'batch_id': batch_id,
                                '_status': 'insert'
                            });
                        }
                        param['details'] = saveData;
                        Leaf.request({
                            url: $('con632_update_col_link').getUrl(),
                            para: param,
                            success: function() {},
                            failure: function() {},
                            error: function() {},
                            scope: this
                        });
                        //
                        for (var i = 0;i < contract_records.length;i++) {
                            var callback_flag = contract_records[i].get('callback_flag');
                            // var real_callback_flag = contract_records[i].get('real_callback_flag');
                            if (contract_records[i].get('contract_lease_item_id')) {
                                var obj = {};
                                obj['callback_id'] = record.get('callback_id');
                                obj['contract_lease_item_id'] = contract_records[i].get('contract_lease_item_id');
                                obj['callback_flag'] = callback_flag;
                                // obj['real_callback_flag'] = real_callback_flag;
                                obj['_status'] = 'update';
                                datas[i] = obj;
                            }
                        }
                        // if (!callback_flag && !real_callback_flag) {
                        // Leaf.showMessage('${l:HLS.PROMPT}', '请至少选择一个清收状态!');
                        // } else {
                        Leaf.showConfirm('${l:HLS.PROMPT}', '确认提交?', function() {
                            //插入待处置清单表
                            Leaf.request({
                                url: $('${/parameter/@layout_code}_insert_management_link').getUrl(),
                                para: datas,
                                success: function() {
                                    //启动工作流
                                    Leaf.request({
                                        url: $('${/parameter/@layout_code}_submit_approval_link').getUrl(),
                                        para: {
                                            callback_id: record.get('callback_id')
                                        },
                                        success: function(res) {
                                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                            $('${/parameter/@winid}').close();
                                            Leaf.SideBar.show({
                                                msg: '操作成功',
                                                duration: 2000
                                            });
                                        },
                                        failure: function() {
                                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                        },
                                        error: function() {
                                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                        },
                                        scope: this
                                    });
                                },
                                failure: function() {
                                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                },
                                error: function() {
                                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                },
                                scope: this
                            });
                        });
                        // }
                    }
                }
            };
            
            // 加载时调用(grid,table,gridBox)
            window['${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function(ds, record) {
            
                var ds_call_id = '${/parameter/@layout_code}_G_CAR_hls_bp_master_ds';
                jQuery("div").hover(function() {
                    if (ds_call_id) {
                        var records = $(ds_call_id).getAll();
                        for (var i = 0;i < records.length;i++) {
                            //
                            var id = "#${/parameter/@layout_code}_G_CAR_hls_bp_master_layout_grid_id__" + records[i].id;
                            //获取实际清收状态,如果有值,则不能选择
                            if (records[i].get('col_management_status') == 'WAIT_FOR_MANAGEMENT' || records[i].get('col_management_status') == 'FINISH_MANAGEMENT' || records[i].get('col_management_status') == 'MANAGEMENTING') {
                                //
                                jQuery(id).removeClass("grid-ckb item-ckb-u").addClass('grid-ckb item-ckb-readonly-u');
                            }
                            jQuery("div").unbind(); //移除所有
                        }
                    }
                });
            
            };
            
            //保存submitsuccess调用
            window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function(ds, record, res, bp_seq) {
                //
                dirty_flag = 'N';
                if ('${/parameter/@layout_code}' == 'COL_CALLBACK_DETAIL_WFL') {
                    var collection_call_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_collection_callback');
            		if (collection_call_id) {
                        var collection_record = $(collection_call_id).getCurrentRecord();
                        var callback_id = collection_record.get('callback_id');
                        var assign_user_id = collection_record.get('assign_user_id');
                        // collection_record.set('col_count', ${/model/col_count_path/record/@col_count});
                        Leaf.request({
                            url: $('update_assign_user_link').getUrl(),
                            para: {
                                callback_id: callback_id,
                                assign_user_id: assign_user_id
                            },
                            success: function() {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }
                }
                if ('${/parameter/@layout_code}' != 'COL_CALLBACK_DETAIL_WFL' && '${/parameter/@layout_code}' != 'COL_CALLBACK_DETAIL_REFUSED') {
                    var collection_call_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_collection_callback');
                    if (collection_call_id) {
                        var collection_record = $(collection_call_id).getCurrentRecord();
                        var callback_id = collection_record.get('callback_id');
                        // collection_record.set('col_count', ${/model/col_count_path/record/@col_count});
                        Leaf.request({
                            url: $('get_col_count_link').getUrl(),
                            para: {
                                callback_id: callback_id,
                                col_number: '${/parameter/@col_number}'
                            },
                            success: function() {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }
                } else {
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                }
            };
            
            var isLoaded = 'N';
            //	ds_call_id 进入后无法自动刷新,设置定时刷新
            var check_isload = setInterval(function() {
                if (isLoaded == 'N') {
                    if (isLoaded == 'N') {
                        var ds_call_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_collection_call_hd');
                        if (ds_call_id) {
                            jQuery("#${/parameter/@layout_code}_G_PHONE_COLLECTION_con_collection_call_hd_layout_grid_id_wrap .nav-refresh").click();
                            jQuery("div").unbind(); //移除所有
                            isLoaded = 'Y';
                        }
                    }
                } else {
                    clearInterval(check_isload);
                }
            }, 1000);
            
            
            //查询时调用(grid,table,gridBox)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function(ds, qpara, bp_seq) {
                //
                var ds_check_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
                var ds_call_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_collection_call_hd');
                if (ds_check_id == ds.id && ds_check_id) {
                    $(ds_check_id).setQueryParameter('bp_id', '${/parameter/@bp_id}');
                } else if (ds.id == '${/parameter/@layout_code}_G_CAR_hls_bp_master_ds') {
                    $('${/parameter/@layout_code}_G_CAR_hls_bp_master_ds').setQueryParameter('bp_id', '${/parameter/@bp_id}');
                }
            
                if (ds_call_id == ds.id && ds_call_id) {
                    var col_number = '${/parameter/@col_number}';
                    col_number = col_number.replace('CC', '');
                    $(ds_call_id).setQueryParameter('col_id', col_number);
                }
            
            };
            
            function open_contract_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON301';
                param['maintain_type'] = 'UPDATE';
                param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con_contract_modify_link', ds_id, '${/parameter/@layout_code}');
            }
            
            function open_project_Window(ds_id, record_id) {
                //
                var record = $(ds_id).findById(record_id);
                var param = {};
                param['company_id'] = record.get('company_id');
                param['project_id'] = record.get('project_id');
                param['function_code'] = 'PRJ502D';
                param['function_usage'] = 'QUERY';
                param['bp_class'] = record.get('bp_class');
                param['maintain_type'] = 'QUERY';
                param['url_title'] = '${l:HLS.PROJECT_MAITAIN}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'car_modify_special_link', ds_id, '${/parameter/@layout_code}');
            }
            
            function open_col_detail_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'CON632_PDQ';
                param['function_usage'] = 'QUERY';
                param['maintain_type'] = 'READONLY';
                param['url_title'] = '催收详情';
                param['winid'] = 'col_detail_id';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, '${/parameter/@layout_code}_col_detail_link', ds_id, '${/parameter/@layout_code}');
            }
            
            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('contract_lease_item_id')) {
                    var url;
                    if (query_only == 'Y' || '${/parameter/@function_usage}' == 'QUERY' || '${/parameter/@maintain_type}' == 'READONLY' || record.get('callback_flag')) {
                        url = $('${/parameter/@layout_code}_cdd_downloadFile_id').getUrl() + '?table_name=CON_CONTRACT_LEASE_ITEM&header_id=' + record.get('contract_lease_item_id');
                    } else {
                        url = $('${/parameter/@layout_code}_cdd_uploadFile_id').getUrl() + '?table_name=CON_CONTRACT_LEASE_ITEM&header_id=' + record.get('contract_lease_item_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();
                    });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
            
                }
            }
            
            
            
            function upload_file_acy(id, name, query_only) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                if (record.get('col_attachment_id')) {
                    var url;
                    if (query_only == 'Y' || '${/parameter/@function_usage}' == 'QUERY' || '${/parameter/@maintain_type}' == 'READONLY' || record.get('callback_flag')) {
                        url = $('${/parameter/@layout_code}_cdd_downloadFile_id').getUrl() + '?table_name=COL_COLLECTION_ATTACHMENT&header_id=' + record.get('col_attachment_id');
                    } else {
                        url = $('${/parameter/@layout_code}_cdd_uploadFile_id').getUrl() + '?table_name=COL_COLLECTION_ATTACHMENT&header_id=' + record.get('col_attachment_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();
                    });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
            
                }
            }
            
            function open_bp_modify_win(ds_id, record_id) {
                var record = $(ds_id).findById(record_id);
                var param = record.data;
                param['function_code'] = 'HLS214D';
                param['bp_id'] = record.get('bp_id');
                param['bp_category'] = '${/parameter/@bp_category}';
                param['bp_class'] = '${/parameter/@bp_class}';
                if ('${/parameter/@bp_category}' == 'AGENT') {
                    param['function_code'] = 'HLS228DL';
                }
                param['function_usage'] = 'QUERY';
                if ('${/parameter/@bp_function_usage}' == 'MODIFY') {
                    param['function_usage'] = 'MODIFY';
                }
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'hls_bp_master_modify_link', null, '${/parameter/@layout_code}');
            }
            
            // function open_bp_modify_win(ds_id, record_id) {
            // var record = $(ds_id).findById(record_id);
            // var param = record.data;
            // param['function_code'] = 'CON501H';
            // param['function_usage'] = 'QUERY';
            // param['url_title'] = '${l:HLS212.BP_MASTER_QUERY}';
            // hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'hls_bp_master_modify_link', ds_id);
            // }
            
            //超链接渲染
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
                window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                if (name == 'project_number' && value) {
                    return '<a href="javascript:open_project_Window(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                } else if (name == 'contract_number' && value) {
                    return '<a href="javascript:open_contract_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + value + '</a>';
                } else if (name == 'bp_modify') {
                    return '<a href="javascript:open_bp_modify_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + config_record.get('prompt') + '</a>';
                } else if (name == 'col_detail' && !record.isNew) {
                    return '<a href="javascript:open_col_detail_win(\'' + record.ds.id + '\',\'' + record.id + '\')">' + config_record.get('prompt') + '</a>';
                } else if (name == 'attachment') {
                    link_function = 'upload_file';
                    if (record.get('attach_count') == 0 || !record.get('attach_count')) {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    } else {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '(' + record.get('attach_count') + ')' + '</a>';
                    }
                } else if (name == 'attachment2') {
                    link_function = 'upload_file_acy';
                    if (record.get('attach_count') == 0 || !record.get('attach_count')) {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    } else {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '(' + record.get('attach_count') + ')' + '</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;
                    }
                }
                return value;
            };
            
            //add by zhuxianfei 20180302 --begin
            var dirty_flag;
            //更新时调用
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {
                var con_col_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_col_management_hd');
                if (ds.id == con_col_ds_id) {
                    if (name == 'real_callback_flag' || name == 'car_commission') {
                        dirty_flag = 'Y';
                    }
                }
            };
            
            // //保存submitsuccess调用
            // window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function(ds, record, res, bp_seq) {
            // window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            // dirty_flag = 'N';
            // };
            
            
            //modify by zhuxianfei  提交校验必输提示保存
            
            function zjwfl5110_beforeapproveCheck(agree) {
                //
                if ('${/parameter/@instance_id}') {
                    if ('${/parameter/@check_flag}' == 'Y') {
                        var root_ds = $('${/parameter/@layout_code}_virtual_ds');
                        var records = root_ds.getAll();
                        if (root_ds.validate()) {
                            if (dirty_flag == 'Y') {
                                Leaf.showMessage('提示', '界面数据已更改,请先保存');
                                return false;
                            } else {
                                return true;
                            }
                        } else {
                            return false;
                        }
                    } else {
                        return true;
                    }
                }
            }
            //--end
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>