rt-sim-training-client/src/views/publish/publishISCS/index.vue

181 lines
6.3 KiB
Vue
Raw Normal View History

2020-12-29 15:59:43 +08:00
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<el-dialog title="复制iscs数据" :visible.sync="dialogVisible" width="400px" center>
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
<el-button :loading="loading" type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
2020-12-29 15:59:43 +08:00
<el-button @click="close">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { getIscsDataByPage, copyIscsData, deleteIscs} from '@/api/iscs';
import {getPublishMapListOnline } from '@/api/jmap/map';
export default {
name: 'PublishISCS',
data() {
return {
mapListMap:{},
mapList:[],
dialogVisible:false,
loading:false,
formModel:{
2020-12-30 09:32:19 +08:00
fromMapId: '',
2020-12-29 15:59:43 +08:00
toMapId: ''
},
rules: {
toMapId: [
{ required: true, message: this.$t('rules.mapInput'), trigger: 'change' }
]
},
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
queryForm: {
labelWidth: '80px',
reset: true,
queryObject: {
mapId: {
type: 'select',
label: '地图名称',
config: {
data: []
}
}
}
},
queryList: {
query: getIscsDataByPage,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: '所属地图',
prop: 'mapId',
type: 'tag',
columnValue: (row) => { return this.covertMap(row); },
2020-12-29 16:51:00 +08:00
tagType: (row) => { return 'success'; }
2020-12-29 15:59:43 +08:00
},
{
title: '父系统',
prop: 'totalSystem'
},
{
title: '子系统',
prop: 'system'
},
{
title: '子图',
prop: 'userInterface'
},
{
type: 'button',
title: this.$t('global.operate'),
width: '300',
buttons: [
2020-12-30 09:32:19 +08:00
// {
// name: this.$t('publish.copy'),
// handleClick: this.handleCopy
// },
2020-12-29 15:59:43 +08:00
{
name: this.$t('global.delete'),
handleClick: this.handleDelete,
type: 'danger',
showControl: () => { return this.isShow != -1; }
}
]
}
2020-12-30 09:32:19 +08:00
],
actions: [
{ text: '复制', btnCode: 'copy', handler: this.handleCopy }
2020-12-29 15:59:43 +08:00
]
}
};
},
computed: {
isShow() {
return this.$store.getters['roles'].indexOf('05');
},
form() {
return {
labelWidth: '100px',
items: [
2020-12-30 09:32:19 +08:00
{ prop: 'fromMapId', label: '数据来源', type: 'select', required: true, options: this.covertOtherData()},
2020-12-29 15:59:43 +08:00
{ prop: 'toMapId', label: '复制到', type: 'select', required: true, options: this.covertData()}
]
};
}
},
created() {
this.loadInitData();
},
methods:{
async loadInitData() {
const res = await getPublishMapListOnline();
res.data.forEach(elem=>{
this.mapList.push({label:elem.name, value:parseInt(elem.id)});
this.queryForm.queryObject.mapId.config.data.push({label:elem.name, value:elem.id});
this.mapListMap[elem.id] = elem.name;
});
},
covertData() {
2020-12-30 09:32:19 +08:00
return this.mapList.filter(data=>{ return data.value != this.formModel.fromMapId; });
},
covertOtherData() {
return this.mapList.filter(data=>{ return data.value != this.formModel.toMapId; });
2020-12-29 15:59:43 +08:00
},
covertMap(row) {
2020-12-29 16:51:00 +08:00
return this.mapListMap[row.mapId];
2020-12-29 15:59:43 +08:00
},
handleDelete(index, row) {
this.$confirm('此操作将删除iscs数据是否继续?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
deleteIscs(row.id).then(res=>{
this.$message.success(this.$t('publish.deleteSuccess'));
this.reloadTable();
}).catch(() => {
this.reloadTable();
this.$messageBox(this.$t('error.deleteFailed'));
});
});
},
reloadTable() {
this.queryList.reload();
},
handleCopy(index, row) {
2020-12-30 09:32:19 +08:00
// this.formModel.fromId = row.id;
2020-12-29 15:59:43 +08:00
this.$nextTick(()=>{
this.dialogVisible = true;
});
},
doSave() {
this.$refs.dataform.validateForm(() => {
this.loading = true;
2020-12-29 15:59:43 +08:00
copyIscsData(this.formModel).then(res=>{
this.loading = false;
2020-12-29 15:59:43 +08:00
this.$message.success('复制ISCS数据成功');
this.close();
this.reloadTable();
}).catch(() => {
this.loading = false;
2020-12-29 15:59:43 +08:00
this.reloadTable();
this.$messageBox('复制ISCS数据失败');
});
});
},
close() {
this.$refs.dataform.resetForm();
this.dialogVisible = false;
}
}
};
</script>