hls_bp_master_modify.lview 39.4 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129
    $Date: 2014-8-4 下午03:12:06
    $Revision: 1.0
    $Purpose: 商业伙伴维护
-->
niminmin's avatar
niminmin committed
8 9
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
          trace="true">
25484's avatar
25484 committed
10 11
    <a:init-procedure>
        <a:model-query fetchAll="true" model="prj.PRJ500D.user_agent_description" rootPath="user_agent_description"/>
25484's avatar
25484 committed
12
        <a:model-query fetchAll="true" model="hls.HLS214N.hls_bp_master_modify_user" rootPath="modify_user"/>
25484's avatar
25484 committed
13
    </a:init-procedure>
Spencer Chang's avatar
Spencer Chang committed
14 15 16
    <a:view>
        <a:link id="bank_account_num_link" model="hls.HLS214.hls_bp_bank_account_num" modelaction="update"/>
        <a:link id="bp_agent_modify_link" url="${/request/@context_path}/modules/hls/HLS303/bp_agent_create.lview"/>
niminmin's avatar
niminmin committed
17 18
        <script src="${/request/@context_path}/modules/prj/PRJ500N/javascripts/input_validator.js"
                type="text/javascript"/>
Spencer Chang's avatar
Spencer Chang committed
19 20 21
        <a:link id="${/parameter/@layout_code}_downloadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="hls214N_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="hls214N_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
niminmin's avatar
niminmin committed
22 23
        <a:link id="${/parameter/@layout_code}_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>
Spencer Chang's avatar
Spencer Chang committed
24
        <a:link id="hls214_bp_master_save_link_id" model="hls.HLS214.hls_bp_change_agent" modelaction="update"/>
25 26
        <a:link id="${/parameter/@layout_code}_signer_create_link_id" model="hls.HLS213.hls_bp_master_signer_create_check"
                modelaction="update"/>
25484's avatar
25484 committed
27 28 29 30
        <!--        <a:link id="hls214_sap_eai_create_customer_link" url="${/request/@context_path}/modules/interface/INTERFACE_EAI/hls_sap_eai_CrCustomer.lsc"/>-->
        <!--        <a:link id="hls214_sap_eai_create_vender_link" url="${/request/@context_path}/modules/interface/INTERFACE_EAI/hls_sap_eai_CrVender.lsc"/>-->
        <!--        <script src="${/request/@context_path}/javascripts/identity_card_info_query.js"-->
        <!--                type="text/javascript"></script>-->
Spencer Chang's avatar
Spencer Chang committed
31
        <script type="text/javascript"><![CDATA[
32
        //保存前调用
niminmin's avatar
niminmin committed
33
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function (ds, record) {
stone's avatar
stone committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

            //     window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            //     var bp_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            //     debugger
            //     var Pattern = /^[A-Za-z]+$/;
            //     var  record=$(bp_ds_id).getCurrentRecord();
            //     var record_name=record.get('extra_nam');
            //     if(record_name=='extra_nam'){
            //
            //         if((!Pattern.test(record_name)||(record_name.length!=3))){
            //             Leaf.showMessage('${l:HLS.PROMPT}', '简称不合规!');
            //             window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            //             return;
            //         }
            //     }
25484's avatar
25484 committed
49 50
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var bp_record = $(ds_id).getCurrentRecord();
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106

            var address_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_address');
            var records_addr = $(address_ds_id).getAll();
            if (bp_record.get('bp_class') == 'NP'){
                //判断户籍地址
                var flag = true;
                if (records_addr.length <=0){
                    Leaf.showErrorMessage('${l:PROMPT}', '自然人必填[通讯地址]和[户籍地址],请在地址信息新增!');
                    return false;
                }else{
                    for(var i=0;i<records_addr.length;i++){
                        if (records_addr[i].get('address_type') == 'HOUSEHOLD_ADDRESS'){
                            flag = true;
                            break;
                        }else{
                            flag = false;
                        }
                    }
                    //判断通讯地址
                    var flag1 = true;
                    for(var i=0;i<records_addr.length;i++){
                        if (records_addr[i].get('address_type') == 'POSTAL_ADDRESS'){
                            flag1 = true;
                            break;
                        }else{
                            flag1 = false;
                        }
                    }
                    if (flag == false || flag1 == false){
                        Leaf.showErrorMessage('${l:PROMPT}', '自然人必填[通讯地址]和[户籍地址],请在地址信息新增!');
                        return  false;
                    }
                }

            }else if (bp_record.get('bp_class') == 'ORG'){
                //判断通讯地址
                var flag1 = true;
                if (records_addr.length <= 0){
                    Leaf.showErrorMessage('${l:PROMPT}', '法人必填[通讯地址],请在地址信息新增!');
                    return  false;
                }else {
                    for(var i=0;i<records_addr.length;i++){
                        if (records_addr[i].get('address_type') == 'POSTAL_ADDRESS'){
                            flag1 = true;
                            break;
                        }else{
                            flag1 = false;
                        }
                    }
                    if (flag1 == false){
                        Leaf.showErrorMessage('${l:PROMPT}', '法人必填[通讯地址],请在地址信息新增!');
                        return  false;
                    }
                }
            }

niminmin's avatar
niminmin committed
107 108 109 110
            if (old_id_card != new_id_card) {
                bp_record.set('id_card_no_change_flag', 'Y');
            } else {
                bp_record.set('id_card_no_change_flag', 'N');
25484's avatar
25484 committed
111 112 113
            }


niminmin's avatar
niminmin committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
            if (old_bp_name != new_bp_name) {
                bp_record.set('bp_name_change_flag', 'Y');
            } else {
                record.set('bp_name_change_flag', 'N');
            }
            if (bp_record.get('marital_status') && (bp_record.get('marital_status') !== '30' && bp_record.get('marital_status') !== '40')) {
                bp_record.set('bp_name_sp', null);
                bp_record.set('card_type_sp', null);
                bp_record.set('card_type_sp_n', null);
                bp_record.set('id_no_sp', null);
                bp_record.set('date_of_birth_sp', null);
                bp_record.set('cell_phone_sp', null);
                bp_record.set('work_unit_phone_sp', null);
                bp_record.set('work_unit_name_sp', null);
                bp_record.set('work_unit_address_sp', null);
                return true;
25484's avatar
25484 committed
130
            }
stone's avatar
stone committed
131

niminmin's avatar
niminmin committed
132
            return true;
stone's avatar
stone committed
133 134


25484's avatar
25484 committed
135
        };
136

25484's avatar
25484 committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173

        function CheckSocialCreditCode(Code) {
            var patrn = /^[0-9A-Z]+$/;
            //18位校验及大写校验
            if ((Code.length != 18) || (patrn.test(Code) == false)) {
                return false;
            } else {
                var Ancode;//统一社会信用代码的每一个值
                var Ancodevalue;//统一社会信用代码每一个值的权重
                var total = 0;
                var weightedfactors = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];//加权因子
                var str = '0123456789ABCDEFGHJKLMNPQRTUWXY';
                //不用I、O、S、V、Z
                for (var i = 0; i < Code.length - 1; i++) {
                    Ancode = Code.substring(i, i + 1);
                    Ancodevalue = str.indexOf(Ancode);
                    total = total + Ancodevalue * weightedfactors[i];
                    //权重与加权因子相乘之和
                }
                var logiccheckcode = 31 - total % 31;

                if (logiccheckcode == 31) {
                    logiccheckcode = 0;
                }
                var Str = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,T,U,W,X,Y";
                var Array_Str = Str.split(',');
                logiccheckcode = Array_Str[logiccheckcode];

                var checkcode = Code.substring(17, 18);
                if (logiccheckcode != checkcode) {
                    return false;
                } else {
                    return true;
                }
            }
        }

Spencer Chang's avatar
Spencer Chang committed
174
        //保存submitsuccess调用
niminmin's avatar
niminmin committed
175
        window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function (ds, record, res, bp_seq) {
25484's avatar
25484 committed
176
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
177 178 179 180 181 182
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
            var bp_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var records = $(ds_id);
            if (!(records == 'undefined' || records == null)) {
                $(ds_id).query();
            }
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
            //add by zc
            var signer_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_signer');
            var record = $(bp_ds_id).getCurrentRecord();
            bp_id = prj_check_bp_id(record);
            if (!bp_id) {
                return;
            }
            Leaf.request({
                url: $('${/parameter/@layout_code}_signer_create_link_id').getUrl(),
                para: {
                    bp_id: bp_id
                },
                success: function (res) {
                    $(signer_ds_id).query();
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
                failure: function (res) {
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
                error: function () {
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
                scope: this
            });
207
            // 简称校验
208
            //
209 210 211 212 213 214 215 216 217
            // var Pattern = /^[A-Za-z]+$/;
            //
            // if(record.getField('extra_nam')=='extra_nam'){
            //     if((!Pattern.text(extra_nam)||(extra_nam.length!=3))){
            //         Leaf.showMessage('${l:HLS.PROMPT}', '简称不合规!');
            //         return true;
            //     }
            // }

25484's avatar
25484 committed
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
            // Leaf.request({
            //     url: $('hls214_sap_eai_create_customer_link').getUrl(),
            //     para: {
            //         bp_id: bp_id
            //     },
            //     scope: this,
            //     success: function () {
            //         Leaf.request({
            //             url: $('hls214_sap_eai_create_vender_link').getUrl(),
            //             para: {
            //                 bp_id: bp_id
            //             },
            //             scope: this,
            //             success: function () {
            //                 $(bp_ds_id).query();
            //                 window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //             },
            //             failure: function () {
            //                 window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //             },
            //             error: function () {
            //                 window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //             },
            //             sync: true
            //         });
            //     },
            //     failure: function () {
            //         window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //     },
            //     error: function () {
            //         window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //     },
            //     sync: true
            // });
252
            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
Spencer Chang's avatar
Spencer Chang committed
253 254
        };

255

Spencer Chang's avatar
Spencer Chang committed
256 257 258 259 260 261 262 263 264 265 266 267 268
        function prj_check_bp_id(record) {
            var bp_id;
            if (record) {
                bp_id = record.get('bp_id');
            }
            if (!bp_id) {
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                bp_id = '';
            }
            return bp_id;
        }

        //财务报表模板导入
niminmin's avatar
niminmin committed
269
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
Spencer Chang's avatar
Spencer Chang committed
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var record = $(ds_id).getCurrentRecord();

            bp_id = prj_check_bp_id(record);
            if (!bp_id) {
                return;
            }
            new Leaf.Window({
                id: 'rsc_fin_statement_prj_import_handle_winid',
                url: '${/request/@context_path}/modules/rsc/RSC303/rsc_fin_statement_prj_import_handle.lview',
                params: {
                    bp_id: bp_id,
                    winid: 'rsc_fin_statement_prj_import_handle_winid'
                },
                title: '${l:STATEMENTS_BUSINESS_DATA_IMPORT}',
                width: 950,
                height: 200
            });
        };

        //财务报表模板查看
niminmin's avatar
niminmin committed
291
        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function () {
Spencer Chang's avatar
Spencer Chang committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var record = $(ds_id).getCurrentRecord();
            var bp_id = prj_check_bp_id(record);
            if (!bp_id) {
                return;
            }
            new Leaf.Window({
                id: 'rsc_fin_statement_prj_all_query_winid',
                url: '${/request/@context_path}/modules/rsc/RSC303/rsc_fin_statement_prj_all_query.lview',
                params: {
                    bp_id: bp_id,
                    winid: 'rsc_fin_statement_prj_all_query_winid'
                },
                title: '${l:STATEMENTS_BUSINESS_DATA_IMPORT}',
                fullScreen: true,
                draggable: true
            });
        };

        // function fin_institution_code_validate(record, name, value) {
        // if (!value) {
        // return '金融机构代码不能为空';
        // } else {
        // if (value.length != 11) {
        // return '金融机构代码长度必须为11位';
        // }
        // }
        // return true;
        // }

        // function trade_type_code_validate(record, name, value) {
        // var trade_type_code = record.get('trade_type_code');
        // if(!trade_type_code){
        // if(trade_type_code != trade_type_code.toLowerCase()){
        // return '行业分类代码必须为小写字母';
        // }}
        // return true;
        // }

25484's avatar
25484 committed
331 332 333 334 335
        var old_id_card;
        var new_id_card;
        var old_bp_name;
        var new_bp_name;

Spencer Chang's avatar
Spencer Chang committed
336
        //新增和加载时调用form
niminmin's avatar
niminmin committed
337
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function (ds, record, config_records, bp_seq) {
338

339
            // if ((ds.id).indexOf('hls_bp_master_credit') != -1 && (ds.id).indexOf('F_ORG_CREDIT') != -1) {
stone's avatar
stone committed
340 341 342 343 344 345 346
            // if (ds.fields.fin_institution_code) {
            // ds.fields.fin_institution_code.pro.validator = fin_institution_code_validate;
            // }
            // if (ds.fields.trade_type_code) {
            // ds.fields.trade_type_code.pro.validator = trade_type_code_validate;
            // }
            // }
347 348
            // }
            if ((ds.id).indexOf('hls_bp_master') != -1 && (ds.id).indexOf('F_BASIC') != -1) {
25484's avatar
25484 committed
349 350

                var employee_type_id = '${/model/modify_user/record/@employee_type_id}';
25484's avatar
25484 committed
351 352
                old_bp_name = record.get('bp_name');
                new_bp_name = record.get('bp_name');
niminmin's avatar
niminmin committed
353
                if (record.get('id_type') == 'ID_CARD') {
25484's avatar
25484 committed
354 355 356
                    old_id_card = record.get('id_card_no');
                    new_id_card = record.get('id_card_no');
                }
25484's avatar
25484 committed
357

358
                if (record.get('bp_category') == 'VENDER') {
25484's avatar
25484 committed
359 360
                    record.getField('unit_id_n').setReadOnly(true);
                    record.getField('unit_id_n').setRequired(false);
niminmin's avatar
niminmin committed
361 362
                } else {
                    if (employee_type_id == '64') {
25484's avatar
25484 committed
363 364
                        record.getField('unit_id_n').setReadOnly(true);
                        record.getField('unit_id_n').setRequired(false);
niminmin's avatar
niminmin committed
365
                    } else {
stone's avatar
stone committed
366 367
                        record.getField('unit_id_n').setReadOnly(true);
                        record.getField('unit_id_n').setRequired(false);
25484's avatar
25484 committed
368
                    }
369
                }
niminmin's avatar
niminmin committed
370 371 372 373 374 375 376 377 378 379 380
                if(record.get('bp_class')&&record.get('bp_class')=='NP'){
                if (record.get('marital_status') && (record.get('marital_status') == '30' || record.get('marital_status') == '40')) {
                    document.getElementById('${/parameter/@layout_code}_F_SPOUSE_1_component_id').style.display = 'block';
                    record.getField('bp_name_sp').setRequired(true);
                    record.getField('card_type_sp').setRequired(true);
                    record.getField('card_type_sp_n').setRequired(true);
                    record.getField('id_no_sp').setRequired(true);
                } else {
                    document.getElementById('${/parameter/@layout_code}_F_SPOUSE_1_component_id').style.display = 'none';
                }
            }
25484's avatar
25484 committed
381

Spencer Chang's avatar
Spencer Chang committed
382 383 384 385
            }
        };


niminmin's avatar
niminmin committed
386
        window['${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function (ds, line_record) {
Spencer Chang's avatar
Spencer Chang committed
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
            var dsId = ds.id;
            var base_table_temp = 'hls_bp_master_role_ds';
            if (dsId.substring(dsId.length - base_table_temp.length, dsId.length) == base_table_temp) {
                var record = ds.getCurrentRecord();
                if (record) {
                    record.getField('bp_type_n').setReadOnly(true);
                    record.getField('enabled_flag').setReadOnly(true);
                }
            }
            if (ds.fields.parent_id) {
                record.getField('parent_id_n').setReadOnly(true);
            }
        };

        //更新时调用 add by liukang
        //填写银行账号时 允许银行账号相同 但是给一个提示(提示一下而已)
niminmin's avatar
niminmin committed
403
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function (ds, record, name, value, old_value, bp_seq) {
Spencer Chang's avatar
Spencer Chang committed
404 405 406
            var f_bp_create_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var gird_ds_id = 'BP_NP_MODIFY_N_BP_ASSETS01_hls_bp_assets_ds';
            var gird_ds_id2 = 'BP_NP_MODIFY_N_BP_ASSETS04_hls_bp_assets_ds';
25484's avatar
25484 committed
407
            var gird_ds_id3 = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_bank_flow');
niminmin's avatar
niminmin committed
408 409 410 411 412 413 414 415
            if (gird_ds_id == ds.id || gird_ds_id2 == ds.id) {
                if (name == 'relationship_with_bp') {
                    if (value == 'A7501') {
                        record.set('owership', $(f_bp_create_ds_id).getAt(0).get('bp_name'));
                    } else if (value == 'A7502') {
                        record.set('owership', $(f_bp_create_ds_id).getAt(0).get('bp_name_sp'));
                    } else {
                        record.set('owership', '');
Spencer Chang's avatar
Spencer Chang committed
416
                    }
25484's avatar
25484 committed
417
                }
Spencer Chang's avatar
Spencer Chang committed
418
            }
niminmin's avatar
niminmin committed
419 420 421 422 423 424 425 426
            if (gird_ds_id3 == ds.id) {
                if (name == 'relationship_with_bp') {
                    if (value == 'A7501') {
                        record.set('owner_name', $(f_bp_create_ds_id).getAt(0).get('bp_name'));
                    } else if (value == 'A7502') {
                        record.set('owner_name', $(f_bp_create_ds_id).getAt(0).get('bp_name_sp'));
                    } else {
                        record.set('owner_name', '');
25484's avatar
25484 committed
427 428
                    }
                }
Spencer Chang's avatar
Spencer Chang committed
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
            }

            var role_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_role');
            if (role_ds == ds.id) {
                var primary_flag = record.get('primary_flag');
                if (primary_flag == 'Y') {
                    var bm_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
                    var bm_record = $(bm_ds_id).getCurrentRecord();
                    bm_record.set('bp_type', record.get('bp_type'));
                    bm_record.set('bp_type_n', record.get('bp_type_n'));
                    bm_record.set('bp_category', record.get('bp_category'));
                    bm_record.set('bp_category_n', record.get('bp_category_n'));
                }

            }

            var hls_bp_master_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var hls_bank_acc_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_bank_account');
            var hls_bp_master_credit_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_credit');
            var bp_record = $(hls_bp_master_ds_id).getCurrentRecord();
            if ((ds.id).indexOf('hls_bp_master') != -1 && (ds.id).indexOf('F_BASIC') != -1) {
25484's avatar
25484 committed
450

niminmin's avatar
niminmin committed
451
                if (name == 'bp_name') {
25484's avatar
25484 committed
452 453 454
                    new_bp_name = record.get('bp_name');
                }

Spencer Chang's avatar
Spencer Chang committed
455 456 457 458 459 460 461
                if (name == 'agent_type') {
                    if (value == 'AGENT_NO_REBATE' || value == 'AGENT_EE') {
                        record.getField('parent_id_n').setReadOnly(false);
                    } else {
                        record.getField('parent_id_n').setReadOnly(true);
                    }
                }
462
                if (name == 'social_code' && value) {
25484's avatar
25484 committed
463 464
                    if (!CheckSocialCreditCode(value)) {
                        Leaf.showMessage('提示', '统一社会信用代码有误,请重新输入!');
niminmin's avatar
niminmin committed
465 466 467
                        setTimeout(function () {
                            record.set('social_code', '');
                        }, 20);
25484's avatar
25484 committed
468 469 470
                        return false;
                    }
                }
Spencer Chang's avatar
Spencer Chang committed
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487
            }
            if (ds.id == hls_bp_master_ds_id) {
                if ($L.CmpManager.get(hls_bp_master_ds_id)) {
                    if (name == 'province_id') {
                        record.set('city_sp', '');
                        record.set('city_sp_n', '');
                    }
                }
            }
            if (ds.id == hls_bank_acc_ds_id) {
                var bank_account_num = record.get('bank_account_num');
                if (name == 'bank_account_num') {
                    Leaf.request({
                        url: $('bank_account_num_link').getUrl(),
                        para: {
                            bank_account_num: bank_account_num
                        },
niminmin's avatar
niminmin committed
488
                        success: function (res) {
Spencer Chang's avatar
Spencer Chang committed
489 490 491 492 493 494
                            var number = res.result.num;
                            //alert(number);
                            if (number > 0) {
                                Leaf.showMessage('提示', '该银行账号在系统中已存在!');
                            }
                        },
niminmin's avatar
niminmin committed
495 496 497 498
                        failure: function (res) {
                        },
                        error: function () {
                        },
Spencer Chang's avatar
Spencer Chang committed
499 500 501 502 503 504 505 506 507 508 509 510 511
                        scope: this
                    });
                }
            }


            if ((ds.id).indexOf('hls_bp_master') != -1) {
                // //身份证验证
                // if (ds.fields.id_card_no &&  bp_record.get('bp_class') == 'NP' && bp_record.get('id_type') == 'ID_CARD') {

                // ds.fields.id_card_no.pro.validator = id_card_no_validate;
                // ds.fields.id_no_sp.pro.validator = id_card_no_validate;
                // }
512
                if (name == 'cell_phone' && value) {
Spencer Chang's avatar
Spencer Chang committed
513 514
                    if (!checkMobile(value)) {
                        Leaf.showMessage('提示', '基本信息中,请输入正确格式的手机号码!');
niminmin's avatar
niminmin committed
515 516 517 518
                        setTimeout(function () {
                            record.set('cell_phone', '');
                        }, 20);
                        return false;
Spencer Chang's avatar
Spencer Chang committed
519 520
                    }
                }
521
                if (name == 'leader_mobile_number' && value) {
Spencer Chang's avatar
Spencer Chang committed
522 523
                    if (!checkMobile(value)) {
                        Leaf.showMessage('提示', '公司负责人中,请输入正确格式的手机号码!');
niminmin's avatar
niminmin committed
524 525 526 527
                        setTimeout(function () {
                            record.set('leader_mobile_number', '');
                        }, 20);
                        return false;
Spencer Chang's avatar
Spencer Chang committed
528 529 530
                    }
                }

niminmin's avatar
niminmin committed
531 532
                if (name == 'id_card_no' && value) {
                    if (record.get('id_type') == 'ID_CARD') {
25484's avatar
25484 committed
533 534
                        if (!checkCard(value)) {
                            Leaf.showMessage('提示', '基本信息中,请输入正确格式的身份证!');
niminmin's avatar
niminmin committed
535 536 537 538
                            setTimeout(function () {
                                record.set('id_card_no', '');
                            }, 20);
                            return false;
25484's avatar
25484 committed
539
                        } else if (value.length == 18) {
25484's avatar
25484 committed
540
                            new_id_card = record.get('id_card_no');
25484's avatar
25484 committed
541
                            //自动带出籍贯
542
                            //record.set('resident_addres', get_native_place(value));
25484's avatar
25484 committed
543 544 545 546 547 548 549 550 551
                            record.set('date_of_birth', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
                            record.set('age', new Date().getFullYear() - value.substr(6, 4));
                            if (value.substr(16, 1) % 2 == 1) {
                                record.set('gender', 'MALE');
                                record.set('gender_n', '男');
                            } else if (value.substr(16, 1) % 2 == 0) {
                                record.set('gender', 'FEMALE');
                                record.set('gender_n', '女');
                            }
Spencer Chang's avatar
Spencer Chang committed
552

25484's avatar
25484 committed
553
                        }
Spencer Chang's avatar
Spencer Chang committed
554 555 556
                    }
                }

niminmin's avatar
niminmin committed
557
                if (name == 'id_no_sp' && value) {
Spencer Chang's avatar
Spencer Chang committed
558
                    //
stone's avatar
stone committed
559 560 561
                    if (record.get('card_type_sp') == 'ID_CARD') {
                        if (!checkCard(value)) {
                            Leaf.showMessage('提示', '配偶信息中,请输入正确格式的身份证!');
niminmin's avatar
niminmin committed
562 563 564 565
                            setTimeout(function () {
                                record.set('id_no_sp', '');
                            }, 20);
                            return false;
stone's avatar
stone committed
566 567 568 569
                        } else if (value.length == 18) {

                            new_id_card = record.get('id_card_no_leg');

570 571
                            //record.set('resident_addres_sp', get_native_place(value));
                            record.set('date_of_birth_sp', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
572 573
                            // 配偶的信息不能回写
                            /*record.set('age', new Date().getFullYear() - value.substr(6, 4));
stone's avatar
stone committed
574 575 576 577 578 579
                            if (value.substr(16, 1) % 2 == 1) {
                                record.set('gender', 'MALE');
                                record.set('gender_n', '男');
                            } else if (value.substr(16, 1) % 2 == 0) {
                                record.set('gender', 'FEMALE');
                                record.set('gender_n', '女');
580
                            }*/
Spencer Chang's avatar
Spencer Chang committed
581

stone's avatar
stone committed
582
                        }
Spencer Chang's avatar
Spencer Chang committed
583
                    }
stone's avatar
stone committed
584 585 586 587 588 589 590 591

                }
            }

            var test_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC', 'hls_bp_master');
            var test_ds_id1 = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_SPOUSE_1', 'hls_bp_master');
            var test_ds_id2 = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_SPOUSE', 'hls_bp_master');

niminmin's avatar
niminmin committed
592
            if (ds.id == f_bp_create_ds_id) {
593

niminmin's avatar
niminmin committed
594 595 596
                var hd_ds = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC', 'hls_bp_master');
                record = $(hd_ds).getCurrentRecord();
                if(record.get('bp_class')=='NP'){
597 598
                if (name == 'marital_status' && value) {

niminmin's avatar
niminmin committed
599 600 601 602 603 604 605 606 607 608
                    if (value == '30' || value == '40') {
                        document.getElementById('${/parameter/@layout_code}_F_SPOUSE_1_component_id').style.display = 'block';
                        record.getField('bp_name_sp').setRequired(true);
                        record.getField('card_type_sp').setRequired(true);
                        record.getField('card_type_sp_n').setRequired(true);
                        record.getField('id_no_sp').setRequired(true);
                        if (!record.get('card_type_sp')) {
                            record.set('card_type_sp', 'ID_CARD');
                            record.set('card_type_sp_n', '身份证');
                        }
stone's avatar
stone committed
609

niminmin's avatar
niminmin committed
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
                    } else {
                        document.getElementById('${/parameter/@layout_code}_F_SPOUSE_1_component_id').style.display = 'none';
                        record.getField('bp_name_sp').setRequired(false);
                        record.getField('card_type_sp').setRequired(false);
                        record.getField('card_type_sp_n').setRequired(false);
                        record.getField('id_no_sp').setRequired(false);
                        // record.set('bp_name_sp', null);
                        // record.set('card_type_sp', null);
                        // record.set('card_type_sp_n', null);
                        // record.set('id_no_sp', null);
                        // record.set('date_of_birth_sp', null);
                        // record.set('cell_phone_sp', null);
                        // record.set('work_unit_phone_sp', null);
                        // record.set('work_unit_name_sp', null);
                        // record.set('work_unit_address_sp', null);
                    }
Spencer Chang's avatar
Spencer Chang committed
626 627
                }
            }
628 629 630 631 632 633 634
                if (name == 'bp_name'){
                    // alert(record.get('bp_name')+'2222');
                    record.set('invoice_title',record.get('bp_name'));
                }else if (name == 'social_code'){
                    // alert(record.get('social_code')+'2222');
                    record.set('tax_registry_num',record.get('social_code'));
                }
niminmin's avatar
niminmin committed
635
            }
Spencer Chang's avatar
Spencer Chang committed
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657


        };

        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 = $('hls214N_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                } else {
                    url = $('hls214N_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
                });

niminmin's avatar
niminmin committed
658
                win.on('close', function () {
Spencer Chang's avatar
Spencer Chang committed
659 660 661 662 663 664 665 666
                    record.ds.query();
                });
            } else {
                Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');

            }
        }

667 668 669 670 671 672 673 674 675
        function upload_signer_file(id, name, query_only) {
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            if (record.get('hls_bp_signer_id')) {
                var url;
                if (query_only == 'Y') {
                    url = $('hls214N_cdd_downloadFile_id').getUrl() + '?table_name=HLS_BP_MASTER_SIGNER&header_id=' + record.get('hls_bp_signer_id');
                } else {
                    url = $('hls214N_cdd_uploadFile_id').getUrl() + '?table_name=HLS_BP_MASTER_SIGNER&header_id=' + record.get('hls_bp_signer_id');
                }
676

677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
                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}', '请先保存!');

            }
        }
Spencer Chang's avatar
Spencer Chang committed
693
        //超链接渲染
niminmin's avatar
niminmin committed
694
        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
Spencer Chang's avatar
Spencer Chang committed
695 696 697 698 699 700 701 702 703 704 705 706 707 708
            //
            window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
            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 == 'attach_file_name') {
                if (value != null) {
                    var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                    var str = value.split(';;');
                    var url = '';
niminmin's avatar
niminmin committed
709
                    for (var i = 0; i < str.length; i++) {
Spencer Chang's avatar
Spencer Chang committed
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
                        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;

                }
            } else if (name == 'description') {
                if (record.get('important_flag') == 'Y') {
                    return '<font color="RED">' + value + '</font>';
                }
                return value;
731 732 733 734
            } //签约人授权书附件
            else if(name == 'signer_attachment'){
                var signer_link_function = 'upload_signer_file';
                return '<a href="javascript:window[\'' + signer_link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
Spencer Chang's avatar
Spencer Chang committed
735 736 737 738 739
            }
        };


        //经销商准入
niminmin's avatar
niminmin committed
740
        window['${/parameter/@layout_code}_user_button4_layout_dynamic_click'] = function () {
Spencer Chang's avatar
Spencer Chang committed
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760

            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var record = $(ds_id).getCurrentRecord();
            var agent_instance_status = record.get('agent_instance_status');
            if (agent_instance_status == 'APPROVED') {
                Leaf.showMessage('提示', '该商业伙伴已进行过经销商准入流程,不允许再次操作!');
                return;
            } else if (agent_instance_status == 'APPROVING') {
                Leaf.showMessage('提示', '该商业伙伴已经在准入流程中,不允许再次操作!');
                return;
            } else if (agent_instance_status == 'REJECT') {
                Leaf.showMessage('提示', '该商业伙伴准入流程已被拒绝,不允许再次操作!');
                return;
            }
            window['${/parameter/@bp_seq}${/parameter/@layout_code}_lock_layout_dynamic_window']();
            Leaf.request({
                url: $('hls214_bp_master_save_link_id').getUrl(),
                para: {
                    'bp_id': record.get('bp_id')
                },
niminmin's avatar
niminmin committed
761
                success: function (res) {
Spencer Chang's avatar
Spencer Chang committed
762 763 764 765 766 767 768 769 770 771 772 773 774 775
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    var param = {};
                    param['function_code'] = 'HLS303';
                    param['function_usage'] = 'MODIFY';
                    param['maintain_type'] = 'MODIFY';
                    param['url_title'] = '经销商准入';
                    param['bp_id'] = record.get('bp_id');
                    param['bp_class'] = record.get('bp_class');
                    param['bp_type'] = record.get('bp_type');
                    param['agent_instance_flag'] = 'Y';

                    hls_doc_get_layout_code('${/parameter/@layout_code}_get_layout_code_link_id', param, 'bp_agent_modify_link', ds_id, '${/parameter/@layout_code}');

                },
niminmin's avatar
niminmin committed
776
                failure: function (res) {
Spencer Chang's avatar
Spencer Chang committed
777 778
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
niminmin's avatar
niminmin committed
779
                error: function () {
Spencer Chang's avatar
Spencer Chang committed
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823
                    window['${/parameter/@bp_seq}${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                },
                scope: this
            });


        };
        //add by  zhuxianfei 20180103

        // function id_card_no_validate(record, name, value) {
        // if(name == 'id_card_no' && record.get('id_type') != 'ID_CARD'){
        // return true;
        // }else if(name == 'id_no_sp' && record.get('card_type_sp') != 'ID_CARD'){
        // return true;
        // }
        // if (!checkCard(value)) {
        // Leaf.showMessage('提示', '请输入正确格式的身份证!');
        // return '请输入正确格式的身份证';
        // }
        // if (value.length == 18) {
        // record.set('date_of_birth', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
        // record.set('age', new Date().getFullYear() - value.substr(6, 4));
        // if (value.substr(16, 1) % 2 == 1) {
        // record.set('gender', 'MALE');
        // record.set('gender_n', '男');
        // } else if (value.substr(16, 1) % 2 == 0) {
        // record.set('gender', 'FEMALE');
        // record.set('gender_n', '女');
        // }

        // }
        // return true;
        // }

        /*Leaf.onReady(init);

        function init() {
            var bp_class = '${/parameter/@bp_class}';
            if (bp_class != 'ORG') {
                var user_button4 = document.getElementById('${/parameter/@layout_code}' + '_user_button4');
                user_button4.style.display = 'none';
            }
        }*/
        ]]></script>
niminmin's avatar
niminmin committed
824
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
Spencer Chang's avatar
Spencer Chang committed
825 826
    </a:view>
</a:screen>