Browse Source

配置权限调整

zhangjie 2 năm trước cách đây
mục cha
commit
1a2c26de33

+ 1 - 0
src/components/EnvSelect.vue

@@ -52,6 +52,7 @@ export default {
       }
     },
     appId(val, oldval) {
+      if (this.manualFetch) return;
       if (val !== oldval) {
         this.search();
         this.$emit("input", "");

+ 1 - 0
src/components/ModuleSelect.vue

@@ -52,6 +52,7 @@ export default {
       }
     },
     appId(val, oldval) {
+      if (this.manualFetch) return;
       if (val !== oldval) {
         this.search();
         this.$emit("input", "");

+ 65 - 0
src/components/UserSelect.vue

@@ -0,0 +1,65 @@
+<template>
+  <el-select
+    v-model="selected"
+    class="user-select"
+    :placeholder="placeholder"
+    filterable
+    :clearable="clearable"
+    :disabled="disabled"
+    @change="select"
+  >
+    <el-option
+      v-for="item in optionList"
+      :key="item.id"
+      :value="item.id"
+      :label="item.name"
+    >
+    </el-option>
+  </el-select>
+</template>
+
+<script>
+import { userListQuery } from "../modules/admin/api";
+
+export default {
+  name: "user-select",
+  props: {
+    disabled: { type: Boolean, default: false },
+    placeholder: { type: String, default: "请选择用户" },
+    value: { type: [Number, String], default: "" },
+    clearable: { type: Boolean, default: true }
+  },
+  data() {
+    return {
+      optionList: [],
+      selected: ""
+    };
+  },
+  watch: {
+    value: {
+      immediate: true,
+      handler(val) {
+        this.selected = val;
+      }
+    }
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    async search() {
+      this.optionList = [];
+
+      const res = await userListQuery();
+      this.optionList = res || [];
+    },
+    select() {
+      this.$emit("input", this.selected);
+      this.$emit(
+        "change",
+        this.optionList.find(item => item.id === this.selected)
+      );
+    }
+  }
+};
+</script>

+ 1 - 0
src/components/VersionSelect.vue

@@ -59,6 +59,7 @@ export default {
       }
     },
     appId(val, oldval) {
+      if (this.manualFetch) return;
       if (val !== oldval) {
         this.search();
         this.$emit("input", "");

+ 2 - 10
src/constants/navs.js

@@ -36,8 +36,7 @@ export const ROLE_NAV = {
         "app_config_baseline_item_edit",
         "app_config_test",
         "app_config_prod",
-        "app_config_nginx",
-        "app_config_nginx_edit"
+        "app_config_nginx"
       ]
     }
   ],
@@ -50,8 +49,6 @@ export const ROLE_NAV = {
         "app_config",
         "app_config_baseline",
         "app_config_test",
-        "app_config_test_item_add",
-        "app_config_test_item_edit",
         "app_config_prod",
         "app_config_nginx"
       ]
@@ -65,13 +62,8 @@ export const ROLE_NAV = {
         "app_config",
         "app_config_baseline",
         "app_config_test",
-        "app_config_test_item_add",
-        "app_config_test_item_edit",
         "app_config_prod",
-        "app_config_prod_item_add",
-        "app_config_prod_item_edit",
-        "app_config_nginx",
-        "app_config_nginx_edit"
+        "app_config_nginx"
       ]
     }
   ],

+ 19 - 7
src/modules/admin/components/AppConfigManage.vue

@@ -247,14 +247,21 @@ export default {
       configGroups: [],
       curGroupForAdd: null,
       groupConfigList: [],
-      hideReadonly: true
+      hideReadonly: true,
+      user: {}
     };
   },
   computed: {
     IS_BASELINE() {
       return this.filter.envId === null;
+    },
+    IS_MAINTAINER() {
+      return this.curEnv.userId === this.user.id;
     }
   },
+  created() {
+    this.user = this.$ls.get("user", {});
+  },
   methods: {
     isEmpty(val) {
       return val === null || val === "" || val === undefined;
@@ -264,11 +271,14 @@ export default {
       await this.appConfigGroups();
       if (!this.filter.appId !== this.app.id) this.resetData();
       this.filter.appId = this.app.id;
-      await this.$refs.VersionSelect.search();
-      await this.$refs.ModuleSelect.search();
 
-      await this.getEnvList();
-      this.selectEnv(this.envList[0]);
+      this.$nextTick(async () => {
+        await this.$refs.VersionSelect.search();
+        await this.$refs.ModuleSelect.search();
+
+        await this.getEnvList();
+        this.selectEnv(this.envList[0]);
+      });
     },
     resetData() {
       this.filter = {
@@ -291,7 +301,8 @@ export default {
         (this.checkPrivilege("app_config_test_item_add") &&
           this.curEnv.type === "TEST") ||
         (this.checkPrivilege("app_config_prod_item_add") &&
-          this.curEnv.type === "PROD");
+          this.curEnv.type === "PROD") ||
+        this.IS_MAINTAINER;
       return group.name !== "custom" && !this.IS_BASELINE && privilege;
     },
     checkEditPrivilege(item) {
@@ -304,7 +315,8 @@ export default {
       return (
         (item.mode !== "READONLY" && privilege) ||
         (this.checkPrivilege("app_config_baseline_item_edit") &&
-          this.IS_BASELINE)
+          this.IS_BASELINE) ||
+        (!this.IS_BASELINE && this.IS_MAINTAINER)
       );
     },
     cancel() {

+ 8 - 4
src/modules/admin/components/AppEnvManage.vue

@@ -35,22 +35,24 @@
 
       <div class="part-box part-box-pad">
         <el-table ref="TableList" :data="dataList">
-          <el-table-column prop="id" label="ID" width="80"></el-table-column>
+          <el-table-column prop="id" label="ID" width="60"></el-table-column>
           <el-table-column prop="name" label="名称"> </el-table-column>
           <el-table-column prop="code" label="编码"> </el-table-column>
           <el-table-column prop="typeName" label="分类" width="100">
           </el-table-column>
-          <el-table-column prop="createTime" label="创建时间" width="170">
+          <el-table-column prop="userName" label="维护人" width="100">
+          </el-table-column>
+          <el-table-column prop="createTime" label="创建时间" width="160">
             <span slot-scope="scope">{{
               scope.row.createTime | timestampFilter
             }}</span>
           </el-table-column>
-          <el-table-column prop="updateTime" label="修改时间" width="170">
+          <el-table-column prop="updateTime" label="修改时间" width="160">
             <span slot-scope="scope">{{
               scope.row.updateTime | timestampFilter
             }}</span>
           </el-table-column>
-          <el-table-column label="操作" width="100" class-name="action-column">
+          <el-table-column label="操作" width="70" class-name="action-column">
             <template slot-scope="scope">
               <el-button
                 v-if="checkPrivilege('app_env_edit')"
@@ -138,6 +140,8 @@ export default {
       const data = await appEnvList(datas);
       this.dataList = data.map(item => {
         item.typeName = this.envTypeMap[item.type];
+        item.userId = item.user && item.user.id;
+        item.userName = item.user && item.user.name;
         return item;
       });
     },

+ 6 - 5
src/modules/admin/components/AppNginxManage.vue

@@ -35,7 +35,6 @@
               ref="ModuleSelect"
               v-model="filter.moduleId"
               :app-id="filter.appId"
-              manual-fetch
             ></module-select>
           </el-form-item>
           <el-form-item label-width="0px">
@@ -117,7 +116,7 @@ export default {
     }
   },
   methods: {
-    async visibleChange() {
+    visibleChange() {
       this.isEdit = false;
       this.nginxContent = "";
       this.filter = {
@@ -125,9 +124,11 @@ export default {
         moduleId: null,
         envId: null
       };
-      await this.$refs.EnvSelect.search();
-      await this.$refs.ModuleSelect.search();
-      this.search();
+
+      this.$nextTick(async () => {
+        await this.$refs.EnvSelect.search();
+        this.search();
+      });
     },
     cancel() {
       this.modalIsShow = false;

+ 16 - 2
src/modules/admin/components/ModifyAppEnv.vue

@@ -15,7 +15,7 @@
       :model="modalForm"
       :rules="rules"
       :key="modalForm.id"
-      label-width="60px"
+      label-width="80px"
     >
       <el-form-item prop="name" label="名称:">
         <el-input
@@ -46,6 +46,12 @@
           ></el-option>
         </el-select>
       </el-form-item>
+      <el-form-item prop="userId" label="维护人:">
+        <user-select
+          v-model="modalForm.userId"
+          placeholder="请选择维护人"
+        ></user-select>
+      </el-form-item>
     </el-form>
     <div slot="footer">
       <el-button type="danger" @click="cancel" plain>取消</el-button>
@@ -64,7 +70,8 @@ const initModalForm = {
   appId: null,
   name: "",
   code: "",
-  type: ""
+  type: "",
+  userId: null
 };
 
 export default {
@@ -127,6 +134,13 @@ export default {
             message: "请选择分类",
             trigger: "change"
           }
+        ],
+        userId: [
+          {
+            required: true,
+            message: "请选择维护人",
+            trigger: "change"
+          }
         ]
       }
     };

+ 3 - 1
src/plugins/globalVuePlugins.js

@@ -8,13 +8,15 @@ import AppSelect from "@/components/AppSelect.vue";
 import EnvSelect from "@/components/EnvSelect.vue";
 import VersionSelect from "@/components/VersionSelect.vue";
 import ModuleSelect from "@/components/ModuleSelect.vue";
+import UserSelect from "@/components/UserSelect.vue";
 
 const components = {
   ViewFooter,
   AppSelect,
   EnvSelect,
   VersionSelect,
-  ModuleSelect
+  ModuleSelect,
+  UserSelect
 };
 
 export default {