|
@@ -17,19 +17,21 @@
|
|
|
label-position="left"
|
|
|
label-width="80px"
|
|
|
:model="filter"
|
|
|
- :rules="rules"
|
|
|
inline
|
|
|
>
|
|
|
<el-form-item prop="envId" label="环境">
|
|
|
- <env-select
|
|
|
- ref="EnvSelect"
|
|
|
+ <el-select
|
|
|
v-model="filter.envId"
|
|
|
- :app-id="filter.appId"
|
|
|
- :clearable="false"
|
|
|
- manual-fetch
|
|
|
- select-default
|
|
|
+ placeholder="请选择环境"
|
|
|
@change="envChange"
|
|
|
- ></env-select>
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in envList"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="moduleId" label="模块">
|
|
|
<module-select
|
|
@@ -44,10 +46,7 @@
|
|
|
>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <div
|
|
|
- v-if="checkPrivilege('app_config_nginx_edit') || IS_MAINTAINER"
|
|
|
- class="part-box-action"
|
|
|
- >
|
|
|
+ <div v-if="checkEditPrivilege()" class="part-box-action">
|
|
|
<el-button
|
|
|
v-if="isEdit"
|
|
|
type="primary"
|
|
@@ -79,7 +78,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { appNginxConfig, appNginxConfigUpdate } from "../api";
|
|
|
+import { appNginxConfig, appNginxConfigUpdate, appEnvList } from "../api";
|
|
|
|
|
|
export default {
|
|
|
name: "app-nginx-manange",
|
|
@@ -100,17 +99,8 @@ export default {
|
|
|
envId: null
|
|
|
},
|
|
|
searchFilter: {},
|
|
|
- rules: {
|
|
|
- envId: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- type: "number",
|
|
|
- message: "请选择环境",
|
|
|
- triggr: "change"
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
nginxContent: "",
|
|
|
+ envList: [],
|
|
|
isEdit: false,
|
|
|
loading: false,
|
|
|
curSelectEnv: {},
|
|
@@ -122,6 +112,9 @@ export default {
|
|
|
title() {
|
|
|
return `应用nginx配置-${this.app.name}`;
|
|
|
},
|
|
|
+ IS_BASELINE() {
|
|
|
+ return this.filter.envId === null;
|
|
|
+ },
|
|
|
IS_MAINTAINER() {
|
|
|
return (
|
|
|
this.curSearchEnv.user && this.curSearchEnv.user.id === this.user.id
|
|
@@ -142,7 +135,9 @@ export default {
|
|
|
};
|
|
|
|
|
|
this.$nextTick(async () => {
|
|
|
- await this.$refs.EnvSelect.search();
|
|
|
+ await this.getEnvList();
|
|
|
+ this.filter.envId = this.envList[0] && this.envList[0].id;
|
|
|
+ this.curSelectEnv = this.envList[0] || {};
|
|
|
this.search();
|
|
|
});
|
|
|
},
|
|
@@ -152,21 +147,47 @@ export default {
|
|
|
open() {
|
|
|
this.modalIsShow = true;
|
|
|
},
|
|
|
- envChange(val) {
|
|
|
- this.curSelectEnv = val || {};
|
|
|
+ async getEnvList() {
|
|
|
+ const res = await appEnvList({
|
|
|
+ appId: this.app.id
|
|
|
+ });
|
|
|
+ let envList = res || [];
|
|
|
+ const testValid = this.checkPrivilege("app_nginx_test");
|
|
|
+ const prodValid = this.checkPrivilege("app_nginx_prod");
|
|
|
+ this.envList = envList.filter(env => {
|
|
|
+ return (
|
|
|
+ (testValid && env.type === "TEST") ||
|
|
|
+ (prodValid && env.type === "PROD")
|
|
|
+ );
|
|
|
+ });
|
|
|
+ if (this.checkPrivilege("app_nginx_baseline"))
|
|
|
+ this.envList.unshift({ id: null, name: "基线" });
|
|
|
+ },
|
|
|
+ envChange() {
|
|
|
+ const curSearchEnv = this.envList.find(
|
|
|
+ item => item.id === this.filter.envId
|
|
|
+ );
|
|
|
+ this.curSelectEnv = curSearchEnv || {};
|
|
|
+ this.search();
|
|
|
},
|
|
|
- async search() {
|
|
|
- const valid = await this.$refs.FilterForm.validate().catch(() => {});
|
|
|
- if (!valid) return;
|
|
|
+ checkEditPrivilege() {
|
|
|
+ const privilege =
|
|
|
+ (this.checkPrivilege("app_nginx_test_edit") &&
|
|
|
+ this.curSelectEnv.type === "TEST") ||
|
|
|
+ (this.checkPrivilege("app_nginx_prod_edit") &&
|
|
|
+ this.curSelectEnv.type === "PROD") ||
|
|
|
+ (this.checkPrivilege("app_nginx_baseline_edit") && this.IS_BASELINE);
|
|
|
|
|
|
+ return privilege || (!this.IS_BASELINE && this.IS_MAINTAINER);
|
|
|
+ },
|
|
|
+ async search() {
|
|
|
this.searchFilter = { ...this.filter };
|
|
|
const data = await appNginxConfig(this.searchFilter);
|
|
|
this.nginxContent = data.content || "";
|
|
|
this.curSearchEnv = { ...this.curSelectEnv };
|
|
|
},
|
|
|
async confirm() {
|
|
|
- if (!this.checkPrivilege("app_config_nginx_edit") && !this.IS_MAINTAINER)
|
|
|
- return;
|
|
|
+ if (!this.checkEditPrivilege()) return;
|
|
|
|
|
|
if (!this.nginxContent) {
|
|
|
this.$message.error("请输入配置内容!");
|