修改代码

This commit is contained in:
zyy 2019-07-26 15:59:31 +08:00
parent 797f31f142
commit 1305046304
5 changed files with 213 additions and 86 deletions

View File

@ -2,9 +2,15 @@ export function getAttrList(code, key, that) {
attribute[code][key].items.forEach(ele => {
if (ele.type == 'select') {
ele.options = that[ele.optionCode];
if (ele.change && that[ele.deviceChange]) {
ele.deviceChange = that[ele.deviceChange];
}
}
if (ele.change && that[ele.deviceChange]) {
ele.deviceChange = that[ele.deviceChange];
}
if (ele.isDisabled) {
ele.disabled = that[ele.isDisabled];
}
if (ele.hiddenName) {
ele.isHidden = !that[ele.hiddenName];
}
});
return Object.assign({}, attribute[code][key]);
@ -20,15 +26,15 @@ export const attribute = {
attr: {
labelWidth: '130px',
items: [
{ prop: 'code', label: 'Link编码:', type: 'select', required: true, options: [], optionCode: 'linkList', change: true, deviceChange: 'deviceChange' },
{ prop: 'code', label: 'Link编码:', type: 'select', optionLabel: 'name&&code', required: true, options: [], optionCode: 'linkList', change: true, deviceChange: 'deviceChange' },
{ prop: 'name', label: 'Link名称:', type: 'input', required: true },
{ prop: 'lengthShow', label: 'Link显示长度:', type: 'number', required: false },
{ prop: 'lengthFact', label: 'Link实际长度:', type: 'number', required: true },
{ prop: 'color', label: 'Link颜色:', type: 'color', required: false },
{ prop: 'leftFdCode', label: '左侧正向Link:', type: 'select', required: false, options: [], optionCode: 'linkList' },
{ prop: 'leftSdCode', label: '左侧侧向Link:', type: 'select', required: false, options: [], optionCode: 'linkList' },
{ prop: 'rightFdCode', label: '右侧正向Link:', type: 'select', required: false, options: [], optionCode: 'linkList' },
{ prop: 'rightSdCode', label: '右侧侧向Link:', type: 'select', required: false, options: [], optionCode: 'linkList' },
{ prop: 'leftFdCode', label: '左侧正向Link:', type: 'select', optionLabel: 'name&&code', required: false, options: [], optionCode: 'linkList' },
{ prop: 'leftSdCode', label: '左侧侧向Link:', type: 'select', optionLabel: 'name&&code', required: false, options: [], optionCode: 'linkList' },
{ prop: 'rightFdCode', label: '右侧正向Link:', type: 'select', optionLabel: 'name&&code', required: false, options: [], optionCode: 'linkList' },
{ prop: 'rightSdCode', label: '右侧侧向Link:', type: 'select', optionLabel: 'name&&code', required: false, options: [], optionCode: 'linkList' },
{ prop: 'lp', label: 'Link 起点坐标:', type: 'coordinate', children: [
{ prop: 'x', label: 'x:', type: 'number', labelWidth: '20px', disabled: true, required: false },
{ prop: 'y', label: 'y:', type: 'number', labelWidth: '20px', disabled: true, required: false }
@ -50,5 +56,96 @@ export const attribute = {
]
}
}
},
// model model数据名称 disabledType 判断禁用类型 disabledValue 判断值
section: {
attr: {
labelWidth: '160px',
items: [
{ prop: 'stationCode', label: '所属设备集中站:', type: 'select', optionLabel: 'name&&code', disabled: false, required: true, options: [], optionCode: 'stationList', isDisabled: 'isStationCodeDisabled'},
{ prop: 'parentCode', label: '关联物理区段:', type: 'select', optionLabel: 'code&&name', disabled: true, required: false, options: [], optionCode: 'stationList', isHidden: true, hiddenName: 'isParentCode' },
{ prop: 'code', label: '区段编码:', type: 'select', optionLabel: 'code&&name', required: true, options: [], optionCode: 'stationList', change: true, deviceChange: 'deviceChange' },
{ prop: 'type', label: '区段类型:', type: 'select', optionLabel: 'name', required: true, options: [], optionCode: 'SectionTypeList' },
{ prop: 'name', label: '区段名称:', type: 'input', required: true },
{ prop: 'namePoint', label: '区段名称偏移量:', type: 'coordinate', children: [
{ prop: 'x', label: 'x:', type: 'number', labelWidth: '20px', required: true },
{ prop: 'y', label: 'y:', type: 'number', labelWidth: '20px', required: true }
] },
{ prop: 'kmRangeLeft', label: '左侧公里标(米):', type: 'number', required: false },
{ prop: 'kmRangeRight', label: '右侧公里标(米):', type: 'number', required: false },
{ prop: 'region', label: '区间:', type: 'select', optionLabel: 'label', required: false, options: [], optionCode: 'regionList' },
{ prop: 'nameShow', label: '是否显示区段名称:', type: 'checkbox', required: false },
{ prop: 'axleShow', label: '是否显示计轴:', type: 'checkbox', disabled: false, required: false, isHidden: true, hiddenName: 'isSectionType', isDisabled: 'isStationAxleShow' },
{ prop: 'logicSectionShow', label: '是否显示逻辑区段:', type: 'checkbox', disabled: false, required: false, isHidden: true, hiddenName: 'isSectionType' },
{ prop: 'logicSectionNameShow', label: '是否显示逻辑区段名称:', type: 'checkbox', disabled: false, required: false, isHidden: true, hiddenName: 'isSectionType', isDisabled: 'islogicSectionNameShow' },
{ prop: 'isStandTrack', label: '是否站台轨:', type: 'checkbox', disabled: false, required: false, isHidden: true, hiddenName: 'isSectionType' },
{ prop: 'standTrackName', label: '站台轨名称:', type: 'input', required: true, isHidden: true, hiddenName: 'isstandTrackNameShow' },
{ prop: 'standTrackNamePosition', label: '站台轨名称偏移量:', type: 'coordinate', children: [
{ prop: 'x', label: 'x:', type: 'number', labelWidth: '20px', disabled: true, required: false },
{ prop: 'y', label: 'y:', type: 'number', labelWidth: '20px', disabled: true, required: false }
] }
// { prop: 'leftSdCode', label: '左侧侧向Link:', type: 'select', required: false, options: [], optionCode: 'linkList' },
// { prop: 'rightFdCode', label: '右侧正向Link:', type: 'select', required: false, options: [], optionCode: 'linkList' },
// { prop: 'rightSdCode', label: '右侧侧向Link:', type: 'select', required: false, options: [], optionCode: 'linkList' },
// { prop: 'lp', label: 'Link 起点坐标:', type: 'coordinate', children: [
// { prop: 'x', label: 'x:', type: 'number', labelWidth: '20px', disabled: true, required: false },
// { prop: 'y', label: 'y:', type: 'number', labelWidth: '20px', disabled: true, required: false }
// ] },
// { prop: 'rp', label: 'Link 终点坐标:', type: 'coordinate', children: [
// { prop: 'x', label: 'x:', type: 'number', labelWidth: '20px', disabled: true, required: false },
// { prop: 'y', label: 'y:', type: 'number', labelWidth: '20px', disabled: true, required: false }
// ] }
],
rules: {
code: [
{ required: true, message: '请选择设备', trigger: 'change' }
],
name: [
{ required: true, message: '请输入区段名称', trigger: 'blur' }
],
type: [
{ required: true, message: '请输入区段类型', trigger: 'blur' }
],
relStandCode: [
{ required: true, message: '请选择关联站台', trigger: 'change' }
],
leftStopPointOffset: [
{ required: true, message: '请输入左向停车点偏移量', trigger: 'blur' }
],
rightStopPointOffset: [
{ required: true, message: '请输入右向停车点偏移量', trigger: 'blur' }
],
destinationCode: [
{ required: true, message: '请输入目的地码', trigger: 'blur' }
],
'destinationCodePoint.x': [
{ required: true, message: '请输入目的地码坐标X', trigger: 'blur' }
],
'destinationCodePoint.y': [
{ required: true, message: '请输入目的地码坐标Y', trigger: 'blur' }
],
'namePoint.x': [
{ required: true, message: '请输入区段名称坐标X', trigger: 'blur' }
],
'namePoint.y': [
{ required: true, message: '请输入区段名称坐标Y', trigger: 'blur' }
],
logicSectionNameSort: [
{ required: true, message: '请选择逻辑区段名称排序', trigger: 'change' }
],
offsetLeft: [
{ required: true, message: '请输入左侧Link偏移量', trigger: 'blur' }
],
sepTypeLeft: [
{ required: true, message: '请选择左侧分隔符', trigger: 'change' }
],
offsetRight: [
{ required: true, message: '请输入右侧Link偏移量', trigger: 'blur' }
],
sepTypeRight: [
{ required: true, message: '请选择右侧分隔符', trigger: 'change' }
]
}
}
}
};

View File

@ -184,11 +184,13 @@ export default {
},
//
handleDataLoaded() {
this.$store.dispatch('map/mapDataLoaded');
console.log('dataloaded');
},
//
handleViewLoaded() {
console.log('viewLoaded');
this.$store.dispatch('map/mapViewLoaded');
this.mapViewLoaded(false);
},
//

View File

@ -2,7 +2,7 @@
<el-form ref="form" :label-width="form.labelWidth" size="mini" :rules="rules" :model="formModel">
<template v-for="item in form.items">
<template v-if="checkFieldType(item, 'select')">
<el-form-item :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<template v-if="item.change">
<el-select
v-model="formModel[item.prop]"
@ -14,7 +14,7 @@
<el-option
v-for="option in item.options"
:key="option.code"
:label="option.name + ' (' + option.code+ ')'"
:label="handleLabel(option, item.optionLabel)"
:value="option.code"
/>
</el-select>
@ -29,42 +29,64 @@
<el-option
v-for="option in item.options"
:key="option.code"
:label="option.name + ' (' + option.code+ ')'"
:label="handleLabel(option, item.optionLabel)"
:value="option.code"
/>
</el-select>
</template>
</el-form-item>
</template>
<template v-if="checkFieldType(item, 'selectHover')">
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-select
v-model="formModel[item.prop]"
filterable
:placeholder="item.placeholder"
:disabled="item.disabled"
>
<el-option
v-for="option in item.options"
:key="option.code"
:label="handleLabel(option, item.optionLabel)"
:value="option.code"
/>
</el-select>
<el-button
:type="item.buttonType ? 'danger' : 'primary'"
@click="hover(item.selectHover)"
>激活</el-button>
</el-form-item>
</template>
<template v-if="checkFieldType(item, 'input')">
<el-form-item :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-input v-model="formModel[item.prop]" :disabled="item.disabled" />
</el-form-item>
</template>
<template v-if="checkFieldType(item, 'number')">
<el-form-item :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-input-number v-model="formModel[item.prop]" :min="50" :label="item.label" :disabled="item.disabled" />px
</el-form-item>
</template>
<template v-if="checkFieldType(item, 'color')">
<el-form-item :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-color-picker v-model="formModel[item.prop]" :predefine="skins" :disabled="item.disabled" />
</el-form-item>
</template>
<template v-if="checkFieldType(item, 'coordinate')">
<div :key="item.prop" class="coordinate">
<div v-if="!item.isHidden" :key="item.prop" class="coordinate">
<span class="title">{{ item.label }}</span>
<div v-for="opt in item.children" :key="opt.code" class="listWidth">
<el-form-item
:label="opt.label"
:prop="opt.prop"
:label-width="opt.labelWidth"
>
<el-form-item :label="opt.label" :prop="opt.prop" :label-width="opt.labelWidth">
<el-input-number v-model="formModel[item.prop][opt.prop]" :label="opt.label" :disabled="opt.disabled" />
</el-form-item>
</div>
</div>
</template>
<template v-if="checkFieldType(item, 'checkbox')">
<el-form-item v-if="!item.isHidden" :key="item.prop" :label="item.label" :prop="item.prop" :required="item.required">
<el-checkbox v-model="formModel[item.prop]" />
</el-form-item>
</template>
</template>
</el-form></template>
@ -91,6 +113,19 @@ export default {
};
},
methods: {
handleLabel(option, label) {
if (label == 'name') {
return option.name;
} else if (label == 'code') {
return option.code;
} else if (label == 'label') {
return option.label;
} else if (label == 'name&&code') {
return option.name + ' (' + option.code+ ')';
} else if (label == 'code&&name') {
return option.code + ' (' + option.name+ ')';
}
},
checkFieldType(field, type) {
if (field.hasOwnProperty('show')) {
return field.type === type && field.show;

View File

@ -129,7 +129,7 @@ import { mapGetters } from 'vuex';
import { getUID } from '@/jmap/utils/Uid';
import { getUName } from '@/jmap/utils/Uname';
import ConfigList from './config/list';
import { getAttrList, getAttrRules, attribute } from '@/scripts/attribute';
import { getAttrList, getAttrRules } from '@/scripts/attribute';
export default {
name: 'LinkDraft',
@ -266,7 +266,6 @@ export default {
this.activeName = 'first';
},
'$store.state.map.mapDataLoadedCount': function() {
console.log(1111);
this.form = getAttrList('link', 'attr', this);
}
},

View File

@ -4,7 +4,7 @@
<el-tab-pane class="view-control" label="属性" name="first">
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: cardHeight +'px' }">
<el-form ref="form" :model="editModel" label-width="160px" size="mini" :rules="rules">
<el-form-item label="所属设备集中站:" prop="stationCode">
<!-- <el-form-item label="所属设备集中站:" prop="stationCode">
<el-select v-model="editModel.stationCode" filterable :disabled="editModel.type === '02'">
<el-option
v-for="item in stationList"
@ -88,29 +88,28 @@
</el-form-item>
<el-form-item label="是否显示区段名称:" prop="nameShow">
<el-checkbox v-model="editModel.nameShow" />
</el-form-item>
</el-form-item> -->
<template v-if="editModel.type !== '03'">
<el-form-item label="是否显示计轴:" prop="axleShow">
<el-checkbox v-model="editModel.axleShow" :disabled="editModel.section === '02'" />
</el-form-item>
<el-form-item label="是否显示逻辑区段:" prop="logicSectionShow">
<!-- <el-form-item label="是否显示计轴:" prop="axleShow">
<el-checkbox v-model="editModel.axleShow" />
</el-form-item> -->
<!-- <el-form-item label="是否显示逻辑区段:" prop="logicSectionShow">
<el-checkbox
v-model="editModel.logicSectionShow"
:disabled="editModel.section === '02'"
/>
</el-form-item>
<el-form-item label="是否显示逻辑区段名称:" prop="logicSectionNameShow">
</el-form-item> -->
<!-- <el-form-item label="是否显示逻辑区段名称:" prop="logicSectionNameShow">
<el-checkbox
v-model="editModel.logicSectionNameShow"
:disabled="editModel.section === '02'|| editModel.section !== '02'&&!editModel.logicSectionShow"
:disabled="!editModel.logicSectionShow"
/>
</el-form-item>
</el-form-item> -->
<div class="coordinate">
<el-form-item label="是否站台轨:" prop="isStandTrack">
<el-checkbox v-model="editModel.isStandTrack" />
</el-form-item>
<div v-if="editModel.isStandTrack">
<el-form-item label="站台轨名称:" prop="standTrackName">
<!-- <el-form-item label="站台轨名称:" prop="standTrackName">
<el-input v-model="editModel.standTrackName" />
</el-form-item>
<span class="title">站台轨名称偏移量:</span>
@ -129,7 +128,7 @@
label-width="20px"
>
<el-input-number v-model="editModel.standTrackNamePosition.y" />
</el-form-item>
</el-form-item> -->
<el-form-item v-if="editModel.type=='01'" label="站台编码:" prop="relStandCode">
<el-select v-model="editModel.relStandCode" filterable>
<el-option
@ -377,6 +376,7 @@
</el-form-item>
</template>
</el-form>
<config-list ref="dataform" :form="form" :form-model="editModel" :rules="rules" />
</el-scrollbar>
<el-button-group class="map-draft-group">
<el-button type="primary" @click="edit">修改</el-button>
@ -530,10 +530,13 @@
import { mapGetters } from 'vuex';
import { getUID } from '@/jmap/utils/Uid';
import JTriangle from '@/jmap/utils/JTriangle';
import ConfigList from './config/list';
import { getAttrList, getAttrRules } from '@/scripts/attribute';
export default {
name: 'SectionDraft',
components: {
ConfigList
},
props: {
selected: {
@ -549,6 +552,7 @@ export default {
},
data() {
return {
form: getAttrList('section', 'attr', this),
linksCollection: [],
activeName: 'first',
SectionTypeList: [],
@ -616,56 +620,6 @@ export default {
logicSectionNums: [1],
fieldS: '',
field: '',
rules: {
code: [
{ required: true, message: '请选择设备', trigger: 'change' }
],
name: [
{ required: true, message: '请输入区段名称', trigger: 'blur' }
],
type: [
{ required: true, message: '请输入区段类型', trigger: 'blur' }
],
relStandCode: [
{ required: true, message: '请选择关联站台', trigger: 'change' }
],
leftStopPointOffset: [
{ required: true, message: '请输入左向停车点偏移量', trigger: 'blur' }
],
rightStopPointOffset: [
{ required: true, message: '请输入右向停车点偏移量', trigger: 'blur' }
],
destinationCode: [
{ required: true, message: '请输入目的地码', trigger: 'blur' }
],
'destinationCodePoint.x': [
{ required: true, message: '请输入目的地码坐标X', trigger: 'blur' }
],
'destinationCodePoint.y': [
{ required: true, message: '请输入目的地码坐标Y', trigger: 'blur' }
],
'namePoint.x': [
{ required: true, message: '请输入区段名称坐标X', trigger: 'blur' }
],
'namePoint.y': [
{ required: true, message: '请输入区段名称坐标Y', trigger: 'blur' }
],
logicSectionNameSort: [
{ required: true, message: '请选择逻辑区段名称排序', trigger: 'change' }
],
offsetLeft: [
{ required: true, message: '请输入左侧Link偏移量', trigger: 'blur' }
],
sepTypeLeft: [
{ required: true, message: '请选择左侧分隔符', trigger: 'change' }
],
offsetRight: [
{ required: true, message: '请输入右侧Link偏移量', trigger: 'blur' }
],
sepTypeRight: [
{ required: true, message: '请选择右侧分隔符', trigger: 'change' }
]
},
addRules: {
code: [
{ required: true, message: '请选择区段名称', trigger: 'change' }
@ -700,6 +654,15 @@ export default {
'stationStandList',
'skinStyle'
]),
rules() {
const baseRules = getAttrRules('section', 'attr');
//
this.$nextTick(function () {
this.$refs.dataform.clearValidate();
});
return baseRules;
},
PhysicalSectionList() {
let list = [];
if (this.sectionList && this.sectionList.length) {
@ -728,6 +691,26 @@ export default {
});
}
return list;
},
//
isParentCode() {
return this.editModel.type == '02' || this.editModel.relSwitchCode;
},
isStationCodeDisabled() {
return this.editModel.type == '02';
},
isSectionType() {
return this.editModel.type !== '03';
},
isStationAxleShow() {
return this.editModel.section == '02';
},
islogicSectionNameShow() {
return !this.editModel.logicSectionShow && this.editModel.isStandTrack;
},
isstandTrackNameShow() {
return this.editModel.type !== '03';
}
},
watch: {
@ -735,8 +718,19 @@ export default {
this.deviceSelect(val);
},
$route() {
this.$refs.form.resetFields();
this.$refs.dataform.clearValidate();
this.activeName = 'first';
},
editModel: {
handler: function() {
if (this.sectionList) {
this.form = getAttrList('section', 'attr', this);
}
},
deep: true
},
'$store.state.map.mapDataLoadedCount': function() {
this.form = getAttrList('section', 'attr', this);
}
},
mounted() {