rt-sim-training-client/src/views/system/userSimulation/index.vue

159 lines
5.3 KiB
Vue
Raw Normal View History

2019-10-31 15:34:38 +08:00
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<users-training-edit ref="edit" type="EDIT" @reloadTable="reloadTable" />
<users-training-add ref="add" type="ADD" @reloadTable="reloadTable" />
</div>
</template>
<script>
import { getSimulationList, deleteSimulationStats } from '@/api/simulation';
import { listPublishMap } from '@/api/jmap/map';
import { getPublishLessonList } from '@/api/jmap/lesson';
import UsersTrainingEdit from './edit';
import UsersTrainingAdd from './add';
export default {
2019-11-07 15:54:49 +08:00
name: 'UserTrainingEdit',
components: {
UsersTrainingEdit,
UsersTrainingAdd
},
data() {
return {
examResultList: [],
LessonList: [],
mapList: [],
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '120px',
reset: true,
queryObject: {
trainingName: {
type: 'text',
label: this.$t('system.trainingName')
},
userName: {
type: 'text',
label: this.$t('system.userName')
}
}
2019-10-31 15:34:38 +08:00
2019-11-07 15:54:49 +08:00
},
queryList: {
query: getSimulationList,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('system.userName'),
prop: 'userName'
},
{
title: this.$t('global.mobile'),
prop: 'userMobile'
},
{
title: this.$t('system.mapName'),
prop: 'mapName'
},
{
title: this.$t('system.trainingUseTime'),
prop: 'duration',
type: 'tag',
columnValue: (row) => { return this.computation(row.duration); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('system.productName'),
prop: 'mapPrdName'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '250',
hide: (row) => { return !row.fake; },
buttons: [
{
name: this.$t('global.edit'),
handleClick: this.edit,
showControl: (row) => { return row.fake; }
},
{
name: this.$t('global.delete'),
handleClick: this.handleDelete,
type: 'danger',
showControl: (row) => { return row.fake; }
}
]
}
],
actions: [
{ text: this.$t('global.add'), handler: this.createTraining }
]
},
currentModel: {}
};
},
created() {
this.loadInitData();
},
methods: {
async loadInitData() {
const res = await listPublishMap();
this.mapList = res.data;
const response = await getPublishLessonList();
const data = response.data;
if (data && data.length) {
data.forEach(elem => {
this.LessonList.push({ value: elem.prdId, name: elem.name });
});
}
},
createTraining() {
this.$refs.add.show();
},
computation(fieldValue) {
if (fieldValue) {
const f = parseInt(fieldValue / 60);
const s = fieldValue % 60;
if (f > 0) {
return `${f} ${this.$t('system.minute')} ${s} ${this.$t('system.second')}`;
} else {
return `${s} ${this.$t('system.second')}`;
}
}
},
2019-10-31 15:34:38 +08:00
2019-11-07 15:54:49 +08:00
// 编辑
edit(index, row) {
this.$refs.edit.show(row);
},
2019-10-31 15:34:38 +08:00
2019-11-07 15:54:49 +08:00
// 删除
handleDelete(index, row) {
this.$confirm(this.$t('system.wellDelUserSimulation'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteSimulationStats(row.id).then(response => {
this.$message.success(this.$t('system.deleteSuccess'));
this.reloadTable();
}).catch(() => {
this.reloadTable();
this.$messageBox(this.$t('error.deleteFailed'));
});
});
},
2019-10-31 15:34:38 +08:00
2019-11-07 15:54:49 +08:00
reloadTable() {
this.queryList.reload();
}
}
2019-10-31 15:34:38 +08:00
};
</script>