rt-sim-training-client/src/views/ibp/home.vue
2020-10-09 17:27:46 +08:00

205 lines
6.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="joylink-card">
<div class="scriptHeader">
<div class="scriptList">IBP盘列表</div>
<el-button size="small" type="primary" class="createScript" style="margin-top: 5px" @click="handleCreate">{{ $t('scriptRecord.scriptCreate') }}</el-button>
<el-button size="small" type="primary" class="createScript" @click="createByPublish">发布数据创建</el-button>
</div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" style="width: 91%;margin-left:4%;margin-top:20px;" />
<create-ibp ref="createScript" :title="'创建数据'" @reloadTable="reloadTable" />
<create-ibp ref="modifyScript" :title="'修改数据'" @reloadTable="reloadTable" />
<copy-ibp ref="copyIbp" @reloadTable="reloadTable" />
</div>
</template>
<script>
// import Cookies from 'js-cookie';
import { getStationList } from '@/api/runplan';
// import ConstConfig from '@/scripts/ConstConfig';
import { postIbpPublish, getIbpAllList, deleteIbpInfo } from '@/api/ibp';
import CreateIbp from './create';
import CopyIbp from './copy';
export default {
name: 'ScriptDraft',
components: {
CreateIbp,
CopyIbp
},
data() {
return {
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '100px',
reset: true,
show:false
},
stationList: [],
queryList: {
query: this.queryFunction,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: '关联站台',
prop: 'stationCode',
type: 'tag',
columnValue: (row) => { return this.covertData(row); },
tagType: (row) => { return ''; }
},
{
title: '创建时间',
prop: 'createTime'
},
{
type: 'button',
title: this.$t('scriptRecord.operate'),
width: '400',
buttons: [
{
name: '修改基础信息',
handleClick: this.editInfo,
type: 'primary'
},
{
name: '绘图',
handleClick: this.handleModify,
type: 'primary'
},
{
name: '删除',
handleClick: this.deleteScript,
type: 'danger'
},
{
name: '发布',
handleClick: this.publishScript,
type: 'primary'
// showControl: (row) => { return !row.publish; }
}
]
}
]
}
};
},
watch: {
'$route' () {
this.reloadTable();
}
},
async created () {
try {
const res = await getStationList(this.$route.params.mapId);
this.stationList = [];
if (res.code == 200) {
res.data.forEach(station => {
const param = {
name: station.name,
code: station.code
};
this.stationList.push(param);
});
}
} catch (error) {
console.log(error);
}
},
methods: {
queryFunction(params) {
const param = {
...params,
mapId: this.$route.params.mapId,
stationCode: ''
};
return getIbpAllList(param);
},
reloadTable() {
if (this.queryList && this.queryList.reload) {
this.queryList.reload();
}
},
covertData(row) {
const staitonlist = this.stationList.filter(element => {
return row.stationCode == element.code;
});
if (staitonlist.length) {
return staitonlist[0].name;
} else {
return '';
}
},
// 进入绘图数据
handleModify(index, row) {
const query = { mapId: this.$route.params.mapId, stationCode: row.stationCode, ibpId: row.id };
this.$router.push({ path: `/design/ibp/edit`, query: query });
},
// 更新
editInfo(index, row) {
this.$refs.modifyScript.doShow(row);
},
// 创建
handleCreate() {
this.$refs.createScript.doShow(null);
},
// 发布
publishScript(index, row) {
this.$confirm('您确定发布此条IBP盘数据', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
postIbpPublish(row.id).then(response => {
this.$message.success('发布成功');
this.reloadTable();
}).catch(() => {
this.$messageBox('发布失败');
});
}).catch(() => { });
},
// 删除此条数据
deleteScript(index, row) {
this.$confirm('您确定是否删除此条IBP盘数据', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteIbpInfo(row.id).then(response => {
this.$message.success('删除成功');
this.reloadTable();
}).catch(() => {
this.$messageBox('删除失败');
});
}).catch(() => { });
},
createByPublish() {
this.$refs.copyIbp.doShow(null);
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.joylink-card{
height: 100%;
overflow: auto;
}
.createScript{
float: right;
margin-right:20px;
}
.scriptHeader{
display:inline-block;margin-top:40px;width: 90%;margin-left:5%;
}
.scriptList{
display:inline-block;padding:7px 0px
}
/deep/.el-button+.el-button {
margin-left: 5px;
margin-top: 5px;
}
</style>