|
22 | 22 | {value: 2, text: '一个仓库只记录一次', qtip: '一个仓库只记录一次'},
|
23 | 23 | ];
|
24 | 24 |
|
| 25 | + var queue = { |
| 26 | + config: [ |
| 27 | + {text: '待执行', color: 'gray'}, |
| 28 | + {text: '执行中', color: 'green'}, |
| 29 | + ], |
| 30 | + tpl: new Ext.XTemplate('<div class="tag tag-{color}">{text}</div>'), |
| 31 | + } |
| 32 | +
|
25 | 33 | var grid = Ext.create('plugin.grid', {
|
26 | 34 | store: Ext.data.StoreManager.lookup('store'),
|
27 | 35 | bufferedRenderer: false,
|
|
35 | 43 | handler: winHelp,
|
36 | 44 | },
|
37 | 45 | '->',
|
| 46 | + { |
| 47 | + text: '任务队列', |
| 48 | + iconCls: 'icon-page-db', |
| 49 | + handler: winQueue, |
| 50 | + }, |
| 51 | + '-', |
38 | 52 | {
|
39 | 53 | text: '批量删除',
|
40 | 54 | iconCls: 'icon-cross',
|
|
98 | 112 | dataIndex: 'keyword',
|
99 | 113 | flex: 1,
|
100 | 114 | align: 'center',
|
| 115 | + renderer: function (value) { |
| 116 | + return Ext.String.htmlEncode(value); |
| 117 | + } |
101 | 118 | },
|
102 | 119 | {
|
103 | 120 | text: '扫描页数',
|
|
147 | 164 | flex: 1,
|
148 | 165 | align: 'center',
|
149 | 166 | renderer: function (value) {
|
150 |
| - return value ? value : '-'; |
| 167 | + return value ? Ext.String.htmlEncode(value) : '-'; |
151 | 168 | }
|
152 | 169 | },
|
153 | 170 | {
|
@@ -328,6 +345,67 @@ function winHelp() {
|
328 | 345 | }).removeCls('x-unselectable');
|
329 | 346 | }
|
330 | 347 |
|
| 348 | + var taskRunner = new Ext.util.TaskRunner(); |
| 349 | +
|
| 350 | + function newTask(interval, run) { |
| 351 | + var task = taskRunner.newTask({ |
| 352 | + run: run, |
| 353 | + interval: interval, |
| 354 | + fireOnStart: true, |
| 355 | + }); |
| 356 | + task.start(); |
| 357 | + return task; |
| 358 | + } |
| 359 | +
|
| 360 | + function winQueue() { |
| 361 | + var gridQueue = Ext.create('plugin.grid', { |
| 362 | + disableSelection: true, |
| 363 | + viewConfig: { |
| 364 | + loadMask: false, |
| 365 | + emptyText: '<div style="text-align:center;padding:20px;color:#AAA">任务队列为空..</div>' |
| 366 | + }, |
| 367 | + store: { |
| 368 | + autoLoad: true, |
| 369 | + pageSize: 99999, |
| 370 | + proxy: { |
| 371 | + type: 'ajax', |
| 372 | + url: '/api/configJob/queue', |
| 373 | + }, |
| 374 | + }, |
| 375 | + columns: [ |
| 376 | + { |
| 377 | + text: '关键字', |
| 378 | + dataIndex: 'keyword', |
| 379 | + align: 'center', |
| 380 | + flex: 2, |
| 381 | + }, |
| 382 | + { |
| 383 | + text: '状态', |
| 384 | + dataIndex: 'status', |
| 385 | + align: 'center', |
| 386 | + flex: 1, |
| 387 | + renderer: function (value) { |
| 388 | + return queue.tpl.apply(queue.config[value]); |
| 389 | + }, |
| 390 | + }, |
| 391 | + ] |
| 392 | + }); |
| 393 | +
|
| 394 | + Ext.create('Ext.window.Window', { |
| 395 | + title: '任务队列', |
| 396 | + iconCls: 'icon-page-db', |
| 397 | + width: 800, |
| 398 | + height: 500, |
| 399 | + layout: 'fit', |
| 400 | + items: [gridQueue], |
| 401 | + }).show(); |
| 402 | +
|
| 403 | + // 每 5 秒自动刷新 |
| 404 | + newTask(5000, function () { |
| 405 | + gridQueue.store.reload(); |
| 406 | + }); |
| 407 | + } |
| 408 | +
|
331 | 409 | Ext.create('Ext.container.Container', {
|
332 | 410 | renderTo: Ext.getBody(),
|
333 | 411 | height: '100%',
|
|
0 commit comments