sdic_other_contract_wfl.lview 25 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2016-1-6 上午11:04:17  
    $Revision: 1.0  
    $Purpose:其他业务明细
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true" trace="true">
    <a:view>
        <a:link id="sdic100d_con_contract_get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
        <a:link id="sdic100d_get_special_fields_link_id" model="cont.CON500.con_contract_get_special_fields" modelaction="update"/>
        <a:link id="hls_bp_master_modify_link" url="${/request/@context_path}/modules/hls/HLS214N/hls_bp_master_modify.lview"/>
        <a:link id="sdic100d_cdd_uploadFile_id" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="sdic100d_cdd_downloadFile_id" url="${/request/@context_path}/downloadFile.lview"/>
        <a:link id="sdic100d_submit_other_contract_link_id" model="sdic.SDIC100.submit_other_contract" modelaction="update"/>
        <a:link id="sdic100d_con_cf_info_upload_link_id" url="${/request/@context_path}/modules/sdic/SDIC100/other_con_cf_info_upload.lview"/>
        <a:link id="sdic120d_contract_close_link_id" model="sdic.SDIC120.sdic_other_con_close" modelaction="update"/>
        <a:link id="sdic100d_other_con_get_base_rate" model="sdic.SDIC100.other_con_get_base_rate" modelaction="query"/>
        <script type="text/javascript"><![CDATA[
          //excel导入
          window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function() {
              var head_record_ds=get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'sdic_other_contract');
              var head_record=$(head_record_ds).getAt(0);
              var cf_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'sdic_other_contract_cf');
                var url_l = $('sdic100d_con_cf_info_upload_link_id').getUrl();
                if(head_record.get('contract_id')){
                 var win = new Leaf.Window({
                        id: 'other_con_cf_info_handle_win',
                        url: url_l,
                        params: {
                            'contract_id':head_record.get('contract_id'),
                            'winid': 'other_con_cf_info_handle_win',
                            'session_id': '${/session/@session_id}',
                            'parent_ds_id': cf_ds
                        },
                        title: '应收应付导入',
                        width: 430,
                        height: 290
                    });
                    win.on('close', function() {
                        $(cf_ds).setQueryParameter('contract_id',head_record.get('contract_id'));
                        $(cf_ds).query();
                    });
                    }else{
                       Leaf.showMessage('${l:HLS.PROMPT}', '请先保存数据!');
                    return;
                    }
          };
           //关闭合同
           window['${/parameter/@layout_code}_user_button2_layout_dynamic_click'] = function() {
              var head_record_ds=get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'sdic_other_contract');
              var head_record=$(head_record_ds).getAt(0);
              Leaf.showConfirm('${HLS.PROMPT}', '确认关闭当前合同吗?', function() {
              Leaf.request({
                    url: $('sdic120d_contract_close_link_id').getUrl(),
                    para: {
                        contract_id: head_record.get('contract_id')
                    },
                    success: function(res) {
                        
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                         Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                        $('${/parameter/@winid}').close();
                    },
                    error: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    }
                });
                 }, function() {
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                });
          }
          
        
          //保存前调用,生成单据编号
            window['${/parameter/@layout_code}_on_layout_dynamic_before_submit'] = function(ds, record) {
                window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                var check_flag = false;
                if (record.get('contract_number')) {
                    $('${/parameter/@layout_code}_virtual_ds').setSubmitParameter('document_id', record.get('contract_id'));
                $('${/parameter/@layout_code}_virtual_ds').setSubmitParameter('document_category', 'OTHER_CONTRACT');
                    return true;
                }
                Leaf.request({
                    url: $('sdic100d_get_special_fields_link_id').getUrl(),
                    para: {
                        document_category: record.get('document_category'),
                        document_type: record.get('document_type')
                    },
                    success: function(res) {
                        var document_number = res.result.document_number;
                        record.set('contract_number', document_number);
                        check_flag = true;
                    },
                    error: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    failure: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                    },
                    sync: true,
                    scope: this
                });
                
                return check_flag;
            };
             
             //商业伙伴信息
             function opwn_bp_more_info(name, record_id) {
                var bp_ds = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'sdic_other_contract_bp');
                var bp_record = $(bp_ds).findById(record_id);
                var param = bp_record.data;
                param['document_id'] = bp_record.get('bp_id');
                param['cond_para2'] = bp_record.get('bp_type');
                param['function_code'] = 'HLS306';
                param['function_usage'] = 'QUERY';
                param['url_title'] = '${l:HLS212.BP_MASTER_MAINTAIN}';
                hls_doc_get_layout_code('sdic100d_con_contract_get_layout_code_link_id', param, 'hls_bp_master_modify_link');
            }
            
            //报价
             function quote_link(name, record_id,query_only) {
                window['${/parameter/@layout_code}_lock_layout_dynamic_window'];
                var head_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'sdic_other_contract');
                var head_record = $(head_ds_id).getAt(0);
                var prj_quotation_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_quotation');
                //var prj_quotation_record = $(prj_quotation_ds_id).getCurrentRecord();
                var prj_quotation_record = $(prj_quotation_ds_id).findById(record_id);
                var calc_recreate_L_formula;
                var saveData = [];
                if(query_only=='Y'){
                     url = $('${/parameter/@layout_code}_hls_fin_calculator_readonly_link_id').getUrl();
                    new Leaf.Window({
                        id: '${/parameter/@layout_code}_hls_fin_calc_readonly_link_winid',
                        params: {
                            document_id:  head_record.get('contract_id'),
                            document_category: head_record.get('document_category'),
                            maintain_type: 'READONLY',
                            calc_session_id: prj_quotation_record.get('calc_session_id'),
                            winId: '${/parameter/@layout_code}_hls_fin_calc_readonly_link_winid',
                            global_flag: 'Y',
                            calc_type: 'CLASSIC_CALCULATOR'
                        },
                        url: url,
                        fullScreen: true,
                        draggable: true
                    });
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window'];
                    return;
                }else{
                    url = $('${/parameter/@layout_code}_hls_fin_calculator_update_link_id').getUrl();
              
                prj_quotation_record.set('to_doc_table', 'HLS_FIN_CALCULATOR_HD');
                prj_quotation_record.set('function_code', '${/parameter/@function_code}');
                prj_quotation_record.set('function_usage', '${/parameter/@function_usage}');
                prj_quotation_record.set('document_id', head_record.get('contract_id'));
            
                if (prj_quotation_record.get('quotation_id') && !prj_quotation_record.get('calc_session_id')) {
                    calc_recreate_L_formula = 'Y';
                    prj_quotation_record.set('_status', 'update');
                } else if (prj_quotation_record.get('quotation_id') && prj_quotation_record.get('calc_session_id')) {
                    calc_recreate_L_formula = 'N';
                    prj_quotation_record.set('_status', 'execute');
                } else if (!head_record.get('contract_id')) {
                    Leaf.showMessage('${l:HLS.PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                    return;
                } else {
                    calc_recreate_L_formula = 'Y';
                    prj_quotation_record.set('_status', 'insert');
                }
            
                prj_quotation_record.set('from_doc_table', 'PRJ_QUOTATION');
                prj_quotation_record.set('from_doc_pk', prj_quotation_record.get('quotation_id'));
                prj_quotation_record.set('calculate_flag', 'N');
                saveData.push(prj_quotation_record.data);
                Leaf.request({
                    url: $('${/parameter/@layout_code}_hls_fin_doc_quotation_link_id').getUrl(),
                    para: saveData,
                    success: function(res) {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window'];
                        var quotation_id = prj_quotation_record.get('quotation_id') || res.result.quotation_id;
                        var win = new Leaf.Window({
                            id: '${/parameter/@layout_code}_hls_fin_calc_quotation_link_winid',
                            params: {
                                document_id: head_record.get('contract_id'),
                                document_category: '${/parameter/@document_category}',
                                maintain_type: '${/parameter/@maintain_type}',
                                calc_session_id: res.result.record.calc_session_id,
                                quotation_id: quotation_id,
                                dsId: prj_quotation_ds_id,
                                winId: '${/parameter/@layout_code}_hls_fin_calc_quotation_link_winid',
                                global_flag: 'Y',
                                id_num: 0,
                                calc_type: 'CLASSIC_CALCULATOR',
                                recreate_L_formula: calc_recreate_L_formula
                            },
                            url: url,
                            // title: '${l:HLS.FIN_CALCULATOR}',
                            fullScreen: true,
                            draggable: true
                        });
                        win.on('close', function() {
                            $(prj_quotation_ds_id).setQueryParameter('contract_id', head_record.get('contract_id'));
                            //$(hls_fin_calculator_ln_ds_id).setQueryParameter('project_id', project_id);
                            $(prj_quotation_ds_id).query();
                            //$(hls_fin_calculator_ln_ds_id).query();
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window'];
                        });
                    },
                    failure: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window'];
                    },
                    error: function() {
                        window['${/parameter/@layout_code}_unlock_layout_dynamic_window'];
                    },
                    scope: this
                });
                }
            }
            
              //保存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'], 'sdic_other_contract');
                var cdd_item_ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'prj_cdd_item_doc_ref');
                if (ds_id && cdd_item_ds_id) {
                    record = $(ds_id).getAt(0);
                    var prj_cdd_item_doc_ref_ds = $(cdd_item_ds_id);
                    prj_cdd_item_doc_ref_ds.setQueryParameter('cdd_list_id', record.get('cdd_list_id'));
                    prj_cdd_item_doc_ref_ds.query();
                }
                window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
            
            };
            
            function upload_file(id, name, query_only) {
                var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
                if (record.get('check_id')) {
                    var url;
                    if (query_only == 'Y') {
                        url = $('sdic100d_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                    } else {
                            url = $('sdic100d_cdd_downloadFile_id').getUrl() + '?table_name=PRJ_CDD_ITEM_CHECK&header_id=' + record.get('check_id');
                       // url = $('sdic100d_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}', '请先保存!');
            
                }
            };
           
            //超链接渲染
            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 === 'more' && !record.isNew) {
                    return '<a href="javascript:opwn_bp_more_info(\'' + name + '\',\'' + record.id + '\')">明细</a>';
                } else if (name === 'quote' && !record.isNew){
                     return '<a href="javascript:quote_link(\'' + name + '\',\'' + record.id + '\',\'' + config_record.get('query_only') + '\')">报价</a>';
                }if (name == 'attachment') {
                    link_function = 'upload_file';
                    if (record.get('attach_count') == 0 || !record.get('attach_count')) {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '</a>';
                    } else {
                        return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + config_record.get('prompt') + '(' + record.get('attach_count') + ')' + '</a>';
                    }
                } else if (name == 'attach_file_name') {
                    if (value != null) {
                        var link = '${/request/@context_path}/atm_download.lsc?attachment_id=';
                        var str = value.split(';;');
                        var url = '';
                        for (var i = 0;i < str.length;i++) {
                            var temp = str[i].split('--');
                            if (!Leaf.isEmpty(temp[0])) {
                                url = url + '<a href=' + link + temp[1] + '>' + temp[0] + '</a>' + ',';
                            }
                        }
                        return url;
            
                    }
                } else {
                    return '';
                } 
            };     
           
               window['${/parameter/@layout_code}_submit_approval_layout_dynamic_click'] = function() {
                 window['${/parameter/@layout_code}_SAVE_LAYOUT_DYNAMIC_CLICK'](submit_wfl);
                 
            };
           
            //提交审批
             function submit_wfl(){
               
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'sdic_other_contract');
                var head_record = $(ds_id).getAt(0);
                Leaf.showConfirm('${HLS.PROMPT}', '确认提交审批吗?', function() {
                     window['${/parameter/@layout_code}_lock_layout_dynamic_window']();
                    Leaf.request({
                        url: $('sdic100d_submit_other_contract_link_id').getUrl(),
                        para: {
                            contract_id: head_record.get('contract_id')
                        },
                        success: function(res) {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                            Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            $('${/parameter/@winid}').close();
                        },
                        failure: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        error: function() {
                            window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                        },
                        scope: this
                    });
                }, function() {
                    window['${/parameter/@layout_code}_unlock_layout_dynamic_window']();
                });
             }
             
              //更新时调用
            window['${/parameter/@layout_code}_on_layout_dynamic_update'] = function(ds, record, name, value, old_valuess) {
                var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'sdic_other_contract');
                if (ds.id == ds_id) {
                    //获取基准利率
                    if (name == 'base_rate_type' || name == "contract_start_date" || name == "contract_end_date" || name == 'interest_period') {
                        if (record.get('base_rate_type') && (name == 'base_rate_type' || name == "contract_start_date" || name == "contract_end_date") && (record.get('base_rate_type') == 'FIXED' || record.get('base_rate_type') == 'PBOC' || record.get('base_rate_type') == 'LPR')) {
                            if (record.get('contract_start_date') && record.get('contract_end_date') && record.get('base_rate_type')) {
            
                                Leaf.request({
                                    url: $('sdic100d_other_con_get_base_rate').getUrl(),
                                    para: {
                                        base_rate_type: record.get('base_rate_type'),
                                        loan_date_to: record.get('contract_end_date'),
                                        loan_date_from: record.get('contract_start_date'),
                                        currency: record.get('currency')
                                    },
                                    success: function(data) {
                                        if (data.result.record && !data.result.record.length) {
                                            record.set('base_rate', data.result.record.base_rate);
                                        } else {
                                            record.set('base_rate', '');
                                        }
            
                                    },
                                    failure: function() {
            
                                       },
                                    error: function() {
            
                                       },
                                    scope: this
                                });
                            }
                        } else if (record.get('base_rate_type') && (name == 'base_rate_type' || name == "interest_period" || name == 'contract_start_date')) {
                            if (record.get('interest_period') && record.get('base_rate_type') && record.get('contract_start_date')) {
                                Leaf.request({
                                    url: $('sdic100d_other_con_get_base_rate').getUrl(),
                                    para: {
                                        base_rate_type: record.get('base_rate_type'),
                                        interest_period: record.get('interest_period'),
                                        loan_date_from: record.get('contract_start_date'),
                                        loan_date_to: record.get('contract_end_date'),
                                        currency: record.get('currency')
                                    },
                                    success: function(data) {
                                        if (data.result.record && !data.result.record.length) {
                                            record.set('base_rate', data.result.record.base_rate);
                                        } else {
                                            record.set('base_rate', '');
                                        }
            
                                    },
                                    failure: function() {
            
                                       },
                                    error: function() {
            
                                       },
                                    scope: this
                                });
            
                            }
                        }
                    }
                    //获取利率
                    if (name == 'base_rate' || name == "int_rate_fixing_way" || name == 'int_rate_fixing_range') {
                        
                        if ((record.get('base_rate') || record.get('base_rate') == 0) && record.get('int_rate_fixing_way') && record.get('int_rate_fixing_range')) {
                            var int_rate = 0;
                            //下调
                            if (record.get('int_rate_fixing_way') == 'DECREASE') {
                                record.set('int_rate', minus(record.get('base_rate'), record.get('int_rate_fixing_range')));
                                //上调
                            } else if (record.get('int_rate_fixing_way') == 'PLUS') {
                                record.set('int_rate', plus(record.get('base_rate'), record.get('int_rate_fixing_range')));
                                //下浮
                            } else if (record.get('int_rate_fixing_way') == 'FLOATING_DOWNWARD') {
                                record.set('int_rate', mul(record.get('base_rate'), minus(1, record.get('int_rate_fixing_range'))));
                            }
                            //上浮
                            else if (record.get('int_rate_fixing_way') == 'MUTIPLY') {
                                record.set('int_rate', mul(record.get('base_rate'), plus(1, record.get('int_rate_fixing_range'))));
                            }
                            if(record.get('int_rate')<0){
                                Leaf.showMessage('提示','注意合同利率为负数');
                            }
                        }
                    }
            
            
                }
            };
  ]]></script>
        <a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
    </a:view>
</a:screen>