prj_project_maintain.lview 104 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
Spencer Chang's avatar
Spencer Chang committed
2
<!--
王炜's avatar
王炜 committed
3 4 5 6
    $Author: wangwei5743
    $Date: 2014-10-8 下午3:16:19
    $Revision: 1.0
    $purpose: 租赁申请创建  创建界面
Spencer Chang's avatar
Spencer Chang committed
7 8 9 10 11 12
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script"
          customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.user_id=${/session/@user_id}" model="prj.PRJ500D.sys_user_lv"
                       rootPath="user_name_path"/>
13 14 15 16
        <a:model-query
                defaultWhereClause="v.role_id = ${/session/@role_id} and v.role_code in (&apos;HAND&apos;,&apos;0017&apos;)"
                model="zjwfl.sys_role_flag" rootPath="role_flag_path"/>
        <a:model-query fetchAll="true" model="prj.PRJ500D.user_agent_description" rootPath="user_agent_description"/>
17
        <a:model-query fetchAll="true" model="prj.PRJ500D.prj_project_get_description" rootPath="description"/>
Spencer Chang's avatar
Spencer Chang committed
18
        <s:server-script import="contract_print_path.js"><![CDATA[
19 20 21
        $ctx.parameter.file_path = con_print_path['con_print_path'];
        $ctx.parameter.tomcat_source = con_print_path['tomcat_source'];
        ]]>
Spencer Chang's avatar
Spencer Chang committed
22 23 24
        </s:server-script>
    </a:init-procedure>
    <a:view>
25 26
        <a:link id="hls_bp_master_billing_link" model="prj.PRJ500N.hls_bp_master_billing" modelaction="query"/>
        <a:link id="bp_tenant_detail_query_link" model="prj.PRJ500D.bp_tenant_old_r_query" modelaction="query"/>
Spencer Chang's avatar
Spencer Chang committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}get_special_fields_link_id"
                model="cont.CON500.con_contract_get_special_fields" modelaction="update"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id"
                url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_id"
                url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_calc_quotation_header_link_id"
                url="${/request/@context_path}/modules/hls/HLS500/hls_fin_calc_quotation_header.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_calculator_update_link_id"
                url="${/request/@context_path}/modules/hls/HLS500N/hls_fin_calculator_update_n.lview"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_doc_quotation_for_deron_link_id"
                url="${/request/@context_path}/modules/hls/HLS500/hls_fin_doc_quotation_for_deron.lsc"/>
        <a:link id="${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_doc_quotation_link_id"
                url="${/request/@context_path}/modules/hls/HLS500/hls_fin_doc_quotation.lsc"/>

42
        <a:link id="${/parameter/@layout_code}_principal_eq_pymt_adj_link_n" model="hls.HLS500N.query_principal_eq_pymt_adj" modelaction="update"/>
Spencer Chang's avatar
Spencer Chang committed
43 44 45
        <a:link id="${/parameter/@layout_code}hls_bp_master_query_link"
                url="${/request/@context_path}/modules/hls/HLS215N/hls_bp_master_query.lview"/>

lijingjing's avatar
lijingjing committed
46 47
        <a:link id="${/parameter/@layout_code}contract_number_query_link"
                url="${/request/@context_path}/modules/cont/CON505/con_contract_modify.lview"/>
48 49
        <a:link id="${/parameter/@layout_code}_tenant_rate_query_link"
                url="${/request/@context_path}/modules/prj/PRJ902/prj_project_score_result.lview"/>
Spencer Chang's avatar
Spencer Chang committed
50 51 52 53 54 55 56 57 58
        <a:link id="${/parameter/@layout_code}_hls_fin_calc_get_base_rate_link_id"
                model="hls.HLS500.hls_fin_calc_get_base_rate" modelaction="update"/>
        <a:link id="${/parameter/@layout_code}_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code"
                modelaction="update"/>

        <!-- <script src="${/request/@context_path}/modules/prj/PRJ500N/javascripts/check_org_code.js" type="text/javascript"/> -->
        <!--  <a:link id="prj_project_create_con_id" model="prj.PRJ513N.prj_peoject_create_con" modelaction="update"/> -->
        <a:link id="${/parameter/@layout_code}_prj_project_create_contract_link_id"
                model="prj.PRJ505.prj_project_create_contract" modelaction="update"/>
niminmin's avatar
niminmin committed
59 60
        <a:link id="${/parameter/@layout_code}_prj_project_update_status_link_id"
                model="prj.PRJ505.prj_project_create_contract" modelaction="execute"/>
lijingjing's avatar
lijingjing committed
61
        <a:link id="prj_approval_link_id" model="prj.PRJ501N.project_approval" modelaction="update"/>
lijingjing's avatar
lijingjing committed
62
        <a:link id="check_prj_lease_item_link_id" model="prj.PRJ501N.project_approval" modelaction="execute"/>
63
        <script src="${/request/@context_path}/javascripts/jquery-1.6.4.min.js" type="text/javascript"/>
Spencer Chang's avatar
Spencer Chang committed
64 65
        <!--<link href="${/request/@context_path}/css/lightbox.css" rel="stylesheet" type="text/css"/>
        <script src="${/request/@context_path}/javascripts/lightbox.js" type="text/javascript"/>-->
66
        <a:link id="prj_check_prj_record_link_n" model="hls.HLS500N.check_prj_record" modelaction="execute"/>
67 68
        <a:link id="get_atch_download_link"
                url="${/request/@context_path}/modules/batch_download/lease_atm_batch_dl.lsc"/>
69 70 71
        <link href="${/request/@context_path}/modules/viewerjs/viewer.css" rel="stylesheet"/>
        <script src="${/request/@context_path}/modules/viewerjs/viewer.js"/>
        <script src="${/request/@context_path}/modules/viewerjs/viewer_tool.js"/>
Spencer Chang's avatar
Spencer Chang committed
72
        <script type="text/javascript"><![CDATA[
73
        jQuery.noConflict();
Spencer Chang's avatar
Spencer Chang committed
74 75 76 77 78 79
        window['${/parameter/@layout_code}_user_button5_layout_dynamic_click'] = function () {
            Leaf.showConfirm('提示', '是否确认生成合同?', function () {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
                var quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
                var quo_record = $(quotation_ds_id).getCurrentRecord();

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 107 108
                var cal_hd_price_list = quo_record.get('cal_hd_price_list');
                var price_list = quo_record.get('price_list');
                if (cal_hd_price_list == price_list) {
                    var url = $('${/parameter/@layout_code}_prj_project_create_contract_link_id').getUrl();
                    var record = $(ds_id).getCurrentRecord();
                    if ($(ds_id).validate()) {
                        window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                        Leaf.request(
                            {
                                url: url,
                                para: {
                                    project_id: record.get('project_id'),
                                    contract_seq: 1,
                                    bp_contract_seq: 1,
                                    contract_type: 'CARCON',
                                    contract_name: record.get('project_name'),
                                    billing_method: record.get('billing_method'),
                                },
                                success: function (res) {
                                    $('${/parameter/@winid}').close();
                                    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']();
                                },
                                scope: this
Spencer Chang's avatar
Spencer Chang committed
109

110 111 112 113
                            }
                        );
                    }
                } else {
Spencer Chang's avatar
Spencer Chang committed
114
                    Leaf.showMessage('${l:PROMPT}', '报价有变动请重新计算!');
niminmin's avatar
niminmin committed
115

Spencer Chang's avatar
Spencer Chang committed
116 117 118 119 120 121 122 123 124 125 126
                }
            });
        };


        //add by zhuxianfei
        window['${/parameter/@layout_code}_quote_layout_dynamic_click'] = function () {

            var url;
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
127
            var history_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_CASHFLOW_NS', 'prj_quotation');
lijingjing's avatar
lijingjing committed
128

Spencer Chang's avatar
Spencer Chang committed
129 130 131 132 133 134 135 136 137 138 139
            var record = $(quotation_ds_id).getCurrentRecord();
            var head_record = $(ds_id).getAt(0);
            if ('${/parameter/@calc_type}' == 'LITE_CALCULATOR') {
                url = $('${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_calc_quotation_header_link_id').getUrl();
            } else if ('${/parameter/@calc_type}' == 'CLASSIC_CALCULATOR') {
                url = $('${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_calculator_update_link_id').getUrl();
            } else {
                url = $('${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_calculator_update_link_id').getUrl();
                // Leaf.showMessage('${l:PROMPT}', '${l:HLS.CALC_TYPE_IS_NULL}');
                //    return;
            }
140
            if (head_record.dirty == true) {
lijingjing's avatar
lijingjing committed
141 142 143
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                return;
            }
Spencer Chang's avatar
Spencer Chang committed
144 145 146 147 148
            if (record.dirty == true) {
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                return;
            }
            if ($(quotation_ds_id).validate()) {
149 150 151 152
                /* if (!record.get('price_list') || !record.get('currency') || !record.get('lease_times')) {
                     Leaf.showMessage('${l:PROMPT}', '${l:HLS.QUOTATION_EXECUTE_AFTER_SAVE}');
                     return;
                 }*/
Spencer Chang's avatar
Spencer Chang committed
153 154

                var parent_pk_value = head_record.get('project_id');
lijingjing's avatar
lijingjing committed
155 156
                var secondary_lease = head_record.get('secondary_lease');
                var payment_deduction = head_record.get('payment_deduction');
Spencer Chang's avatar
Spencer Chang committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
                record.set('function_code', 'PRJ505_QUOTATION');
                record.set('function_usage', 'UPDATE');
                record.set('project_id', parent_pk_value);
                //拆分合同可维护
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                //首次插入
                if (!record.get('calc_session_id')) {
                    record.set('to_doc_table', 'HLS_FIN_CALCULATOR_HD');
                    var calc_recreate_L_formula;
                    calc_recreate_L_formula = 'Y';

                    record.set('_status', 'update');
                    record.set('from_doc_table', 'PRJ_QUOTATION');
                    record.set('from_doc_pk', record.get('quotation_id'));
                    record.set('calculate_flag', 'N');
                    if (!'${/parameter/@document_id}') {
                        record.set('document_id', parent_pk_value);
                    }
175
                    var price_list = record.get('price_list');
Spencer Chang's avatar
Spencer Chang committed
176 177 178 179 180 181 182 183
                    var saveData = [];
                    saveData.push(record.data);
                    Leaf.request({
                        url: $('${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_doc_quotation_link_id').getUrl(),
                        para: saveData,
                        success: function (res) {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            $(quotation_ds_id).query();
lijingjing's avatar
lijingjing committed
184
                            $(history_ds_id).query();
Spencer Chang's avatar
Spencer Chang committed
185 186 187 188
                            var quotation_id = record.get('quotation_id') || res.result.record.quotation_id;
                            var win = new Leaf.Window({
                                id: 'hls_fin_calc_quotation_link_winid',
                                params: {
niminmin's avatar
niminmin committed
189
                                    layout_code: '${/parameter/@layout_code}',
Spencer Chang's avatar
Spencer Chang committed
190
                                    document_id: parent_pk_value,
lijingjing's avatar
lijingjing committed
191
                                    price_list: price_list,
192 193
                                    secondary_lease: secondary_lease,
                                    payment_deduction: payment_deduction,
lijingjing's avatar
lijingjing committed
194
                                    document_category: 'PROJECT',
Spencer Chang's avatar
Spencer Chang committed
195
                                    maintain_type: 'MODIFY',
niminmin's avatar
niminmin committed
196
                                    business_type: head_record.get('business_type'),
Spencer Chang's avatar
Spencer Chang committed
197 198 199 200 201 202 203 204 205 206 207 208 209
                                    calc_session_id: res.result.record.calc_session_id,
                                    quotation_id: quotation_id,
                                    dsId: quotation_ds_id,
                                    winId: 'hls_fin_calc_quotation_link_winid',
                                    global_flag: 'Y',
                                    id_num: 1,
                                    calc_type: '${/parameter/@calc_type}' || 'CLASSIC_CALCULATOR',
                                    recreate_L_formula: calc_recreate_L_formula
                                },
                                url: url,
                                fullScreen: true,
                                draggable: true
                            });
210

Spencer Chang's avatar
Spencer Chang committed
211 212
                            win.on('close', function () {
                                $(quotation_ds_id).query();
lijingjing's avatar
lijingjing committed
213
                                $(history_ds_id).query();
Spencer Chang's avatar
Spencer Chang committed
214 215 216 217 218 219 220 221 222 223 224 225 226

                            });
                        },
                        failure: function () {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        error: function () {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        scope: this
                    });
                } else {
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
227 228 229
                    var cal_hd_price_list = record.get('cal_hd_price_list');
                    var price_list = record.get('price_list');
                    if (cal_hd_price_list == price_list) {
Spencer Chang's avatar
Spencer Chang committed
230 231 232 233 234

                        //直接进入报价页面
                        var win = new Leaf.Window({
                            id: 'hls_fin_calc_quotation_update_link_winid',
                            params: {
niminmin's avatar
niminmin committed
235
                                layout_code: '${/parameter/@layout_code}',
Spencer Chang's avatar
Spencer Chang committed
236
                                document_id: parent_pk_value,
lijingjing's avatar
lijingjing committed
237
                                price_list: price_list,
238 239
                                secondary_lease: secondary_lease,
                                payment_deduction: payment_deduction,
lijingjing's avatar
lijingjing committed
240
                                document_category: 'PROJECT',
Spencer Chang's avatar
Spencer Chang committed
241
                                maintain_type: 'MODIFY',
niminmin's avatar
niminmin committed
242
                                business_type: head_record.get('business_type'),
Spencer Chang's avatar
Spencer Chang committed
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
                                calc_session_id: record.get('calc_session_id'),
                                quotation_id: record.get('quotation_id'),
                                dsId: quotation_ds_id,
                                winId: 'hls_fin_calc_quotation_update_link_winid',
                                global_flag: 'Y',
                                id_num: 1,
                                calc_type: '${/parameter/@calc_type}',
                                recreate_L_formula: 'N'
                            },
                            url: url,
                            fullScreen: true,
                            draggable: true
                        });
                        win.on('close', function () {
                            $(quotation_ds_id).query();
lijingjing's avatar
lijingjing committed
258
                            $(history_ds_id).query();
Spencer Chang's avatar
Spencer Chang committed
259
                        });
260
                    } else {
Spencer Chang's avatar
Spencer Chang committed
261 262 263 264 265 266 267 268 269 270 271
                        record.set('to_doc_table', 'HLS_FIN_CALCULATOR_HD');
                        var calc_recreate_L_formula;
                        calc_recreate_L_formula = 'Y';

                        record.set('_status', 'update');
                        record.set('from_doc_table', 'PRJ_QUOTATION');
                        record.set('from_doc_pk', record.get('quotation_id'));
                        record.set('calculate_flag', 'N');
                        if (!'${/parameter/@document_id}') {
                            record.set('document_id', parent_pk_value);
                        }
272
                        var price_list = record.get('price_list');
Spencer Chang's avatar
Spencer Chang committed
273 274 275 276 277 278 279 280 281
                        var saveData = [];
                        saveData.push(record.data);
                        Leaf.request({
                            url: $('${/parameter/@layout_code}${/parameter/@tree_code}_hls_fin_doc_quotation_link_id').getUrl(),
                            para: saveData,
                            success: function (res) {

                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                $(quotation_ds_id).query();
lijingjing's avatar
lijingjing committed
282
                                $(history_ds_id).query();
Spencer Chang's avatar
Spencer Chang committed
283 284 285 286
                                var quotation_id = record.get('quotation_id') || res.result.record.quotation_id;
                                var win = new Leaf.Window({
                                    id: 'hls_fin_calc_quotation_link_winid',
                                    params: {
niminmin's avatar
niminmin committed
287
                                        layout_code: '${/parameter/@layout_code}',
Spencer Chang's avatar
Spencer Chang committed
288
                                        document_id: parent_pk_value,
lijingjing's avatar
lijingjing committed
289
                                        price_list: price_list,
290 291
                                        secondary_lease: secondary_lease,
                                        payment_deduction: payment_deduction,
lijingjing's avatar
lijingjing committed
292
                                        document_category: 'PROJECT',
Spencer Chang's avatar
Spencer Chang committed
293
                                        maintain_type: 'MODIFY',
niminmin's avatar
niminmin committed
294
                                        business_type: head_record.get('business_type'),
Spencer Chang's avatar
Spencer Chang committed
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
                                        calc_session_id: res.result.record.calc_session_id,
                                        quotation_id: quotation_id,
                                        dsId: quotation_ds_id,
                                        winId: 'hls_fin_calc_quotation_link_winid',
                                        global_flag: 'Y',
                                        id_num: 1,
                                        calc_type: '${/parameter/@calc_type}' || 'CLASSIC_CALCULATOR',
                                        recreate_L_formula: calc_recreate_L_formula
                                    },
                                    url: url,
                                    fullScreen: true,
                                    draggable: true
                                });
                                win.on('close', function () {
                                    $(quotation_ds_id).query();
lijingjing's avatar
lijingjing committed
310
                                    $(history_ds_id).query();
Spencer Chang's avatar
Spencer Chang committed
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352

                                });
                            },
                            failure: function () {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            error: function () {
                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            },
                            scope: this
                        });
                    }
                }
            }
        };


        function prj501n_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' || '${/parameter/@function_usage}' == 'QUERY') {
                    url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                } else {
                    url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                }
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'prj500_cdd_uploadFile_screen_id',
                    width: 850,
                    height: 400
                });

                win.on('close', function () {
                    record.ds.query();
                });
            } else {
                Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
            }
        }

353 354 355 356 357 358 359 360 361 362 363 364 365 366
        function prj501n_upload_file_new(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' || '${/parameter/@function_usage}' == 'QUERY') {
                    if('${/model/role_flag_path/record/@sys_role_flag}' == 'Y') {
                        url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    }else{
                        url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    }
                } else {
                    url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                }*/

367
                if ('${/model/role_flag_path/record/@sys_role_flag}' == 'Y') {
368
                    url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_uploadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
369
                } else {
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
                    url = $('${/parameter/@layout_code}${/parameter/@pre_layout}prj500_cdd_downloadFile_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
                });

                win.on('close', function () {
                    record.ds.query();
                });
            } else {
                Leaf.showMessage('${l:HLS.PROMPT}', '请先保存!');
            }
        }

Spencer Chang's avatar
Spencer Chang committed
388 389 390 391 392
        function prj501n_bp_code_renderer(id, name, query_only) {
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            var param = {};
            param['bp_id'] = record.get('bp_id');
            param['bp_class'] = record.get('bp_class');
393
            if (record.get('bp_category') == 'AGENT') {
lijingjing's avatar
lijingjing committed
394 395 396
                param['function_code'] = 'HLS303_Q';
                param['function_usage'] = 'QUERY';

397
            } else {
lijingjing's avatar
lijingjing committed
398 399 400
                param['function_code'] = 'HLS215D';
                param['function_usage'] = 'QUERY';
            }
Spencer Chang's avatar
Spencer Chang committed
401 402 403 404 405
            param['winid'] = '${/parameter/@layout_code}_bp_win_id';
            param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
            hls_doc_get_layout_code('${/parameter/@layout_code}_get_layout_code_link_id', param, '${/parameter/@layout_code}hls_bp_master_query_link', record.ds.id, '${/parameter/@layout_code}');
        }

406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
        function prj501n_project_number_renderer(id, name, query_only) {
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            var param = {};
            param['bp_id'] = record.get('project_id');
            param['bp_class'] = record.get('bp_class');
            param['function_code'] = 'PRJ501D';
            param['function_usage'] = 'QUERY';
            param['maintain_type'] = 'READONLY';
            param['winid'] = '${/parameter/@layout_code}_project_number_win_id';
            param['prj_bp_id'] = record.get('prj_bp_id');

            hls_doc_get_layout_code('${/parameter/@layout_code}_get_layout_code_link_id', param, '${/parameter/@layout_code}project_number_query_link', record.ds.id, '${/parameter/@layout_code}');
        }

        function prj501n_contract_number_renderer(id, name, query_only) {
            var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
            var param = {};
            param['contract_id'] = record.get('contract_id');
            param['function_code'] = 'CON301';
            param['function_usage'] = 'QUERY';
            param['winid'] = '${/parameter/@layout_code}_project_number_win_id';
            param['url_title'] = '${l:CON301.CONTRACT_DETAIL}';
            hls_doc_get_layout_code('${/parameter/@layout_code}_get_layout_code_link_id', param, '${/parameter/@layout_code}contract_number_query_link', record.ds.id, '${/parameter/@layout_code}');

        }
Spencer Chang's avatar
Spencer Chang committed
431 432 433 434 435 436 437

        //超链接渲染
        window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
            var link_function = '';
            window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
            if (name == 'attachment') {
                link_function = 'prj501n_upload_file';
438
                if (record.get('cdd_item') == 'ADD_ATTACH') {
439 440
                    link_function = 'prj501n_upload_file_new';
                }
Spencer Chang's avatar
Spencer Chang committed
441 442 443
                return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
            } else if (name == 'attach_file_name') {

444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
                /* 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;

                  }*/
466
                if (value != null) {
Spencer Chang's avatar
Spencer Chang committed
467 468 469
                    var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                    var str = value.split(';;');
                    var url = '';
470
                    for (var i = 0; i < str.length; i++) {
Spencer Chang's avatar
Spencer Chang committed
471 472 473 474 475 476
                        //
                        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();
477

478 479 480 481 482 483 484
                            // if (file_name.indexOf('.BMP') >= 0 || file_name.indexOf('.JPG') >= 0 || file_name.indexOf('.JPEG') >= 0 || file_name.indexOf('.PNG') >= 0 || file_name.indexOf('.GIF') >= 0) {
                            //     url = url + '<a href=' + link + temp[1] + ' ref="img">' + temp[0] + '</a>' + ',';
                            // }
                            if (file_suffix == 'BMP' || file_suffix == 'JPG' || file_suffix == 'JPEG' || file_suffix == 'PNG' || file_suffix == 'GIF') {
                                // url = url + '<a ref="img" href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                                link_function = 'show_viewer_more';
                                url = url + '<a href="javascript:window[\'' + link_function + '\'](\'' + link + '\',\'' + temp[1] + '\',\'' + temp[0] + '\',\'' + value + '\');">' + temp[0] + '</a>' + ',';
485
                            } else {
Spencer Chang's avatar
Spencer Chang committed
486 487 488 489 490 491 492
                                url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                            }
                        }
                    }
                    return url;

                }
lijingjing's avatar
lijingjing committed
493
            } else if (name == 'bp_link' && !record.isNew) {
Spencer Chang's avatar
Spencer Chang committed
494
                link_function = 'prj501n_bp_code_renderer';
495
                return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
Spencer Chang's avatar
Spencer Chang committed
496

497
            } else if (name == 'project_number') {
lijingjing's avatar
lijingjing committed
498
                link_function = 'prj501n_project_number_renderer';
499
                return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + value + '</a>';
lijingjing's avatar
lijingjing committed
500

501
            } else if (name == 'contract_number') {
lijingjing's avatar
lijingjing committed
502
                link_function = 'prj501n_contract_number_renderer';
503
                return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + value + '</a>';
Spencer Chang's avatar
Spencer Chang committed
504 505 506 507 508 509 510
            }
        };

        //保存submitsuccess调用
        window['${/parameter/@layout_code}_on_layout_dynamic_submitsuccess'] = function (ds, record, res) {
            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
511
            var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
512 513 514 515
            var bp_ds_ids = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC_INFO_1', 'prj_project');
            var prj_project_lease_item_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_LEASE_HEAD_CAR', 'prj_project_lease_item');
            var bp_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_BP', 'prj_project_bp');
            var tenant_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'T_HISTORY_INGO', 'hls_bp_master');
Spencer Chang's avatar
Spencer Chang committed
516
            var cdd_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
517 518 519
            var virtual_ds_id = '${/parameter/@layout_code}_virtual_ds';
            var score_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_TENANT_SCORE_INFO', 'bp_tenant_rate_detail');
            if (ds_id == ds.id || virtual_ds_id == ds.id) {
Spencer Chang's avatar
Spencer Chang committed
520 521
                $(cdd_item_ds_id).query();
                $(bp_ds_id).query();
lijingjing's avatar
lijingjing committed
522
                $(tenant_ds_id).query();
523
                $(prj_project_lease_item_ds_id).query();
524
                $(prj_quotation_ds_id).query();
525
                $(score_ds_id).query();
Spencer Chang's avatar
Spencer Chang committed
526 527 528 529 530 531
            }

            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
        };

        //选择事件(grid,attach,gridbox,table)
532 533
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_select'] = function (ds, record, bp_seq) {
            var bp_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_BP', 'prj_project_bp');
Spencer Chang's avatar
Spencer Chang committed
534 535 536 537
            if (bp_ds_id == ds.id && bp_ds_id) {
                if (record.get('bp_category') == 'TENANT') {
                    //实际为不选中
                    Leaf.showMessage('${l:HLS.PROMPT}', '无法删除主承租人!');
niminmin's avatar
niminmin committed
538 539 540 541 542
                    //ds.unSelect(record);
                    //ds.select(record);
                    setTimeout(function () {
                        ds.unSelect(record);
                    }, 1);
Spencer Chang's avatar
Spencer Chang committed
543 544 545 546
                }
                if (record.get('bp_category') == 'AGENT') {
                    //实际为不选中
                    Leaf.showMessage('${l:HLS.PROMPT}', '无法删除经销商!');
niminmin's avatar
niminmin committed
547 548 549 550 551
                    // ds.unSelect(record);
                    // ds.select(record);
                    setTimeout(function () {
                        ds.unSelect(record);
                    }, 1);
Spencer Chang's avatar
Spencer Chang committed
552 553 554
                }
            }
        };
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587

        function jsGetAge(strBirthday) {
            var returnAge;
            var strBirthdayArr = strBirthday.split("-");
            var birthYear = strBirthdayArr[0];
            var birthMonth = strBirthdayArr[1];
            var birthDay = strBirthdayArr[2];

            var d = new Date();
            var nowYear = d.getFullYear();
            var nowMonth = d.getMonth() + 1;
            var nowDay = d.getDate();

            if (nowYear == birthYear) {
                returnAge = 0;//同年 则为0岁  
            } else {
                var ageDiff = nowYear - birthYear; //年之差  
                if (ageDiff > 0) {
                    if (nowMonth == birthMonth) {
                        var dayDiff = nowDay - birthDay;//日之差  
                        if (dayDiff < 0) {
                            returnAge = ageDiff - 1;
                        } else {
                            returnAge = ageDiff;
                        }
                    } else {
                        var monthDiff = nowMonth - birthMonth;//月之差  
                        if (monthDiff < 0) {
                            returnAge = ageDiff - 1;
                        } else {
                            returnAge = ageDiff;
                        }
                    }
588
                } else {
589 590 591 592 593 594 595 596
                    returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天  
                }
            }
            return returnAge;//返回周岁年龄  
        }

        //更新时调用
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_update'] = function (ds, record, name, value, old_value, bp_seq) {
597
            debugger;
598 599 600
            var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var prj_project_history_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'T_HISTORY_INGO', 'hls_bp_master');
            var score_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_TENANT_SCORE_INFO', 'bp_tenant_rate_detail');
601
            var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
602
            var lease_item_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_LEASE_HEAD_CAR', 'prj_project_lease_item');
gzj34291's avatar
gzj34291 committed
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
            var tenant_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC_INFO_1', 'prj_project');

            if(tenant_ds_id == ds.id&&tenant_ds_id){

                if(name == 'send_message_n'){
                    if(value=='是'){
                        record.getField('cell_phone').setRequired(true);
                    } else if(value=='否'){
                        record.getField('cell_phone').setRequired(false);
                    }
                }

            }



619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
            if (lease_item_ds_id == ds.id && lease_item_ds_id) {
                if(division=='70'){
                    record.getField('lease_name_n').setRequired(true);
                    record.getField('brand_value').setRequired(true);
                    record.getField('produce_date').setRequired(true);
                    record.getField('using_hour').setRequired(true);
                    record.getField('machine_number_70').setRequired(true);
                    record.getField('modelcd').setReadOnly(false);
                    record.getField('modelcd').setRequired(true);
                    record.getField('full_name').setRequired(false);
                    record.getField('full_name_n').setRequired(false);
                    record.getField('ownership_flag_n').setRequired(true);
                    record.getField('residual_value_amount').setRequired(true);
                    if(name=='lease_name_n'){
                        record.data.type_name=value;
                    }else if(name=='modelcd'){
                        record.data.pattern=value;
                    }
                }else {
                    record.getField('modelcd').setReadOnly(true);
                }
            }
641
            //选择承租人带出开票信息
642
            if (prj_project_ds_id == ds.id && prj_project_ds_id) {
niminmin's avatar
niminmin committed
643 644 645 646 647 648 649 650 651 652 653
                if (name == "payment_deduction" && value == "DOWN_PAYMENT_DEDUCTION") {
                    //业务类型回租时,默认只读“首付款抵扣”选项
                    if ($(prj_project_ds_id).getAt(0).get('business_type') == 'LEASE') {
                        Leaf.showInfoMessage("提示", "直租业务不能选择首付款抵扣");
                        setTimeout(function () {
                            $(prj_project_ds_id).getAt(0).set('payment_deduction', null);
                            $(prj_project_ds_id).getAt(0).set('payment_deduction_n', null);
                        }, 10);

                    }
                }
654
                if (name == "bp_id_tenant_n" && value) {
655 656 657 658 659
                    var bp_id_tenant = record.get('bp_id_tenant');
                    Leaf.Masker.mask(Ext.getBody());
                    Leaf.request({
                        url: $('hls_bp_master_billing_link').getUrl(),
                        para: {
660
                            bp_id: bp_id_tenant
661
                        },
662 663
                        success: function (res) {
                            var billing_into = res.result.record;
664 665
                            var prj_project_bp_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');

666 667 668 669 670 671 672 673 674
                            $(prj_project_bp_ds_id).getAt(0).set('taxpayer_type_n', billing_into.taxpayer_type_n);
                            $(prj_project_bp_ds_id).getAt(0).set('taxpayer_type', billing_into.taxpayer_type);
                            $(prj_project_bp_ds_id).getAt(0).set('invoice_title', billing_into.invoice_title);
                            $(prj_project_bp_ds_id).getAt(0).set('invoice_bp_address', billing_into.invoice_bp_address);
                            $(prj_project_bp_ds_id).getAt(0).set('invoice_bp_phone_num', billing_into.invoice_bp_phone_num);
                            $(prj_project_bp_ds_id).getAt(0).set('invoice_bp_bank', billing_into.invoice_bp_bank);
                            $(prj_project_bp_ds_id).getAt(0).set('invoice_bp_bank_account', billing_into.invoice_bp_bank_account);
                            $(prj_project_bp_ds_id).getAt(0).set('tax_registry_num', billing_into.tax_registry_num);
                            $(prj_project_bp_ds_id).getAt(0).set('ref_v07', billing_into.ref_v07);
675 676 677 678 679 680 681 682 683 684 685 686 687 688

                            //record.set();
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        failure: function () {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function () {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                    //根据承租人查找该承租人的历史合同信息
                    $(prj_project_history_ds_id).setQueryUrl('${/request/@context_path}/autocrud/prj.PRJ501N.prj_project_history_display/query');
689
                    $(prj_project_history_ds_id).setQueryParameter("bp_id", bp_id_tenant);
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
                    $(prj_project_history_ds_id).query();

                    Leaf.Masker.mask(Ext.getBody());
                    $(score_ds_id).getCurrentRecord().set('score_name', value);
                    Leaf.request({
                        url: $('bp_tenant_detail_query_link').getUrl(),
                        para: {
                            bp_id: bp_id_tenant
                        },
                        success: function (res) {
                            var obj = res.result.record;
                            if (obj) {
                                var bp_tenant_detail_r = $(score_ds_id).getCurrentRecord();
                                if (bp_tenant_detail_r) {
                                    for (var key in bp_tenant_detail_r.data) {
                                        if (key != 'bp_detail_id' && key != 'score_name' && key != 'bp_age') {
                                            var vl = obj[key];
                                            if (key == 'bp_birth' && obj[key]) {
                                                vl = new Date(obj[key].toString());
                                            }
                                            if (vl != "null" && vl != "undefined") {
                                                bp_tenant_detail_r.set(key, vl);
                                            }
                                        }
                                    }
                                }
                            }
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        failure: function () {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        error: function () {
                            Leaf.Masker.unmask(Ext.getBody());
                        },
                        scope: this
                    });
                }
728
                if (name == 'legal_person' && value) {
729
                    $(score_ds_id).getCurrentRecord().set('score_name', value);
730
                }
731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
                if (name == 'pay_method') {
                    if (record.get('pay_method') == 'WIRE_TRANSFER') {
                        record.set('bank_account_id', null);
                        record.set('bank_account_id_n', null);
                        record.set('bank_branch_num', '');
                        record.set('bank_account_name', '');
                        record.getField('bank_account_id').setReadOnly(true);
                        record.getField('bank_account_id_n').setReadOnly(true);
                        record.getField('bank_account_id').setRequired(false);
                        record.getField('bank_account_id_n').setRequired(false);
                    } else {
                        record.getField('bank_account_id').setReadOnly(false);
                        record.getField('bank_account_id_n').setReadOnly(false);
                        record.getField('bank_account_id').setRequired(false);
                        record.getField('bank_account_id_n').setRequired(false);
                    }
747

niminmin's avatar
niminmin committed
748
                }
749 750 751 752 753 754 755 756 757 758 759 760
                if (name == 'payment_deduction') {
                    var quoation_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_QUOTATION_N', 'prj_quotation');
                    var quoation_record = $(quoation_ds_id).getCurrentRecord();
                    var down_payment = quoation_record.get('down_payment') || 0;
                    var calc_session_id = quoation_record.get('calc_session_id');
                    var other_payment2;
                    if (value && calc_session_id && value == 'NO_DEDUCTION') {
                        other_payment2 = 0;
                    } else if (value && calc_session_id && value != 'NO_DEDUCTION') {
                        other_payment2 = down_payment;
                    }
                    window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
niminmin's avatar
niminmin committed
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778
                    Leaf.request({
                        url: $('${/parameter/@layout_code}_prj_project_update_status_link_id').getUrl(),
                        para: {
                            other_payment2: other_payment2,
                            calc_session_id: calc_session_id
                        },
                        success: function (arg) {
                            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']();
                        },
                        scope: this

                    });
779
                }
780 781
                if (name == 'bp_id_tenant') {
                    if (!value) {
782 783 784
                        var bp_tenant_detail_r = $(score_ds_id).getCurrentRecord();
                        if (bp_tenant_detail_r) {
                            for (var key in bp_tenant_detail_r.data) {
785
                                bp_tenant_detail_r.set(key, '');
786 787 788 789 790
                            }
                        }
                    }
                    record.getField('bank_account_id').setLovPara('bp_id_tenant', record.get('bp_id_tenant'));
                }
niminmin's avatar
niminmin committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810
                //add by niminmin
                //当“二次租赁”字段选择‘是’时,“回购合同编号”字段为必填。当选择‘否’时,“回购合同编号”字段为只读。
                if (name == 'secondary_lease') {
                    if (value == 'YES') {
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID_prompt').style.display = 'block';
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID').style.display = 'block';
                        record.getField('repur_contract_id').setRequired(true);
                        record.getField('repur_contract_id_n').setRequired(true);
                        record.getField('repur_contract_id').setReadOnly(false);
                        record.getField('repur_contract_id_n').setReadOnly(false);
                    } else if (value == 'NO') {
                        record.getField('repur_contract_id').setRequired(false);
                        record.getField('repur_contract_id_n').setRequired(false);
                        record.getField('repur_contract_id').setReadOnly(true);
                        record.getField('repur_contract_id_n').setReadOnly(true);
                        record.set('repur_contract_id', null);
                        record.set('repur_contract_id_n', null);
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID_prompt').style.display = 'none';
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID').style.display = 'none';
                    }
811 812 813 814
                }
                //新增 “限制金额”字段;
                //“扣款限额”:“租金支付方式”为“建行扣款(三方)”时展示,必填,大于0,默认20万,可修改;
                if (name=='pay_method') {
gzj34291's avatar
gzj34291 committed
815
                    if(value=='CCB_THREE'||value=='CCB_TWO'){
816 817 818 819 820 821 822 823 824 825 826 827
                        document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT_prompt').style.display = 'block';
                        document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT').style.display = 'block';
                        record.getField('deduction_limit').setRequired(true);
                        if(Ext.isEmpty(record.get('deduction_limit'))){
                            record.set('deduction_limit',200000);
                        }
                    }else{
                        record.getField('deduction_limit').setRequired(false);
                        record.set('deduction_limit',null);
                        document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT_prompt').style.display = 'none';
                        document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT').style.display = 'none';
                    }
niminmin's avatar
niminmin committed
828
                }
829 830 831 832 833 834 835 836 837 838 839 840
            }
            if (score_ds_id == ds.id) {
                if (name == 'bp_birth' && value) {
                    if (jsGetAge(value.format('yyyy-mm-dd').toString()) == -1) {
                        Leaf.showInfoMessage("提示", "出生日期不能大于当前日期");
                        setTimeout(function () {
                            record.set('bp_birth', old_value);
                        }, 0);
                    } else {
                        record.set('bp_age', jsGetAge(value.format('yyyy-mm-dd').toString()));
                    }
                }
王炜's avatar
王炜 committed
841 842 843 844 845 846 847 848 849 850
                if(name=='third_guar_score'&&!Ext.isEmpty(value)){
                    if(value<0||value>10){
                        setTimeout(function () {
                            record.set('third_guar_score', '');
                        }, 0);
                        Leaf.showInfoMessage("提示", "第三方担保附件分数范围为0-10,请重新输入!");

                    }
                }

851 852 853 854 855 856 857 858 859 860 861
            }
            var device_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_SCORE_DEVICE', 'bp_tenant_rate_item');
            if (device_ds_id == ds.id) {
                if (name == 'quantity') {
                    if (value <= 0) {
                        Leaf.showInfoMessage("提示", "数量必须大于0");
                        setTimeout(function () {
                            record.set('quantity', old_value);
                        }, 0);
                    }
                }
862
            }
863 864 865 866 867 868 869 870 871
            var bp_code='${/model/user_agent_description/record/@bp_code}';
            if (!Ext.isEmpty(bp_code)){
                // if (bp_code == 'C00010168' || bp_code == 'C00010198' || bp_code == 'C00010170'){
                if (bp_code == 'D00000041' || bp_code =='D00010001' || bp_code=='D00000026') {
                    if (prj_quotation_ds_id == ds.id){
                        if (name == 'price_list' && value){
                            var quotation_record =  $(prj_quotation_ds_id).getCurrentRecord();
                            if ($(prj_project_ds_id).getAt(0).get('business_type') == 'LEASE') {
                                if (value == 'HL_PRICR_E' || value == 'HL_PRICR_EN'){
872 873
                                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'block';
                                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'block';
874 875 876
                                }else{
                                    quotation_record.set('large_balance','NO');
                                    quotation_record.set('large_balance_n','否');
877 878
                                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'none';
                                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'none';
879 880 881 882 883 884
                                }
                            }
                        }
                    }
                }
            }
王炜's avatar
王炜 committed
885 886
            document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'none';
            document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'none';
Spencer Chang's avatar
Spencer Chang committed
887 888
        };

889

Spencer Chang's avatar
Spencer Chang committed
890
        //加载时调用(grid,table,gridBox)
891

892 893
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_load'] = function (ds, record, config_records, bp_seq) {
            var bp_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_BP', 'prj_project_bp');
894 895
            var lease_item_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_LEASE_HEAD_CAR', 'prj_project_lease_item');

gzj34291's avatar
gzj34291 committed
896
            /* var bp_ds_ids = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'],'F_HISTORY_INFO_1', 'prj_project_bp');
897
              $(bp_ds_ids).setQueryParameter('bp_id','${/parameter/@bp_id_tenant}');
gzj34291's avatar
gzj34291 committed
898
              $(bp_ds_ids).query(); */
899 900 901
            if(lease_item_ds_id == ds.id &&lease_item_ds_id){
                var gridId= ds.bindname+'_layout_grid_id';
                if(division=='70'&&division!=''){
gzj34291's avatar
gzj34291 committed
902
                   //debugger;
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935
                    if(record!=''){
                        record.getField('lease_name_n').setRequired(true);
                        record.getField('brand_value').setRequired(true);
                        record.getField('produce_date').setRequired(true);
                        record.getField('using_hour').setRequired(true);
                        record.getField('modelcd').setReadOnly(false);
                        record.getField('modelcd').setRequired(true);
                        record.getField('ownership_flag_n').setRequired(true);
                        record.getField('residual_value_amount').setRequired(true);
                        record.getField('full_name').setRequired(false);
                        record.getField('full_name_n').setRequired(false);
                    }else {
                        record.getField('modelcd').setReadOnly(true);
                    }
                    $(gridId).hideColumn('full_name_n');
                    $(gridId).hideColumn('division_n');
                    $(gridId).hideColumn('equipments');
                    $(gridId).hideColumn('machine_model_class_n');
                    $(gridId).hideColumn('item_type_n');
                    $(gridId).hideColumn('equipment_type_n');
                    $(gridId).hideColumn('machine_number');
                }else if(division!=''){
                    $(gridId).hideColumn('machine_number_70');
                    $(gridId).hideColumn('lease_name_n');
                    $(gridId).hideColumn('brand_value');
                    $(gridId).hideColumn('type_name');
                    $(gridId).hideColumn('produce_date');
                    $(gridId).hideColumn('using_hour');
                    $(gridId).hideColumn('detention_amount');
                    $(gridId).hideColumn('residual_value_amount');
                    $(gridId).hideColumn('ownership_flag_n');
                    $(gridId).hideColumn('created_by_n');
                }
gzj34291's avatar
gzj34291 committed
936 937 938 939 940 941 942 943 944 945
                if (lease_item_ds_id == ds.id && lease_item_ds_id) {
                    if(division=='30'||division=='50'||division=='80'){
                        record.getField('set_number').setRequired(true);
                    }else{
                        record.getField('set_number').setReadOnly(true);
                        if(Ext.isEmpty(record.get('set_number'))){
                            record.set('set_number',1);
                        }
                    }
                }
946
            }
Spencer Chang's avatar
Spencer Chang committed
947 948 949 950 951 952 953 954 955 956
            if (bp_ds_id == ds.id && bp_ds_id) {
                if (record.get('bp_category') == 'TENANT') {
                    record.getField('bp_category_n').setReadOnly(true);
                    record.getField('bp_id_n').setReadOnly(true);
                }
                if (record.get('bp_category') == 'AGENT') {
                    record.getField('bp_category_n').setReadOnly(true);
                    record.getField('bp_id_n').setReadOnly(true);
                }
            }
lijingjing's avatar
lijingjing committed
957

958
        };
lijingjing's avatar
lijingjing committed
959

960 961 962 963 964 965 966 967 968
        function arrToObject(arr) {
            var strJs = '({';
            for (var i = 0; i < arr.length; i += 1) {
                var as = arr[i].split("=");
                strJs = strJs + as[0] + ':' + '"' + as[1] + '"' + ',';
            }
            strJs = strJs.substr(0, strJs.length - 1) + '})';
            return eval(strJs);
        }
969
        var division='';
gzj34291's avatar
gzj34291 committed
970
        //新增和加载时调用(form)
971
        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
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991

            var tenant_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_BASIC_INFO_1', 'prj_project');

            if(tenant_ds_id == ds.id){
                //debugger;
                if (Leaf.isEmpty(record.get('send_message'))){
                    record.set('send_message', 'YES');
                    record.set('send_message_n', '是');
                    record.getField('cell_phone').setRequired(true);
                } else if( record.get('send_message') == 'YES'){
                    record.getField('cell_phone').setRequired(true);
                }

                if (Leaf.isEmpty(record.get('cell_phone'))){
                    record.set('cell_phone', record.get('phone_number'));
                }


            }

992
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
993
            var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
994
            if (ds_id == ds.id && ds_id) {
995
                division=record.get('division');
996
                if (record.get('pay_method') == 'WIRE_TRANSFER') {
25484's avatar
25484 committed
997 998 999 1000
                    record.getField('bank_account_id').setReadOnly(true);
                    record.getField('bank_account_id_n').setReadOnly(true);
                    record.getField('bank_account_id').setRequired(false);
                    record.getField('bank_account_id_n').setRequired(false);
1001
                }
gzj34291's avatar
gzj34291 committed
1002 1003 1004 1005




1006 1007
                //新增 “限制金额”字段;
                //“扣款限额”:“租金支付方式”为“建行扣款(三方)”时展示,必填,大于0,默认20万,可修改;
gzj34291's avatar
gzj34291 committed
1008
                if (record.get('pay_method') == 'CCB_THREE'||record.get('pay_method') == 'CCB_TWO') {
1009 1010 1011 1012 1013 1014 1015 1016
                    document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT_prompt').style.display = 'block';
                    document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT').style.display = 'block';
                    record.getField('deduction_limit').setRequired(true);
                } else {
                    document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_PAY_INFO_PRJ_PROJECT_DEDUCTION_LIMIT').style.display = 'none';
                    record.getField('deduction_limit').setRequired(false);
                }
niminmin's avatar
niminmin committed
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 1042 1043 1044 1045
                if ('${/parameter/@function_usage}' != 'QUERY') {
                    if (record.get('secondary_lease') == 'YES') {
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID_prompt').style.display = 'block';
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID').style.display = 'block';
                        record.getField('repur_contract_id').setRequired(true);
                        record.getField('repur_contract_id_n').setRequired(true);
                        record.getField('repur_contract_id').setReadOnly(false);
                        record.getField('repur_contract_id_n').setReadOnly(false);
                    } else if (record.get('secondary_lease') == 'NO') {
                        record.getField('repur_contract_id').setRequired(false);
                        record.getField('repur_contract_id_n').setRequired(false);
                        record.getField('repur_contract_id').setReadOnly(true);
                        record.getField('repur_contract_id_n').setReadOnly(true);
                        record.set('repur_contract_id', null);
                        record.set('repur_contract_id_n', null);
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID_prompt').style.display = 'none';
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID').style.display = 'none';
                    }
                } else {
                    if (record.get('secondary_lease') == 'YES') {
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID_prompt').style.display = 'block';
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID').style.display = 'block';
                    } else if (record.get('secondary_lease') == 'NO') {
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID_prompt').style.display = 'none';
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_REPUR_CONTRACT_ID').style.display = 'none';
                    }
                }
                //业务类型回租时,默认只读“首付款抵扣”选项
                if (record.get('business_type') == 'LEASEBACK') {
1046 1047 1048 1049
                    //record.set('payment_deduction', 'DOWN_PAYMENT_DEDUCTION');
                    //record.set('payment_deduction_n', "首付款抵扣");
                    //record.getField('payment_deduction').setReadOnly(true);
                    //record.getField('payment_deduction_n').setReadOnly(true);
niminmin's avatar
niminmin committed
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
                    record.set('pay_method', 'WIRE_TRANSFER');
                    record.set('pay_method_n', "电汇");
                    record.getField('pay_method').setReadOnly(true);
                    record.getField('pay_method_n').setReadOnly(true);
                    record.getField('bank_account_id').setReadOnly(true);
                    record.getField('bank_account_id_n').setReadOnly(true);
                    record.getField('bank_account_id').setRequired(false);
                    record.getField('bank_account_id_n').setRequired(false);

                }
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
                //深圳美鹏和hcs显示分公司,其他隐藏
                var bp_code = '${/model/user_agent_description/record/@bp_code}';
                if (!Ext.isEmpty(bp_code) && bp_code !== 'D00010001' && bp_code !== 'D00000009') {
                    record.getField('branch_code').setRequired(false);
                    record.getField('branch_code_n').setRequired(false);
                    if (document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_BRANCH_CODE')) {
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_BRANCH_CODE_prompt').style.display = 'none';
                        document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_BRANCH_CODE').style.display = 'none';
                    }
                }
                if (Ext.isEmpty(bp_code)) {
                    record.getField('branch_code').setRequired(false);
                    record.getField('branch_code_n').setRequired(false);
                }
1074
                //获取员工类型
gzj34291's avatar
gzj34291 committed
1075
                //debugger;
1076 1077 1078
                var description = '${/model/description/record/@employee_type_code}';
                var bp_code='${/model/user_agent_description/record/@bp_code}';
                var credit_record = $(ds_id).getCurrentRecord();
1079 1080 1081 1082
                if(division=='80'){
                    credit_record.set('credit_line','TENANT');
                    credit_record.set('credit_line_n','承租人');
                }
1083 1084
                if(!Ext.isEmpty(description) && description == 'AGENT'){
                    if(!Ext.isEmpty(bp_code)){
王炜's avatar
王炜 committed
1085 1086
                        if(bp_code !== 'D00000026' && bp_code !== 'D00000029' && bp_code !== 'D00000030' && bp_code !== 'D00000031'){
                            if(bp_code =='X00010005' || bp_code =='J00010006'){
1087 1088 1089
                                credit_record.set('credit_line','TENANT');
                                credit_record.set('credit_line_n','承租人');
                                credit_record.getField('credit_line').setReadOnly(true);
1090
                                credit_record.getField('credit_line_n').setReadOnly(true);
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105
                                credit_record.getField('credit_line').setRequired(false);
                                credit_record.getField('credit_line_n').setRequired(false);

                            }else {
                                document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_CREDIT_LINE_prompt').style.display = 'none';
                                document.getElementById('${/parameter/@layout_code}_F_BASIC_INFO_1_PRJ_PROJECT_CREDIT_LINE').style.display = 'none';
                            }
                        }
                    }
                }else {
                    credit_record.getField('credit_line').setReadOnly(true);
                    credit_record.getField('credit_line_n').setReadOnly(true);
                    credit_record.getField('credit_line').setRequired(false);
                    credit_record.getField('credit_line_n').setRequired(false);
                }
1106
            }
1107 1108 1109 1110 1111 1112
            //只读页面隐藏保存按钮
            if('${/parameter/@function_usage}' == 'QUERY'){
                if(document.getElementById('${/parameter/@layout_code}_save')){
                    document.getElementById('${/parameter/@layout_code}_save').style.display = "none";
                }
            }
1113
            if (prj_quotation_ds_id == ds.id && prj_quotation_ds_id){
1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150
                if(division!='70'&&division!=''){
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_CUSTOMER_MARGIN_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_CUSTOMER_MARGIN').style.display = 'none'
                    ;
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_BRAND_VALUE_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_BRAND_VALUE').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_MODELCD_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_MODELCD').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_USING_HOUR_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_USING_HOUR').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_RESIDUAL_VALUE_AMOUNT_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_RESIDUAL_VALUE_AMOUNT').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_OWNERSHIP_FLAG_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_OWNERSHIP_FLAG').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_PRODUCE_DATE_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_PRODUCE_DATE').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_CONTRACT_AMOUNT_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_CONTRACT_AMOUNT').style.display = 'none';
                }else if(division=='70'&&division!=''){
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_OTHER_FEE_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_OTHER_FEE').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_THIRD_PARTY_DEPOSIT_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_THIRD_PARTY_DEPOSIT').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_OTHER_FEE2_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_OTHER_FEE2').style.display = 'none';

                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'none';
                }
1151
                var bp_code = '${/model/user_agent_description/record/@bp_code}';
1152 1153 1154 1155 1156
                if (!Ext.isEmpty(bp_code)){
                    // if (bp_code == 'C00010168' || bp_code == 'C00010198' || bp_code == 'C00010170') {
                    if (bp_code == 'D00000041' || bp_code =='D00010001' || bp_code=='D00000026') {
                        //===============================
                        // var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
1157
                        // var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
1158 1159 1160
                        var quotation_record =  $(prj_quotation_ds_id).getCurrentRecord();
                        if ($(ds_id).getAt(0).get('business_type') == 'LEASE') {
                            if (quotation_record.get('price_list') == 'HL_PRICR_E' || quotation_record.get('price_list') == 'HL_PRICR_EN'){
1161 1162
                                document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'block';
                                document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'block';
1163 1164 1165
                            }else{
                                quotation_record.set('large_balance','NO');
                                quotation_record.set('large_balance_n','否');
1166 1167
                                document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'none';
                                document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'none';
1168 1169 1170
                            }
                        }
                    }else{
1171 1172
                        document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'none';
                        document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'none';
1173 1174
                    }
                }else {
1175 1176
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'none';
1177
                }
1178 1179 1180
            }
            var score_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_TENANT_SCORE_INFO', 'bp_tenant_rate_detail');
            if (score_ds_id == ds.id) {
1181 1182 1183 1184
                if (division != '70' && division != '') {
                    document.getElementById('${/parameter/@layout_code}_F_TENANT_SCORE_INFO_BP_TENANT_RATE_DETAIL_TJ_SCORE_prompt').style.display = 'none';
                    document.getElementById('${/parameter/@layout_code}_F_TENANT_SCORE_INFO_BP_TENANT_RATE_DETAIL_TJ_SCORE').style.display = 'none';
                }
1185 1186 1187 1188 1189
                if (!record.get('score_name')) {
                    if ($(ds_id).getCurrentRecord()) {
                        var score_name = $(ds_id).getCurrentRecord().get('legal_person') || $(ds_id).getCurrentRecord().get('bp_id_tenant_n');
                        record.set('score_name', score_name);
                    }
1190 1191
                }
            }
王炜's avatar
王炜 committed
1192 1193
            document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE_prompt').style.display = 'none';
            document.getElementById('${/parameter/@layout_code}_F_QUOTATION_N_PRJ_QUOTATION_LARGE_BALANCE').style.display = 'none';
Spencer Chang's avatar
Spencer Chang committed
1194 1195 1196 1197 1198 1199 1200 1201 1202
        };

        //pdf预览  add by zhuxianfei
        function view_pdf(attachment_id) {
            Leaf.request({
                url: '${/request/@context_path}/autocrud/fnd.fnd_atm_attachment/query',
                para: {
                    attachment_id: attachment_id
                },
1203
                success: function (res) {
Spencer Chang's avatar
Spencer Chang committed
1204 1205 1206 1207 1208 1209 1210 1211 1212 1213
                    var path = res.result.record.file_path;
                    path = path.substr(path.indexOf('hls_attachment'));
                    var tomcat_source = '${/parameter/@tomcat_source}';
                    var source_path = 'http://' + window.location.host + '/' + tomcat_source + '/' + path;
                    var oWin = window.open(source_path);
                },
                scope: this
            });
        }

lijingjing's avatar
lijingjing committed
1214

1215 1216 1217
        Leaf.onReady(function () {
            var bp_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'T_HISTORY_INGO', 'hls_bp_master');
            var url = '${/request/@context_path}/autocrud/prj.PRJ501N.prj_project_history_display/query?project_id=${/parameter/@project_id}&bp_id=${/parameter/@bp_id}';
lijingjing's avatar
lijingjing committed
1218 1219
            $(bp_ds_id).setQueryUrl(url);
            $(bp_ds_id).query();
niminmin's avatar
niminmin committed
1220 1221
            var quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
            $(quotation_ds_id).query();
1222 1223 1224 1225 1226 1227 1228
            // var billing_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'],'F_INVOICE_INFO', 'prj_project_bp');
            var billing_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');
            var billing_url = '${/request/@context_path}/autocrud/prj.PRJ501N.prj_project_bp/query?project_id=${/parameter/@project_id}';
            $(billing_ds_id).setQueryUrl(billing_url);
            $(billing_ds_id).query();


niminmin's avatar
niminmin committed
1229
        });
lijingjing's avatar
lijingjing committed
1230
        //序号自增  add by lijingjing
1231
        window['${/parameter/@bp_seq}${/parameter/@layout_code}_on_layout_dynamic_grid_add'] = function (ds, record, config_records, bp_seq) {
lijingjing's avatar
lijingjing committed
1232 1233 1234 1235 1236 1237 1238
            //租赁物序号
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
            if (ds_id == ds.id && ds_id) {
                //设置序号
                var measure_records = ds.getAll(),
                    seq_num = 0;
                if (measure_records.length) {
1239
                    for (var j = 0; j < measure_records.length; j++) {
lijingjing's avatar
lijingjing committed
1240 1241 1242 1243 1244 1245 1246 1247 1248
                        var measure_record = measure_records[j],
                            rk = measure_record.get('lease_item_seq');
                        if (seq_num <= rk) {
                            seq_num = rk;
                        }
                    }
                }
                var rk_value = seq_num + 1;
                record.set('lease_item_seq', rk_value);
1249

lijingjing's avatar
lijingjing committed
1250
            }
1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270
            var device_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_SCORE_DEVICE', 'bp_tenant_rate_item');
            var traffic_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'G_SCORE_TRAFFIC', 'bp_tenant_rate_item');
            if ((device_ds_id == ds.id && device_ds_id) || (traffic_ds_id == ds.id && traffic_ds_id)) {
                //设置序号
                var rs = ds.getAll(),
                    seq_num = 0;
                if (rs.length) {
                    for (var j = 0; j < rs.length; j++) {
                        var r = rs[j],
                            rk = r.get('seq_num');
                        if (seq_num <= rk) {
                            seq_num = rk;
                        }
                    }
                }
                var rk_value = seq_num + 1;
                record.set('seq_num', rk_value);

            }

lijingjing's avatar
lijingjing committed
1271
        };
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283
        //indexchange事件(grid,attach,gridbox,table)
        // window['${/parameter/@layout_code}_on_layout_dynamic_grid_indexchange'] = function(ds, record, bp_seq) {
        //     if(!record.get('pattern')){
        //
        //         var nodes=document.querySelectorAll('td[dataindex="machine_number"]');
        //         // var nodes=document.getElementsByClassName('cell-editor-div');
        //         for (var i=1;i<nodes.length;i++){
        //             nodes[i].children[0].style.backgroundColor= "#FAFACD";
        //         }
        //         //  $('.cell-editor-div').parent().css("background-color","yellow");
        //     }
        // };
lijingjing's avatar
lijingjing committed
1284
        //客户评分
1285
        window['${/parameter/@layout_code}_user_button9_layout_dynamic_click'] = function () {
lijingjing's avatar
lijingjing committed
1286

lijingjing's avatar
lijingjing committed
1287 1288 1289
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');

            var record = $(ds_id).getCurrentRecord();
1290 1291 1292 1293 1294 1295 1296 1297
            if (record) {
                var param = record.data;
                if (record.get('project_id')) {
                    param['project_id'] = record.get('project_id');
                    param['winid'] = 'hl_tenant_score_rate_win_id';
                    param['url_title'] = '客户评分明细';
                    var score_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_TENANT_SCORE_INFO', 'bp_tenant_rate_detail');
                    var r = $(score_ds_id).getCurrentRecord();
Darming's avatar
Darming committed
1298
                    if (r.dirty && '${/parameter/@function_usage}' == 'MODIFY') {
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310
                        Leaf.showInfoMessage('提示', '评分数据发生修改,请先保存再进行评分');
                        return;
                    }
                    if ($(ds_id).validate()) {
                        var win = new Leaf.Window({
                            id: param['winid'],
                            params: param,
                            url: $('${/parameter/@layout_code}_tenant_rate_query_link').getUrl(),
                            title: param['url_title'],
                            fullScreen: true,
                            draggable: true
                        });
1311
                        win.on('close', function () {
1312 1313 1314 1315 1316
                            $(ds_id).query();
                        });
                    }
                } else {
                    Leaf.showMessage('${l:PROMPT}', '请先保存');
niminmin's avatar
niminmin committed
1317

lijingjing's avatar
lijingjing committed
1318 1319 1320
                }
            }

1321
        };
lijingjing's avatar
lijingjing committed
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331
        window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
            var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var lease_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_lease_item');
            var quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
            var bp_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project_bp');
            var record = $(quotation_ds_id).getCurrentRecord();
            var current_record = $(ds_id).getCurrentRecord();
            var lease_item_record = $(lease_item_ds_id).getCurrentRecord();
            var bp_record = $(bp_ds_id).getCurrentRecord();
            var project_id = current_record.get('project_id');
1332 1333 1334 1335
            var score_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_TENANT_SCORE_INFO', 'bp_tenant_rate_detail');
            var bp_tenant_detail_r = $(score_ds_id).getCurrentRecord();
            if (bp_tenant_detail_r) {
                for (var key in bp_tenant_detail_r.data) {
1336 1337 1338 1339 1340 1341 1342 1343
                    if(division!='70'){
                        if (key != 'bp_detail_id' && key != 'score_name'&& key != 'contract_id' && key != 'bp_age' && key != 'project_id' && key != 'third_party_credibility' && key != 'third_party_credibility_n'&& key != 'third_guar_score'&& key != 'tj_score' ) {
                            //if (!bp_tenant_detail_r.get(key)) {
                            if (typeof bp_tenant_detail_r.get(key) == "null" || typeof bp_tenant_detail_r.get(key) == "undefined" || bp_tenant_detail_r.get(key) === "") {
                                Leaf.showInfoMessage("提示", "承租人评分信息区域的所有字段,除\"第三方担保附件分数\"外,其他都为必输字段,请填写!");
                                return;
                            }
                        }
gzj34291's avatar
gzj34291 committed
1344

1345 1346 1347 1348 1349 1350 1351
                    }else{
                        if (key != 'bp_detail_id' && key != 'score_name'&& key != 'contract_id' && key != 'bp_age' && key != 'project_id' && key != 'third_party_credibility' && key != 'third_party_credibility_n'&& key != 'third_guar_score' ) {
                            //if (!bp_tenant_detail_r.get(key)) {
                            if (typeof bp_tenant_detail_r.get(key) == "null" || typeof bp_tenant_detail_r.get(key) == "undefined" || bp_tenant_detail_r.get(key) === "") {
                                Leaf.showInfoMessage("提示", "承租人评分信息区域的所有字段,除\"第三方担保附件分数\"外,其他都为必输字段,请填写!");
                                return;
                            }
1352 1353
                        }
                    }
1354

1355 1356
                }
            }
gzj34291's avatar
gzj34291 committed
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382
            if(current_record.get('division')=='70'){
                var bp_number;
                $L.request({
                    url: '${/request/@context_path}/autocrud/prj.PRJ500N.get_bp_address/query',
                    para: {
                        bp_id_tenant: current_record.get('bp_id_tenant')
                    },
                    sync: true,
                    success: function (res) {
                        bp_number=res.result.record.bp_number;
                    },
                    error: function () {

                    },
                    failure: function () {

                    },
                    scope: this,
                    sync: true,
                });

                if( bp_number ==0){
                    Leaf.showMessage('提示','承租人的居住地址不能为空');
                    return ;
                }
            }
lijingjing's avatar
lijingjing committed
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398
            if (current_record.dirty == true) {
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                return;
            }
            if (record.dirty == true) {
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                return;
            }
            if (lease_item_record.dirty == true) {
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                return;
            }
            if (bp_record.dirty == true) {
                Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                return;
            }
1399 1400
            if (record.get('large_balance') == 'YES') {
                var project_number = current_record.get('project_number');
niminmin's avatar
niminmin committed
1401
                Leaf.request({
1402
                    url: $('${/parameter/@layout_code}_principal_eq_pymt_adj_link_n').getUrl(),
1403 1404
                    para: {p_project_number: project_number},
                    scope: this,
niminmin's avatar
niminmin committed
1405
                    success: function (res) {
1406 1407 1408 1409 1410 1411 1412 1413 1414
                        //先查询数量
                        var principal_eq_pymt_adj = res.result.principal_eq_pymt_adj;
                        //根据数量,一个直接查询显示,多个显示空
                        if (principal_eq_pymt_adj == null || principal_eq_pymt_adj == undefined || principal_eq_pymt_adj <= 0) {
                            Leaf.showMessage('${l:PROMPT}', '大额尾款报价需调整且只能调整最后一期租金');
                            return;
                        }else{
                            //验证通过---开始
                            if (current_record.get('business_type') == 'LEASE') {
niminmin's avatar
niminmin committed
1415
                                Leaf.request({
1416
                                    url: $('prj_check_prj_record_link_n').getUrl(),
niminmin's avatar
niminmin committed
1417
                                    para: {
1418
                                        'project_id': project_id
niminmin's avatar
niminmin committed
1419
                                    },
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461
                                    success: function (res) {
                                        var secondary_lease = res.result.secondary_lease;
                                        var payment_deduction = res.result.payment_deduction;
                                        var price_list = res.result.price_list;
                                        var down_payment_rate_new = res.result.down_payment_rate_new;
                                        var H16 = record.get('down_payment');
                                        var H97 = record.get('third_party_deposit');
                                        var H99 = record.get('other_fee');
                                        var H102 = record.get('other_fee2');

                                        var show = down_payment_rate_new * 100;
                                        if ((price_list == 'HL_PRICR_E' || price_list == 'HL_PRICR_TEST' || price_list == 'HL_PRICR_NTEST' || price_list == 'HL_PRICR_EN') && secondary_lease == 'NO') {
                                            if ((div((H16 + H97), (H99 + H102 - H16)).toFixed(2) * 1) < down_payment_rate_new) {
                                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                                Leaf.showMessage('${l:PROMPT}', '首付款比例+首付款保证金比例之和不能低于' + down_payment_rate_new * 100 + '%');
                                                return;
                                            }
                                        }
                                        if ($(ds_id).validate()) {
                                            Leaf.showConfirm('${HLS.PROMPT}', '确认要提交工作流吗?', function () {
                                                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                                                Leaf.request({
                                                    url: $('prj_approval_link_id').getUrl(),
                                                    para: {
                                                        project_id: project_id
                                                    },
                                                    scope: this,
                                                    success: function () {
                                                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                                        $('${/parameter/@winid}').close();
                                                    },
                                                    failure: function () {
                                                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                                    },
                                                    error: function () {
                                                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                                    }
                                                });
                                            });

                                        }

niminmin's avatar
niminmin committed
1462 1463
                                    },
                                    failure: function () {
1464
                                        unlock_calc_current_window('${l:HLS.SAVING}');
niminmin's avatar
niminmin committed
1465 1466
                                    },
                                    error: function () {
1467 1468 1469
                                        unlock_calc_current_window('${l:HLS.SAVING}');
                                    },
                                    scope: this
niminmin's avatar
niminmin committed
1470
                                });
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
                            } else {
                                if ($(ds_id).validate()) {
                                    Leaf.showConfirm('${HLS.PROMPT}', '确认要提交工作流吗?', function () {
                                        window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                                        Leaf.request({
                                            url: $('prj_approval_link_id').getUrl(),
                                            para: {
                                                project_id: project_id
                                            },
                                            scope: this,
                                            success: function () {
                                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                                $('${/parameter/@winid}').close();
                                            },
                                            failure: function () {
                                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                            },
                                            error: function () {
                                                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                            }
                                        });
                                    });
lijingjing's avatar
lijingjing committed
1493

1494 1495 1496 1497
                                }

                            }
                            //验证通过END
1498

1499
                        }
niminmin's avatar
niminmin committed
1500 1501
                    },
                    failure: function () {
1502
                        Leaf.Masker.unmask(Ext.getBody());
niminmin's avatar
niminmin committed
1503 1504
                    },
                    error: function () {
1505 1506
                        Leaf.Masker.unmask(Ext.getBody());
                    }
niminmin's avatar
niminmin committed
1507
                });
1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532
            }else {
                //其他情况正常
                if (current_record.get('business_type') == 'LEASE') {
                    Leaf.request({
                        url: $('prj_check_prj_record_link_n').getUrl(),
                        para: {
                            'project_id': project_id
                        },
                        success: function (res) {
                            var secondary_lease = res.result.secondary_lease;
                            var payment_deduction = res.result.payment_deduction;
                            var price_list = res.result.price_list;
                            var down_payment_rate_new = res.result.down_payment_rate_new;
                            var H16 = record.get('down_payment');
                            var H97 = record.get('third_party_deposit');
                            var H99 = record.get('other_fee');
                            var H102 = record.get('other_fee2');

                            var show = down_payment_rate_new * 100;
                            if ((price_list == 'HL_PRICR_E' || price_list == 'HL_PRICR_TEST' || price_list == 'HL_PRICR_NTEST' || price_list == 'HL_PRICR_EN') && secondary_lease == 'NO') {
                                if ((div((H16 + H97), (H99 + H102 - H16)).toFixed(2) * 1) < down_payment_rate_new) {
                                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                    Leaf.showMessage('${l:PROMPT}', '首付款比例+首付款保证金比例之和不能低于' + down_payment_rate_new * 100 + '%');
                                    return;
                                }
niminmin's avatar
niminmin committed
1533
                            }
1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554
                            if ($(ds_id).validate()) {
                                Leaf.showConfirm('${HLS.PROMPT}', '确认要提交工作流吗?', function () {
                                    window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                                    Leaf.request({
                                        url: $('prj_approval_link_id').getUrl(),
                                        para: {
                                            project_id: project_id
                                        },
                                        scope: this,
                                        success: function () {
                                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                            $('${/parameter/@winid}').close();
                                        },
                                        failure: function () {
                                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                        },
                                        error: function () {
                                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                        }
                                    });
                                });
niminmin's avatar
niminmin committed
1555

1556
                            }
niminmin's avatar
niminmin committed
1557

1558 1559 1560
                        },
                        failure: function () {
                            unlock_calc_current_window('${l:HLS.SAVING}');
lijingjing's avatar
lijingjing committed
1561

1562 1563 1564
                        },
                        error: function () {
                            unlock_calc_current_window('${l:HLS.SAVING}');
lijingjing's avatar
lijingjing committed
1565

1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680
                        },
                        scope: this
                    });
                } else {
                    if ($(ds_id).validate()) {
                        Leaf.showConfirm('${HLS.PROMPT}', '确认要提交工作流吗?', function () {
                            window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                            Leaf.request({
                                url: $('prj_approval_link_id').getUrl(),
                                para: {
                                    project_id: project_id
                                },
                                scope: this,
                                success: function () {
                                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                    $('${/parameter/@winid}').close();
                                },
                                failure: function () {
                                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                },
                                error: function () {
                                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                                }
                            });
                        });

                    }

                }
            }
            // if (current_record.get('business_type') == 'LEASE') {
            //     Leaf.request({
            //         url: $('prj_check_prj_record_link_n').getUrl(),
            //         para: {
            //             'project_id': project_id
            //         },
            //         success: function (res) {
            //             var secondary_lease = res.result.secondary_lease;
            //             var payment_deduction = res.result.payment_deduction;
            //             var price_list = res.result.price_list;
            //             var down_payment_rate_new = res.result.down_payment_rate_new;
            //             var H16 = record.get('down_payment');
            //             var H97 = record.get('third_party_deposit');
            //             var H99 = record.get('other_fee');
            //             var H102 = record.get('other_fee2');
            //
            //             var show = down_payment_rate_new * 100;
            //             if ((price_list == 'HL_PRICR_E' || price_list == 'HL_PRICR_TEST' || price_list == 'HL_PRICR_NTEST' || price_list == 'HL_PRICR_EN') && secondary_lease == 'NO') {
            //                 if ((div((H16 + H97), (H99 + H102 - H16)).toFixed(2) * 1) < down_payment_rate_new) {
            //                     window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //                     Leaf.showMessage('${l:PROMPT}', '首付款比例+首付款保证金比例之和不能低于' + down_payment_rate_new * 100 + '%');
            //                     return;
            //                 }
            //             }
            //             if ($(ds_id).validate()) {
            //                 Leaf.showConfirm('${HLS.PROMPT}', '确认要提交工作流吗?', function () {
            //                     window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            //                     Leaf.request({
            //                         url: $('prj_approval_link_id').getUrl(),
            //                         para: {
            //                             project_id: project_id
            //                         },
            //                         scope: this,
            //                         success: function () {
            //                             window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //                             $('${/parameter/@winid}').close();
            //                         },
            //                         failure: function () {
            //                             window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //                         },
            //                         error: function () {
            //                             window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //                         }
            //                     });
            //                 });
            //
            //             }
            //
            //         },
            //         failure: function () {
            //             unlock_calc_current_window('${l:HLS.SAVING}');
            //
            //         },
            //         error: function () {
            //             unlock_calc_current_window('${l:HLS.SAVING}');
            //
            //         },
            //         scope: this
            //     });
            // } else {
            //     if ($(ds_id).validate()) {
            //         Leaf.showConfirm('${HLS.PROMPT}', '确认要提交工作流吗?', function () {
            //             window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
            //             Leaf.request({
            //                 url: $('prj_approval_link_id').getUrl(),
            //                 para: {
            //                     project_id: project_id
            //                 },
            //                 scope: this,
            //                 success: function () {
            //                     window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //                     $('${/parameter/@winid}').close();
            //                 },
            //                 failure: function () {
            //                     window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //                 },
            //                 error: function () {
            //                     window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            //                 }
            //             });
            //         });
            //
            //     }
            //
            // }
Darming's avatar
Darming committed
1681 1682 1683 1684 1685 1686 1687 1688
        };

        var bp_rate_flag;
        /*保存前调用,生成项目编号*/
        window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function (ds, record) {
            var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var score_ds_id = get_dsid_by_tabcode_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'F_TENANT_SCORE_INFO', 'bp_tenant_rate_detail');
            var bp_tenant_detail_r = $(score_ds_id).getCurrentRecord();
1689
            if (prj_project_ds_id == ds.id && prj_project_ds_id) {
gzj34291's avatar
gzj34291 committed
1690
                if ((record.get('pay_method') == 'CCB_THREE'||record.get('pay_method') == 'CCB_TWO') && record.get('deduction_limit') <= 0) {
1691 1692 1693
                    Leaf.showMessage('${l:HLS.PROMPT}', '扣款限额应大于0');
                    return false;
                }
1694
                if (record.get('signing_city')){
gzj34291's avatar
gzj34291 committed
1695 1696
                   // var reg = /^([\u2E80-\u9FFF]){4,}$/;
                    var reg = /^(.){4,}$/;
1697
                    if (!reg.test(record.get('signing_city'))) {
gzj34291's avatar
gzj34291 committed
1698
                        $L.showErrorMessage('', '建议格式:“xx市xx区”(也可填写详细地址)!');
1699 1700 1701
                        return false;
                    }
                }
1702
            }
Darming's avatar
Darming committed
1703 1704
            if (bp_tenant_detail_r && ds.id == prj_project_ds_id) {
                for (var key in bp_tenant_detail_r.data) {
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725
                    if(division != '70'){
                        if (key != 'bp_detail_id' && key != 'score_name' && key != 'bp_age'&& key != 'contract_id' && key != 'project_id' && key != 'third_party_credibility' && key != 'third_party_credibility_n'&& key != 'third_guar_score'&&key != 'tj_score') {
                            //if (!bp_tenant_detail_r.get(key)) {
                            if (typeof bp_tenant_detail_r.get(key) == "null" || typeof bp_tenant_detail_r.get(key) == "undefined" || bp_tenant_detail_r.get(key) === "") {
                                Leaf.showInfoMessage("提示", "承租人评分信息区域的所有字段,除\"第三方担保附件得分\"外,其他都为必输字段,请填写!");
                                bp_rate_flag = false;
                                break;
                            } else {
                                bp_rate_flag = true;
                            }
                        }
                    }else{
                        if (key != 'bp_detail_id' && key != 'score_name' && key != 'bp_age'&& key != 'contract_id' && key != 'project_id' && key != 'third_party_credibility' && key != 'third_party_credibility_n'&& key != 'third_guar_score') {
                            //if (!bp_tenant_detail_r.get(key)) {
                            if (typeof bp_tenant_detail_r.get(key) == "null" || typeof bp_tenant_detail_r.get(key) == "undefined" || bp_tenant_detail_r.get(key) === "") {
                                Leaf.showInfoMessage("提示", "承租人评分信息区域的所有字段,除\"第三方担保附件得分\"外,其他都为必输字段,请填写!");
                                bp_rate_flag = false;
                                break;
                            } else {
                                bp_rate_flag = true;
                            }
Darming's avatar
Darming committed
1726 1727 1728 1729
                        }
                    }
                }
            }
1730
            if (!bp_rate_flag) {
Darming's avatar
Darming committed
1731 1732 1733 1734 1735
                return false;
            }

            return true;
        };
1736 1737 1738 1739 1740 1741
        //附件打包下载
        window['${/parameter/@layout_code}_ACY_USER_BUTTON1_layout_dynamic_tab_click'] = function () {
            var prj_project_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_project');
            var prj_project_record = $(prj_project_ds_id).getAt(0);
            var project_id = prj_project_record.get('project_id');
            var project_number = prj_project_record.get('project_number');
1742
            var url_l = $('get_atch_download_link').getUrl() + '?table_pk_value=' + project_id + '&table_name=PRJ_PROJECT' + '&doc_code=' + project_number;
1743 1744
            window.open(href = url_l, target = "_self");
        };
lijingjing's avatar
lijingjing committed
1745

Spencer Chang's avatar
Spencer Chang committed
1746 1747 1748 1749
        ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>