|
@@ -1,7 +1,7 @@
|
|
<template>
|
|
<template>
|
|
<div class="app-config-manage">
|
|
<div class="app-config-manage">
|
|
<el-dialog
|
|
<el-dialog
|
|
- class="page-dialog"
|
|
|
|
|
|
+ class="page-dialog config-manage-dialog"
|
|
:visible.sync="modalIsShow"
|
|
:visible.sync="modalIsShow"
|
|
title="应用配置管理"
|
|
title="应用配置管理"
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
@@ -61,25 +61,66 @@
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <div class="part-box part-box-pad">
|
|
|
|
- <el-table ref="TableList" :data="configList">
|
|
|
|
- <el-table-column prop="key" label="配置项"> </el-table-column>
|
|
|
|
- <el-table-column prop="value" label="配置值"> </el-table-column>
|
|
|
|
- <el-table-column prop="mode" label="模式">
|
|
|
|
- <span slot-scope="scope">{{ modeMap[scope.row.mode] }}</span>
|
|
|
|
- </el-table-column>
|
|
|
|
- <el-table-column prop="comment" label="注释"> </el-table-column>
|
|
|
|
- <el-table-column label="操作" width="80" class-name="action-column">
|
|
|
|
- <template slot-scope="scope">
|
|
|
|
|
|
+ <div class="config-table">
|
|
|
|
+ <div class="part-box part-box-pad config-table-guide">
|
|
|
|
+ <ul>
|
|
|
|
+ <li
|
|
|
|
+ v-for="group in groupConfigList"
|
|
|
|
+ :key="group.name"
|
|
|
|
+ @click="scrollTo(group)"
|
|
|
|
+ >
|
|
|
|
+ {{ group.name }}
|
|
|
|
+ </li>
|
|
|
|
+ </ul>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div
|
|
|
|
+ ref="ConfigTableBody"
|
|
|
|
+ class="part-box part-box-pad config-table-body"
|
|
|
|
+ >
|
|
|
|
+ <div
|
|
|
|
+ v-for="group in groupConfigList"
|
|
|
|
+ :key="group.name"
|
|
|
|
+ class="table-part"
|
|
|
|
+ :id="group.name"
|
|
|
|
+ >
|
|
|
|
+ <div class="box-justify mb-2">
|
|
|
|
+ <h3 class="table-part-title">
|
|
|
|
+ {{ group.name | groupNameFilter }}
|
|
|
|
+ </h3>
|
|
<el-button
|
|
<el-button
|
|
- class="btn-primary"
|
|
|
|
- type="text"
|
|
|
|
- @click="toEdit(scope.row)"
|
|
|
|
- >编辑</el-button
|
|
|
|
|
|
+ v-if="group.name !== 'custom' && !IS_BASELINE"
|
|
|
|
+ size="mini"
|
|
|
|
+ type="primary"
|
|
|
|
+ @click="toAddGroupConfigItem(group)"
|
|
|
|
+ >新增</el-button
|
|
|
|
+ >
|
|
|
|
+ </div>
|
|
|
|
+ <el-table ref="TableList" :data="group.children" border>
|
|
|
|
+ <el-table-column prop="key" label="配置项"> </el-table-column>
|
|
|
|
+ <el-table-column prop="value" label="配置值"> </el-table-column>
|
|
|
|
+ <el-table-column prop="mode" label="模式" width="100">
|
|
|
|
+ <span slot-scope="scope">{{ modeMap[scope.row.mode] }}</span>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="comment" label="注释"> </el-table-column>
|
|
|
|
+ <el-table-column
|
|
|
|
+ label="操作"
|
|
|
|
+ width="80"
|
|
|
|
+ class-name="action-column"
|
|
>
|
|
>
|
|
- </template>
|
|
|
|
- </el-table-column>
|
|
|
|
- </el-table>
|
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-button
|
|
|
|
+ v-if="scope.row.mode !== 'READONLY'"
|
|
|
|
+ class="btn-primary"
|
|
|
|
+ type="text"
|
|
|
|
+ @click="toEdit(scope.row)"
|
|
|
|
+ >编辑</el-button
|
|
|
|
+ >
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
|
@@ -93,12 +134,14 @@
|
|
<modify-app-baseline-item
|
|
<modify-app-baseline-item
|
|
ref="ModifyAppBaselineItem"
|
|
ref="ModifyAppBaselineItem"
|
|
:instance="curBaselineItem"
|
|
:instance="curBaselineItem"
|
|
|
|
+ :modes="configModes"
|
|
@modified="baselineItemModified"
|
|
@modified="baselineItemModified"
|
|
></modify-app-baseline-item>
|
|
></modify-app-baseline-item>
|
|
<!-- ModifyAppConfigItem -->
|
|
<!-- ModifyAppConfigItem -->
|
|
<modify-app-config-item
|
|
<modify-app-config-item
|
|
ref="ModifyAppConfigItem"
|
|
ref="ModifyAppConfigItem"
|
|
:instance="curConfigItem"
|
|
:instance="curConfigItem"
|
|
|
|
+ :group="curGroupForAdd"
|
|
></modify-app-config-item>
|
|
></modify-app-config-item>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -126,6 +169,11 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ filters: {
|
|
|
|
+ groupNameFilter(val) {
|
|
|
|
+ return val === "custom" ? "应用配置自定义" : val;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
modalIsShow: false,
|
|
modalIsShow: false,
|
|
@@ -159,12 +207,19 @@ export default {
|
|
baselineCaches: {},
|
|
baselineCaches: {},
|
|
baselineList: [],
|
|
baselineList: [],
|
|
curBaselineItem: {},
|
|
curBaselineItem: {},
|
|
|
|
+ configModes: [],
|
|
modeMap: {},
|
|
modeMap: {},
|
|
envList: [],
|
|
envList: [],
|
|
configGroups: [],
|
|
configGroups: [],
|
|
|
|
+ curGroupForAdd: null,
|
|
groupConfigList: []
|
|
groupConfigList: []
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ IS_BASELINE() {
|
|
|
|
+ return this.filter.envId === null;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
async visibleChange() {
|
|
async visibleChange() {
|
|
await this.getConfigModes();
|
|
await this.getConfigModes();
|
|
@@ -207,6 +262,7 @@ export default {
|
|
if (Object.keys(this.modeMap).length) return;
|
|
if (Object.keys(this.modeMap).length) return;
|
|
|
|
|
|
const data = await appConfigModes();
|
|
const data = await appConfigModes();
|
|
|
|
+ this.configModes = data;
|
|
let modeMap = {};
|
|
let modeMap = {};
|
|
data.forEach(({ code, name }) => {
|
|
data.forEach(({ code, name }) => {
|
|
modeMap[code] = name;
|
|
modeMap[code] = name;
|
|
@@ -236,6 +292,7 @@ export default {
|
|
await this.getBaselineList();
|
|
await this.getBaselineList();
|
|
this.buildGroupConfigList(this.baselineList);
|
|
this.buildGroupConfigList(this.baselineList);
|
|
}
|
|
}
|
|
|
|
+ this.$refs.ConfigTableBody.scrollTop = 0;
|
|
},
|
|
},
|
|
getCacheBaselineList() {
|
|
getCacheBaselineList() {
|
|
const k = [
|
|
const k = [
|
|
@@ -262,16 +319,26 @@ export default {
|
|
|
|
|
|
const data = await appConfigBaseline(this.searchFilter);
|
|
const data = await appConfigBaseline(this.searchFilter);
|
|
this.setCacheBaselineList(data);
|
|
this.setCacheBaselineList(data);
|
|
|
|
+ this.baselineList = data;
|
|
},
|
|
},
|
|
async getConfigList() {
|
|
async getConfigList() {
|
|
await this.getBaselineList();
|
|
await this.getBaselineList();
|
|
const data = await appConfigList(this.searchFilter);
|
|
const data = await appConfigList(this.searchFilter);
|
|
- // TODO:merge config data
|
|
|
|
- this.configList = data;
|
|
|
|
|
|
+
|
|
|
|
+ let configList = this.baselineList.map(item => {
|
|
|
|
+ return { ...item };
|
|
|
|
+ });
|
|
|
|
+ data.forEach(item => {
|
|
|
|
+ let bIndex = configList.findIndex(citem => citem.key === item.key);
|
|
|
|
+ if (bIndex !== -1) {
|
|
|
|
+ configList[bIndex] = { ...item };
|
|
|
|
+ } else {
|
|
|
|
+ configList.push({ ...item });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.configList = configList;
|
|
},
|
|
},
|
|
buildGroupConfigList(dataList) {
|
|
buildGroupConfigList(dataList) {
|
|
- console.log(dataList);
|
|
|
|
-
|
|
|
|
let groupConfigList = [];
|
|
let groupConfigList = [];
|
|
dataList.forEach(configItem => {
|
|
dataList.forEach(configItem => {
|
|
const info = this.getConfigItemGroupPosInfo(configItem.key);
|
|
const info = this.getConfigItemGroupPosInfo(configItem.key);
|
|
@@ -280,7 +347,10 @@ export default {
|
|
gitem => gitem.name === info.group.name
|
|
gitem => gitem.name === info.group.name
|
|
);
|
|
);
|
|
if (!group) {
|
|
if (!group) {
|
|
- group.children = [];
|
|
|
|
|
|
+ group = {
|
|
|
|
+ ...info.group,
|
|
|
|
+ children: []
|
|
|
|
+ };
|
|
groupConfigList.push(group);
|
|
groupConfigList.push(group);
|
|
}
|
|
}
|
|
group.children.push({
|
|
group.children.push({
|
|
@@ -290,20 +360,18 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- let group = groupConfigList.find(gitem => gitem.name === "other");
|
|
|
|
|
|
+ let group = groupConfigList.find(gitem => gitem.name === "custom");
|
|
if (!group) {
|
|
if (!group) {
|
|
- group = [
|
|
|
|
- {
|
|
|
|
- name: "other",
|
|
|
|
- prefix: "",
|
|
|
|
- children: []
|
|
|
|
- }
|
|
|
|
- ];
|
|
|
|
|
|
+ group = {
|
|
|
|
+ name: "custom",
|
|
|
|
+ prefix: "",
|
|
|
|
+ children: []
|
|
|
|
+ };
|
|
groupConfigList.push(group);
|
|
groupConfigList.push(group);
|
|
}
|
|
}
|
|
group.children.push({
|
|
group.children.push({
|
|
...configItem,
|
|
...configItem,
|
|
- available: info.available
|
|
|
|
|
|
+ available: null
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
@@ -311,7 +379,7 @@ export default {
|
|
},
|
|
},
|
|
getConfigItemGroupPosInfo(configItemKey) {
|
|
getConfigItemGroupPosInfo(configItemKey) {
|
|
const curGroup = this.configGroups.find(group =>
|
|
const curGroup = this.configGroups.find(group =>
|
|
- configItemKey.include(group.prefix)
|
|
|
|
|
|
+ configItemKey.includes(group.prefix)
|
|
);
|
|
);
|
|
if (!curGroup) return;
|
|
if (!curGroup) return;
|
|
let groupData = {
|
|
let groupData = {
|
|
@@ -321,7 +389,7 @@ export default {
|
|
|
|
|
|
for (let i = 0; i < curGroup.available.length; i++) {
|
|
for (let i = 0; i < curGroup.available.length; i++) {
|
|
const avai = { ...curGroup.available[i] };
|
|
const avai = { ...curGroup.available[i] };
|
|
- if (avai.key.include(".*.")) {
|
|
|
|
|
|
+ if (avai.key.includes(".*.")) {
|
|
const regCont = avai.key
|
|
const regCont = avai.key
|
|
.split(".")
|
|
.split(".")
|
|
.join("\\.")
|
|
.join("\\.")
|
|
@@ -342,6 +410,10 @@ export default {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return {
|
|
|
|
+ group: groupData,
|
|
|
|
+ available: null
|
|
|
|
+ };
|
|
},
|
|
},
|
|
async toUpdate() {
|
|
async toUpdate() {
|
|
const valid = await this.$refs.FilterForm.validate().catch(() => {});
|
|
const valid = await this.$refs.FilterForm.validate().catch(() => {});
|
|
@@ -349,6 +421,33 @@ export default {
|
|
|
|
|
|
this.$refs.UpdateAppBaseline.open();
|
|
this.$refs.UpdateAppBaseline.open();
|
|
},
|
|
},
|
|
|
|
+ toAddGroupConfigItem(group) {
|
|
|
|
+ const ginfo = this.configGroups.find(item => item.name === group.name);
|
|
|
|
+ if (!ginfo) {
|
|
|
|
+ this.$message.error("当前分组不存在!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const unvalidKeys = group.children.map(item => item.key);
|
|
|
|
+ this.curGroupForAdd = { ...ginfo, unvalidKeys };
|
|
|
|
+ this.curGroupForAdd.available = this.curGroupForAdd.available.filter(
|
|
|
|
+ item => !unvalidKeys.includes(item.key)
|
|
|
|
+ );
|
|
|
|
+ if (!this.curGroupForAdd.available.length && ginfo.available.length) {
|
|
|
|
+ this.$message.error("当前分组不可添加配置项!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.curConfigItem = { ...this.filter };
|
|
|
|
+ this.$refs.ModifyAppConfigItem.open();
|
|
|
|
+ },
|
|
|
|
+ toEdit(row) {
|
|
|
|
+ if (this.filter.envId) {
|
|
|
|
+ this.toEditConfigItem(row);
|
|
|
|
+ } else {
|
|
|
|
+ this.toEditBaseline(row);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
toEditBaseline(row) {
|
|
toEditBaseline(row) {
|
|
this.curBaselineItem = { ...row, ...this.filter };
|
|
this.curBaselineItem = { ...row, ...this.filter };
|
|
this.$refs.ModifyAppBaselineItem.open();
|
|
this.$refs.ModifyAppBaselineItem.open();
|
|
@@ -362,6 +461,10 @@ export default {
|
|
},
|
|
},
|
|
baselineModified(data) {
|
|
baselineModified(data) {
|
|
this.setCacheBaselineList(data);
|
|
this.setCacheBaselineList(data);
|
|
|
|
+ },
|
|
|
|
+ scrollTo(group) {
|
|
|
|
+ this.$refs.ConfigTableBody.scrollTop =
|
|
|
|
+ document.getElementById(group.name).offsetTop - 20;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|