Просмотр исходного кода

1、调整租户设置配置信息

yys 6 дней назад
Родитель
Сommit
d891d9221c
3 измененных файлов с 76 добавлено и 7 удалено
  1. 18 0
      src/api/tenant/tenant.js
  2. 30 7
      src/views/saas/tenant/config/index.vue
  3. 28 0
      src/views/saas/tenant/index.vue

+ 18 - 0
src/api/tenant/tenant.js

@@ -76,3 +76,21 @@ export function menuEdit(data) {
     data: data
   })
 }
+
+// 查询租户配置
+export function getTenantConfigByKey(configKey, id) {
+  return request({
+    url: '/tenant/tenant/getConfigByKey/' + configKey,
+    method: 'get',
+    params: { id }
+  })
+}
+
+// 修改租户配置
+export function editTenantConfig(data) {
+  return request({
+    url: '/tenant/tenant/config/edit',
+    method: 'post',
+    data: data
+  })
+}

+ 30 - 7
src/views/saas/tenant/config/index.vue

@@ -27,6 +27,7 @@
 
 <script>
 import {getConfigByKey, updateConfigByKey} from '@/api/system/config';
+import {editTenantConfig, getTenantConfigByKey} from '@/api/tenant/tenant';
 import yaml from "js-yaml";
 import MonacoEditor from "vue-monaco";
 
@@ -37,11 +38,17 @@ export default {
     MonacoEditor
   },
 
+  props: {
+    tenantId: {
+      type: [String, Number],
+      default: null
+    }
+  },
+
   data() {
     return {
       activeName: "projectConfig",
       projectYaml: "",
-      tenantId: null,
       monacoOptions: {
         automaticLayout: true,
         minimap: { enabled: false },
@@ -65,7 +72,11 @@ export default {
 
   methods: {
     loadConfig(key) {
-      getConfigByKey(key).then(response => {
+      const requestFn = this.tenantId
+        ? getTenantConfigByKey(key, this.tenantId)
+        : getConfigByKey(key);
+
+      requestFn.then(response => {
         if (!response.data) {
           this.configId = null;
           this.projectYaml = '';
@@ -99,11 +110,23 @@ export default {
         }
         const param = { configId: this.configId, configKey: this.activeName, configValue: JSON.stringify(json) }
 
-        updateConfigByKey(param).then(response => {
-          if (response.code === 200) {
-            this.msgSuccess('修改成功')
-          }
-        })
+        if (this.tenantId) {
+          // 从租户管理页面进入,使用租户配置编辑接口
+          param.id = this.tenantId;
+          editTenantConfig(param).then(response => {
+            if (response.code === 200) {
+              this.msgSuccess('修改成功');
+              this.$emit('success');
+            }
+          })
+        } else {
+          // 默认使用系统配置接口
+          updateConfigByKey(param).then(response => {
+            if (response.code === 200) {
+              this.msgSuccess('修改成功')
+            }
+          })
+        }
       } catch (e) {
         this.$message.error("YAML 格式错误:" + e.message);
       }

+ 28 - 0
src/views/saas/tenant/index.vue

@@ -141,6 +141,13 @@
                 @click="handleComMenuChange(scope.row,'com')"
                 v-hasPermi="['tenant:tenant:edit']"
               >销售菜单权限</el-button>
+              <el-button
+                size="mini"
+                type="text"
+                icon="el-icon-setting"
+                @click="handleConfig(scope.row)"
+                v-hasPermi="['tenant:config:edit']"
+              >修改配置</el-button>
             </div>
           </template>
         </el-table-column>
@@ -236,6 +243,11 @@
         <el-button @click="cancelMenu">取 消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 修改租户配置 -->
+    <el-dialog title="修改配置" :visible.sync="openConfig" width="900px" append-to-body class="tenant-dialog">
+      <config-index v-if="openConfig" :tenant-id="configTenantId" @success="handleConfigSuccess" />
+    </el-dialog>
   </div>
 </template>
 
@@ -252,9 +264,13 @@ import {
 } from "@/api/tenant/tenant";
 import {code} from "quill/ui/icons";
 import {getRole} from "@/api/system/role";
+import ConfigIndex from "./config/index";
 
 export default {
   name: "Tenant",
+  components: {
+    ConfigIndex
+  },
   data() {
     return {
       // 遮罩层
@@ -343,6 +359,8 @@ export default {
         label: "label"
       },
       isAdd: false,
+      openConfig: false,
+      configTenantId: null,
     };
   },
   created() {
@@ -623,6 +641,16 @@ export default {
         });
       })
     },
+
+    /** 修改配置按钮操作 */
+    handleConfig(row) {
+      this.configTenantId = row.id;
+      this.openConfig = true;
+    },
+    /** 配置保存成功回调 */
+    handleConfigSuccess() {
+      this.openConfig = false;
+    },
   }
 };
 </script>