@@ -207,17 +207,21 @@ import TaskStatus from '@/components/TaskStatus.vue';
207
207
import socket from ' @/socket' ;
208
208
import VirtualList from ' vue-virtual-scroll-list' ;
209
209
import TaskLogViewRecord from ' @/components/TaskLogViewRecord.vue' ;
210
+ import ProjectMixin from ' @/components/ProjectMixin' ;
210
211
211
212
export default {
212
213
components: { TaskStatus, VirtualList },
214
+
215
+ mixins: [ProjectMixin],
216
+
213
217
props: {
214
- itemId : Number ,
218
+ item : Object ,
215
219
projectId: Number ,
216
220
},
221
+
217
222
data () {
218
223
return {
219
224
itemComponent: TaskLogViewRecord,
220
- item: {},
221
225
output: [],
222
226
outputBuffer: [],
223
227
user: {},
@@ -238,6 +242,10 @@ export default {
238
242
},
239
243
240
244
computed: {
245
+ itemId () {
246
+ return this .item ? .id ;
247
+ },
248
+
241
249
isTaskStopped () {
242
250
return [
243
251
' stopped' ,
@@ -334,7 +342,6 @@ export default {
334
342
},
335
343
336
344
reset () {
337
- this .item = {};
338
345
this .output = [];
339
346
this .outputBuffer = [];
340
347
this .outputInterval = null ;
@@ -358,40 +365,33 @@ export default {
358
365
... data,
359
366
id: data .time + data .output ,
360
367
});
361
-
362
- // this.$nextTick(() => {
363
- // if (this.$refs.records) {
364
- // this.$refs.records.scrollToBottom();
365
- // }
366
- // });
367
-
368
368
break ;
369
369
default :
370
370
break ;
371
371
}
372
372
},
373
373
374
374
async loadData () {
375
- this . item = ( await axios ({
376
- method : ' get ' ,
377
- url : ` /api/project/ ${ this .projectId } /tasks/ ${ this . itemId } ` ,
378
- responseType : ' json ' ,
379
- })). data ;
380
-
381
- this . output = ( await axios ({
382
- method : ' get ' ,
383
- url : ` /api/project/ ${ this . projectId } /tasks/ ${ this . itemId } /output ` ,
384
- responseType : ' json ' ,
385
- })). data . map (( item ) => ({
386
- ... item,
387
- id : item . time + item . output ,
388
- }));
389
-
390
- this . user = this . item . user_id ? ( await axios ({
391
- method : ' get ' ,
392
- url : ` /api/users/ ${ this . item . user_id } ` ,
393
- responseType : ' json ' ,
394
- })). data : null ;
375
+ [
376
+ this . output ,
377
+ this .user ,
378
+ ] = await Promise . all ([
379
+
380
+ ( await axios ({
381
+ method : ' get ' ,
382
+ url : ` /api/project/ ${ this . projectId } /tasks/ ${ this . itemId } /output ` ,
383
+ responseType : ' json ' ,
384
+ })). data . map (( item ) => ({
385
+ ... item,
386
+ id : item . time + item . output ,
387
+ })) ,
388
+
389
+ this . item . user_id ? ( await axios ({
390
+ method : ' get ' ,
391
+ url : ` /api/users/ ${ this . item . user_id } ` ,
392
+ responseType : ' json ' ,
393
+ })). data : null ,
394
+ ]) ;
395
395
},
396
396
},
397
397
};
0 commit comments