fnd_concurrent_request.lview 12.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
<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="fnd_concurrent_request_log_link" url="${/request/@context_path}/modules/fnd/FND5030/fnd_concurrent_request_log.lview"/>
        <a:link id="fnd_concurrent_request_job_log_link" url="${/request/@context_path}/modules/fnd/FND5030/fnd_concurrent_request_job_log.lview"/>
        <script type="text/javascript"><![CDATA[
            
            function queryResultDs() {
                $('requestResultDs').query();
            }
            
            function resetParaDs() {
                $('requestParaDs').reset();
            }
            
            function openRequestWin() 
            {
                new Leaf.Window({
                    id: 'fnd_concurrent_request_create_window',
                    url: 'fnd_concurrent_request_create.lview',
                    title: '请求创建',
                    height: 520,
                    width: 600
                });
            }
            //定义操作:
            //SLEEP:暂挂|WAKE:恢复|DELETE:删除|RUN:执行
            var operation=
            {
                SLEEP:
                {
                    name:'暂挂',
                    validateStatus:
                    {
                        RUNNING:true,
                    	OTHERS:'只有处于运行状态的请求才能被暂挂,请查证!'
                    }
                },
                WAKE:
                {
                    name:'恢复',
                    validateStatus:
                    {
                        SLEEP:true,
                    	OTHERS:'只有处于挂起状态的请求才能被恢复,请查证!'
                    }
                    
                },
                DELETE:
                {
                    name:'删除',
                    validateStatus:
                    {
                        DELETE:'该请求已经处于删除状态,请查证!',
	                 	FINISH:'该请求已经处于完成状态,请查证!',
	                 	OTHERS:true   
                    }
                },
                RUN:
                {
                    name:'执行',
                    validateStatus:
                    {
	                    DELETE:'删除状态的请求不能运行,请查证!',
	                    FINISH:'完成状态的请求不能运行,请查证!',
	                    OTHERS:true
                    }
                }
            };
            //校验状态
            function validateJobPara(p_operation,p_type,p_status,p_circle_or_not)
            {
                if(p_circle_or_not=='N')
                {
                    return '您所选的请求中包含非周期性的请求,请查证!';
                }
                else
                {
                    var temp=p_operation[p_type]['validateStatus'];
                    var value=temp[p_status];
                    if (value==undefined)
                    {
                        return temp['OTHERS'];
                    }
                    else
                    {
                        return value;
                    }
                }
            }
            
            function handleJob(p_type)
            {
                var records = $('requestResultDs').getSelected();
                if (records.length < 1) {
                    Leaf.showMessage('提示', '请至少选择一条数据!');
                }
                var msg;
                var data = [];
                for (var i = 0;i < records.length;i++) {
                    //校验状态
                    msg=validateJobPara(operation,p_type,records[i].get('phase_code'),records[i].get('job_flag'));
		            if(!Ext.isBoolean(msg)||msg!=true)
		            {
		                Leaf.showMessage('提示', msg);
		                return false;
		            }
                    data.push(records[i].data);
                }
                
                Leaf.showConfirm('提示', '确认要'+operation[p_type]['name']+'吗?', function()
                {
                    Leaf.request(
                    {
                        url: 'fnd_request_job_handle.lsc?type='+p_type,
                        para: data,
                        success: function() {
                            Leaf.showMessage('提示', '操作成功!', function()
                            {
                                queryResultDs();
                            });
                        },
                        scope: this
                    });
                });
            }
            
            function showdetails(path) 
            {
                new Leaf.Window({
                    id: 'fnd_concurrent_request_detail_window',
                    url: path,
                    title: '请求结果',
                    fullScreen: true
            
                });
            }
            
            function requestDetails(value, record, name) {
                if (!Ext.isEmpty(value)) 
                {
                    if(Ext.isEmpty(record.get('url')))
                    {
                        return value;
                    }
                    else
                    {
                        var url = record.get('url'); 
	                    var path = '${/request/@context_path}/'+url+ '?request_id=' + value;
	                    return "<a href=\"javascript:showdetails('" + path + "')\">"+value+"</a>";
                    }
                } 
                else 
                {
                    return '';
                }
            }
            
            function openLogWin(id, path) {
                new Leaf.Window(
                {
                    id: id,
                    url: path,
                    title: '日志信息',
                    fullScreen: true
            
                });
            }
            
            function actionRenderer(value, record, name) {
                var request_id=record.get('request_id');
                if (!Ext.isEmpty(request_id)) 
                {
                    var window_id = "fnd_concurrent_request_log_window";
                    var path;
                    if (record.get('job_flag') == 'Y') 
                    {
                        path = $('fnd_concurrent_request_job_log_link').getUrl() + '?request_id=' + request_id + '&job_name=' + record.get('job_name');
                    } 
                    else 
                    {
                        path = $('fnd_concurrent_request_log_link').getUrl() + '?request_id=' + request_id;
                    }
                    return "<a href=\"javascript:openLogWin('" + window_id + "','" + path + "')\">日志信息</a>";
                }
                else 
                {
                    return '';
                }
            }
            
            function sleepJob() {
                handleJob('SLEEP');
            }
            function wakeJob() {
                handleJob('WAKE');
            }
            function deleteJob() {
                handleJob('DELETE');
            }
            function runJob() {
                handleJob('RUN');
            }
            
            var statusColor={RUNNING:'00FF00',FINISH:'00FF00',DELETE:'00FF00',ERROR:'FF0000',SLEEP:'FFFF00',WAITING:'FFFFFF'};
            
            function PhaseCodeRenderer(value, record, name) {
                return "<div style='background-color:#"+statusColor[record.get('phase_code')]+"'>" + value + "</div>";
            }
            
            function StatusCodeRenderer(value, record, name) {
                return "<div style='background-color:#"+statusColor[record.get('status_code')]+"'>" + value + "</div>";
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="job_flag_ds">
                <a:datas>
                    <a:record name="是" code="Y"/>
                    <a:record name="否" code="N"/>
                </a:datas>
            </a:dataSet>
            <a:dataSet id="request_status_ds" lookupCode="FND_CONCURRENT_REQUEST_STATUS"/>
            <a:dataSet id="status_code_ds" lookupCode="FND_CONCURRENT_REQUEST_STATUS"/>
            <a:dataSet id="requestParaDs" model="fnd.FND5030.fnd_concurrent_request">
                <a:fields>
                    <a:field name="parent_request_id"/>
                    <a:field name="phase_code_desc" displayField="code_value_name" options="request_status_ds" returnField="phase_code" valueField="code_value"/>
                    <a:field name="status_code_desc" displayField="code_value_name" options="status_code_ds" returnField="status_code" valueField="code_value"/>
                    <a:field name="request_code" lovHeight="500" lovService="fnd.FND5030.fnd_request_info_lov" lovWidth="500" title="请求编码">
                        <a:mapping>
                            <a:map from="request_info_id" to="request_info_id"/>
                            <a:map from="request_code" to="request_code"/>
                            <a:map from="request_name" to="request_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="job_flag_desc" displayField="name" options="job_flag_ds" returnField="job_flag" valueField="code"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="requestResultDs" autoCount="true" autoQuery="true" fetchAll="false" model="fnd.FND5030.fnd_concurrent_request" queryDataSet="requestParaDs" selectable="true"/>
        </a:dataSets>
        <a:screenBody>
            <a:form column="3" labelWidth="100" marginWidth="65" title="请求定义" width="750">
                <a:textField name="request_id" bindTarget="requestParaDs" prompt="请求ID"/>
                <a:lov name="request_code" bindTarget="requestParaDs" prompt="请求编码"/>
                <a:label name="request_name" bindTarget="requestParaDs" prompt="请求名称"/>
                <a:comboBox name="phase_code_desc" bindTarget="requestParaDs" prompt="运行状态"/>
                <a:comboBox name="status_code_desc" bindTarget="requestParaDs" prompt="请求状态"/>
                <a:comboBox name="job_flag_desc" bindTarget="requestParaDs" prompt="周期性"/>
                <a:numberField name="parent_request_id" allowDecimals="false" allowNegative="false" bindTarget="requestParaDs" prompt="父请求ID"/>
            </a:form>
            <a:hBox>
                <a:button click="queryResultDs" text="HAP_QUERY"/>
                <a:button click="resetParaDs" text="HAP_RESET"/>
                <a:button click="openRequestWin" text="提交新请求"/>
                <a:button click="sleepJob" text="JOB暂挂"/>
                <a:button click="wakeJob" text="JOB恢复"/>
                <a:button click="deleteJob" text="JOB删除"/>
                <a:button click="runJob" text="立即执行"/>
            </a:hBox>
            <a:grid id="grid" bindTarget="requestResultDs" height="430" marginWidth="65" navBar="true" width="750">
                <a:columns>
                    <a:column name="request_id" align="center" prompt="请求ID" renderer="requestDetails" width="45"/>
                    <a:column name="request_code" align="center" prompt="请求编码" width="70"/>
                    <a:column name="request_name" align="center" prompt="请求名称" width="80"/>
                    <a:column name="phase_code_desc" align="center" prompt="运行状态" renderer="PhaseCodeRenderer" width="50"/>
                    <a:column name="status_code_desc" align="center" prompt="请求状态" renderer="StatusCodeRenderer" width="50"/>
                    <a:column name="job_flag_desc" align="center" prompt="周期性" width="40"/>
                    <a:column name="request_parameter" align="center" prompt="请求参数" width="100"/>
                    <a:column name="start_date_desc" align="center" prompt="开始时间" width="115"/>
                    <a:column name="end_date_desc" align="center" prompt="结束时间/下次运行时间" width="115"/>
                    <a:column name="log" align="center" prompt="日志" renderer="actionRenderer" width="55"/>
                </a:columns>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>