prj_project_print_detail.lview 20.2 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2015-11-4 下午5:28:45  
    $Revision: 1.0  
    $Purpose: 虚拟合同生成文本明细
-->
<a:screen xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="cont.CON500N.bgfl_get_contract_print_file_path" rootPath="contract_file_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="con_contract_content_asset_detail_link_id" url="${/request/@context_path}/modules/cont/CON505/con_contract_content_asset_detail.lview"/>
        <a:link id="con_contract_update_print_fin_link_id" url="${/request/@context_path}/modules/cont/CON500/con_contract_update_print_word.lview"/>
        <a:link id="prj_project_create_content_link_id" model="prj.PRJ506.prj_project_create_content" modelaction="insert"/>
        <a:link id="prj_project_print_dir_link_id" model="prj.PRJ506.prj_project_create_content" modelaction="update"/>
        <a:link id="con_contract_save_print_information_link_id" model="cont.CON505.con_contract_save_print_information" modelaction="update"/>
        <a:link id="get_mapping_xml_svc_link_id" model="cont.CON505.con_contract_save_print_information" modelaction="execute"/>
        <a:link id="con_contract_uploadfile" url="${/request/@context_path}/uploadFile.lview"/>
        <a:link id="con_contract_content_bp_link" model="cont.CON505.con_contract_content_bp_for_lov" modelaction="query"/>
        <a:link id="con543_con_batch_dl_link_id" url="${/request/@context_path}/modules/prj/PRJ506/prj_atm_batch_dl.lsc"/>
        <a:link id="con_contract_dowload_uploadfile_id" url="${/request/@context_path}/modules/cont/CON500/con_atm_batch_dl.lsc"/>
        <script type="text/javascript"><![CDATA[
            function con_print_detail_print() {
                if ($('con_contract_update_print_detail_line_ds').validate(true)) {
                    var records = $('con_contract_update_print_detail_line_ds').getSelected();
                    if (records.length == 0) {
                        Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                        return;
                    }
            
                    // if(Ext.isEmpty(record.get('templet_name')) || Ext.isEmpty(record.get('content_number'))){
                    // Leaf.showMessage('${l:PROMPT}', '合同条款模板和合同文本编号不能为空!');
                    // unlock_current_window();
                    // return;
                    // }
            
                    // if (record.dirty) {
                    // Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
                    // unlock_current_window();
                    // return;
                    // }
            
                    lock_current_window();
                    $('con500_print_btn').disable();
                    for (i = 0;i < records.length;i++) {
                        var record = records[i];
                        var templt_name, clause_usage = record.get('clause_usage'),
                            business_type = '${/parameter/@business_type}',
                            templet_id = record.get('templet_id'),
                            bp_id = record.get('bp_id'),
                            bp_class = record.get('bp_class'),
                            mortgage_id = record.get('mortgage_id') || '',
                            couple_guarantee_flag = record.get('couple_guarantee_flag'),
                            content_number = record.get('content_number'),
                            content_id = record.get('content_id'),
                            bp_name = record.get('bp_name'),
                            prj_bp_id = record.get('prj_bp_id');
                        if (!bp_id) {
                            bp_id = '';
                        }

                        //var file_path = '${/parameter/@file_path}'; /* file_path = file_path+search_term_1; */
                        var file_path = $('contract_file_path_ds').getAt(0).get('contract_file_path');
                        Leaf.request({
                            url: $('prj_project_print_dir_link_id').getUrl(),
                            para: {
                                project_id: '${/parameter/@project_id}',
                                content_id: record.get('content_id'),
                                file_path: file_path,
                                type: 'doc',
                                file_name: content_number + bp_name
                            },
                            success: function() {
            
                                Leaf.request({
                                    url: $('get_mapping_xml_svc_link_id').getUrl(),
                                    para: {
                                        templet_code: record.get('templet_code')
            
                                    },
                                    success: function(res) {

                                        var xml = res.result.mapping_xml;
                                        var svc = res.result.mapping_svc;
            
                                        templt_name = xml;
                                        if (clause_usage == 'FIN') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '融资租赁合同';
                                        } else if (clause_usage == 'GUT' && bp_class == 'ORG') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '保证合同(法人)';
                                        } else if (clause_usage == 'GUT' && bp_class == 'NP') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '保证合同(自然人)';
                                        } else if (clause_usage == 'OWN') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '资产转让合同';
                                        } else if (clause_usage == 'PUR') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '购买合同';
                                        } else if (clause_usage == 'MOR') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '抵押合同';
                                        } else if (clause_usage == 'DEPOSIT') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '保证金合同';
                                        } else if (clause_usage == 'COA') {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '';
                                        } else {
                                            //templt_name = 'fin_contract.xml';
                                            con_name = '';
                                        }
                                        //存入数据库的名称
                                        var timestamp = Date.parse(new Date());
                                        var url = '${/request/@context_path}/' + svc + '?templt_name=' + templt_name + '&file_name=' + timestamp + '&file_path=' + file_path + '&project_id=${/parameter/@project_id}&clause_usage=' + clause_usage + '&templet_id=' + templet_id + '&content_id=' + content_id + '&bp_id=' + bp_id + '&prj_bp_id=' + prj_bp_id;
                                        window.open(url, '', '_self', 'false');
                                        unlock_current_window();
            
                                    },
                                    scope: this,
                                    sync: true
            
                                });
                                /*
                                 var url = $('con_contract_update_print_fin_link_id').getUrl() + '?templt_name=' + templt_name + '&file_name=' + search_term_1 + content_number + bp_name + '&file_path=' + file_path + '&contract_id=${/parameter/@contract_id}&clause_usage=' + clause_usage + '&templet_id=' + templet_id + '&content_id=' + content_id + '&bp_id=' + bp_id + '&con_contract_bp_id=' + con_contract_bp_id;
                                 window.open(url);
                                 unlock_current_window();
                                 var form = document.createElement("form");
                                 form.target = "word_export_window";
                                 form.method = "post";
                                 form.action = url;
                                 var iframe = Ext.get('word_export_window') || new Ext.Template('<iframe id ="word_export_window" name="word_export_window" style="position:absolute;left:-10000px;top:-10000px;width:1px;height:1px;display:none"></iframe>').insertFirst(document.body, {}, true);
                                 document.body.appendChild(form);
                                 form.submit();
                                 Ext.fly(form).remove(); */
            
                            },
                            failure: function() {
                                unlock_current_window();
                            },
                            error: function() {
                                unlock_current_window();
                            },
                            scope: this,
                            sync: true
                        });
                    }
                    $('con_contract_update_print_detail_line_ds').query();
                    $('con500_print_btn').enable();
                }
            }
            
            function lock_current_window() {
                Leaf.Masker.mask($('${/parameter/@winid}').wrap, '${l:HLS.EXECUTING}');
            }
            
            function unlock_current_window() {
                Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
            }
            
            function con_print_detail_create() {
                lock_current_window();
                Leaf.request({
                    url: $('prj_project_create_content_link_id').getUrl(),
                    para: {
                        project_id: '${/parameter/@project_id}'
                    },
                    success: function(res) {
                        var result_ds = $('con_contract_update_print_detail_line_ds');
                        result_ds.query(result_ds.currentPage);
                        unlock_current_window();
                    },
                    error: function() {
                        unlock_current_window();
                    },
                    failure: function() {
                        unlock_current_window();
                    },
                    scope: this
                });
            }
            
            function on_result_load(ds) {
                var records = ds.getAll();
                for (var i = 0;i < records.length;i++) {
                    var record = records[i];
                }
            }
            
            function update_attachment_renderer(value, record, name) {

                var content_id = record.get('content_id');
                var record_id = record.id;
                   return '<a href="javascript:downloadfile_link(' + content_id + ',\''+record_id+'\')">下载</a>';                 
            }
            
            function downloadfile_link(content_id,record_id) {
                var res = $('con_contract_update_print_detail_line_ds').findById(record_id);
                var content_print_flag = res.get('content_print_flag');
                if(content_print_flag =='Y' ){  
                   var url = $('con543_con_batch_dl_link_id').getUrl() + '?content_id=' + content_id + '&contract_id=' + '${/parameter/@contract_id}' + '&content_type=' + '${/parameter/@content_type}';
                window.open(url, '_self'); 
                }else{
                    Leaf.showMessage('${l:PROMPT}', '合同文本未生成!');
                    return;
                } 
            }
            
            function con_download_zip() {
                var url = $('con543_con_batch_dl_link_id').getUrl() + '?contract_id=' + '${/parameter/@contract_id}';
                window.open(url, '_self');
            }
            
            function con500_delete_print() {
                $('con_contract_update_print_detail_grid_1').remove();
            }
            
            function detail_upload_window(record_id) {
            
                var url = $('con_contract_uploadfile').getUrl() + '?table_name=CON_CONTRACT_CONTENT_V&header_id=' + record_id;
                var win = new Leaf.Window({
                    url: url,
                    title: '${l:HLS.SUPPORTING_DOCUMENT}',
                    id: 'insurance_records_uploadFile_id',
                    width: 850,
                    height: 400
                });
                win.on('close', function() {
                    $('con_contract_update_print_detail_line_ds').query();
                });
            }
            
            function attachment_upload(val, rec, name) {
                return '<a href=javascript:detail_upload_window(' + rec.get('content_id') + ')>附件上传</a>';
            }
            
            window['con500_link_render'] = function(value, record, 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] + ' ref="img">' + temp[0] + '</a>' + ',';
                        }
                    }
                    return url;
                }
            };
            
            function con_download_zip() {
            
                var project_id = $('con_contract_update_print_detail_line_ds').getAt(0).get('project_id');
                var doc_code = '合同文本附件';
                var url_l = $('con543_con_batch_dl_link_id').getUrl() + '?project_id=' + project_id + '&doc_code=' + encodeURI(doc_code) + '&type=ZIP';
            
                window.open(href = url_l, target = "_self");
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="basic_clause_tmplet_usage_ds" lookupCode="CON_TMPLET_USAGE"/>
            <a:dataSet id="contract_file_path_ds">
                <a:datas dataSource="/model/contract_file_path"/>
            </a:dataSet>
            <a:dataSet id="con_contract_update_print_detail_header_ds" autoQuery="true" model="prj.PRJ506.prj_project_create_content" queryUrl="${/request/@context_path}/autocrud/prj.PRJ506.prj_project_create_content/query?project_id=${/parameter/@project_id}">
                <a:fields>
                    <a:field name="virtual_con_number" readOnly="true"/>
                    <a:field name="contract_name" readOnly="true"/>
                    <a:field name="project_name" readOnly="true"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con_contract_update_print_detail_line_ds" autoQuery="true" queryUrl="${/request/@context_path}/autocrud/prj.PRJ506.prj_project_content_v/query?project_id=${/parameter/@project_id}" selectable="true" selectionModel="single" submitUrl="${/request/@context_path}/modules/prj/PRJ506/con_contract_content_save.lsc">
                <a:fields>
                    <a:field name="bp_name" lovGridHeight="350" lovHeight="500" lovLabelWidth="100" lovService="cont.CON505.con_contract_content_bp_for_lov?contract_id=${/parameter/@contract_id}" lovWidth="550" required="true" title="HLS.BP_TITLE">
                        <a:mapping>
                            <a:map from="record_id" to="con_contract_bp_id"/>
                            <a:map from="bp_name" to="bp_name"/>
                            <a:map from="bp_category" to="bp_category"/>
                            <a:map from="bp_category_desc" to="bp_category_desc"/>
                            <a:map from="bp_class" to="bp_class"/>
                            <a:map from="bp_class_desc" to="bp_class_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="clause_usage_name" displayField="code_value_name" options="basic_clause_tmplet_usage_ds" required="true" returnField="clause_usage" valueField="code_value"/>
                    <a:field name="clause_usage"/>
                    <a:field name="templet_name" lovGridHeight="350" lovHeight="500" lovService="basic.con_clause_templet_for_lov" lovWidth="500" title="CON505.CON_CONTENT_TEMPLET_NAME">
                        <a:mapping>
                            <a:map from="templet_id" to="templet_id"/>
                            <a:map from="description" to="templet_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="content_number"/>
                    <a:field name="available_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="print_date" datatype="java.util.DATE"/>
                </a:fields>
                <a:events>
                    <a:event name="load" handler="on_result_load"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar style="width:848px">
                <a:gridButton click="con_print_detail_create" text="CON505.CON_CONTENT_CREATE"/>
                <a:gridButton id="con500_print_btn" click="con_print_detail_print" text="PRJ702.GENERATE_THE_FILE"/>
                <!-- <a:gridButton click="con_download_zip" text="打包下载"/> -->
                <a:gridButton click="con500_delete_print" text="HLS.REMOVE"/>
            </a:screenTopToolbar>
            <a:form column="2" title="CON505.CON_CONTENT_PRINT" width="900">
                <a:textField name="virtual_con_number" bindTarget="con_contract_update_print_detail_header_ds" prompt="HLS.CONTRACT_NUMBER"/>
                <a:textField name="project_name" bindTarget="con_contract_update_print_detail_header_ds" prompt="HLS.CONTRACT_NAME" width="330"/>
            </a:form>
            <a:grid id="con_contract_update_print_detail_grid_1" bindTarget="con_contract_update_print_detail_line_ds" height="300" navBar="true" width="930">
                <a:columns>
                    <a:column name="content_number" prompt="CON505.CON_CONTENT_NUMBER" width="200"/>
                    <!-- <a:column name="clause_usage_name" prompt="HLS.CONTRACT_USAGE"/> -->
                    <!--  <a:column name="ref_n05" align="right" prompt="PRJ702.NUMBER_OF_COPIES" width="70"/> -->
                    <a:column name="print_date" prompt="PRJ702.FILE_GENERATED_DATE" renderer="Leaf.formatDate" width="80"/>
                    <!-- <a:column name="bp_class_desc" prompt="HLS.BP_CLASS"/> -->
                    <!-- <a:column name="asset_detail" align="center" prompt="CON505.CON_CONTENT_ASSET_DETAIL" renderer="see_asset_detail_renderer"/> -->
                    <!-- <a:column name="templet_name" editor="print_detail_grid_lov_id" prompt="CON505.CON_CONTENT_TEMPLET_NAME"/> -->
                    <a:column name="bp_name" prompt="HLS.BP_NAME"/>
                    <a:column name="bp_category_desc" prompt="HLS.BP_CATEGORY"/>
                    <a:column name="content_print_flag_name" prompt="CON505.CON_CONTENT_STATUS" width="80"/>
                    <a:column name="attachment" align="center" prompt="HLS.ATTACHMENT" renderer="update_attachment_renderer" width="50"/>
                    <a:column align="center" prompt="附件上传" renderer="attachment_upload" width="80"/>
                    <a:column name="file_name" align="left" prompt="附件名" renderer="con500_link_render" width="220"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>