hls_bp_master_create.lview 69.6 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129
    $Date: 2014-8-29 下午03:53:38
    $Revision: 1.0
    $Purpose: 商业伙伴创建 明细页面
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
          trace="true">
25484's avatar
25484 committed
10
    <a:init-procedure>
25484's avatar
25484 committed
11
        <a:model-query fetchAll="true" model="hls.HLS213N.hls_bp_master_unit" 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"/>
gzj34291's avatar
gzj34291 committed
13
        <a:model-query model="cont.CON620.get_sys_role" rootPath="role_info"/>
25484's avatar
25484 committed
14
    </a:init-procedure>
Spencer Chang's avatar
Spencer Chang committed
15
    <a:view>
16 17
        <a:link id="get_special_fields_link_id" model="hls.HLS213N.social_code_exist" modelaction="update"/>

Spencer Chang's avatar
Spencer Chang committed
18 19 20
        <a:link id="gh_nc_post_addsupplierinfo_link" model="hls.HLS213.hls_bp_master_nc_post" modelaction="update"/>
        <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"/>
25484's avatar
25484 committed
21 22
        <script src="${/request/@context_path}/modules/prj/PRJ500N/javascripts/input_validator.js"
                type="text/javascript"/>
Spencer Chang's avatar
Spencer Chang committed
23
        <a:link id="gh_nc_post_addcustomerinfo_link" model="hls.HLS213.hls_bp_master_nc_post" modelaction="execute"/>
24 25
        <a:link id="${/parameter/@layout_code}_signer_create_link_id" model="hls.HLS213.hls_bp_master_signer_create_check"
                modelaction="update"/>
lizhe's avatar
lizhe committed
26
        <a:link id="rsc303_fin_statement_link" url="${/request/@context_path}/modules/rsc/RSC303/rsc_fin_statement_prj_all_query.lview"/>
Spencer Chang's avatar
Spencer Chang committed
27
        <script type="text/javascript"><![CDATA[
28
        Leaf.onReady(function () {
25484's avatar
25484 committed
29 30
            var unit_id = '${/model/user_agent_description/record/@unit_id}';
            var unit_id_n = '${/model/user_agent_description/record/@bp_name}';
25484's avatar
25484 committed
31
            var employee_type_id = '${/model/modify_user/record/@employee_type_id}';
25484's avatar
25484 committed
32

Spencer Chang's avatar
Spencer Chang committed
33
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_role');
34

Spencer Chang's avatar
Spencer Chang committed
35
            var bp_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
36

37 38
            var address_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_address');

Spencer Chang's avatar
Spencer Chang committed
39
            var bp_record = $(bp_ds_id).getCurrentRecord();
gzj34291's avatar
gzj34291 committed
40 41
            var bank_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_bank_account');
            var bank_record = $(bank_ds_id).getCurrentRecord();
42

25484's avatar
25484 committed
43 44 45 46
            bp_record.set('bp_category', '${/parameter/@bp_category}');
            bp_record.set('owner_user_id', '${/session/@user_id}');
            bp_record.set('unit_id', unit_id);
            bp_record.set('unit_id_n', unit_id_n);
gzj34291's avatar
gzj34291 committed
47 48 49 50 51 52 53 54
            if(bp_record.get('bp_type')!='THIRD_PARTY'){
                if (employee_type_id == '64') {
                    bp_record.getField('unit_id_n').setReadOnly(true);
                    bp_record.getField('unit_id_n').setRequired(false);
                } else {
                    bp_record.getField('unit_id_n').setReadOnly(false);
                    bp_record.getField('unit_id_n').setRequired(true);
                }
55
            }
Spencer Chang's avatar
Spencer Chang committed
56 57
            if ('${/parameter/@bp_type}' == 'AGENT') {
                bp_record.getField('agent_type_n').setReadOnly(false);
58
                // bp_record.getField('agent_type_n').setRequired(true);
Spencer Chang's avatar
Spencer Chang committed
59 60
            } else {
                bp_record.getField('agent_type_n').setReadOnly(true);
61
                // bp_record.getField('agent_type_n').setRequired(false);
Spencer Chang's avatar
Spencer Chang committed
62
            }
lizhe's avatar
lizhe committed
63 64 65 66
            //自然人不展示财报按钮
            if('${/parameter/@bp_class}' == 'NP' && document.getElementById('${/parameter/@layout_code}_user_button2')){
                document.getElementById('${/parameter/@layout_code}_user_button2').style.display = 'none';
            }
Spencer Chang's avatar
Spencer Chang committed
67 68
            if (ds_id && '${/parameter/@default_value_dsid}') {
                var head_record = $('${/parameter/@default_value_dsid}').getCurrentRecord();
69

Spencer Chang's avatar
Spencer Chang committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
                var bp_master_role_ds = $(ds_id);
                var record = new Leaf.Record({
                    'primary_flag': 'Y',
                    'bp_category': head_record.get('bp_category'),
                    'bp_category_n': head_record.get('bp_category_n'),
                    'bp_type': head_record.get('bp_type'),
                    'bp_type_n': head_record.get('bp_type_n'),
                    'bp_class': head_record.get('bp_class'),
                    'bp_class_n': head_record.get('bp_class_n'),
                    'company_nature': head_record.get('company_nature'),
                    'conpany_personal': head_record.get('conpany_personal'),
                    'actual_online': head_record.get('actual_online'),
                    'brand_unbrand': head_record.get('brand_unbrand'),
                    'enabled_flag': 'Y'
                });
                bp_master_role_ds.add(record);
86 87
                var address_ds_id_ds = $(address_ds_id);
                var address_bp_record = $('${/parameter/@default_value_dsid}').getCurrentRecord();
gzj34291's avatar
gzj34291 committed
88
                if (address_bp_record.get('bp_class') == 'NP'&&record.get('bp_type') != 'THIRD_PARTY'){
89 90 91 92
                    //POSTAL_ADDRESS  通讯地址
                    var record1 = new Leaf.Record({
                        'address_type': 'HOUSEHOLD_ADDRESS',
                        'address_type_n': '户籍地址',
93 94
                        'country_id': 32,
                        'country_id_n': '中华人民共和国'
95 96 97 98
                    });
                    var record2 = new Leaf.Record({
                        'address_type': 'POSTAL_ADDRESS',
                        'address_type_n': '通讯地址',
99 100
                        'country_id': 32,
                        'country_id_n': '中华人民共和国'
101 102 103 104 105 106 107 108 109 110 111 112
                    });
                    address_ds_id_ds.add(record1);
                    address_ds_id_ds.add(record2);

                    var address_record = address_ds_id_ds.getAt(0);
                    address_record.getField('address_type_n').setReadOnly(true);
                    address_record.getField('country_id_n').setReadOnly(true);

                    var address_record1 = address_ds_id_ds.getAt(1);
                    address_record1.getField('address_type_n').setReadOnly(true);
                    address_record1.getField('country_id_n').setReadOnly(true);

gzj34291's avatar
gzj34291 committed
113
                }else if (address_bp_record.get('bp_class') == 'ORG'&&record.get('bp_type') != 'THIRD_PARTY'){
114 115
                    //法人
                    //POSTAL_ADDRESS  通讯地址
gzj34291's avatar
gzj34291 committed
116 117 118 119 120 121 122 123 124 125 126 127 128
                    if(bp_record.get('bp_type')!='THIRD_PARTY') {
                        var record2 = new Leaf.Record({
                            'address_type': 'POSTAL_ADDRESS',
                            'address_type_n': '通讯地址',
                            'country_id': 32,
                            'country_id_n': '中华人民共和国'
                        });
                        address_ds_id_ds.add(record2);

                        var address_record = address_ds_id_ds.getAt(0);
                        address_record.getField('address_type_n').setReadOnly(true);
                        address_record.getField('country_id_n').setReadOnly(true);
                    }
lizhe's avatar
lizhe committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
                    //征信 企业默认添加 法定代表人 企业关联信息记录 add start
                    var company_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_company_info');
                    var company_ds_id_ds = $(company_ds_id);
                    if(bp_record.get('bp_type')!='VENDER') {
                        var init_company_record = new Leaf.Record({
                            'other_relationships': '1',
                            'other_relationships_n': '主要组成人员',
                            'identity_type': '11',
                            'identity_type_n': '法定代表人',
                            'ref_v01': '1',
                            'ref_v01_n': '自然人'
                        });
                        company_ds_id_ds.add(init_company_record);

                        var company_record = company_ds_id_ds.getAt(0);
                        company_record.getField('other_relationships_n').setReadOnly(true);
                        company_record.getField('identity_type_n').setReadOnly(true);
                        company_record.getField('ref_v01_n').setReadOnly(true);
                    }
                    //征信 企业默认添加 法定代表人 企业关联信息记录 add end
149
                }
Spencer Chang's avatar
Spencer Chang committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163
                var current_record = bp_master_role_ds.getAt(0);
                current_record.getField('bp_type_n').setReadOnly(true);
                current_record.getField('enabled_flag').setReadOnly(true);
                if (head_record.get('bp_category') == 'MANUFACTURER') {
                    bp_record.set('company_nature_n', '');
                    bp_record.getField('company_nature_n').setReadOnly(true);
                    bp_record.set('conpany_personal_n', '');
                    bp_record.getField('conpany_personal_n').setReadOnly(true);
                    bp_record.set('actual_online_n', '');
                    bp_record.getField('actual_online_n').setReadOnly(true);
                    bp_record.set('brand_unbrand_n', '');
                    bp_record.getField('brand_unbrand_n').setReadOnly(true);
                    current_record.getField('bp_type_n').setReadOnly(true);
                    current_record.getField('enabled_flag').setReadOnly(true);
25484's avatar
25484 committed
164 165 166
                } else if (head_record.get('bp_category') == 'VENDER') {
                    bp_record.getField('unit_id_n').setReadOnly(true);
                    bp_record.getField('unit_id_n').setRequired(false);
167
					bp_record.getField('unit_id').setRequired(false);
25484's avatar
25484 committed
168
                } else {
Spencer Chang's avatar
Spencer Chang committed
169 170 171 172 173 174
                    current_record.getField('bp_type_n').setReadOnly(true);
                    current_record.getField('enabled_flag').setReadOnly(true);
                }
            }
        });

175 176 177 178 179 180 181 182 183
        //删除角色按钮
        window['${/parameter/@layout_code}_G_ROLE_USER_BUTTON1_layout_dynamic_tab_click'] = function () {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_role');
            var records = $(ds_id).getSelected();
            if (!records.length) {
                Leaf.showMessage('${l:PROMPT}', '请至少选择一条记录');
                return false;
            }
            //else{
25484's avatar
25484 committed
184
            // Leaf.showMessage('${l:PROMPT}', '是否删除角色?');
185 186 187 188
            //}
            //alert(records.length);
            for (var i = 0; i < records.length; i++) {
                var primary_flag = records[i].get('primary_flag');
25484's avatar
25484 committed
189
                if (primary_flag == 'Y') {
190 191
                    Leaf.showMessage('${l:PROMPT}', '主角色无法被删除!');
                    continue;
25484's avatar
25484 committed
192
                } else {
193 194 195 196
                    $(ds_id).remove(records[i]);
                }
            }
        };
197 198 199 200 201
		
		//法人供应商经办人身份证号非必填  18083 2022/12/1
		
	  window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_add'] = function(ds, record, config_records, bp_seq) {
	   	var bp_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC', 'hls_bp_master');
18083's avatar
18083 committed
202 203
            var sign_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC_SIGNER', 'hls_bp_master_signer');
            var bp_record=$(bp_ds_id).getCurrentRecord();
204 205 206
			if(bp_record.get('bp_class') == 'ORG' && bp_record.get("bp_type") == 'VENDER'){
				if(sign_ds_id == ds.id &&sign_ds_id){
			     var records = $(sign_ds_id).getAll();
18083's avatar
18083 committed
207
                    for (i = 0; i < records.length; i++) {
208 209 210 211 212 213
					 records[i].getField('id_card').setRequired(false);
					}
			     } 
			 }
		}
		
18083's avatar
18083 committed
214

Spencer Chang's avatar
Spencer Chang committed
215
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function (ds, record, config_records, bp_seq) {
gzj34291's avatar
gzj34291 committed
216 217 218 219 220 221 222 223 224 225 226
            //第三方创建页面隐藏角色新增按钮
            debugger;
            if( record.get('bp_type')== 'THIRD_PARTY'){
                if(document.getElementById('${/parameter/@layout_code}_G_ROLE_ADD_layout_dynamic_button_id')){
                    document.getElementById('${/parameter/@layout_code}_G_ROLE_ADD_layout_dynamic_button_id').style.display = "none";
                }
                if(document.getElementById('${/parameter/@layout_code}_G_ROLE_USER_BUTTON1_layout_dynamic_button_id')){
                    document.getElementById('${/parameter/@layout_code}_G_ROLE_USER_BUTTON1_layout_dynamic_button_id').style.display = "none";
                }
            }

227

Spencer Chang's avatar
Spencer Chang committed
228
            if ((ds.id).indexOf('hls_bp_master') != -1) {
229

lizhe's avatar
lizhe committed
230
                //征信add start
231 232 233
                if(record.get('bp_class') && record.get('bp_class') == 'ORG'){
                    if(record.get('bp_type') == 'TENANT'){
                        record.getField('etp_sts').setRequired(true);
lizhe's avatar
lizhe committed
234
                        //record.getField('credit_code').setRequired(true);
235 236 237 238 239 240 241 242 243 244
                        record.getField('etp_sts_n').setRequired(true);
                        record.getField('org_type').setRequired(true);
                        record.getField('org_type_n').setRequired(true);
                        record.getField('org_type_sub').setRequired(true);
                        record.getField('org_type_sub_n').setRequired(true);
                        record.getField('enterprise_scale').setRequired(true);
                        record.getField('enterprise_scale_n').setRequired(true);
                        record.getField('due_date').setRequired(true);
                        record.getField('org_unit_property').setRequired(true);
                        record.getField('org_unit_property_n').setRequired(true);
lizhe's avatar
lizhe committed
245 246 247 248 249 250 251 252 253 254
                        //record.getField('industry').setRequired(true);
                        //record.getField('industry_n').setRequired(true);
                        record.getField('industry_a').setRequired(true);
                        record.getField('industry_a_n').setRequired(true);
                        record.getField('industry_b').setRequired(true);
                        record.getField('industry_b_n').setRequired(true);
                        record.getField('industry_c').setRequired(true);
                        record.getField('industry_c_n').setRequired(true);
                        record.getField('industry_d').setRequired(true);
                        record.getField('industry_d_n').setRequired(true);
255
                        record.getField('nationalities').setRequired(true);
lizhe's avatar
lizhe committed
256
                        record.getField('nationalities_n').setRequired(true);
257 258
                    }
                }
lizhe's avatar
lizhe committed
259
                //征信add end
260

25484's avatar
25484 committed
261
                // record.getField('cell_phone').setRequired(true);
262
                //record.getField('cell_phone').setRequired(true);
18083's avatar
18083 committed
263 264 265 266
                 //法人供应商非必填 18083 2022/11/25
                if(record.get('bp_class') == 'ORG' && record.get("bp_type") == 'VENDER'){
                record.getField('id_card_no_leg').setRequired(false);
                }
Spencer Chang's avatar
Spencer Chang committed
267 268 269
                //身份证验证
                if (ds.fields.id_card_no) {

270
                    //ds.fields.id_card_no.pro.validator = id_card_no_validate;
Spencer Chang's avatar
Spencer Chang committed
271 272 273 274 275
                }

                if (ds.fields.parent_id) {
                    record.getField('parent_id_n').setReadOnly(true);
                }
liyuan.chen's avatar
liyuan.chen committed
276 277
                if (record.get('bp_class') && record.get('bp_class') == 'ORG') {
                    if (record.get('invoice_method') == 'BILLING') {
278 279 280 281 282 283 284 285
                            record.getField('taxpayer_type').setRequired(true);
                            record.getField('taxpayer_type_n').setRequired(true);
                            record.getField('tax_registry_num').setRequired(true);
                            record.getField('invoice_title').setRequired(true);
                            record.getField('invoice_bp_address').setRequired(true);
                            record.getField('invoice_bp_phone_num').setRequired(true);
                            record.getField('invoice_bp_bank').setRequired(true);
                            record.getField('invoice_bp_bank_account').setRequired(true);
liyuan.chen's avatar
liyuan.chen committed
286 287
                    }
                    if (record.get('invoice_method') == 'NO_BILLING') {
288 289
                        record.getField('taxpayer_type').setRequired(true);
                        record.getField('taxpayer_type_n').setRequired(true);
liyuan.chen's avatar
liyuan.chen committed
290 291 292 293 294 295
                        record.getField('tax_registry_num').setRequired(false);
                        record.getField('invoice_title').setRequired(false);
                        record.getField('invoice_bp_address').setRequired(false);
                        record.getField('invoice_bp_phone_num').setRequired(false);
                        record.getField('invoice_bp_bank').setRequired(false);
                        record.getField('invoice_bp_bank_account').setRequired(false);
296
                    }
297 298


299
                }
liyuan.chen's avatar
liyuan.chen committed
300
                if (record.get('bp_class') && record.get('bp_class') == 'NP') {
niminmin's avatar
niminmin committed
301 302
                    record.set('taxpayer_type', 'SMALL_SCALE_TAXPAYER');
                    record.set('taxpayer_type_n', '小规模纳税人');
liyuan.chen's avatar
liyuan.chen committed
303 304 305 306 307 308 309 310 311 312 313
                    // 自然人才有配偶
                    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';
                    }

niminmin's avatar
niminmin committed
314
                }
liyuan.chen's avatar
liyuan.chen committed
315
                record.set('invoice_title', record.get('bp_name'));
gzj34291's avatar
gzj34291 committed
316
                if(record.get('taxpayer_type') == 'GENERAL_TAXPAYER'&&record.get('bp_type') != 'THIRD_PARTY'){
317 318 319
                    //设置开票类型为纸质只读
                    record.set('invoice_type','PAPER');
                    record.set('invoice_type_n','纸质发票');
320
					//取消开票类型为纸质只读  18083
321 322
                    //record.getField('invoice_type').setReadOnly(true);
                    //record.getField('invoice_type_n').setReadOnly(true);
323 324 325
                    record.getField('invoice_type').setRequired(false);
                    record.getField('invoice_type_n').setRequired(false);
                    record.getField('reception_maile').setRequired(false);
gzj34291's avatar
gzj34291 committed
326
                }else if(record.get('taxpayer_type') == 'SMALL_SCALE_TAXPAYER'&&record.get('bp_type') != 'THIRD_PARTY'){
327 328 329 330 331 332 333
                    record.set('invoice_type','ECT');
                    record.set('invoice_type_n','电子发票');
                    record.getField('invoice_type').setRequired(true);
                    record.getField('invoice_type_n').setRequired(true);
                    record.getField('invoice_type').setReadOnly(false);
                    record.getField('invoice_type_n').setReadOnly(false);
                }
niminmin's avatar
niminmin committed
334

Spencer Chang's avatar
Spencer Chang committed
335
            }
stone's avatar
stone committed
336

Spencer Chang's avatar
Spencer Chang committed
337 338 339 340 341
        };
        var card_identity_flag;
        var sp_identity_flag;

        function id_card_no_validate(record, name, value) {
25484's avatar
25484 committed
342 343
            var id_type = record.get('id_type');
            var card_type_sp = record.get('card_type_sp');
Spencer Chang's avatar
Spencer Chang committed
344 345 346 347 348
            if (name == 'id_card_no') {
                var bp_name = record.get('bp_name');
            } else if (name == 'id_no_sp') {
                bp_name = record.get('bp_name_sp');
            }
25484's avatar
25484 committed
349 350 351 352 353 354 355 356 357 358 359 360
            if (id_type == 'ID_CARD') {
                var id_card_no = record.get('id_card_no');
                if (!checkCard(id_card_no)) {
                    return '请输入正确格式的身份证';
                } else {
                    card_identity_flag = 'N';
                    sp_identity_flag = 'N';

                }
            } else {
                card_identity_flag = 'N';
                sp_identity_flag = 'N';
Spencer Chang's avatar
Spencer Chang committed
361
            }
25484's avatar
25484 committed
362 363 364 365 366 367 368
            if (card_type_sp == 'ID_CARD') {
                var id_no_sp = record.get('id_no_sp');
                if (!checkCard(id_no_sp)) {
                    return '请输入正确格式的身份证';
                } else {
                    card_identity_flag = 'N';
                    sp_identity_flag = 'N'
Spencer Chang's avatar
Spencer Chang committed
369

25484's avatar
25484 committed
370 371 372 373 374
                }
            } else {
                card_identity_flag = 'N';
                sp_identity_flag = 'N';
            }
Spencer Chang's avatar
Spencer Chang committed
375 376 377 378 379 380 381 382 383 384 385 386 387 388
            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;
        }
389

390
        function CheckSocialCreditCode(Code) {
25484's avatar
25484 committed
391

392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
            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
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446

        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;
        // }

447 448 449 450 451 452 453 454 455 456 457
        //        //新增和加载时调用form
        //        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_form_add_and_load'] = function(ds, record, config_records, bp_seq) {
        //            if ((ds.id).indexOf('hls_bp_master_credit') != -1 && (ds.id).indexOf('F_ORG_CREDIT') != -1) {
        //                // 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;
        //                // }
        //            }
        //        };
Spencer Chang's avatar
Spencer Chang committed
458

niminmin's avatar
niminmin committed
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
        /*保存前调用,生成项目编号*/
        // window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function (ds, record) {
        //
        //     window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
        //     var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
        //     var head_record = $(ds_id).getCurrentRecord();
        //     var check_flag = false;
        //     if (head_record.get('bp_code')) {
        //         return true;
        //     }
        //     Leaf.request({
        //         url: $('get_special_fields_link_id').getUrl(),
        //         para: {
        //             bp_id: head_record.get('bp_id')
        //         },
        //         success: function (res) {
        //             var document_number = res.result.document_number;
        //             head_record.set('bp_code', document_number);
        //             if (head_record.get('marital_status') && (head_record.get('marital_status') !== '30' && head_record.get('marital_status') !== '40')) {
        //                 head_record.set('bp_name_sp', null);
        //                 head_record.set('card_type_sp', null);
        //                 head_record.set('card_type_sp_n', null);
        //                 head_record.set('id_no_sp', null);
        //                 head_record.set('date_of_birth_sp', null);
        //                 head_record.set('cell_phone_sp', null);
        //                 head_record.set('work_unit_phone_sp', null);
        //                 head_record.set('work_unit_name_sp', null);
        //                 head_record.set('work_unit_address_sp', null);
        //             }
        //             check_flag = true;
        //             window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        //
        //         },
        //         error: function () {
        //             window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        //         },
        //         failure: function () {
        //             window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        //         },
        //         sync: true,
        //         scope: this
        //     });
        //     return check_flag;
        //
        // };
        window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function (ds, record) {
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var head_record = $(ds_id).getCurrentRecord();
gzj34291's avatar
gzj34291 committed
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
            var bank_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_bank_account');
            var bank_record = $(bank_ds_id).getAll();
            var file_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
            var file_record = $(file_ds_id).getAll();
            if(bank_record.length>0){
                var flag = true;
                for(var i=0;i<bank_record.length;i++){
                    var full_name=bank_record[i].get('bank_full_name');
                    var branch_name=bank_record[i].get('bank_branch_name');
                    if (!Leaf.isEmpty(bank_record[i].get('bank_full_name'))&&
                        !Leaf.isEmpty(bank_record[i].get('bank_branch_name'))){
                        if(branch_name.indexOf(full_name)==-1){
                            flag = false;
                        }
                    }
                    if(flag == false){
                        Leaf.showErrorMessage('${l:PROMPT}', '请填写支行全称(例如:上海浦东发展银行外高桥保税区支行)');
                        return false;
                    }
                }
            }
529 530 531 532 533 534 535
			 //若选择开票类型为“纸质发票”,则系统校验无法选择“是否全电发票”为“是”  18083 2022/11/30
            if (head_record.get('invoice_type')=='PAPER'){
             if(head_record.get('full_elec_invoice_flag')=='Y'){
              Leaf.showErrorMessage('${l:PROMPT}', '开票类型为纸质发票,不能选择【是否全电发票】为是');
                                 return false;
             }
            }
gzj34291's avatar
gzj34291 committed
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
            var role_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_role');
            var role_records = $(role_ds_id).getAll();
            var role_flag=true;
            if(role_records.length>1){
                for (var i = 0;i < role_records.length;i++) {
                    if(role_records[i].get('bp_type')=='THIRD_PARTY'){
                        role_flag=false;
                    }
                }
            }
            if(role_flag==false){
                Leaf.showErrorMessage('${l:PROMPT}', '第三方不能含有其他角色类型');
                return false;
            }

             if(head_record.get('bp_type')=='THIRD_PARTY'){
                var flag = true;
                if (bank_record.length <=0){
                    Leaf.showErrorMessage('${l:PROMPT}', '第三方必填[银行帐户信息],请在银行帐户信息新增!');
                    return false;
                } else{
                    for(var i=0;i<bank_record.length;i++){
                        if (Leaf.isEmpty(bank_record[i].get('bank_account_name'))||
                            Leaf.isEmpty(bank_record[i].get('bank_account_num'))||
                            Leaf.isEmpty(bank_record[i].get('bank_full_name'))){
                            flag = false;
                            break;
                        }
                        else{
                            flag = true;
                        }
                   }
                if(flag == false){
                    Leaf.showErrorMessage('${l:PROMPT}', '请将银行账户信息填写完整');
                    return false;
                }


            }
             }
576 577 578

            //验证是否有户籍地址,或者通讯地址
            var address_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_address');
lizhe's avatar
lizhe committed
579
            var records_addr = $(address_ds_id).getAll();
gzj34291's avatar
gzj34291 committed
580
            if (head_record.get('bp_class') =='NP'&&head_record.get('bp_type')!='THIRD_PARTY'){
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
                //判断户籍地址
                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;
                    }
                }
gzj34291's avatar
gzj34291 committed
610
            }else if (head_record.get('bp_class') == 'ORG'&&head_record.get('bp_type')!='THIRD_PARTY'){
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629
                //判断通讯地址
                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;
                    }
                }
lizhe's avatar
lizhe committed
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
                //征信校验 企业关联方至少一条法定代表人数据 start
                var company_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_company_info');
                var records_company = $(company_ds_id).getAll();
                var flag_company = 0;

                for(var i=0;i<records_company.length;i++){
                    if (records_company[i].get('identity_type') == '11'){
                        flag_company ++;
                    }
                }
                if (flag_company == 0 &&head_record.get('bp_type')!='VENDER'){
                    Leaf.showErrorMessage('${l:PROMPT}', '法人必填[法定代表人],请在企业关联信息新增!');
                    return  false;
                }
                if (flag_company > 1){
                    Leaf.showErrorMessage('${l:PROMPT}', '法人只能填写一条[法定代表人],请在企业关联信息修改!');
                    return  false;
                }
                //征信校验 企业关联方至少一条法定代表人数据 end
649 650 651
            }

            //=================
niminmin's avatar
niminmin committed
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
            var check_flag = false;
            if (head_record.get('marital_status') && (head_record.get('marital_status') !== '30' && head_record.get('marital_status') !== '40')) {
                head_record.set('bp_name_sp', null);
                head_record.set('card_type_sp', null);
                head_record.set('card_type_sp_n', null);
                head_record.set('id_no_sp', null);
                head_record.set('date_of_birth_sp', null);
                head_record.set('cell_phone_sp', null);
                head_record.set('work_unit_phone_sp', null);
                head_record.set('work_unit_name_sp', null);
                head_record.set('work_unit_address_sp', null);
            }
            check_flag = true;
            return check_flag;
        };


669
        //保存submitsuccess调用
niminmin's avatar
niminmin committed
670
        window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function (ds, record, res, bp_seq) {
Darming's avatar
Darming committed
671 672
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var head_record = $(ds_id).getCurrentRecord();
niminmin's avatar
niminmin committed
673
            if (!head_record.get('bp_code')) {
Darming's avatar
Darming committed
674 675 676 677
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                Leaf.request({
                    url: $('get_special_fields_link_id').getUrl(),
                    para: {
niminmin's avatar
niminmin committed
678
                        bp_id: head_record.get('bp_id')
Darming's avatar
Darming committed
679 680 681
                    },
                    success: function (res) {
                        var document_number = res.result.document_number;
niminmin's avatar
niminmin committed
682
                        head_record.set('bp_code', document_number);
Darming's avatar
Darming committed
683 684 685 686 687 688 689 690 691 692 693 694 695
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();

                    },
                    error: function () {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function () {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    sync: true,
                    scope: this
                });
            }
liyuan.chen's avatar
liyuan.chen committed
696 697
            $(ds_id).setQueryParameter('bp_id', head_record.get('bp_id'));
            $(ds_id).query();
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
            //add by zc
            var signer_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_signer');
            if(head_record.get('bp_id')){
                Leaf.request({
                    url: $('${/parameter/@layout_code}_signer_create_link_id').getUrl(),
                    para: {
                        bp_id: head_record.get('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
                });
            }
Darming's avatar
Darming committed
719 720
            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        };
721

25484's avatar
25484 committed
722
        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
723 724 725 726
            var f_bp_create_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var gird_ds_id = 'BP_NP_CREATE_BP_ASSETS01_hls_bp_assets_ds';
            var gird_ds_id2 = 'BP_NP_CREATE_BP_ASSETS04_hls_bp_assets_ds';
            var gird_ds_id3 = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_bank_flow');
lizhe's avatar
lizhe committed
727
            //征信add start 中征码校验
728 729
            if (record.get('bp_class') == 'ORG') {

lizhe's avatar
lizhe committed
730 731


732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751
                if(record.get('bp_type') == 'TENANT'){
                    var credit_code = record.get('credit_code');
                    if (!Leaf.isEmpty(credit_code)) {
                        if (credit_code.length == '16'){
                            if(!(/^[A-Z][A-z0-9]*$/).test(credit_code)){
                                Leaf.showMessage('提示', '中征码首字母需要大写');
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                return false;

                            }else {
                                return true;
                            }
                        }else {
                            Leaf.showMessage('提示', '请输入16位中征码');
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                }
            }
lizhe's avatar
lizhe committed
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 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 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858

            if (name == 'org_type') {
                record.set('org_type_sub', '');
                record.set('org_type_sub_n', '');
                //企业规模,当组织机构类型为机关、事业单位时,为空且只读,其他情况必填
                if(value =='3'||value =='5'){
                    record.set('enterprise_scale', '');
                    record.set('enterprise_scale_n', '');
                    record.getField('enterprise_scale_n').setReadOnly(true);
                    record.getField('enterprise_scale').setRequired(false);
                    record.getField('enterprise_scale_n').setRequired(false);
                }else{
                    record.getField('enterprise_scale_n').setReadOnly(false);
                    record.getField('enterprise_scale').setRequired(true);
                    record.getField('enterprise_scale_n').setRequired(true);
                }
            }
            //法人承租人添加 法人姓名和法人身份证号 时,更新企业关联信息的法人数据
            var company_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_company_info');
            if((name == 'legal_person'|| name == 'id_card_no_leg')){
                var records_company = $(company_ds_id).getAll();
                for(var i=0;i<records_company.length;i++){
                    if (records_company[i].get('identity_type') == '11'){//法定代表人
                        if(name == 'legal_person'){
                            records_company[i].set('person_name',value);
                        } else if (name == 'id_card_no_leg'){
                            records_company[i].set('associate_id_no',value);
                            records_company[i].set('ref_v01','1');
                            records_company[i].set('ref_v01_n','自然人');
                            records_company[i].set('id_type','110');
                            records_company[i].set('id_type_n','身份证');
                        }

                    }
                }
            }
            //出资人 出资比例必填
            if(name == 'other_relationships'){
                if(value == '2'){
                    record.getField('capital_key').setRequired(true);
                }else{
                    record.getField('capital_key').setRequired(false);
                }

            }

            if(name == 'work_status'){
                //当“就业状况”为“11 国家公务员”、“ 13 专业技术人员”、“ 17 职员”、“ 21 企业管理人员”、“ 24 工人”或“ 91 在职”时,
                // “单位名称”、“单位性质”、“单位所属行业”、“职业类型 、“职务”、“职称”、“入职年份”、单位地址、“单位所在地邮编”、“单位所在地行政区划”、“单位电话”必填。
                // 其余情况,这些字段为空只读
                if(value == '11'||value == '13'||value == '17'||value == '21'||value == '24'||value == '91'){
                    record.getField('work_unit').setReadOnly(false);
                    record.getField('work_unit').setRequired(true);
                    record.getField('unit_properties_n').setReadOnly(false);
                    record.getField('unit_properties_n').setRequired(true);
                    record.getField('occuption_n').setReadOnly(false);
                    record.getField('occuption_n').setRequired(true);
                    record.getField('position_n').setReadOnly(false);
                    record.getField('position_n').setRequired(true);
                    record.getField('positional_titles').setReadOnly(false);
                    record.getField('positional_titles').setRequired(true);
                    record.getField('entry_date').setReadOnly(false);
                    record.getField('entry_date').setRequired(true);
                    record.getField('work_unit_address').setReadOnly(false);
                    record.getField('work_unit_address').setRequired(true);
                    record.getField('work_unit_zip').setReadOnly(false);
                    record.getField('work_unit_zip').setRequired(true);
                    record.getField('work_province_n').setReadOnly(false);
                    record.getField('work_province_n').setRequired(true);
                    record.getField('work_city_n').setReadOnly(false);
                    record.getField('work_city_n').setRequired(true);
                    record.getField('work_district_n').setReadOnly(false);
                    record.getField('work_district_n').setRequired(true);
                    record.getField('work_unit_phone').setReadOnly(false);
                    record.getField('work_unit_phone').setRequired(true);
                    record.getField('industry_a_n').setReadOnly(false);
                    record.getField('industry_a_n').setRequired(true);
                }else{
                    record.getField('work_unit').setReadOnly(true);
                    record.getField('work_unit').setRequired(false);
                    record.getField('unit_properties_n').setReadOnly(true);
                    record.getField('unit_properties_n').setRequired(false);
                    record.getField('occuption_n').setReadOnly(true);
                    record.getField('occuption_n').setRequired(false);
                    record.getField('position_n').setReadOnly(true);
                    record.getField('position_n').setRequired(false);
                    record.getField('positional_titles').setReadOnly(true);
                    record.getField('positional_titles').setRequired(false);
                    record.getField('entry_date').setReadOnly(true);
                    record.getField('entry_date').setRequired(false);
                    record.getField('work_unit_address').setReadOnly(true);
                    record.getField('work_unit_address').setRequired(false);
                    record.getField('work_unit_zip').setReadOnly(true);
                    record.getField('work_unit_zip').setRequired(false);
                    record.getField('work_province_n').setReadOnly(true);
                    record.getField('work_province_n').setRequired(false);
                    record.getField('work_city_n').setReadOnly(true);
                    record.getField('work_city_n').setRequired(false);
                    record.getField('work_district_n').setReadOnly(true);
                    record.getField('work_district_n').setRequired(false);
                    record.getField('work_unit_phone').setReadOnly(true);
                    record.getField('work_unit_phone').setRequired(false);
                    record.getField('industry_a_n').setReadOnly(true);
                    record.getField('industry_a_n').setRequired(false);
                }
            }
            //征信add end
Spencer Chang's avatar
Spencer Chang committed
859 860 861 862
            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'));
25484's avatar
25484 committed
863
                    } else if (value == 'A7502') {
Spencer Chang's avatar
Spencer Chang committed
864
                        record.set('owership', $(f_bp_create_ds_id).getAt(0).get('bp_name_sp'));
25484's avatar
25484 committed
865
                    } else {
Spencer Chang's avatar
Spencer Chang committed
866 867 868 869 870 871 872 873
                        record.set('owership', '');
                    }
                }
            }
            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'));
25484's avatar
25484 committed
874
                    } else if (value == 'A7502') {
Spencer Chang's avatar
Spencer Chang committed
875
                        record.set('owner_name', $(f_bp_create_ds_id).getAt(0).get('bp_name_sp'));
25484's avatar
25484 committed
876
                    } else {
Spencer Chang's avatar
Spencer Chang committed
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
                        record.set('owner_name', '');
                    }
                }
            }

            if ((ds.id).indexOf('hls_bp_master') != -1 && (ds.id).indexOf('F_BASIC') != -1) {
                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);
                    }
                }
                if (name == 'id_card_no') {
                    // record = $(hls_bp_master_ds_id).getCurrentRecord();
                    // var id_num = record.get('id_card_no');
                    // var bp_age = getAge(id_num);
                    // record.set('age', bp_age);
                    if (!value) {
                        record.set('ccx_resmsg', '');
                    }
25484's avatar
25484 committed
898
                    if (record.get('id_type') == 'ID_CARD') {
899
                        if (!checkCard(value)) {
25484's avatar
25484 committed
900
                            Leaf.showMessage('${l:HLS.PROMPT}', '个人身份证号错误!');
niminmin's avatar
niminmin committed
901 902 903
                            setTimeout(function () {
                                record.set('id_card_no', '');
                            }, 20);
904
                            return false;
niminmin's avatar
niminmin committed
905
                        } else {
Darming's avatar
Darming committed
906 907 908 909 910 911 912 913 914 915 916 917
                            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', '女');
                                }

                            }
918 919 920
                        }
                    }
                    // ds.fields.id_card_no.pro.validator = id_card_no_validate;
Spencer Chang's avatar
Spencer Chang committed
921
                    //自动带出籍贯
Darming's avatar
Darming committed
922
                    // record.set('resident_addres', get_native_place(value))
Spencer Chang's avatar
Spencer Chang committed
923
                }
niminmin's avatar
niminmin committed
924
                if (name == 'id_no_sp' && value) {
stone's avatar
stone committed
925

25484's avatar
25484 committed
926 927 928
                    if (!value) {
                        record.set('ccx_resmsg1', '');
                    }
stone's avatar
stone committed
929

25484's avatar
25484 committed
930
                    if (record.get('card_type_sp') == 'ID_CARD') {
25484's avatar
25484 committed
931
                        if (!checkCard(value)) {
25484's avatar
25484 committed
932
                            Leaf.showMessage('${l:HLS.PROMPT}', '配偶身份证号错误!');
niminmin's avatar
niminmin committed
933 934 935
                            setTimeout(function () {
                                record.set('id_no_sp', '');
                            }, 20);
25484's avatar
25484 committed
936
                            return false;
niminmin's avatar
niminmin committed
937
                        } else {
Darming's avatar
Darming committed
938 939 940
                            if (value.length == 18) {
                                record.set('date_of_birth_sp', new Date(value.substr(6, 4) + '/' + value.substr(10, 2) + '/' + value.substr(12, 2)));
                            }
25484's avatar
25484 committed
941 942 943
                        }
                    }
                    // ds.fields.id_no_sp.pro.validator = id_card_no_validate;
Darming's avatar
Darming committed
944
                    // record.set('resident_addres_sp', get_native_place(value))
25484's avatar
25484 committed
945
                }
liyuan.chen's avatar
liyuan.chen committed
946 947 948
                if (name == 'bp_name') {
                    record.set('invoice_title', value);
                }
949
            }
Spencer Chang's avatar
Spencer Chang committed
950

stone's avatar
stone committed
951
            var hls_bp_master_ds_id = f_bp_create_ds_id;
952
            if (ds.id == hls_bp_master_ds_id && hls_bp_master_ds_id) {
953 954 955 956 957 958
                if (name == 'id_card_no_leg') {
                    if (!value) {
                        record.set('ccx_resmsg1', '');
                    }
                    var id_card_no_leg = record.get('id_card_no_leg');
                    if (!checkCard(id_card_no_leg)) {
25484's avatar
25484 committed
959
                        Leaf.showMessage('${l:HLS.PROMPT}', '法人代表身份证号格式错误!');
niminmin's avatar
niminmin committed
960 961 962
                        setTimeout(function () {
                            record.set('id_card_no_leg', '');
                        }, 20);
963 964 965
                        return false;
                    }
                }
liyuan.chen's avatar
liyuan.chen committed
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
                if (name == 'social_code') {
                    if (value) {
                        if (!CheckSocialCreditCode(value)) {
                            Leaf.showMessage('提示', '统一社会信用代码有误,请重新输入!');
                            setTimeout(function () {
                                record.set('social_code', '');
                            }, 20);
                            // window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            return false;
                        }
                    }
                    record.set('tax_registry_num', value);
                }
                if (name == 'cell_phone' && value) {
                    if (!checkMobile(value)) {
                        Leaf.showMessage('提示', '基本信息中,请输入正确格式的手机号码!');
niminmin's avatar
niminmin committed
982
                        setTimeout(function () {
liyuan.chen's avatar
liyuan.chen committed
983
                            record.set('cell_phone', '');
niminmin's avatar
niminmin committed
984
                        }, 20);
985 986 987
                        return false;
                    }
                }
liyuan.chen's avatar
liyuan.chen committed
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
                if (name == 'invoice_title') {
                    if (value != record.get('bp_name')) {
                        setTimeout(function () {
                            record.set('invoice_title', record.get('bp_name'));
                        }, 20);
                    }
                }
                if (name == 'tax_registry_num') {
                    if (value != record.get('social_code')) {
                        setTimeout(function () {
                            record.set('tax_registry_num', record.get('social_code'));
                        }, 20);
                    }
                }
1002
                /*if (name == 'invoice_bp_phone_num' && value) {
niminmin's avatar
niminmin committed
1003 1004 1005
                    if (!checkMobile(value)) {
                        Leaf.showMessage('提示', '基本信息中,请输入正确格式的手机号码!');
                        setTimeout(function () {
liyuan.chen's avatar
liyuan.chen committed
1006
                            record.set('invoice_bp_phone_num', '');
niminmin's avatar
niminmin committed
1007 1008 1009
                        }, 20);
                        return false;
                    }
1010
                }*/
Spencer Chang's avatar
Spencer Chang committed
1011
            }
stone's avatar
stone committed
1012

niminmin's avatar
niminmin committed
1013
            if (ds.id == f_bp_create_ds_id) {
stone's avatar
stone committed
1014 1015
                var hd_ds = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC', 'hls_bp_master');
                record = $(hd_ds).getCurrentRecord();
niminmin's avatar
niminmin committed
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
                if (name == 'marital_status') {
                    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', '身份证');
                        }
                    } 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);
stone's avatar
stone committed
1042
                    }
liyuan.chen's avatar
liyuan.chen committed
1043
                }
1044

liyuan.chen's avatar
liyuan.chen committed
1045 1046
                if (name == 'invoice_method' && value) {
                    if (record.get('bp_class') == 'ORG') {
1047
                        //开票
liyuan.chen's avatar
liyuan.chen committed
1048
                        if (value == 'BILLING') {
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
                            //一般纳税人
                            if( record.get('taxpayer_type') == 'GENERAL_TAXPAYER'){
                                record.getField('taxpayer_type').setRequired(true);
                                record.getField('taxpayer_type_n').setRequired(true);
                                record.getField('tax_registry_num').setRequired(true);
                                record.getField('invoice_title').setRequired(true);
                                record.getField('invoice_bp_address').setRequired(true);
                                record.getField('invoice_bp_phone_num').setRequired(true);
                                record.getField('invoice_bp_bank').setRequired(true);
                                record.getField('invoice_bp_bank_account').setRequired(true);
                            }else if(record.get('taxpayer_type') == 'SMALL_SCALE_TAXPAYER'){
                                //小规模纳税人
                                record.getField('taxpayer_type').setRequired(true);
                                record.getField('taxpayer_type_n').setRequired(true);
                                record.getField('tax_registry_num').setRequired(true);
                                record.getField('invoice_title').setRequired(true);

                                record.getField('invoice_bp_address').setRequired(false);
                                record.getField('invoice_bp_phone_num').setRequired(false);
                                record.getField('invoice_bp_bank').setRequired(false);
                                record.getField('invoice_bp_bank_account').setRequired(false);
                            }

                        }else if (value == 'NO_BILLING'){//暂时不开票
                            //一般纳税人
liyuan.chen's avatar
liyuan.chen committed
1074 1075 1076 1077
                            record.getField('taxpayer_type').setRequired(true);
                            record.getField('taxpayer_type_n').setRequired(true);
                            record.getField('tax_registry_num').setRequired(true);
                            record.getField('invoice_title').setRequired(true);
1078 1079 1080 1081 1082

                            record.getField('invoice_bp_address').setRequired(false);
                            record.getField('invoice_bp_phone_num').setRequired(false);
                            record.getField('invoice_bp_bank').setRequired(false);
                            record.getField('invoice_bp_bank_account').setRequired(false);
liyuan.chen's avatar
liyuan.chen committed
1083
                        }
1084 1085 1086
                    }
                }
                if (name == 'taxpayer_type' && value) {
gzj34291's avatar
gzj34291 committed
1087
                    if (record.get('bp_class') == 'ORG'&&record.get('bp_type') != 'THIRD_PARTY') {
1088 1089
                        if (value == 'SMALL_SCALE_TAXPAYER') {

1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
                            record.getField('taxpayer_type').setRequired(true);
                            record.getField('taxpayer_type_n').setRequired(true);
                            record.getField('tax_registry_num').setRequired(true);
                            record.getField('invoice_title').setRequired(true);

                            record.getField('invoice_bp_address').setRequired(false);
                            record.getField('invoice_bp_phone_num').setRequired(false);
                            record.getField('invoice_bp_bank').setRequired(false);
                            record.getField('invoice_bp_bank_account').setRequired(false);

                            record.set('invoice_type','ECT');
                            record.set('invoice_type_n','电子发票');
                            record.getField('invoice_type').setRequired(true);
                            record.getField('invoice_type_n').setRequired(true);
                            record.getField('invoice_type').setReadOnly(false);
                            record.getField('invoice_type_n').setReadOnly(false);
1106 1107

                        }else if (value == 'GENERAL_TAXPAYER') {
1108 1109 1110
                            //设置开票类型为纸质只读
                            record.set('invoice_type','PAPER');
                            record.set('invoice_type_n','纸质发票');
1111
							//取消开票类型为纸质只读  18083  2022/11/30
1112 1113
                            //record.getField('invoice_type').setReadOnly(true);
                            //record.getField('invoice_type_n').setReadOnly(true);
1114 1115 1116
                            record.getField('invoice_type').setRequired(false);
                            record.getField('invoice_type_n').setRequired(false);
                            record.getField('reception_maile').setRequired(false);
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
                            if (record.get('invoice_method') == 'BILLING'){
                                record.getField('taxpayer_type').setRequired(true);
                                record.getField('taxpayer_type_n').setRequired(true);
                                record.getField('tax_registry_num').setRequired(true);
                                record.getField('invoice_title').setRequired(true);

                                record.getField('invoice_bp_address').setRequired(true);
                                record.getField('invoice_bp_phone_num').setRequired(true);
                                record.getField('invoice_bp_bank').setRequired(true);
                                record.getField('invoice_bp_bank_account').setRequired(true);

                            }else if ( record.get('invoice_method') == 'NO_BILLING'){
                                record.getField('taxpayer_type').setRequired(true);
                                record.getField('taxpayer_type_n').setRequired(true);
                                record.getField('tax_registry_num').setRequired(true);
                                record.getField('invoice_title').setRequired(true);

                                record.getField('invoice_bp_address').setRequired(false);
                                record.getField('invoice_bp_phone_num').setRequired(false);
                                record.getField('invoice_bp_bank').setRequired(false);
                                record.getField('invoice_bp_bank_account').setRequired(false);
                            }
liyuan.chen's avatar
liyuan.chen committed
1139
                        }
1140 1141
                    }
                }
1142
                if(name == 'invoice_type'){
1143
				//设置是否全电发票默认值  18083
1144 1145
                    if(value == 'PAPER'){
                        record.getField('reception_maile').setRequired(false);
1146
						record.set('full_elec_invoice_flag','N');
1147
                        record.set('full_elec_invoice_flag_n','否');
1148 1149
                    }else{
                        record.getField('reception_maile').setRequired(true);
1150
						record.set('full_elec_invoice_flag','Y');
1151
                        record.set('full_elec_invoice_flag_n','是');
1152 1153
                    }
                }
1154
            }
1155 1156 1157

            var role_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master_role');
            if (role_ds == ds.id) {
gzj34291's avatar
gzj34291 committed
1158
                var flag=true;
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
                var bp_type_flag='N';
                var records = $(ds.id).getAll();
                if(name=='bp_type'){
                    for (var i = 0;i < records.length;i++) {
                        if(records[i].get('bp_type')=='TENANT'){
                            bp_type_flag='Y';
                        }
                    }
                    if(bp_type_flag=='Y'){
                        for (var i = 0;i < records.length;i++) {
                            if(records[i].get('bp_type')=='TENANT'){
                                records[i].set('primary_flag','Y')
                            }else{
                                records[i].set('primary_flag','N')
                            }
                        }
                    }
                }

                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'));
                }

            }
Spencer Chang's avatar
Spencer Chang committed
1189 1190 1191 1192 1193 1194 1195 1196 1197
        };

        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 {
1198
                    url = $('hls214N_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
Spencer Chang's avatar
Spencer Chang committed
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216
                }

                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}', '请先保存!');

            }
        }
1217 1218 1219 1220 1221 1222 1223 1224 1225
        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');
                }
Spencer Chang's avatar
Spencer Chang committed
1226

1227 1228 1229 1230 1231 1232 1233
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'prj500_cdd_uploadFile_screen_id',
                    width: 850,
                    height: 400
                });
Spencer Chang's avatar
Spencer Chang committed
1234

1235 1236 1237 1238 1239 1240 1241 1242
                win.on('close', function () {
                    record.ds.query();
                });
            } else {
                Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');

            }
        }
Spencer Chang's avatar
Spencer Chang committed
1243 1244
        //超链接渲染
        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
1245

Spencer Chang's avatar
Spencer Chang committed
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280
            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 = '';
                    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;

                }
            } else if (name == 'description') {
                if (record.get('important_flag') == 'Y') {
                    return '<font color="RED">' + value + '</font>';
                }
                return value;
1281 1282 1283 1284
            }//签约人授权书附件
            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
1285 1286 1287
            }
        };

lizhe's avatar
lizhe committed
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
        //征信 add start 财报查询按钮
        window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function () {
            var bp_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'hls_bp_master');
            var record = $(bp_ds_id).getAt(0)
            if (Ext.isEmpty(record.get('bp_code'))) {
                Leaf.showMessage('${l:PROMPT}', '请先保存商业伙伴数据!');
                return;
            }

            new Leaf.Window({
                id: 'rsc303_fin_statement_query',
                url: $('rsc303_fin_statement_link').getUrl(),
                title: '查看财报',
                fullScreen: true,
                params: {
                    bp_id: record.get('bp_id') ,
                    bp_code:record.get('bp_code')
                }

            });
        }
        //征信 add end
Spencer Chang's avatar
Spencer Chang committed
1310
        ]]></script>
niminmin's avatar
niminmin committed
1311
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
Spencer Chang's avatar
Spencer Chang committed
1312 1313
    </a:view>
</a:screen>