This commit is contained in:
fan 2020-12-14 17:55:08 +08:00
commit 081bebf16d
3 changed files with 30 additions and 73 deletions

View File

@ -107,12 +107,13 @@ export default {
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
// this.$refs.dataform && this.$refs.dataform.resetFields();
// this.editModel = getModel('Arrow');
this.$refs.createForm && this.$refs.createForm.resetFields();
if (selected && selected._type.toUpperCase() === 'Arrow'.toUpperCase()) {
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
this.$nextTick(()=>{
this.$refs.dataform && this.$refs.dataform.resetFields();
this.editModel = deepAssign(this.editModel, selected);
});
}
},
clear() {

View File

@ -14,7 +14,7 @@
<el-tab-pane class="view-control" :label="$t('map.newConstruction')" name="second" :lazy="lazy">
<create-operate
ref="createForm"
:create-form="makeForm"
:create-form="form"
:add-model="addModel"
:create-rules="rules"
@create="create"
@ -99,9 +99,9 @@ export default {
labelWidth: '120px',
items: {
draw: {
name: this.$t('map.drawData'),
name: this.activeName == 'first' ? this.$t('map.drawData') : '',
item: [
{ prop: 'code', label: this.$t('map.lineCoding'), type: 'select', optionLabel: 'code', optionValue: 'code', options: this.outerFrameList, deviceChange: this.deviceChange },
{ prop: 'code', label: this.$t('map.lineCoding'), type: 'select', optionLabel: 'code', optionValue: 'code', options: this.outerFrameList, deviceChange: this.deviceChange, isHidden:this.activeName == 'second' },
{ prop: 'width', label: '宽度:', type: 'number', min: 1, placeholder: 'px' },
{ prop: 'height', label: '高度:', type: 'number', min: 1, placeholder: 'px' },
{ prop: 'showConditions', label: this.$t('map.showConditions'), type: 'radio', optionLabel: 'label', optionValue:'value', radioList: this.showConditionsList},
@ -115,26 +115,6 @@ export default {
};
return form;
},
makeForm() {
const form = {
labelWidth: '120px',
items: {
draw: {
name: this.$t('map.drawData'),
item: [
{ prop: 'width', label: '宽度:', type: 'number', min: 1, placeholder: 'px' },
{ prop: 'height', label: '高度:', type: 'number', min: 1, placeholder: 'px' },
{ prop: 'showConditions', label: this.$t('map.showConditions'), type: 'radio', optionLabel: 'label', optionValue:'value', radioList: this.showConditionsList},
{ prop: 'position', label: '坐标:', type: 'coordinate', width: '110px', 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;
},
isPointsShow() {
return this.editModel.points.length > 0;
}
@ -150,11 +130,14 @@ export default {
this.deviceSelect(this.$store.getters['map/getDeviceByCode'](code));
},
deviceSelect(selected) {
this.$refs.form && this.$refs.form.resetFields();
this.$refs.make && this.$refs.make.resetFields();
this.$refs.createForm && this.$refs.createForm.resetFields();
if (selected && selected._type.toUpperCase() === 'OutFrame'.toUpperCase()) {
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
this.$nextTick(()=>{
this.$refs.dataform && this.$refs.dataform.resetFields();
this.editModel = deepAssign(this.editModel, selected);
});
}
},
clearDeviceSelect() {

View File

@ -14,8 +14,8 @@
<el-tab-pane class="view-control" :label="$t('map.newConstruction')" name="second" :lazy="lazy">
<create-operate
ref="createForm"
:create-form="formMake"
:add-model="addModel"
:create-form="form"
:add-model="editModel"
:create-rules="createRules"
@create="create"
/>
@ -56,16 +56,6 @@ export default {
x: 0,
y: 0
}
},
addModel: {
code: '',
type: 'SplitStation',
rightStationName: '',
leftStationName: '',
position: {
x: 0,
y: 0
}
}
};
},
@ -82,9 +72,9 @@ export default {
item: []
},
draw: {
name: this.$t('map.drawData'),
name: this.activeName == 'first' ? this.$t('map.drawData') : '',
item: [
{ prop: 'code', label: `${this.$t('map.code')}`, type: 'select', optionLabel: 'code', optionValue: 'code', options: this.splitStationList},
{ prop: 'code', label: `${this.$t('map.code')}`, type: 'select', optionLabel: 'code', optionValue: 'code', options: this.splitStationList, isHidden:this.activeName == 'second'},
{ prop: 'rightStationName', label: this.$t('map.rightCentralStationName'), type: 'input'},
{ prop: 'leftStationName', label: this.$t('map.leftCentralStationName'), type: 'input'},
{ prop: 'position', label: this.$t('map.textPoints'), type: 'coordinate', width: '140px', children: [
@ -97,25 +87,6 @@ export default {
};
return form;
},
formMake() {
const form = {
labelWidth: '150px',
items:{
all:{
name:'',
item: [
{ prop: 'rightStationName', label: this.$t('map.rightCentralStationName'), type: 'input'},
{ prop: 'leftStationName', label: this.$t('map.leftCentralStationName'), type: 'input'},
{ prop: 'position', label: this.$t('map.textPoints'), type: 'coordinate', width: '140px', children: [
{ prop: 'position.x', firstLevel: 'position', secondLevel: 'x', label: 'x:', type: 'number', labelWidth: '25px' },
{ prop: 'position.y', firstLevel: 'position', secondLevel: 'y', label: 'y:', type: 'number', labelWidth: '25px' }
] }
]
}
}
};
return form;
},
createRules: function () {
return {
rightStationName: [
@ -135,12 +106,14 @@ export default {
},
methods: {
deviceSelect(selected) {
this.$refs.dataform && this.$refs.dataform.resetFields();
this.$refs.make && this.$refs.make.resetFields();
this.$refs.createForm && this.$refs.createForm.resetFields();
if (selected && selected._type === 'SplitStation') {
this.activeName = 'first';
this.editModel = deepAssign(this.editModel, selected);
this.editModel.type = selected._type;
this.$nextTick(()=>{
this.$refs.dataform && this.$refs.dataform.resetFields();
this.editModel = deepAssign(this.editModel, selected);
this.editModel.type = selected._type;
});
}
},
clearDeviceSelect() {
@ -148,17 +121,17 @@ export default {
},
//
create() {
const uid = getUID(this.addModel.type, this.splitStationList); // uid
const uid = getUID(this.editModel.type, this.splitStationList); // uid
const models = [];
const model = {
_type: this.addModel.type,
type: this.addModel.type,
_type: this.editModel.type,
type: this.editModel.type,
code: uid,
rightStationName: this.addModel.rightStationName,
leftStationName: this.addModel.leftStationName,
rightStationName: this.editModel.rightStationName,
leftStationName: this.editModel.leftStationName,
position: {
x: this.addModel.position.x,
y: this.addModel.position.y
x: this.editModel.position.x,
y: this.editModel.position.y
}
};
models.push(model);