<?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" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="contract_lease_item_maintain_link" url="${/request/@context_path}/modules/cont/CON501N/con_lease_item_maintain.lview"/>
        <a:link id="contract_history_window_link" url="${/request/@context_path}/modules/cont/CON501N/con_document_history_query.lview"/>
        <a:link id="con501_item_detail_maintain" url="${/request/@context_path}/modules/cont/CON501N/con_item_detail_maintain.lview"/>
        <a:link id="con501_hls_bp_master_modify_link" url="${/request/@context_path}/modules/cont/CON501N/hls_bp_master_modify.lview"/>
        <a:link id="con501_contract_maintain_flag_update_link" model="cont.CON500.con_contract_maintain_flag_update" modelaction="execute"/>
        <a:link id="con501_contract_maintain_entrance_link" url="${/request/@context_path}/modules/cont/CON501N/con_contract_modify_entrance.lview"/>
        <a:link id="${/parameter/@layout_code}_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="${/parameter/@layout_code}_prj500_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}_prj500_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="${/parameter/@layout_code}_con_contract_content_confirm_link_id" url="${/request/@context_path}/modules/cont/CON501N/con_contract_content_confirm.lview"/>
        <a:link id="get_atch_download_link" url="${/request/@context_path}/modules/batch_download/lease_atm_batch_dl.lsc"/>
        <a:link id="con_contract_gps_send_link" url="${/request/@context_path}/modules/gps/con_contract_gps_send.lsc"/>
        <a:link id="con_contract_gps_send_address_win_link" url="${/request/@context_path}/modules/gps/con_contract_gps_send.lview"/>
        <a:link id="get_bp_class_link_id" model="cont.CON500.con_get_bp_class" modelaction="update"/>
        <script src="${/request/@context_path}/modules/prj/PRJ500N/javascripts/input_validator.js" type="text/javascript"/>
        <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>
        <link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript"><![CDATA[
            Ext.ux.Lightbox.register('a[ref=img]', true);
            if ('${/parameter/@save_source_type}' == 'JGPS') {
                zjwfl5110_ApproveChecker_add('zjwfl5110_submit', function(type) {
                    var root_ds = $('${/parameter/@layout_code}_virtual_ds');
                    if (type == 'agree') {
                        if (root_ds.validate()) {
                            //提交先保存
                            window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK']();
                            return true;
                        } else {
                            return false;
                        }
                    }
                });
            } else if ('${/parameter/@save_source_type}' == 'CONTRACT_PRINT') {
            
                zjwfl5110_ApproveChecker_add('zjwfl5110_submit', function(type) {
                    var root_ds = $('${/parameter/@layout_code}_virtual_ds');
                    if (type == 'agree') {
                        if (change_flag == 'Y') {
                            Leaf.showErrorMessage('提示', '数据改变,请生成合同文本！');
                            return false;
                        } else {
                            return true;
                        }
                    }
                });
            }
            //保存前调用，生成项目编号  // 确定保存开始校验
            // window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
            //
            // window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            // var check_flag = true;
            // //车辆二手车 车架号校验
            // var ds2 = $('${/parameter/@layout_code}_G_ASSET_con_contract_lease_item_ds');
            // var ds2Record = ds2.getCurrentRecord();
            // if (ds2Record) {
            // if (!Leaf.isEmpty(ds2Record.get('item_frame_number'))) {
            // if (!Leaf.isEmpty(ds2Record.get('item_frame_number'))) {
            // if (!checkVumber(ds2Record.get('item_frame_number'))) {
            // Leaf.showMessage('提示', '二手车信息中，请输入正确格式的车架号！');
            // window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            // return false;
            // }
            // }
            // }
            // }
            // return check_flag;
            // };
            
            
            window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
            
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var contract_id = $(ds_id).getCurrentRecord().get('contract_id');
                new Leaf.Window({
                    id: 'contract_history_window',
                    url: $('contract_history_window_link').getUrl(),
                    params: {
                        contract_id: contract_id
                    },
                    fullScreen: true
                });
            };
            
            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 contract_id = $(ds_id).getCurrentRecord().get('contract_id');
                Leaf.showConfirm('提示', '您确认已保存？', function() {
                    Leaf.request({
                        url: $('con501_contract_maintain_flag_update_link').getUrl(),
                        para: {
                            contract_id: contract_id
                        },
                        success: function() {
                            Leaf.SideBar.show({
                                msg: '已提交',
                                duration: 2000
                            });
                            $('${/parameter/@winid}').close();
                        },
                        scope: this
                    });
            
                });
            };
            
            // window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record) {
            
            // if (name == 'car_detail') {
            // return '<a href="javascript:open_contract_window(\'' + record.id + '\',\'' + record.ds.id + '\')">' + config_record.get('prompt') + '</a>';
            // }
            // return value;
            // };
            
            window['${/parameter/@layout_code}_dynamic_link_renderer'] = function(value, record, name, config_record, bp_seq) {
                var link_function = '';
                window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
                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 == 'car_detail' && record.get('contract_lease_item_id')) {
                    link_function = '${/parameter/@layout_code}_open_lease_item_detail_window';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\');">' + config_record.get('prompt') + '</a>';
                } else if (name == 'attachment') {
                    link_function = '${/parameter/@layout_code}_prj500_cdd_attachtment_upload';
                    return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + 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])) {
            
                                var file_suffix = temp[0].substr(temp[0].lastIndexOf('.') + 1).toUpperCase();
                                if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
                                    url = url + '<a ref="img" href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                } else {
                                    url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                }
                            }
                        }
                        return url;
                    }
                } else if (name == 'link1') {
                    link_function = '${/parameter/@layout_code}_ast_con_cdd_attachtment_upload';
                    if (record.get('atm_num1') > 0) {
                        return '<a style="color:red" href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    } else {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    }
                } else if (name == 'link2') {
                    link_function = '${/parameter/@layout_code}_ast_con_cdd2_attachtment_upload';
                    if (record.get('atm_num2') > 0) {
                        return '<a style="color:red" href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    } else {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    }
            
                } else if (name == 'link3') {
                    link_function = '${/parameter/@layout_code}_ast_con_cdd3_attachtment_upload';
                    if (record.get('atm_num3') > 0) {
                        return '<a style="color:red" href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    } else {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.ds.id + '\',\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    }
                }
            };
            //link1
            window['${/parameter/@layout_code}_ast_con_cdd_attachtment_upload'] = function(ds_id, id, name, query_only) {
                var record = $(ds_id).findById(id);
                if (record.get('ast_con_car_insurance_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}_prj500_cdd_downloadFile_id').getUrl() + '?table_name=AST_CON_INSURANCE&header_id=' + record.get('ast_con_car_insurance_id');
                    } else {
                        url = $('${/parameter/@layout_code}_prj500_cdd_uploadFile_id').getUrl() + '?table_name=AST_CON_INSURANCE&header_id=' + record.get('ast_con_car_insurance_id');
                    }
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: '${/parameter/@layout_code}${/parameter/@tree_code}_ast_con_cdd_attachtment_upload_id',
                        width: 850,
                        height: 400
                    });
                    // win.on('close', function() {
                    // $(ds_id).query();
                    // });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
                }
            };
            //link2
            window['${/parameter/@layout_code}_ast_con_cdd2_attachtment_upload'] = function(ds_id, id, name, query_only) {
                var record = $(ds_id).findById(id);
                if (record.get('ast_con_car_insurance_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}_prj500_cdd_downloadFile_id').getUrl() + '?table_name=AST_CON_INSURANCE_2&header_id=' + record.get('ast_con_car_insurance_id');
                    } else {
                        url = $('${/parameter/@layout_code}_prj500_cdd_uploadFile_id').getUrl() + '?table_name=AST_CON_INSURANCE_2&header_id=' + record.get('ast_con_car_insurance_id');
                    }
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: '${/parameter/@layout_code}${/parameter/@tree_code}_ast_con_cdd2_attachtment_upload_id',
                        width: 850,
                        height: 400
                    });
                    // win.on('close', function() {
                    // $(ds_id).query();
                    // });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
                }
            };
            
            //link3
            window['${/parameter/@layout_code}_ast_con_cdd3_attachtment_upload'] = function(ds_id, id, name, query_only) {
                var record = $(ds_id).findById(id);
                if (record.get('ast_con_car_insurance_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}_prj500_cdd_downloadFile_id').getUrl() + '?table_name=AST_CON_INSURANCE_3&header_id=' + record.get('ast_con_car_insurance_id');
                    } else {
                        url = $('${/parameter/@layout_code}_prj500_cdd_uploadFile_id').getUrl() + '?table_name=AST_CON_INSURANCE_3&header_id=' + record.get('ast_con_car_insurance_id');
                    }
                    var win = new Leaf.Window({
                        url: url,
                        title: '${l:HLS.SUPPORTING_DOCUMENT}',
                        id: '${/parameter/@layout_code}${/parameter/@tree_code}_ast_con_cdd3_attachtment_upload_id',
                        width: 850,
                        height: 400
                    });
                    // win.on('close', function(){
                    // $(ds_id).query();
                    // });
                } else {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
                }
            };
            
            window['${/parameter/@layout_code}_prj500_cdd_attachtment_upload'] = function(ds_id, id, name, query_only) {
                var record = $(ds_id).findById(id);
                if (record.get('check_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('${/parameter/@layout_code}_prj500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    } else {
                        url = $('${/parameter/@layout_code}_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: '${/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}_open_lease_item_detail_window'] = function(id, name) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                var param = record.data;
                param['function_code'] = 'CON501M';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '租赁物明细维护';
                hls_doc_get_layout_code('con_contract_get_layout_code_link_id', param, 'con501_item_detail_maintain', record.ds.id, '${/parameter/@layout_code}');
                // var contract_lease_item_id = record.get('contract_lease_item_id');
                // new Leaf.Window({
                // id: 'contract_lease_item_maintain_window',
                // url: $('contract_lease_item_maintain_link').getUrl(),
                // params: {
                // contract_id:'${/parameter/@contract_id}',
                // contract_lease_item_id: contract_lease_item_id,
                // winid: 'contract_lease_item_maintain_window'
                // },
                // draggable: true,
                // fullScreen: true
                // });
            };
            
            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'] = 'CON501H';
                param['function_usage'] = 'MODIFY';
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
                hls_doc_get_layout_code('${/parameter/@layout_code}_con_contract_get_layout_code_link_id', param, 'con501_hls_bp_master_modify_link', record.ds.id, '${/parameter/@layout_code}');
            };
            
            // function open_contract_window(record_id, ds_id) {
            
            // var record = $(ds_id).findById(record_id);
            
            // var param = record.data;
            // var contract_lease_item_id = record.get('contract_lease_item_id');
            // new Leaf.Window({
            // id: 'contract_lease_item_maintain_window',
            // url: $('contract_lease_item_maintain_link').getUrl(),
            // params: {
            // contract_lease_item_id: contract_lease_item_id
            // },
            // fullScreen: true
            // });
            // // param['function_code'] = 'CON501D';
            // // param['function_usage'] = 'MODIFY';
            // // 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);
            // }
            //数据是否发生改变
            var change_flag = 'N';
            //工作流中合同文本生成按钮
            //基本信息tab页 新增必输字段的校验  add by liukang 20160328
            window['${/parameter/@layout_code}_print_layout_dynamic_click'] = function() {
            
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var con_lease_item_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item');
                var record = $(ds_id).getCurrentRecord();
                var con_lease_record = $(con_lease_item_id).getCurrentRecord();
                var direct_debit_bank_id = record.get('direct_debit_bank_id');
                var dd_bank_account_name = record.get('dd_bank_account_name');
                var dd_bank_account_num = record.get('dd_bank_account_num');
                var color_of_apprearance = con_lease_record.get('color_of_apprearance');
                var item_frame_number = con_lease_record.get('item_frame_number');
                var item_engine_number = con_lease_record.get('item_engine_number');
                var license_number = con_lease_record.get('license_number');
            
                if (Ext.isEmpty(direct_debit_bank_id)) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先填写数据并保存!');
                } else if (!Ext.isEmpty(record.get('contract_number'))) {
                    new Leaf.Window({
                        id: '${/parameter/@layout_code}_con_contract_content_confirm_win_id',
                        params: {
                            contract_id: record.get('contract_id'),
                            company_id: record.get('company_id'),
                            document_category: record.get('document_category'),
                            business_type: record.get('business_type'),
                            winid: '${/parameter/@layout_code}_con_contract_content_confirm_win_id',
                            change_flag: change_flag
                        },
                        url: $('${/parameter/@layout_code}_con_contract_content_confirm_link_id').getUrl(),
                        title: '合同文本生成',
                        width: 1300,
                        height: 550
                    });
                } else {
                    Leaf.showErrorMessage('错误', '请先点击保存生成合同编号！');
                }
            };
            // 合同文本查看
            window['${/parameter/@layout_code}_user_button3_layout_dynamic_click'] = function() {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var con_lease_item_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item');
                var record = $(ds_id).getCurrentRecord();
                var con_lease_record = $(con_lease_item_id).getCurrentRecord();
                var direct_debit_bank_id = record.get('direct_debit_bank_id');
                var dd_bank_account_name = record.get('dd_bank_account_name');
                var dd_bank_account_num = record.get('dd_bank_account_num');
                var color_of_apprearance = con_lease_record.get('color_of_apprearance');
                var item_frame_number = con_lease_record.get('item_frame_number');
                var item_engine_number = con_lease_record.get('item_engine_number');
                var license_number = con_lease_record.get('license_number');
            
                if (Ext.isEmpty(direct_debit_bank_id)) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '请先填写数据并保存!');
                } else if (!Ext.isEmpty(record.get('contract_number'))) {
                    new Leaf.Window({
                        id: '${/parameter/@layout_code}_con_contract_content_confirm_win_id',
                        params: {
                            action: 'VIEW',
                            contract_id: record.get('contract_id'),
                            company_id: record.get('company_id'),
                            document_category: record.get('document_category'),
                            business_type: record.get('business_type'),
                            winid: '${/parameter/@layout_code}_con_contract_content_confirm_win_id'
                        },
                        url: $('${/parameter/@layout_code}_con_contract_content_confirm_link_id').getUrl(),
                        title: '合同查看',
                        width: 1300,
                        height: 550
                    });
                } else {
                    Leaf.showErrorMessage('错误', '请先点击保存生成合同编号！');
                }
            };
            
            window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function() {
            
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var contract_id = $(ds_id).getCurrentRecord().get('contract_id');
                Leaf.showConfirm('提示', '是否确认发送GPS安装请求？', function() {
                    zjwfl5110_approvePage_mask();
                    Leaf.request({
                        url: $('con_contract_gps_send_link').getUrl(),
                        para: {
                            contract_id: contract_id,
                            gps_type: 'NEW_GPS'
                        },
                        success: function(res) {
                            Leaf.SideBar.show({
                                msg: '发送成功！',
                                duration: 2000
                            });
                            zjwfl5110_approvePage_noMask();
                        },
                        failure: function(res) {
                            zjwfl5110_approvePage_noMask();
                        },
                        error: function() {
                            zjwfl5110_approvePage_noMask();
                        },
                        scope: this
                    });
            
                });
            };
            
            window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function() {
            
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var contract_id = $(ds_id).getCurrentRecord().get('contract_id');
                var win = new Leaf.Window({
                    url: $('con_contract_gps_send_address_win_link').getUrl(),
                    title: '实时定位',
                    params: {
                        contract_id: contract_id,
                        winid: '${/parameter/@layout_code}_con_contract_gps_send_address_win_link_winid'
                    },
                    id: '${/parameter/@layout_code}_con_contract_gps_send_address_win_link_winid',
                    width: 600,
                    height: 400
                });
            };
            
            //保存前调用
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                //var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                // var con_lease_item_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item');
                // var record_ds = $(ds_id).getCurrentRecord();
                //var con_lease_record = $(con_lease_item_id).getCurrentRecord();
                if (record.dirty) {
                    change_flag = 'Y';
                }
                var check_flag = true;
                return check_flag;
            };
            
            //加载时调用(grid,table,gridBox)
            // window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function(ds, record, config_records, bp_seq) {
            // var con_contract_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
            // var con_contract_lease_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item');
            // if (ds.id == con_contract_lease_item_ds_id) {
            // if ($L.CmpManager.get(con_contract_ds_id)) {
            // var division = $(con_contract_ds_id).getCurrentRecord().get('division');
            // if (division == '01') {
            
            // record.getField('item_frame_number').setReadOnly(true);
            // }
            // }
            // }
            // };
            
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_value, bp_seq) {
                var ast_con_insurance_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'ast_con_insurance');
            
                if (ds.id == ast_con_insurance_ds_id) {
            
                    if ($L.CmpManager.get(ast_con_insurance_ds_id)) {
                        if (name == 'vci_insurance_date_from') {
                            var date = new Date(value);
                            date.setFullYear(date.getFullYear() + 1);
                            record.set('vci_insurance_date_to', date);
                        } else if (name == 'tci_insurance_date_from') {
                            var date = new Date(value);
                            date.setFullYear(date.getFullYear() + 1);
                            record.set('tci_insurance_date_to', date);
                        }
                    }
                }
            };
            
            //打包下载
            window['${/parameter/@layout_code}_C_ATTCH_USER_BUTTON1_layout_dynamic_tab_click'] = function() {
            
                var con_contract_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                var con_contract_record = $(con_contract_id).getAt(0);
                var con_contract = con_contract_record.get('contract_id');
                var url_l = $('get_atch_download_link').getUrl() + '?table_pk_value=' + con_contract + '&table_name=CON_CONTRACT' + '&doc_code=' + con_contract + '&all_flag=Y';
                window.open(href = url_l, target = "_self");
            };
            
            //新增和加载时调用(form)
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function(ds, record, config_records, bp_seq) {
                //
                //var contract_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                //var contract_lease_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract_lease_item');
                //var record = $(contract_ds_id).getAt(0);
                // var lease_record = $(contract_lease_ds_id).getAt(0);
                // var division = record.get('division');
                //var bp_id_tenant = record.get('bp_id_tenant');
                if (ds.id == '${/parameter/@layout_code}_F_BASIC_con_contract_ds') {
                    var bp_id_tenant = record.get('bp_id_tenant');
                    Leaf.request({
                        url: $('get_bp_class_link_id').getUrl(),
                        para: {
                            bp_id_tenant: bp_id_tenant
                        },
                        success: function(res) {
                            var bp_class_flag = res.result.bp_class_flag;
                            //alert(bp_class_flag);
                            if (bp_class_flag == 'NP') {
                                record.set('ebank_account_prop', '20');
                                record.set('ebank_account_prop_n', '个人账户');
                                record.getField('ebank_account_prop').setReadOnly(true);
                                record.getField('ebank_account_prop_n').setReadOnly(true);
                            }
                        },
                        failure: function() {
            
                           },
                        error: function() {
            
                           },
                        scope: this
                    });
            
                }
                if (ds.id == '${/parameter/@layout_code}_F_INVOICE_con_contract_lease_item_ds') {
                    //
                    var contract_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'con_contract');
                    var con_record = $(contract_ds_id).getAt(0);
                    if (con_record) {
                        var division = con_record.get('division');
                        if (division == '00') {
                            record.getField('bp_name_invoice').setRequired(true);
                            record.getField('invoice_amt').setRequired(true);
                            record.getField('invoice_num').setRequired(true);
                            record.getField('added_invoice_amt').setRequired(true);
                            record.getField('added_invoice_num').setRequired(true);
                            record.getField('trn_of_invoice').setRequired(true);
                            record.getField('invoice_date').setRequired(true);
                        }
                    }
                }
            };
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>
