254 lines
8.9 KiB
Vue
254 lines
8.9 KiB
Vue
|
<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">
|
||
|
<config-data ref="make" :form="formMake" :form-model="addModel" :rules="createRules" />
|
||
|
</el-scrollbar>
|
||
|
</div>
|
||
|
<div class="button_box">
|
||
|
<el-button-group class="map-draft-group">
|
||
|
<el-button type="primary" size="small" @click="create">{{ $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 ConfigList from './config/list';
|
||
|
import ConfigData from './config/data';
|
||
|
import { deepAssign } from '@/utils/index';
|
||
|
|
||
|
export default {
|
||
|
name: 'ZcControlDraft',
|
||
|
components: {
|
||
|
ConfigList,
|
||
|
ConfigData
|
||
|
},
|
||
|
props: {
|
||
|
selected: {
|
||
|
type: Object,
|
||
|
default: function () {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
activeName: 'first',
|
||
|
mapData: null,
|
||
|
editModel: {
|
||
|
code: '',
|
||
|
name: '',
|
||
|
visible: '',
|
||
|
position: {
|
||
|
x: 0,
|
||
|
y: 0
|
||
|
}
|
||
|
},
|
||
|
addModel: {
|
||
|
code: '',
|
||
|
name: '',
|
||
|
visible: '',
|
||
|
position: {
|
||
|
x: 0,
|
||
|
y: 0
|
||
|
}
|
||
|
},
|
||
|
rules: {
|
||
|
code: [
|
||
|
{ required: true, message: this.$t('rules.pleaseSelectEncoding'), trigger: 'change' }
|
||
|
],
|
||
|
name: [
|
||
|
{ required: true, message: this.$t('rules.pleaseEnterStatusSignal'), trigger: 'blur' }
|
||
|
],
|
||
|
visible: [
|
||
|
{ required: true, message: this.$t('rules.visible'), trigger: 'change' }
|
||
|
],
|
||
|
'position.x': [
|
||
|
{ required: true, message: this.$t('rules.trainPositionX'), trigger: 'blur' }
|
||
|
],
|
||
|
'position.y': [
|
||
|
{ required: true, message: this.$t('rules.trainPositionY'), trigger: 'blur' }
|
||
|
]
|
||
|
}
|
||
|
};
|
||
|
},
|
||
|
computed: {
|
||
|
...mapGetters('map', [
|
||
|
'sectionList',
|
||
|
'trainModelList',
|
||
|
'zcList',
|
||
|
'lineCode'
|
||
|
]),
|
||
|
form() {
|
||
|
const form = {
|
||
|
labelWidth: '150px',
|
||
|
items: {
|
||
|
code: {
|
||
|
name: '',
|
||
|
item: []
|
||
|
},
|
||
|
draw: {
|
||
|
name: this.$t('map.drawData'),
|
||
|
item: [
|
||
|
{ prop: 'code', label: `${this.$t('map.zcZoneControl')}${this.$t('map.code')}`, type: 'select', optionLabel: 'name&&code', optionValue: 'code', options: this.zcList, change: true, deviceChange: this.deviceChange },
|
||
|
{ prop: 'name', label: this.$t('map.statusSignalName'), type: 'input' },
|
||
|
{ prop: 'visible', label: this.$t('map.showZc'), type: 'checkboxx' },
|
||
|
{ prop: 'position', label: this.$t('map.stateSignalsPlotCoordinates'), type: 'coordinate', width: '140px', children: [
|
||
|
{ prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px' },
|
||
|
{ prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px' }
|
||
|
] }
|
||
|
]
|
||
|
},
|
||
|
map: {
|
||
|
name: this.$t('map.mapData'),
|
||
|
item: []
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
return form;
|
||
|
},
|
||
|
formMake() {
|
||
|
const form = {
|
||
|
labelWidth: '150px',
|
||
|
items: [
|
||
|
{ prop: 'name', label: this.$t('map.statusSignalName'), type: 'input' },
|
||
|
{ prop: 'position', label: this.$t('map.stateSignalsPlotCoordinates'), type: 'coordinate', width: '140px', children: [
|
||
|
{ prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '20px' },
|
||
|
{ prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '20px' }
|
||
|
] }
|
||
|
]
|
||
|
};
|
||
|
return form;
|
||
|
},
|
||
|
createRules: function () {
|
||
|
return {
|
||
|
name: [
|
||
|
{ required: true, message: this.$t('rules.pleaseEnterStatusSignal'), trigger: 'blur' }
|
||
|
],
|
||
|
'position.x': [
|
||
|
{ required: true, message: this.$t('rules.trainPositionX'), trigger: 'blur' }
|
||
|
],
|
||
|
'position.y': [
|
||
|
{ required: true, message: this.$t('rules.trainPositionY'), trigger: 'blur' }
|
||
|
]
|
||
|
};
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
selected(val, oldVal) {
|
||
|
this.deviceSelect(val);
|
||
|
}
|
||
|
},
|
||
|
mounted() {
|
||
|
},
|
||
|
methods: {
|
||
|
deviceChange(code) {
|
||
|
this.$emit('setCenter', code);
|
||
|
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
|
||
|
},
|
||
|
deviceSelect(selected) {
|
||
|
this.$refs.dataform.resetFields();
|
||
|
this.$refs.make.resetFields();
|
||
|
if (selected && selected._type.toUpperCase() === 'ZcControl'.toUpperCase()) {
|
||
|
this.activeName = 'first';
|
||
|
this.editModel = deepAssign(this.editModel, selected);
|
||
|
}
|
||
|
},
|
||
|
create() {
|
||
|
this.$refs.make.validate((valid) => {
|
||
|
if (valid) {
|
||
|
const uid = getUID('ZcControl');
|
||
|
const model = {
|
||
|
_type: 'ZcControl',
|
||
|
code: uid,
|
||
|
visible: true,
|
||
|
name: this.addModel.name,
|
||
|
position: {
|
||
|
x: this.addModel.position.x,
|
||
|
y: this.addModel.position.y
|
||
|
}
|
||
|
};
|
||
|
this.$emit('updateMapModel', model);
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
// 修改对象
|
||
|
edit() {
|
||
|
this.$refs['dataform'].validate((valid) => {
|
||
|
if (valid) {
|
||
|
const data = Object.assign({_type: 'ZcControl'}, this.editModel);
|
||
|
this.$emit('updateMapModel', data);
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
// 删除对象
|
||
|
deleteObj() {
|
||
|
const selected = this.$store.getters['map/getDeviceByCode'](this.editModel.code);
|
||
|
if (selected && selected._type.toUpperCase() === 'ZcControl'.toUpperCase()) {
|
||
|
const _that = this;
|
||
|
this.$confirm(this.$t('tip.confirmDeletion'), this.$t('tip.hint'), {
|
||
|
confirmButtonText: this.$t('tip.confirm'),
|
||
|
cancelButtonText: this.$t('tip.cancel'),
|
||
|
type: 'warning'
|
||
|
}).then(() => {
|
||
|
_that.$emit('updateMapModel', {...selected, _dispose: true});
|
||
|
_that.deviceSelect();
|
||
|
}).catch(() => {
|
||
|
_that.$message.info(this.$t('tip.cancelledDelete'));
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
</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: 160px;
|
||
|
font-weight: bold;
|
||
|
display: block;
|
||
|
float: left;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.map-draft-group {
|
||
|
color: #3E44BE;
|
||
|
}
|
||
|
</style>
|