prj_project_create_tree.lview 22.4 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 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-6-24 下午03:23:39  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:c="leaf.application.action" xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" customizationEnabled="true" trace="true">
    <a:init-procedure>
        <s:server-script import="aut_authority_validate.js"/>
        <a:model-query fetchAll="true" model="prj.PRJ500.hls_doc_layout_tree_query" rootPath="prj_layout_tree_path"/>
        <a:model-query defaultWhereClause="t1.enabled_flag=&apos;Y&apos; and t1.parent_tree_code is null" fetchAll="true" model="hls.HLS030.hls_doc_layout_tree" rootPath="prj_layout_tree_accordion_path"/>
        <a:model-query defaultWhereClause="t1.parent_table is null and t1.tab_type!=&apos;TAB&apos; and t1.enabled_flag=&apos;Y&apos; and t1.base_table=&apos;PRJ_PROJECT&apos; and rownum=1" fetchAll="true" model="prj.PRJ500.prj_hls_doc_layout_tab_query" rootPath="prj_base_table_path"/>
        <a:model-query fetchAll="true" model="cont.CON500.hls_doc_layout_button" rootPath="layout_main_button_path"/>
    </a:init-procedure>
    <a:view>
        <a:link id="prj_project_create_their_statement_link_id" url="${/request/@context_path}/modules/prj/PRJ500/prj_project_create_their_statement.lview"/>
        <a:link id="prj_project_update_declare_flag_link_id" model="prj.PRJ500.prj_project_update_declare_flag" modelaction="update"/>
        <a:link id="prj_project_application_link_id" url="${/request/@context_path}/modules/prj/PRJ501/print_project_application.lview"/>
        <script src="${/request/@context_path}/javascripts/calculate.js" type="text/javascript"/>
        <script type="text/javascript"><![CDATA[
            var tree_code_list = [],
                currentStep = 0,
                isLoaded = true,
                contentWindow = document.getElementById('mainFrame2_id').contentWindow,
                tree_loading_flag = false,
                first_loading_flag = true;
            
            function prj500_project_save(nextStep) {
                var root_ds = contentWindow.$('${/model/prj_base_table_path/record/@tab_code}_${/model/prj_base_table_path/record/@base_table}_ds');
                if (root_ds.validate()) {
                    lock_tree_window();
                    root_ds.setSubmitParameter('layout_code', '${/parameter/@layout_code}');
                    root_ds.submit();
                }
                root_ds.on('submitsuccess', function(ds, res) {
                    for (var id in contentWindow.$L.CmpManager.cache) {
                        if (contentWindow.$L.CmpManager.cache[id] instanceof contentWindow.$L.DataSet) {
                            if (res.result.document_id) {
                                contentWindow.$(id).setSubmitParameter('document_id', res.result.document_id);
                            }
                            if (id.match(/prj_project_lease_item_ds$/) || id.match(/prj_project_mortgage_ds$/)) {
                                contentWindow.$(id).query();
                            }
                        }
                    }
                    unlock_tree_window();
                    if (typeof(nextStep) == 'function') {
                        nextStep();
                    }
                });
            }
            
            function prj500_project_exit() {
                $('${/parameter/@winid}').close();
            }
            
            function prj500_project_save_exit() {
                prj500_project_save(prj500_project_exit);
            }
            
            function lock_tree_window() {
                Leaf.Masker.mask($('${/parameter/@winid}').wrap, '${l:HLS.EXECUTING}');
            }
            
            function unlock_tree_window() {
                Leaf.Masker.unmask($('${/parameter/@winid}').wrap);
            }
            var ajax_flag = 'N';
            
            function prj500_project_submit() {
                lock_tree_window();
                var confirm_win = Leaf.showConfirm('${HLS.PROMPT}', '${l:HLS.ARE_YOU_SURE_TO_SUBMIT}', function() {
                    ajax_flag = 'Y';
                    Leaf.request({
                        url: '${/request/@context_path}/autocrud/prj.PRJ500.prj_project_submit/update',
                        para: {
                            project_id: '${/parameter/@document_id}'
                        },
                        success: function(res) {
                            unlock_tree_window();
                            parent.Leaf.SideBar.enable = true;
                            parent.Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                            $('${/parameter/@winid}').close();
                        },
                        failure: function() {
                            unlock_tree_window();
                        },
                        error: function() {
                            unlock_tree_window();
                        },
                        scope: this
                    });
                }, function() {
                    unlock_tree_window();
                });
                confirm_win.on('close', function() {
                    if (ajax_flag == 'N') {
                        unlock_tree_window();
                    }
                });
            }
            
            function prj500_project_user_button_1(){
                if('${/parameter/@function_code}'=='PRJ501'){
                     location.href = $('prj_project_application_link_id').getUrl()+"?project_id=${/parameter/@document_id}";
                     $('USER_BUTTON1').disable();
                     $('USER_BUTTON1').setText('正在下载...');
                }
            }
            
            function prj500_define_button(btn) {
                var root_ds = contentWindow.$('${/model/prj_base_table_path/record/@tab_code}_${/model/prj_base_table_path/record/@base_table}_ds');
                contentWindow.prj_define_button(btn, root_ds);
            }
            
            function bind(para) {
                var params = para.split('?');
                var data = [];
                data[0] = params[0];
                for (var i = 1;i < params.length;i++) {
                    data.push(arguments[i] || '?');
                    data.push(params[i]);
                }
                return data.join('');
            }
            
            function linkrenderer(text, record, node) {
                return bind("<span style='cursor:pointer'>?</span>", text);
            }
            
            function on_tree_click(tree, record) {
                if (first_loading_flag) {
                    tree_loading_flag = false;
                }
                if (tree_loading_flag) {
                    Leaf.showMessage('${HLS.PROMPT}', '${l:PRJ501.TREE_CODE_LOADING}');
                    return false;
                }
                tree_loading_flag = true;
                var code = record.get('tree_code');
                if (isLoaded) {
                    jump2(code);
                }
            }
            
            function jump2(id, parentId) {
                mainIFrame2.open_tree_code_child(id, parentId);
            }
            
            function jump(id, acc, index) {
                if (mainIFrame2.open_tree_code) {
                    mainIFrame2.open_tree_code(id, acc, index);
                } else {
                    Ext.get('mainFrame2_id').on('load', function() {
                        if (mainIFrame2) {
                            mainIFrame2.open_tree_code(id, acc, index);
                            page_init = true;
                        }
                    });
                }
            }
            
            function on_accordion_beforeselect(acc, index) {
                var code = acc.bodys.item(index).child('div[_data]').getAttribute('_data');
                if (isLoaded) {
                    if (mainIFrame2.page && mainIFrame2.page[code] && mainIFrame2.page[code].isLoaded) {
                        jump(code);
                    } else {
                        isLoaded = false;
                        jump(code, acc, index);
                        return false;
                    }
                } else {
                    return false;
                }
            }
            
            function prj_statement_confirm() {
                $('statement_info_btn').disable();
                var btn_value = $('label_ds').getAt(0).get('label1');
                if (btn_value == 'Y') {
                    if ('${/parameter/@function_usage}' != 'CREATE') {
                        Leaf.request({
                            url: $('prj_project_update_declare_flag_link_id').getUrl(),
                            para: {
                                project_id: '${/parameter/@document_id}',
                                declare_flag: 'Y'
                            },
                            success: function() {
                                $('statement_info_btn').enable();
                                Ext.get('statement_info').remove();
                            },
                            error: function() {
                                $('statement_info_btn').enable();
                            },
                            failure: function() {
                                $('statement_info_btn').enable();
                            },
                            scope: this
                        });
                    } else {
                        $('statement_info_btn').enable();
                        Ext.get('statement_info').remove();
                    }
                }
            }
            
            function prj_statement_update(ds, record, name, value, oldvalue) {
                var btn = $('statement_info_btn');
                if (name == 'label1') {
                    if (times == 0) {
                        if (value == 'Y') {
                            btn.setText('${l:HLS.CONFIRM}');
                            btn.enable();
                        } else {
                            btn.setText('${l:HLS.CONFIRM_SELECT}');
                            btn.disable();
                        }
                    }
                }
            }
            
            function open_render_window(id, params, url, url_title) {
                new Leaf.Window({
                    id: id,
                    params: params,
                    url: url,
                    title: url_title,
                    fullScreen: true,
                    draggable: true
                });
            }
        ]]></script>
        <style><![CDATA[
	        	#tree_accordion_id .item-accordion-body{
	        		overflow:hidden;
	        	}
	        	#tree_accordion_id .item-accordion .accordion-strip {
	        	    overflow: hidden;
					background-image: url("${/request/@context_path}/resource/leaf.ui.std/hls/toolbar/toolbar_bg.gif");
					text-indent: 5px;
					cursor: pointer;
					height: 24px;
					line-height: 24px;
					border-top: 1px solid #CCCCCC;
				}
	    ]]></style>
        <a:dataSets>
            <a:placeHolder id="dynamicTreeDs_id"/>
            <a:dataSet id="prj_layout_tree_id">
                <a:datas dataSource="/model/prj_layout_tree_path"/>
            </a:dataSet>
            <a:dataSet id="prj_document_update_entrance_ds" autoCreate="true"/>
            <a:dataSet id="prj_layout_tree_statement_id">
                <a:datas dataSource="/model/prj_layout_tree_statement_path"/>
            </a:dataSet>
            <a:dataSet id="label_temp_ds" autoCreate="true"/>
            <a:dataSet id="label_ds" autoCreate="true">
                <a:fields>
                    <a:field name="label1" checkedValue="Y" defaultValue="N" readOnly="true" uncheckedValue="N"/>
                    <a:field name="label2" defaultValue="${l:PRJ501.DUTY_STATEMENT}"/>
                    <a:field name="label3" defaultValue="${l:PRJ501.DUTY_STATEMENT_ONE}"/>
                    <a:field name="label4" defaultValue="${l:PRJ501.DUTY_STATEMENT_TWO}"/>
                    <a:field name="label5" defaultValue="${l:PRJ501.DUTY_STATEMENT_THREE}"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="prj_statement_update"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <div id="statement_info" style="position:absolute;left:0;top:0;width:100%;background:#fff;z-index:999999">
            <a:box style="border:1px solid #ccc;padding:50px 50px 2px 230px;width:100%">
                <a:label name="label2" bindTarget="label_ds" style="font-weight:bold;text-align:center;font-size:180%" width="800"/>
                <a:label name="label3" bindTarget="label_ds" style="font-weight:bold;margin-top:22px;font-size:140%" width="800"/>
                <a:label name="label4" bindTarget="label_ds" style="font-weight:bold;margin-top:25px;font-size:140%" width="800"/>
                <a:label name="label5" bindTarget="label_ds" style="font-weight:bold;margin-top:25px;font-size:140%" width="900"/>
                <a:hBox labelSeparator="" labelWidth="0" style="margin-left:-10px;margin-top:10px">
                    <a:checkBox name="label1" bindTarget="label_ds" prompt=" "/>
                    <a:gridButton id="statement_info_btn" click="prj_statement_confirm" disabled="true" style="margin-top:5px" text="PRJ501.READ_THE_PERFORMANCE_STATEMENT"/>
                </a:hBox>
            </a:box>
        </div>
        <script type="text/javascript"><![CDATA[
            (function() {
                var body = $('${/parameter/@winid}').body;
                if('${/parameter/@declare_flag}'=='Y'){
                    Ext.get('statement_info').remove();
                }else{
	                Ext.fly('statement_info').setHeight(body.setStyle({
	                    display: ''
	                }).getHeight()).setWidth(body.getWidth());
	                body.setStyle({
	                    display: 'none'
	                });
                }
            })();
        ]]></script>
        <a:screenTopToolbar>
            <a:placeHolder id="prj_dynamicButton_id"/>
        </a:screenTopToolbar>
        <TABLE align="center" cellpadding="0" cellspacing="0" width="100%">
            <TR>
                <TD style="vertical-align:top" width="200">
                    <a:accordionPanel id="tree_accordion_id" showIcon="false" width="200">
                        <a:accordions>
                            <a:placeHolder id="dynamicAccordion_id"/>
                        </a:accordions>
                        <a:events>
                            <a:event name="beforeselect" handler="on_accordion_beforeselect"/>
                        </a:events>
                    </a:accordionPanel>
                </TD>
                <TD style="vertical-align:top">
                    <iframe name="mainIFrame2" id="mainFrame2_id" frameborder="0" height="100%" scrolling="no" style="border:none;padding:0px;margin:0px;" width="100%"/>
                    <script type="text/javascript"><![CDATA[
                    var vw,vh;
                    function initSize() {
		                var topBarHeight = 71;
		                var treeWidth = 210;
		                var screenWidth = Leaf.getViewportWidth();
		                var screenHeight = Leaf.getViewportHeight();
		                var bottomHeight = screenHeight - topBarHeight;
		                var bottomWidth = screenWidth - treeWidth;
		                Ext.get('mainFrame2_id').setHeight(bottomHeight);
		                Ext.get('mainFrame2_id').setWidth(bottomWidth);
		                if(Ext.isIE||Ext.isIE9){
		                    vh= bottomHeight;
		                	vw= bottomWidth - 10;
		                }else{
		                    vh= bottomHeight-15;
		                    vw= bottomWidth - 25;
		                }
		            }
		            initSize();
		            $L.Masker.mask(Ext.get('mainFrame2_id'),'${l:HLS.LOADING}');
		            var record;
		            if(!'${/parameter/@document_id}'){
	            		record = $('prj_document_create_entrance_ds').getAt(0);
		            }else{
		                record=$('prj_document_update_entrance_ds').getAt(0);
		            }
		            record.set('layout_code','${/parameter/@layout_code}');
		            record.set('document_category','${/parameter/@document_category}');
		            record.set('document_type','${/parameter/@document_type}');
		            record.set('document_id','${/parameter/@document_id}');
	            	record.set('winid','${/parameter/@winid}');
	            	record.set('calc_type','${/parameter/@calc_type}');
	            	record.set('number_of_tenant','${/parameter/@number_of_tenant}');
	            	record.set('number_of_guarantor','${/parameter/@number_of_guarantor}');
	            	record.set('number_of_actual_controller','${/parameter/@number_of_actual_controller}');
	            	record.set('number_of_quotation','${/parameter/@number_of_quotation}');
	            	record.set('function_usage','${/parameter/@function_usage}');
	            	record.set('function_code','${/parameter/@function_code}');
	            	record.set('cdd_list_id','${/parameter/@cdd_list_id}');
	            	record.set('maintain_type','${/parameter/@maintain_type}');
	            	record.set('default_value_dsid','${/parameter/@default_value_dsid}');
	            	record.set('declare_flag','Y');
	            	record.set('_vh',vh);
	            	record.set('_vw',vw);
	            	$L.post($('prj_project_create_their_statement_link_id').getUrl(),record.getObject(),'mainIFrame2');
	        	]]></script>
                </TD>
                <TD width="25"/>
            </TR>
        </TABLE>
        <script language="javascript"><![CDATA[
            Ext.lib.Event.on(window, "resize",initSize);
            if('${/parameter/@declare_flag}'!='Y'){
	        	var times = 5,
	        	btn = $('statement_info_btn'),
	        	label_record=$('label_ds').getAt(0);
	        	btnInterval = setInterval(function(){
	        		if(--times){
	        			btn.setText('${l:PRJ501.READ_THE_PERFORMANCE_STATEMENT_LEFT}'+times+'${l:PRJ501.SECOND_RIGHT}');
	        		}else{
	        			clearInterval(btnInterval);
	        			btnInterval=null;
	        			btn.setText('${l:HLS.PLEASE_CONFIRM_SELECT}');
	        			label_record.getField('label1').setReadOnly(false);
	        		}
	        	},1000);
	        	$('${/parameter/@winid}').on('close',function(){
	        	    if(btnInterval){
	        	        clearInterval(btnInterval);
	        	        Ext.lib.Event.un(window, "resize",initSize);
	        	    }
	        	});
            }
        ]]></script>
    </a:view>
    <a:view-config>
        <c:create-config targetId="prj_dynamicButton_id">
            <p:loop source="/model/layout_main_button_path">
                <p:switch test="@button_code">
                    <p:case value="SAVE">
                        <c:process-config>
                            <a:gridButton click="prj500_project_save" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="EXIT">
                        <c:process-config>
                            <a:gridButton click="prj500_project_exit" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="SAVE_EXIT">
                        <c:process-config>
                            <a:gridButton click="prj500_project_save_exit" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="SUBMIT_APPROVAL">
                        <c:process-config>
                            <a:gridButton click="prj500_project_submit" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="USER_BUTTON1">
                        <c:process-config>
                            <a:gridButton id="USER_BUTTON1" click="prj500_project_user_button_1" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                    <p:case value="*">
                        <c:process-config>
                            <a:gridButton id="prj500_${@button_code}" click="prj500_define_button" text="${@prompt}"/>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
        <c:create-config targetId="dynamicTreeDs_id">
            <p:loop source="/model/prj_layout_tree_accordion_path">
                <p:switch test="@tree_code">
                    <p:case value="*">
                        <c:process-config>
                            <a:dataSet id="${@layout_code}_${@tree_code}_tree_ds" autoQuery="true" fetchAll="true" queryUrl="${/request/@context_path}/autocrud/prj.PRJ500.hls_doc_layout_accordion_tree/query?layout_code=${/parameter/@layout_code}&amp;parent_tree_code=${@tree_code}"/>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
        <c:create-config targetId="dynamicAccordion_id">
            <p:loop source="/model/prj_layout_tree_accordion_path">
                <p:switch test="@tree_code">
                    <p:case value="*">
                        <c:process-config>
                            <a:accordion prompt="${@tree_desc}" selected="${@expand_boolean_flag}">
                                <script type="text/javascript"><![CDATA[
                            		tree_code_list.push('${@tree_code}');
                            	]]></script>
                                <div _data="${@tree_code}" style="display:none"/>
                                <a:tree bindTarget="${@layout_code}_${@tree_code}_tree_ds" displayField="tree_desc" expandField="expand_flag" idField="tree_code" parentField="parent_tree_code" renderer="linkrenderer" sequenceField="tree_seq" showCheckBox="false" style="margin:8px 0" width="200">
                                    <a:events>
                                        <a:event name="click" handler="on_tree_click"/>
                                    </a:events>
                                </a:tree>
                            </a:accordion>
                        </c:process-config>
                    </p:case>
                </p:switch>
            </p:loop>
        </c:create-config>
    </a:view-config>
</a:screen>