rt-sim-training-client/src/views/planMonitor/detail.vue

350 lines
14 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div class="joylink-card">
2019-11-11 13:22:22 +08:00
<div class="runPlanHeader" style="width: 90%;margin-left:5%;margin-top:40px;display: inline-block;">
2020-05-15 14:59:53 +08:00
<div class="runPlanList">草稿{{ $t('planMonitor.openRunPlan.runPlanList') }}</div>
<el-button v-if="isCreate" size="mini" type="primary" class="createRunPlan" @click="handleCreate">{{ $t('planMonitor.createRunningDiagram') }}</el-button>
</div>
<!--<QueryListPage ref="queryListPage" :query-form="queryForm" :pager-config="pagerConfig" :query-list="queryList" style="width: 91%;margin-left:4%;margin-top:20px;" />-->
<el-card v-loading="loading" style="width: 91%;margin-left:4%;margin-top:20px;">
<el-table
:data="runPlanList"
highlight-current-row
:header-cell-style="headerCellStyle"
size="medium"
stripe
border
>
<el-table-column prop="name" :label="this.$t('planMonitor.runGraphName')" />
<el-table-column v-if="!(/^\/design\/userlist/.test(this.$route.fullPath))" :label="this.$t('global.status')">
<template slot-scope="scope">
<el-tag>{{ handlerStatus(scope.row) }}</el-tag>
</template>
</el-table-column>
<el-table-column
v-if="!(/^\/design\/userlist/.test(this.$route.fullPath))"
prop="explanation"
show-overflow-tooltip
:label="this.$t('planMonitor.explanation')"
/>
<el-table-column :label="this.$t('planMonitor.creationDate')">
<template slot-scope="scope">
<el-tag type="success">{{ handleTime(scope.row.createTime) }}</el-tag>
</template>
</el-table-column>
<el-table-column :label="this.$t('global.operate')" width="400">
<template slot-scope="scope">
<el-button v-if="scope.row.status !=='1'" size="mini" class="button_box" type="success" @click="handleConfirm(scope.row)">{{ $t('planMonitor.load') }}</el-button>
<el-button v-if="isCreate && scope.row.status !=='1'" size="mini" class="button_box" type="primary" @click="handleEdit(scope.row)">{{ $t('planMonitor.modifyName') }}</el-button>
<el-button v-if="isCreate && scope.row.status !=='1'" size="mini" class="button_box" type="danger" @click="handleDelete(scope.row)">{{ $t('global.delete') }}</el-button>
<el-button v-if="isCreate && scope.row.status ==='0'" size="mini" class="button_box" type="primary" @click="handlePublish(scope.row)">{{ hasRelease?$t('global.release'):$t('planMonitor.applyRelease') }}</el-button>
<el-button v-if="scope.row.status === '1'" size="mini" class="button_box" type="primary" @click="handlePreview(scope.row)">{{ $t('planMonitor.preview') }}</el-button>
<el-button v-if="scope.row.status === '1'" size="mini" class="button_box" type="danger" @click="handelRevert(scope.row)">{{ $t('planMonitor.revoke') }}</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<create-empty-plan ref="createEmptyPlan" :plan-convert="PlanConvert" @dispatchDialog="dispatchDialog" @refresh="refresh" />
<edit-plan-name ref="editPlan" @renewal="getRunPlanList" />
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-09-30 15:18:34 +08:00
import EditPlanName from './editTool/menus/editPlanName';
2019-09-30 14:17:20 +08:00
import CreateEmptyPlan from './editTool/menus/createEmptyPlan';
import { publishRunPlan, releaseOrCancelRunPlan, previewRunPlan} from '@/api/designPlatform';
2019-09-30 10:46:29 +08:00
import { getRpListByMapId, deleteRunPlan } from '@/api/runplan';
2019-10-14 13:54:19 +08:00
import { launchFullscreen } from '@/utils/screen';
import { UrlConfig } from '@/scripts/ConstDic';
export default {
name: 'UserRunPlanList',
components: {
CreateEmptyPlan,
EditPlanName
},
filters: {
},
data() {
return {
dialogShow: false,
loading: false,
type: 'add',
runPlanList: [],
runPlanDict: {},
isCreate:false,
PlanConvert: {},
headerCellStyle: {
}
// pagerConfig: {
// pageSize: 'pageSize',
// pageIndex: 'pageNum'
// },
// queryForm: {
// show: false
// },
// queryList: {
// query: this.queryFunction,
// afterQuery: this.afterQuery,
// selectCheckShow: false,
// indexShow: false,
// columns: [
// {
// title: this.$t('planMonitor.runGraphName'),
// prop: 'name'
// },
// {
// title: this.$t('global.status'),
// prop: 'status'
// },
// {
// title: this.$t('planMonitor.explanation'),
// prop: 'explanation'
// },
// {
// title: this.$t('planMonitor.creationDate'),
// prop: 'createTime'
// },
// {
// type: 'button',
// title: this.$t('global.operate'),
// width: '450',
// buttons: [
// {
// name: this.$t('planMonitor.load'),
// handleClick: this.handleConfirm,
// showControl: (row) => {
// return row.status !== '1';
// }
// },
// {
// name: this.$t('planMonitor.modifyName'),
// handleClick: this.handleEdit,
// showControl: (row) => {
// return this.isCreate && row.status !== '1';
// }
// },
// {
// name: this.$t('global.delete'),
// handleClick: this.handleDelete,
// showControl: (row) => {
// return this.isCreate && row.status !== '1';
// }
// },
// {
// name: this.hasRelease ? this.$t('global.release') : this.$t('planMonitor.applyRelease'),
// handleClick: this.handlePublish,
// showControl: (row) => {
// return this.isCreate && row.status === '0';
// }
// },
// {
// name: this.$t('planMonitor.preview'),
// handleClick: this.handlePreview,
// showControl: (row) => {
// return row.status === '1';
// }
// },
// {
// name: this.$t('planMonitor.revoke'),
// handleClick: this.handelRevert,
// showControl: (row) => {
// return row.status === '1';
// }
// }
// ]
// }
// ]
// }
};
},
computed: {
height() {
return this.$store.state.app.height - 60 - 30;
},
2019-10-14 13:04:23 +08:00
hasRelease() {
return this.$store.state.user.roles.includes('04') ||
this.$store.state.user.roles.includes('05');
},
drawWay() {
return this.$route.query.drawWay + '';
2019-10-14 13:04:23 +08:00
}
},
watch: {
'$route' () {
this.getRunPlanList();
2020-03-02 14:46:59 +08:00
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
}
},
created() {
2019-11-08 14:35:58 +08:00
this.PlanConvert = this.$theme.loadPlanConvert(this.$route.query.lineCode);
},
mounted() {
this.getRunPlanList();
},
methods:{
refresh() {
this.getRunPlanList();
},
// queryFunction(params) {
// this.isCreate = !/^\/design\/userlist/.test(this.$route.fullPath);
// return this.isCreate ? getRpListByMapId(this.$route.params.mapId) : getRpListByUserMapId(this.$route.params.mapId);
// },
getRunPlanList() {
this.loading = true;
this.isCreate = true;
getRpListByMapId(this.$route.params.mapId).then((resp) => {
this.runPlanList = resp.data;
this.runPlanList.forEach(elem => {
this.runPlanDict[elem.id] = elem.name;
});
this.loading = false;
}).catch(() => {
this.$messageBox(this.$t('planMonitor.openRunPlan.getRunPlanListFail'));
this.loading = false;
});
},
dispatchDialog() {
this.$refs['createEmptyPlan'].doShow();
},
handleCreate() {
this.$refs['createEmptyPlan'].doShow();
},
handleConfirm(row) {
this.loadRunPlanData({
planId: row.id,
2019-11-08 18:19:35 +08:00
lineCode: this.$route.query.lineCode,
planName: row.name
});
},
// 修改运行图名称
handleEdit(row) {
if (row.id && row.name) {
this.$refs.editPlan.doShow({id: row.id, name: row.name});
} else {
this.$message.info(this.$t('planMonitor.openRunPlan.pleaseSelectRunplan'));
}
},
2019-11-08 18:19:35 +08:00
loadRunPlanData({ refresh, planId, lineCode, planName }) {
if (refresh) {
this.$store.dispatch('runPlan/refresh');
} else {
const query = { lineCode: lineCode, mapId: this.$route.params.mapId, planId: planId, planName: planName, drawWay:this.drawWay };
this.$router.push({ path: `/plan/tool`, query: query });
}
},
// 删除运行图
handleDelete(row) {
this.$confirm(this.$t('planMonitor.openRunPlan.confirmDeleteRunPlan'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
deleteRunPlan(row.id).then(Response => {
this.$message.success(this.$t('planMonitor.openRunPlan.deleteSuccess'));
this.refresh();
}).catch(() => {
this.$messageBox(this.$t('tip.deleteOperationGraphFailed'));
});
}).catch(() => { });
},
2019-10-14 13:04:23 +08:00
handlePublish(row) {
this.$confirm(this.hasRelease ? this.$t('tip.publishRunPlanTips') : this.$t('tip.applyRunPlanTips'), this.$t('tip.hint'), {
2019-10-14 13:04:23 +08:00
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
if (this.hasRelease) {
publishRunPlan(row.id, {runPlanName: name}).then(resp => {
2019-10-30 09:58:23 +08:00
this.$message.success(this.$t('tip.publishRunPlanSuccess'));
2019-10-14 13:04:23 +08:00
this.refresh();
}).catch(() => {
2019-10-30 09:58:23 +08:00
this.$messageBox(this.$t('tip.publishRunPlanFail'));
2019-10-14 13:04:23 +08:00
this.refresh();
});
2019-10-14 13:04:23 +08:00
} else {
releaseOrCancelRunPlan(row.id, '1').then(resp => {
2019-10-30 09:58:23 +08:00
this.$message.success(this.$t('tip.applyRunPlanSuccess'));
2019-10-14 13:04:23 +08:00
this.refresh();
}).catch(() => {
2019-10-30 09:58:23 +08:00
this.$messageBox(this.$t('tip.applyRunPlanFail'));
2019-10-14 13:04:23 +08:00
this.refresh();
});
2019-10-14 13:04:23 +08:00
}
});
},
handelRevert(row) {
2019-11-04 10:33:45 +08:00
this.$confirm(this.$t('tip.cancelRunPlanTips'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
2019-10-14 13:04:23 +08:00
cancelButtonText: this.$t('tip.cancel'),
type:'warning'
}).then(() => {
releaseOrCancelRunPlan(row.id, '0').then(resp=> {
2019-10-30 09:58:23 +08:00
this.$message.success(this.$t('tip.cancelRunPlanSuccess'));
2019-10-14 13:04:23 +08:00
this.refresh();
}).catch(() => {
this.$messageBox(this.$t('tip.cancelRunPlanFail'));
2019-10-14 13:04:23 +08:00
this.refresh();
});
});
2019-10-14 13:04:23 +08:00
},
handlerStatus(row) {
let lessonStatus = '';
switch (row.status) {
case '0':
lessonStatus = this.$t('lesson.notRelease');
break;
case '1':
lessonStatus = this.$t('lesson.pendingReview');
break;
case '2':
lessonStatus = this.$t('lesson.published');
break;
case '3':
lessonStatus = this.$t('lesson.rejected');
break;
2019-10-14 13:04:23 +08:00
}
return lessonStatus;
},
handleTime(time) {
return time.replace('T', ' ');
2019-10-14 13:54:19 +08:00
},
handlePreview(row) {
2019-10-14 13:54:19 +08:00
previewRunPlan(row.id).then(resp => {
const query = {
2019-11-08 18:19:35 +08:00
prdType: '01', group: resp.data, mapId: row.mapId, planId: row.id, from:''
2019-10-14 13:54:19 +08:00
};
this.$router.push({ path: `${UrlConfig.display}/plan`, query: query });
launchFullscreen();
}).catch(error => {
this.$messageBox(this.$t('tip.createSimulationFaild') + this.$t('global.colon') + error.message);
2019-10-14 13:54:19 +08:00
});
2019-10-14 13:04:23 +08:00
}
}
};
2019-07-26 13:32:43 +08:00
</script>
<style scoped>
::-webkit-scrollbar {
width: 3px;
height: 3px;
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.joylink-card{
height: 100%;
overflow: auto;
}
2019-10-30 09:58:23 +08:00
.el-button+.el-button{
margin-top:5px;
margin-left: 0px;
}
2019-09-30 10:46:29 +08:00
.createRunPlan{
display:inline-block;float:right;margin-right:20px;
}
.runPlanHeader{
display:inline-block;margin-top:40px;width: 90%;margin-left:5%;
}
.runPlanList{
display:inline-block;padding:7px 0px
}
</style>