删除页面link设置

This commit is contained in:
joylink_cuiweidong 2019-11-29 13:27:17 +08:00
parent 34272d7644
commit 46713bf074
3 changed files with 1 additions and 563 deletions

View File

@ -119,7 +119,6 @@ export default {
break;
}
}
this.$refs.menu.doClose();
},
showContextMenu(e, obj, node, vueElem) {
if (obj && obj.type == 'map') {

View File

@ -13,14 +13,6 @@
<el-button type="text" style="float: right; padding: 3px 0; margin-right: 5px;" @click="showMap">{{ $t('map.viewLayer') }}</el-button>
</div>
<el-tabs v-model="enabledTab" class="mapEdit" type="card">
<el-tab-pane :label="$t('map.link')" class="tab_pane_box" name="Link">
<link-draft
ref="Link"
:selected="selected"
@updateMapModel="updateMapModel"
@setCenter="setCenter"
/>
</el-tab-pane>
<el-tab-pane :label="$t('map.section')" class="tab_pane_box" name="Section">
<section-draft
ref="Section"
@ -175,7 +167,6 @@
</template>
<script>
import LinkDraft from './link';
import SectionDraft from './section';
import SwitchDraft from './switch';
import SignalDraft from './signal';
@ -201,7 +192,6 @@ export default {
name: 'MapOperate',
components: {
CounterDraft,
LinkDraft,
SectionDraft,
SwitchDraft,
SignalDraft,
@ -249,7 +239,7 @@ export default {
],
logicalLevelsSelect: [],
physicalLevelsSelect: [],
enabledTab: 'Link',
enabledTab: 'Section',
autoSaveTask: null,
show: {
mapEditShow: false,

View File

@ -1,551 +0,0 @@
<template>
<el-tabs v-model="activeName" class="card">
<el-tab-pane class="view-control" :label="$t('map.property')" name="first">
<div style="height: calc(100% - 46px);">
<el-scrollbar wrap-class="scrollbar-wrapper">
<config-list ref="dataform" :form="form" :form-model="editModel" :rules="rules" />
</el-scrollbar>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button type="primary" size="small" @click="edit">{{ $t('map.updateObj') }}</el-button>
<el-button type="danger" size="small" @click="deleteObj">{{ $t('map.deleteObj') }}</el-button>
</el-button-group>
</div>
</el-tab-pane>
<el-tab-pane class="view-control" :label="$t('map.newConstruction')" name="second">
<div style="height: calc(100% - 46px);">
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-form ref="make" label-width="120px" :model="addModel" size="mini">
<el-form-item :label="$t('map.linkType')">
<el-radio-group v-model="LinkType">
<el-radio
v-for="item in LinkTypeList"
:key="item.value"
:label="item.value"
border
:disabled="item.disabled"
size="mini"
>{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="isNew">
<config-data ref="make1" :form="formMake1" :form-model="addModel" :rules="makeRules1" />
</template>
<template v-if="isFd">
<config-data ref="make2" :form="formMake2" :form-model="addModel" :rules="makeRules2" />
</template>
<template v-if="isSd">
<config-data ref="make3" :form="formMake3" :form-model="addModel" :rules="makeRules3" />
</template>
</el-form>
</el-scrollbar>
</div>
<div class="button_box">
<el-button-group class="map-draft-group">
<el-button v-if="isNew" type="primary" size="small" @click="isNewCreate">{{ $t('map.create') }}</el-button>
<el-button v-if="isFd" type="primary" size="small" @click="isFdCreate">{{ $t('map.create') }}</el-button>
<el-button v-if="isSd" type="primary" size="small" @click="isSdCreate">{{ $t('map.create') }}</el-button>
</el-button-group>
</div>
</el-tab-pane>
</el-tabs>
</template>
<script>
import { mapGetters } from 'vuex';
import { getUID } from '@/jmap/utils/Uid';
import { getUName } from '@/jmap/utils/Uname';
import ConfigList from './config/list';
import ConfigData from './config/data';
import { deepAssign } from '@/utils/index';
export default {
name: 'LinkDraft',
components: {
ConfigList,
ConfigData
},
props: {
selected: {
type: Object,
default: function () {
return null;
}
}
},
data() {
return {
linkLists: [],
activeName: 'first',
LinkType: '0',
LinkTypeList: [],
LinkDriectTypeList: [],
editModel: {
code: '',
type: '',
name: '',
lengthFact: 0,
leftFdCode: '',
leftSdCode: '',
rightFdCode: '',
rightSdCode: '',
lp: {
x: 0,
y: 0
},
rp: {
x: 0,
y: 0
}
},
addModel: {
code: '',
type: '01',
direct: 'R',
x: 0,
y: 0,
lengthShow: 200,
lengthFact: 0,
lfd: '',
rfd: ''
},
skins: [],
makeRules1: {
x: [
{ required: true, message: this.$t('rules.linkXCoordinate'), trigger: 'blur' }
],
y: [
{ required: true, message: this.$t('rules.linkYCoordinate'), trigger: 'blur' }
],
lengthShow: [
{ required: true, message: this.$t('rules.linkEnterLength'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkEnterDisplayLength'), trigger: 'blur' }
]
},
makeRules2: {
code: [
{ required: true, message: this.$t('rules.linkSelectBase'), trigger: 'change' }
],
lengthShow: [
{ required: true, message: this.$t('rules.linkEnterLength'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkEnterDisplayLength'), trigger: 'blur' }
]
},
makeRules3: {
lfd: [
{ required: true, message: this.$t('rules.linkEnterLeft'), trigger: 'blur' }
],
rfd: [
{ required: true, message: this.$t('rules.linkEnterRight'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkEnterDisplayLength'), trigger: 'blur' }
]
}
};
},
computed: {
...mapGetters('map', [
'linkList'
]),
form() {
return {
labelWidth: '130px',
items: {
code: {
name: '',
item: []
},
draw: {
name: this.$t('map.drawData'),
item: [
{ prop: 'code', label: this.$t('map.linkCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkList, change: true, deviceChange: this.deviceChange },
{ prop: 'name', label: this.$t('map.linkName'), type: 'input' },
{ prop: 'lp', label: this.$t('map.linkLp'), type: 'coordinate', width: '119px', children: [
{ prop: 'lp.x', firstLevel: 'lp', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px', disabled: false },
{ prop: 'lp.y', firstLevel: 'lp', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px', disabled: false }
] },
{ prop: 'rp', label: this.$t('map.linkRp'), type: 'coordinate', width: '119px', children: [
{ prop: 'rp.x', firstLevel: 'rp', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px', disabled: false },
{ prop: 'rp.y', firstLevel: 'rp', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px', disabled: false }
] },
{ prop: 'leftFdCode', label: this.$t('map.linkLeftFdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists },
{ prop: 'leftSdCode', label: this.$t('map.linkLeftSdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists },
{ prop: 'rightFdCode', label: this.$t('map.linkRightFdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists },
{ prop: 'rightSdCode', label: this.$t('map.linkRightSdCode'), type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.linkLists }
]
},
map: {
name: this.$t('map.mapData'),
item: [
{ prop: 'lengthFact', label: this.$t('map.linkActualLength'), type: 'number', min: 0, placeholder: this.$t('tip.meter') }
]
}
}
};
},
rules() {
return {
code: [
{ required: true, message: this.$t('rules.selectEquipment'), trigger: 'change' }
],
name: [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'lp.x': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'lp.y': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'rp.x': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
'rp.y': [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
],
lengthFact: [
{ required: true, message: this.$t('rules.linkSelectName'), trigger: 'blur' }
]
};
},
formMake1() {
return {
labelWidth: '120px',
items: [
{ prop: 'lengthShow', label: this.$t('rules.lengthShow'), type: 'number', min: 0, placeholder: 'px' },
{ prop: 'lengthFact', label: this.$t('rules.lengthFact'), type: 'number', min: 0, placeholder: this.$t('tip.meter') },
{ prop: 'x', label: this.$t('rules.pointX'), type: 'number', placeholder: 'px' },
{ prop: 'y', label: this.$t('rules.pointY'), type: 'number', placeholder: 'px' }
]
};
},
formMake2() {
return {
labelWidth: '120px',
items: [
{ prop: 'code', label: this.$t('rules.basisLink'), type: 'select', optionLabel: 'name', optionValue: 'code', options: this.linkList },
{ prop: 'direct', label: this.$t('rules.direct'), type: 'radio', border: true, radioList: this.LinkDriectTypeList },
{ prop: 'lengthShow', label: this.$t('rules.lengthShow'), type: 'number', min: 0, placeholder: 'px', isHidden: this.isSd },
{ prop: 'lengthFact', label: this.$t('rules.lengthFact'), type: 'number', min: 0, placeholder: this.$t('tip.meter') }
]
};
},
formMake3() {
return {
labelWidth: '120px',
items: [
{ prop: 'lfd', label: '左侧正向Link:', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.linkList },
{ prop: 'rfd', label: '右侧正向Link:', type: 'select', optionLabel: 'name', optionValue: 'code', options: this.linkList },
{ prop: 'lengthShow', label: this.$t('rules.lengthShow'), type: 'number', min: 0, placeholder: 'px', isHidden: this.isSd },
{ prop: 'lengthFact', label: this.$t('rules.lengthFact'), type: 'number', min: 0, placeholder: this.$t('tip.meter') }
]
};
},
// link
isNew() {
return this.LinkType === '0';
},
// link
isFd() {
return this.LinkType === '1';
},
// link
isSd() {
return this.LinkType === '2';
}
},
watch: {
LinkType(val) {
this.addModel.type = val == '2' ? '02' : '01';
},
selected(val, oldVal) {
this.deviceSelect(val);
},
linkList(value) {
this.linkLists = JSON.parse(JSON.stringify(this.linkList));
this.linkLists.unshift({code: '', name: '无'});
}
},
mounted() {
this.LinkTypeList = this.$ConstSelect.LinkTypeList;
this.LinkDriectTypeList = this.$ConstSelect.LinkDriectTypeList;
},
methods: {
deviceChange(code) {
this.$emit('setCenter', code);
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
this.$nextTick(() => {
this.$refs.dataform.resetFields();
this.$refs.make.resetFields();
if (selected && selected._type.toUpperCase() === 'Link'.toUpperCase()) {
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected); //
this.addModel.code = selected.code;
}
});
},
isNewCreate() {
this.$refs['make1'].validate((valid) => {
if (valid) {
var uid = getUID('Link');
var uname = getUName(this.linkList);
const edits = [];
if (this.isNew) {
// link
const x = this.addModel.x;
const y = this.addModel.y;
var model = {
_type: 'Link',
code: uid,
name: uname,
type: this.addModel.type,
lp: {
x: x,
y: y
},
rp: {
x: x + this.addModel.lengthShow,
y: y
},
lengthFact: this.addModel.lengthFact,
color: this.addModel.color ? this.addModel.color : '#4e8de6'
};
edits.push(model);
}
this.$emit('updateMapModel', edits);
}
});
},
isFdCreate() {
this.$refs['make2'].validate((valid) => {
if (valid) {
var uid = getUID('Link');
var uname = getUName(this.linkList);
const edits = [];
var baseLink = null;
if (this.addModel) {
baseLink = deepAssign({}, this.$store.getters['map/getDeviceByCode'](this.addModel.code));
}
var leftFdCode = '';
var rightFdCode = '';
if (this.isFd) {
let lp = {};
let rp = {};
if (baseLink && baseLink._type.toUpperCase() === 'Link'.toUpperCase()) {
if (this.addModel.direct === 'L') {
lp = {
x: baseLink.lp.x - this.addModel.lengthShow,
y: baseLink.lp.y
};
rp = {
x: baseLink.lp.x,
y: baseLink.lp.y
};
rightFdCode = baseLink.code;
baseLink.leftFdCode = uid;
edits.push(baseLink);
} else {
lp = {
x: baseLink.rp.x,
y: baseLink.rp.y
};
rp = {
x: baseLink.rp.x + this.addModel.lengthShow,
y: baseLink.rp.y
};
leftFdCode = baseLink.code;
baseLink.rightFdCode = uid;
edits.push(baseLink);
}
const model = {
_type: 'Link',
code: uid,
name: uname,
type: this.addModel.type,
lp: lp,
rp: rp,
lengthFact: this.addModel.lengthFact,
leftFdCode: leftFdCode,
rightFdCode: rightFdCode
};
edits.push(model);
}
}
this.$emit('updateMapModel', edits);
}
});
},
isSdCreate() {
this.$refs['make3'].validate((valid) => {
if (valid) {
var uid = getUID('Link');
var uname = getUName(this.linkList);
const edits = [];
if (this.isSd) {
var lnode = this.findLinkData(this.addModel.lfd);
var rnode = this.findLinkData(this.addModel.rfd);
if (lnode && rnode) {
const model = {
_type: 'Link',
code: uid,
name: uname,
type: this.addModel.type,
lp: {
x: lnode.rp.x,
y: lnode.rp.y
},
rp: {
x: rnode.lp.x,
y: rnode.lp.y
},
lengthFact: this.addModel.lengthFact,
color: this.addModel.color ? this.addModel.color : '#4e8de6',
leftFdCode: lnode.code,
rightFdCode: rnode.code
};
if (rnode.lp.y === lnode.rp.y) {
lnode.rightFdCode = uid;
rnode.leftFdCode = uid;
edits.push(lnode);
edits.push(rnode);
} else {
lnode.rightSdCode = uid;
rnode.leftSdCode = uid;
edits.push(lnode);
edits.push(rnode);
}
edits.push(model);
}
}
this.$emit('updateMapModel', edits);
}
});
},
//
edit() {
this.$refs['dataform'].validate((valid) => {
if (valid) {
const data = Object.assign({_type: 'Link'}, this.editModel);
this.$emit('updateMapModel', data);
}
});
},
updateRelatedModel(node, code) {
const data = Object.assign({ _type: 'Link' }, node);
if (node.leftFdCode == code) {
data.leftFdCode = '';
return data;
}
if (node.leftSdCode == code) {
data.leftSdCode = '';
return data;
}
if (node.rightFdCode == code) {
data.rightFdCode = '';
return data;
}
if (node.rightSdCode == code) {
data.rightSdCode = '';
return data;
}
return { _type: 'Link', code: node.code };
},
deleteObj() {
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
if (selected && selected._type.toUpperCase() === 'Link'.toUpperCase()) {
let node = null;
var _that = this;
const updates = [];
// link
if (selected.leftFdCode) {
node = this.findLinkData(selected.leftFdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
if (selected.leftSdCode) {
node = this.findLinkData(selected.leftSdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
if (selected.rightFdCode) {
node = this.findLinkData(selected.rightFdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
if (selected.rightSdCode) {
node = this.findLinkData(selected.rightSdCode);
node && updates.push(this.updateRelatedModel(node, selected.code));
}
this.$confirm(this.$t('tip.confirmDeletion'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel'),
type: 'warning'
}).then(() => {
updates.push(deepAssign(selected, {_dispose: true}));
_that.$emit('updateMapModel', updates);
_that.deviceSelect();
}).catch(() => {
_that.$message.info(this.$t('tip.cancelledDelete'));
});
}
},
findLinkData(code) {
let link = null;
const linkList = this.linkList;
if (linkList && linkList.length) {
for (var i = 0; i < linkList.length; i++) {
if (code === linkList[i].code) {
link = JSON.parse(JSON.stringify(linkList[i]));
return link;
}
}
}
return link;
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.view-control{
height: 100%;
}
.card {
height: 100%;
}
.coordinate {
overflow: hidden;
.title {
text-align: right;
font-size: 14px;
color: #606266;
line-height: 40px;
padding: 0 12px 0 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
line-height: 28px;
width: 120px;
font-weight: bold;
display: block;
float: left;
margin-right: 7px;
}
}
</style>