线路管理 代码调整

This commit is contained in:
joylink_cuiweidong 2020-11-12 09:54:42 +08:00
parent 1a7a6e27c7
commit 1d50db0510
5 changed files with 25 additions and 167 deletions

View File

@ -43,7 +43,6 @@ export default {
const form = {
labelWidth: '100px',
items: [
// type: 'text', disabled: true
{ prop: 'fromCode', label: '源线路', type: 'select', options: this.originList, change:true, onChange:this.originChange},
{ prop: 'targetIds', label:'拷贝线路', type: 'select', options: this.targetList, multiple: true, deviceChange: this.targetChange },
{ prop: 'deviceType', label: '操作对象', type: 'select', options: this.deviceTypeList, multiple: true }

View File

@ -59,9 +59,6 @@
import { getRealLineConfigList, putRealLineConfig } from '@/api/management/mapline';
export default {
name: 'Config',
components: {
// EditConfig
},
props: {
type: {
type: String,
@ -146,21 +143,21 @@ export default {
let rangeStart = 0;
let rangeEnd = 0;
let options = [];
if (this.booleanList.indexOf(key) >= 0) {
if (this.booleanList.includes(key)) {
type = 'boolean';
} else if (this.selectList.indexOf(key) >= 0) {
} else if (this.selectList.includes(key)) {
type = 'select';
options = this.optionsMap[key];
} else if (this.numberList.indexOf(key) >= 0) {
} else if (this.numberList.includes(key)) {
type = 'number';
} else if (this.rangeList.indexOf(key) >= 0) {
} else if (this.rangeList.includes(key)) {
type = 'range';
if (res.data[key]) {
const ranges = res.data[key].split('-');
rangeStart = ranges[0];
rangeEnd = ranges[1];
}
} else if (this.speedList.indexOf(key) >= 0) {
} else if (this.speedList.includes(key)) {
type = 'speed';
} else {
type = 'input';
@ -195,13 +192,6 @@ export default {
this.dialogVisible = false;
}
},
addModel() {
this.$refs.addConfig.show();
},
editModel(item, index) {
this.$refs.editConfig.show(item);
this.index = index;
},
save() {
const param = {};
this.generalData.forEach(item => {

View File

@ -12,12 +12,6 @@
import { addSkinCode, updateSkinCode } from '@/api/management/mapline';
export default {
name: 'DictionaryEdit',
props: {
type: {
type: String,
required: true
}
},
data() {
return {
dialogVisible: false,
@ -27,20 +21,21 @@ export default {
name: '',
origin: { x: 0, y: 0 },
scaling: 1
}
},
isAdd:false,
title:''
};
},
computed: {
form() {
const isAdd = this.type === 'ADD';
const form = {
labelWidth: '100px',
items: [
{ prop: 'code', label: this.$t('system.code'), type: 'text', disabled: !isAdd },
{ prop: 'code', label: this.$t('system.code'), type: 'text', disabled: !this.isAdd },
{ prop: 'name', label: this.$t('system.name'), type: 'text' },
{ prop: 'origin', label: '坐标:', type: 'coordinate', children: [
{ prop: 'origin.x', firstLevel: 'origin', secondLevel: 'x', label: 'x', type: 'number', labelWidth: '20px'},
{ prop: 'origin.y', firstLevel: 'origin', secondLevel: 'y', label: 'y', type: 'number', labelWidth: '20px'}
{ prop: 'origin.x', firstLevel: 'origin', secondLevel: 'x', label: 'x', type: 'number', labelWidth: '30px'},
{ prop: 'origin.y', firstLevel: 'origin', secondLevel: 'y', label: 'y', type: 'number', labelWidth: '30px'}
] },
{ prop: 'scaling', label: '缩放比例:', type: 'number', min: 0.4, max: 8, step: 0.2 }
]
@ -49,6 +44,9 @@ export default {
},
rules() {
const crules = {
code: [
{ required: true, message: this.$t('rules.pleaseInputCode'), trigger: 'blur' }
],
name: [
{ required: true, message: this.$t('rules.pleaseInputName'), trigger: 'blur' }
],
@ -65,27 +63,11 @@ export default {
{ required: true, message: '请输入缩放比例', trigger: 'blur' }
]
};
if (this.type === 'ADD') {
return Object.assign(crules, {
code: [
{ required: true, message: this.$t('rules.pleaseInputCode'), trigger: 'blur' }
]
});
} else {
return crules;
}
},
title() {
if (this.type === 'ADD') {
return this.$t('system.createDirectory');
} else {
return this.$t('system.editDictionary');
}
return crules;
}
},
methods: {
show(row) {
this.dialogVisible = true;
if (row && row.id) {
this.formModel = {
id: row.id,
@ -94,12 +76,18 @@ export default {
origin: row.origin,
scaling: row.scaling
};
this.isAdd = false;
this.title = this.$t('system.editDictionary');
} else {
this.isAdd = true;
this.title = this.$t('system.createDirectory');
}
this.dialogVisible = true;
},
doSave() {
const self = this;
this.$refs.dataform.validateForm(() => {
if (self.type === 'ADD') {
if (this.isAdd === 'ADD') {
self.create();
} else {
self.update();

View File

@ -1,119 +0,0 @@
<template>
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="30%" :before-close="handleClose" center :close-on-click-modal="false" :z-index="3000">
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="dialogVisible = false">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
name: 'DictionaryEdit',
props: {
type: {
type: String,
required: true
}
},
data() {
return {
dialogVisible: false,
formModel: {
configKey: '',
configValue: '',
boolean: false
// description: ''
}
};
},
computed: {
form() {
const form = {
labelWidth: '100px',
items: [
{ prop: 'configKey', label: 'key:', type: 'text' }
// { prop: 'description', label: ':', type: 'text' }
]
};
return form;
},
rules() {
const rules = {
configKey: [
{ required: true, message: '请输入key值', trigger: 'blur' }
],
configValue: [
{ required: true, message: '请输入value值', trigger: 'blur' }
]
// remarks: [
// { required: true, message: '', trigger: 'blur' }
// ]
};
return rules;
},
title() {
if (this.type === 'ADD') {
return '添加配置项';
} else {
return '修改配置项';
}
}
},
methods: {
show(row) {
this.dialogVisible = true;
if (row && row.configKey) {
this.formModel = {
configKey: row.configKey,
configValue: JSON.parse(row.configValue),
boolean: row.boolean
// description: row.description
};
}
},
doSave() {
const self = this;
this.$refs.dataform.validateForm(() => {
if (self.type === 'ADD') {
self.create();
} else {
self.update();
}
});
},
buildModel(data) {
return {
configKey: data.configKey,
configValue: data.boolean ? JSON.stringify(data.configValue) : data.configValue,
boolean: data.boolean
};
},
create() {
this.$emit('create', this.buildModel(this.formModel));
this.handleClose();
},
update() {
this.$emit('update', this.buildModel(this.formModel));
this.handleClose();
},
handleClose(done) {
this.formModel = {
configKey: '',
configValue: ''
// description: ''
};
this.$refs.dataform.resetForm();
if (done) {
done();
} else {
this.dialogVisible = false;
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>

View File

@ -1,8 +1,7 @@
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<edit ref="create" type="ADD" @reloadTable="reloadTable" />
<edit ref="edit" type="EDIT" @reloadTable="reloadTable" />
<edit ref="edit" @reloadTable="reloadTable" />
<config ref="config" @reloadTable="reloadTable" />
</div>
</template>
@ -106,7 +105,8 @@ export default {
},
//
handleAdd() {
this.$refs.create.show();
this.$refs.edit.show();
// this.$refs.create.show();
},
handleDelete(index, row) {
this.$confirm(this.$t('system.wellDelType'), this.$t('global.tips'), {