2019-12-19 18:04:28 +08:00
|
|
|
<template>
|
|
|
|
<div v-show="dialogVisible">
|
|
|
|
<el-dialog v-dialogDrag title="通用配置项" :visible.sync="dialogVisible" width="550px" :before-close="handleClose" center :close-on-click-modal="false" :z-index="2000">
|
|
|
|
<div style="height: 370px; overflow: auto;">
|
|
|
|
<el-table :data="tableData" style="width: 100%;">
|
|
|
|
<el-table-column prop="configKey" label="key" />
|
2020-01-16 18:02:57 +08:00
|
|
|
<el-table-column prop="configValue" label="value">
|
|
|
|
<template slot-scope="scope">
|
2020-04-15 14:13:08 +08:00
|
|
|
<div v-if="scope.row.type === 'input'">
|
|
|
|
<div v-if="!scope.row.focus" style="width: 100%;cursor: pointer;" @click="changeFocus(scope.row, '1')">{{ scope.row.configValue }}</div>
|
|
|
|
<el-input v-if="scope.row.focus" v-model="scope.row.configValue" size="mini" style="width: 100%" @blur="changeFocus(scope.row, '0')" />
|
2020-01-16 18:02:57 +08:00
|
|
|
</div>
|
2020-04-15 14:13:08 +08:00
|
|
|
<div v-else-if="scope.row.type === 'boolean'">
|
2020-01-16 18:02:57 +08:00
|
|
|
<el-checkbox v-model="scope.row.configValue">{{ scope.row.configValue }}</el-checkbox>
|
|
|
|
</div>
|
2020-04-15 14:13:08 +08:00
|
|
|
<div v-else-if="scope.row.type === 'select'">
|
|
|
|
<el-select v-model="scope.row.configValue" size="mini" style="width: 80px;">
|
|
|
|
<el-option
|
|
|
|
v-for="item in scope.row.options"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</div>
|
2020-01-16 18:02:57 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<!-- <el-table-column prop="description" label="描述" /> -->
|
|
|
|
<!-- <el-table-column>
|
|
|
|
<template slot="header">
|
2019-12-19 18:04:28 +08:00
|
|
|
<div class="flex_box">
|
|
|
|
<span>操作</span>
|
|
|
|
<i class="el-icon-circle-plus-outline icon_font" @click="addModel(scope)" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button type="text" size="small" @click="editModel(scope.row, scope.$index)">编辑</el-button>
|
|
|
|
<el-button type="text" size="small" @click="delModel(scope.row, scope.$index)">删除</el-button>
|
|
|
|
</template>
|
2020-01-16 18:02:57 +08:00
|
|
|
</el-table-column> -->
|
2019-12-19 18:04:28 +08:00
|
|
|
</el-table>
|
|
|
|
</div>
|
|
|
|
<span slot="footer" class="dialog-footer">
|
2019-12-20 14:02:11 +08:00
|
|
|
<el-button type="primary" @click="save">{{ $t('global.confirm') }}</el-button>
|
2019-12-19 18:04:28 +08:00
|
|
|
<el-button @click="dialogVisible = false">{{ $t('global.cancel') }}</el-button>
|
|
|
|
</span>
|
|
|
|
</el-dialog>
|
2020-01-16 18:02:57 +08:00
|
|
|
<!-- <edit-config ref="addConfig" type="ADD" @create="createModel" />
|
|
|
|
<edit-config ref="editConfig" type="EDIT" @update="updateModel" /> -->
|
2019-12-19 18:04:28 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-12-20 14:02:11 +08:00
|
|
|
import { getRealLineConfigList, putRealLineConfig } from '@/api/management/mapline';
|
2020-01-16 18:02:57 +08:00
|
|
|
// import EditConfig from './editConfig';
|
2019-12-19 18:04:28 +08:00
|
|
|
export default {
|
|
|
|
name: 'Config',
|
|
|
|
components: {
|
2020-01-16 18:02:57 +08:00
|
|
|
// EditConfig
|
2019-12-19 18:04:28 +08:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
type: {
|
|
|
|
type: String,
|
2020-04-23 18:35:27 +08:00
|
|
|
default() {
|
|
|
|
return '';
|
|
|
|
}
|
2019-12-19 18:04:28 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dialogVisible: false,
|
|
|
|
index: 0,
|
|
|
|
id: '',
|
2020-01-16 18:02:57 +08:00
|
|
|
tableData: [],
|
|
|
|
focus: false,
|
2020-04-15 14:13:08 +08:00
|
|
|
booleanList: ['lockFirst', 'switchSingleHandle'],
|
|
|
|
selectList: ['upDirection'],
|
|
|
|
optionsMap: {
|
|
|
|
upDirection: [{label: 'right', value: 'right'}, {label: 'left', value: 'left'}]
|
|
|
|
}
|
2019-12-19 18:04:28 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async show(row) {
|
|
|
|
this.dialogVisible = true;
|
|
|
|
if (row && row.id) {
|
|
|
|
this.id = row.id;
|
|
|
|
this.getList();
|
|
|
|
}
|
|
|
|
},
|
2020-04-15 14:13:08 +08:00
|
|
|
changeFocus(row, flag) {
|
|
|
|
if (flag === '0') {
|
|
|
|
this.$set(row, 'focus', false);
|
|
|
|
} else {
|
|
|
|
this.$set(row, 'focus', true);
|
|
|
|
}
|
|
|
|
},
|
2019-12-19 18:04:28 +08:00
|
|
|
async getList() {
|
|
|
|
try {
|
2019-12-20 14:02:11 +08:00
|
|
|
const res = await getRealLineConfigList(this.id);
|
2019-12-19 18:04:28 +08:00
|
|
|
if (res.data) {
|
2020-01-16 18:02:57 +08:00
|
|
|
const keys = Object.keys(res.data);
|
|
|
|
this.tableData = [];
|
|
|
|
keys.forEach(key => {
|
|
|
|
// let value = '';
|
2020-04-15 14:13:08 +08:00
|
|
|
let type = 'input';
|
|
|
|
let options = [];
|
|
|
|
if (this.booleanList.indexOf(key) >= 0) {
|
|
|
|
type = 'boolean';
|
|
|
|
} else if (this.selectList.indexOf(key) >= 0) {
|
|
|
|
type = 'select';
|
|
|
|
options = this.optionsMap[key];
|
2020-01-16 18:02:57 +08:00
|
|
|
} else {
|
2020-04-15 14:13:08 +08:00
|
|
|
type = 'input';
|
2020-01-16 18:02:57 +08:00
|
|
|
}
|
|
|
|
const param = {
|
|
|
|
configKey: key,
|
|
|
|
configValue: res.data[key],
|
2020-04-15 14:13:08 +08:00
|
|
|
type: type,
|
|
|
|
options: options
|
2020-01-16 18:02:57 +08:00
|
|
|
};
|
|
|
|
this.tableData.push(param);
|
|
|
|
});
|
2019-12-20 14:02:11 +08:00
|
|
|
} else {
|
|
|
|
this.tableData = [];
|
2019-12-19 18:04:28 +08:00
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleClose(done) {
|
|
|
|
if (done) {
|
|
|
|
done();
|
|
|
|
} else {
|
|
|
|
this.dialogVisible = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
addModel() {
|
|
|
|
this.$refs.addConfig.show();
|
|
|
|
},
|
|
|
|
editModel(item, index) {
|
|
|
|
this.$refs.editConfig.show(item);
|
|
|
|
this.index = index;
|
|
|
|
},
|
|
|
|
delModel(item, index) {
|
|
|
|
this.$confirm('此操作将删除该配置项, 是否继续?', this.$t('global.tips'), {
|
|
|
|
confirmButtonText: this.$t('global.confirm'),
|
|
|
|
cancelButtonText: this.$t('global.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
2019-12-20 14:02:11 +08:00
|
|
|
this.tableData.splice(index, 1);
|
2019-12-19 18:04:28 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
createModel(data) {
|
|
|
|
this.tableData.push(data);
|
|
|
|
},
|
|
|
|
updateModel(data) {
|
|
|
|
this.tableData.splice(this.index, 1, data);
|
2019-12-20 14:02:11 +08:00
|
|
|
},
|
|
|
|
save() {
|
2020-01-16 18:02:57 +08:00
|
|
|
const param = {};
|
|
|
|
this.tableData.forEach(item => {
|
|
|
|
param[item.configKey] = item.configValue;
|
|
|
|
// if (item.boolean) {
|
|
|
|
// const value = item.configValue == 'true';
|
|
|
|
// param[item.configKey] = value;
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
putRealLineConfig(this.id, param).then(res => {
|
2019-12-20 14:02:11 +08:00
|
|
|
this.$message.success(`保存配置项成功!`);
|
|
|
|
this.dialogVisible = false;
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(`保存配置项失败.`);
|
|
|
|
});
|
|
|
|
|
2019-12-19 18:04:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
.icon_font{
|
|
|
|
font-size: 18px;
|
|
|
|
margin-left: 15px;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.flex_box{
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|