rt-sim-training-client/src/views/lesson/taskmanage/list.vue

184 lines
6.7 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div style="height: 100%; overflow-y: auto;">
2019-11-11 13:34:35 +08:00
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" style="width: 98%;margin-left:1%;margin-top:20px;" />
<create-task ref="CreateTask" @reloadTable="reloadTable" />
<div class="draft">
<el-button-group>
<el-button type="primary" @click="turnback">{{ $t('global.back') }}</el-button>
</el-button-group>
2019-07-26 13:32:43 +08:00
</div>
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
import { getTaskList, postTask, postTaskCancel } from '@/api/management/task';
2019-11-08 16:22:05 +08:00
import { getPublishMapListOnline } from '@/api/jmap/map';
import CreateTask from './createTask';
2019-07-26 13:32:43 +08:00
export default {
name: 'ManagementList',
components: {
CreateTask
},
data() {
return {
2019-10-30 19:36:26 +08:00
mapIdList: [],
taskList: [],
taskStatusList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '80px',
queryObject: {
status: {
type: 'select',
label: this.$t('global.status'),
config: {
data: []
2019-07-26 13:32:43 +08:00
}
}
}
},
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
2019-10-30 19:36:26 +08:00
title: this.$t('lesson.mapName'),
prop: 'parameter',
type: 'tag',
2019-10-30 19:36:26 +08:00
columnValue: (row) => { return this.$convertField(row.parameter, this.mapIdList, ['id', 'name']); },
tagType: (row) => { return ''; }
},
{
title: this.$t('lesson.creationTime'),
prop: 'createTime'
},
{
title: this.$t('global.status'),
prop: 'status',
type: 'tag',
columnValue: (row) => { return this.$convertField(row.status, this.taskStatusList, ['code', 'name']); },
tagType: (row) => { if (row.status != '03') { return 'warning'; } else { return 'success'; } }
},
{
title: this.$t('global.startTime'),
prop: 'startTime'
},
{
title: this.$t('lesson.finishTime'),
prop: 'finishTime'
},
{
title: this.$t('lesson.createResults'),
prop: 'result',
width: '400px'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '250',
buttons: [
{
name: this.$t('lesson.start'),
handleClick: this.taskStart,
type: '',
showControl: (row) => { return row.status == '01'; }
},
{
name: this.$t('global.cancel'),
handleClick: this.taskCancel,
type: '',
showControl: (row) => { return row.status == '04'; }
},
{
name: this.$t('lesson.toPerform'),
handleClick: this.taskStart,
type: '',
showControl: (row) => { return row.status == '03' || row.status == '05'; }
}
]
}
],
actions: [
{ text: this.$t('global.create'), btnCode: 'employee_insert', handler: this.createTask }
]
},
2019-07-26 13:32:43 +08:00
currentModel: {}
};
},
created() {
this.loadInitData();
},
methods: {
loadInitData() {
2019-10-30 19:36:26 +08:00
this.mapIdList = [];
2019-11-08 16:22:05 +08:00
getPublishMapListOnline().then(response => {
2019-10-30 19:36:26 +08:00
this.mapIdList = response.data;
});
this.taskStatusList = [];
this.$Dictionary.taskStatus().then(list => {
this.taskStatusList = list;
list.forEach(elem => {
this.queryForm.queryObject.status.config.data.push({ value: elem.code, label: elem.name });
});
});
2019-07-26 13:32:43 +08:00
},
taskStart(index, node) {
this.$confirm( this.$t('tip.startOperationHint'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
postTask({ id: node.id }).then(res => {
this.$message.success(this.$t('lesson.operateSuccess'));
this.reloadTable();
}).catch(error => {
this.reloadTable();
this.$messageBox(`${this.$t('error.operationFailure')}, ${error.message}`);
});
});
2019-07-26 13:32:43 +08:00
},
taskCancel(index, node) {
this.$confirm( this.$t('tip.cancelsTaskHint'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
postTaskCancel(node.id).then(res => {
this.$message.success(this.$t('lesson.operateSuccess'));
this.reloadTable();
}).catch(error => {
this.reloadTable();
this.$messageBox(`${this.$t('error.operationFailure')}, ${error.message}`);
});
});
},
reloadTable() {
this.queryList.reload();
},
createTask() {
this.$refs.CreateTask.doShow();
},
turnback() {
this.$router.go(-1);
},
queryFunction(params) {
params['mapId'] = this.$route.query.mapId;
return getTaskList(params);
2019-07-26 13:32:43 +08:00
}
}
};
2019-08-29 17:16:33 +08:00
</script>
2019-09-30 16:20:31 +08:00
<style rel="stylesheet/scss" lang="scss" scoped>
.draft {
width: 400px;
text-align: center;
margin: 20px auto;
}
</style>