rt-sim-training-client/src/views/planMonitor/editTool/menus/openRunPlan.vue

184 lines
6.1 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-09-04 16:32:41 +08:00
<div>
<el-dialog
v-dialogDrag
class="planEdit__tool open-runplan"
:title="title"
:visible.sync="show"
width="800px"
2019-09-04 16:32:41 +08:00
:before-close="doClose"
:z-index="2000"
:modal="true"
:close-on-click-modal="false"
>
<el-table :data="runPlanList" height="350" border style="width: 100%">
<el-table-column prop="name" label="运行图名称" />
<el-table-column prop="createTime" label="创建日期" width="180" />
<el-table-column label="操作">
<template slot-scope="scope">
<el-button size="mini" class="button_box" @click="handleConfirm(scope.row)">加载</el-button>
<el-button size="mini" class="button_box" @click="handleEdit(scope.row)">修改名称</el-button>
<el-button size="mini" class="button_box" type="danger" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- <el-scrollbar wrap-class="scrollbar-wrapper" :style="{height: height+'px'}">
2019-09-04 16:32:41 +08:00
<el-tree
ref="tree"
class="filter-tree"
:data="runPlanList"
:props="defaultProps"
highlight-current
default-expand-all
:style="{height: height-20+'px'}"
@node-click="handleNodeClick"
/>
</el-scrollbar> -->
<!-- <el-row type="flex" justify="center" class="button-group">
2019-09-04 16:32:41 +08:00
<el-button v-if="type == 'add'" type="primary" @click="handleConfirm">选择运行图</el-button>
<el-button v-if="type == 'delete'" type="primary" @click="handleDelete">删除</el-button>
<el-button v-if="type == 'edit'" type="primary" @click="handleEdit">修改</el-button>
<el-button @click="dialogShow = false"> </el-button>
</el-row> -->
2019-09-04 16:32:41 +08:00
</el-dialog>
<edit-plan-name ref="editPlan" @renewal="getRunPlanList" />
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-09-04 14:47:52 +08:00
import { getRpListByMapId, deleteRunPlan } from '@/api/runplan';
import { UrlConfig } from '@/scripts/ConstDic';
2019-09-04 16:32:41 +08:00
import EditPlanName from './editPlanName';
2019-07-26 13:32:43 +08:00
2019-08-09 18:29:08 +08:00
export default {
2019-11-11 15:54:04 +08:00
name: 'OpenRunPlan',
components: {
EditPlanName
},
props: {
skinCode: {
type: String,
required: true
}
},
data() {
return {
dialogShow: false,
loading: false,
height: 260,
// planId: '',
// planName: '',
type: 'add',
// defaultShowKeys: [],
runPlanList: [],
runPlanDict: {}
// defaultProps: {
// label: 'name'
// }
};
},
computed: {
show() {
return this.dialogShow;
},
title() {
return this.$t('planMonitor.openRunPlan.runPlanList');
}
},
mounted() {
this.loadRunPlanData({
planId: this.$route.query.planId,
skinCode: this.$route.query.skinCode,
planName: this.$route.query.planName
});
},
methods: {
// handleNodeClick(data) {
// this.planId = data.id;
// this.planName = data.name;
// },
loadRunPlanData({ refresh, planId, skinCode, planName }) {
if (refresh) {
this.$store.dispatch('runPlan/refresh');
} else {
const query = { skinCode: skinCode, mapId: this.$route.query.mapId, planId: planId, planName: planName };
this.$router.push({ path: `${UrlConfig.plan.tool}`, query: query });
}
},
getRunPlanList() {
getRpListByMapId(this.$route.query.mapId).then((resp) => {
this.runPlanList = resp.data;
this.runPlanList.forEach(elem => {
this.runPlanDict[elem.id] = elem.name;
});
this.dialogShow = true;
}).catch(() => {
this.$messageBox(this.$t('planMonitor.openRunPlan.getRunPlanListFail'));
});
},
doShow(data) {
this.type = data.type || 'add';
this.getRunPlanList();
},
doClose() {
this.dialogShow = false;
// this.planId = '';
// this.planName = '';
},
// 跳转到对应运行图
handleConfirm(row) {
this.loadRunPlanData({
planId: row.id,
skinCode: this.$route.query.skinCode,
planName: row.name
});
this.doClose();
},
// 删除运行图
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'));
if (row.id === this.$route.query.planId) {
const query = { skinCode: this.$route.query.skinCode, mapId: this.$route.query.mapId };
this.$router.push({ path: `${UrlConfig.plan.tool}`, query: query });
}
this.doClose();
}).catch(() => {
this.$messageBox(this.$t('tip.deleteOperationGraphFailed'));
});
}).catch(() => { });
},
// 修改运行图名称
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-08-09 18:29:08 +08:00
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/deep/ {
.el-button {
margin-left: 40px !important;
margin-right: 40px !important;
}
.el-tree {
margin: 10px !important;
2019-08-29 17:16:33 +08:00
// background: #ECE9D8 !important;
2019-07-26 13:32:43 +08:00
}
}
.button_box{
float: left;
margin: 0 2px!important;
}
2019-08-09 18:29:08 +08:00
</style>