Bladeren bron

nginx配置修改

zhangjie 2 jaren geleden
bovenliggende
commit
bcc3a8cba7

+ 20 - 5
src/constants/navs.js

@@ -36,7 +36,11 @@ export const ROLE_NAV = {
         "app_config_baseline_item_edit",
         "app_config_test",
         "app_config_prod",
-        "app_config_nginx"
+        "app_nginx",
+        "app_nginx_baseline",
+        "app_nginx_baseline_edit",
+        "app_nginx_test",
+        "app_nginx_prod"
       ]
     }
   ],
@@ -50,7 +54,10 @@ export const ROLE_NAV = {
         "app_config_baseline",
         "app_config_test",
         "app_config_prod",
-        "app_config_nginx"
+        "app_nginx",
+        "app_nginx_baseline",
+        "app_nginx_test",
+        "app_nginx_prod"
       ]
     }
   ],
@@ -63,7 +70,10 @@ export const ROLE_NAV = {
         "app_config_baseline",
         "app_config_test",
         "app_config_prod",
-        "app_config_nginx"
+        "app_nginx",
+        "app_nginx_baseline",
+        "app_nginx_test",
+        "app_nginx_prod"
       ]
     }
   ],
@@ -98,8 +108,13 @@ export const ROLE_NAV = {
         "app_config_prod",
         "app_config_prod_item_add",
         "app_config_prod_item_edit",
-        "app_config_nginx",
-        "app_config_nginx_edit"
+        "app_nginx",
+        "app_nginx_baseline",
+        "app_nginx_baseline_edit",
+        "app_nginx_test",
+        "app_nginx_test_edit",
+        "app_nginx_prod",
+        "app_nginx_prod_edit"
       ]
     },
     { url: "UserManage", privilege: ["add", "edit", "resetPwd"] }

+ 1 - 0
src/modules/admin/components/AppConfigManage.vue

@@ -412,6 +412,7 @@ export default {
       let configList = this.baselineList.map(item => {
         let nitem = { ...item };
         if (item.mode === "OVERRIDE") nitem.value = null;
+        nitem.refVal = item.value;
         return nitem;
       });
       data.forEach(item => {

+ 52 - 31
src/modules/admin/components/AppNginxManage.vue

@@ -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("请输入配置内容!");

+ 3 - 1
src/modules/admin/components/ModifyAppConfigItem.vue

@@ -55,7 +55,9 @@
           :available="available"
         ></value-modify>
       </el-form-item>
-
+      <el-form-item v-if="instance.refVal" label="参考值:">
+        {{ instance.refVal }}
+      </el-form-item>
       <el-form-item v-if="modalForm.comment" label="注释:">
         {{ modalForm.comment }}
       </el-form-item>

+ 2 - 2
src/modules/admin/views/AppManage.vue

@@ -86,7 +86,7 @@
               >程序配置</el-button
             >
             <el-button
-              v-if="checkPrivilege('app_config_nginx')"
+              v-if="checkPrivilege('app_nginx')"
               class="btn-primary"
               type="text"
               @click="toEditConfigNginx(scope.row)"
@@ -149,7 +149,7 @@
     ></app-config-manage>
     <!-- AppNginxManage -->
     <app-nginx-manage
-      v-if="checkPrivilege('app_config_nginx')"
+      v-if="checkPrivilege('app_nginx')"
       ref="AppNginxManage"
       :app="curRow"
     ></app-nginx-manage>