Quellcode durchsuchen

1、ai配置关键字通过租户管理进行配置

yys vor 2 Tagen
Ursprung
Commit
a23d12369c
2 geänderte Dateien mit 80 neuen und 3 gelöschten Zeilen
  1. 2 2
      src/api/tenant/tenant.js
  2. 78 1
      src/views/saas/tenant/index.vue

+ 2 - 2
src/api/tenant/tenant.js

@@ -78,11 +78,11 @@ export function menuEdit(data) {
 }
 
 // 查询租户配置
-export function getTenantConfigByKey(configKey, id) {
+export function getTenantConfigByKey(configKey, id, configName) {
   return request({
     url: '/tenant/tenant/getConfigByKey/' + configKey,
     method: 'get',
-    params: { id }
+    params: { id, configName }
   })
 }
 

+ 78 - 1
src/views/saas/tenant/index.vue

@@ -148,6 +148,13 @@
                 @click="handleConfig(scope.row)"
                 v-hasPermi="['tenant:config:edit']"
               >修改配置</el-button>
+              <el-button
+                size="mini"
+                type="text"
+                icon="el-icon-key"
+                @click="handleAiKeyword(scope.row)"
+                v-hasPermi="['tenant:tenant:edit']"
+              >修改AI关键词</el-button>
             </div>
           </template>
         </el-table-column>
@@ -248,6 +255,24 @@
     <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>
+
+    <!-- 修改AI关键词 -->
+    <el-dialog title="修改AI关键词" :visible.sync="openAiKeyword" width="600px" append-to-body class="tenant-dialog">
+      <el-form ref="aiKeywordForm" :model="aiKeywordForm" :rules="aiKeywordRules" label-width="100px">
+        <el-form-item label="AI关键词" prop="aiKeyword">
+          <el-input
+            type="textarea"
+            v-model="aiKeywordForm.aiKeyword"
+            placeholder="请输入AI关键词"
+            :rows="8"
+          />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitAiKeyword">确 定</el-button>
+        <el-button @click="openAiKeyword = false">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -260,7 +285,9 @@ import {
   updateTenant,
   exportTenant,
   roleMenuTreeselect,
-  menuEdit
+  menuEdit,
+  editTenantConfig,
+  getTenantConfigByKey
 } from "@/api/tenant/tenant";
 import {code} from "quill/ui/icons";
 import {getRole} from "@/api/system/role";
@@ -361,6 +388,18 @@ export default {
       isAdd: false,
       openConfig: false,
       configTenantId: null,
+      // AI关键词弹窗
+      openAiKeyword: false,
+      aiKeywordConfigId: null,
+      aiKeywordForm: {
+        tenantId: null,
+        aiKeyword: ''
+      },
+      aiKeywordRules: {
+        aiKeyword: [
+          { required: true, message: "AI关键词不能为空", trigger: "blur" }
+        ]
+      },
     };
   },
   created() {
@@ -651,6 +690,44 @@ export default {
     handleConfigSuccess() {
       this.openConfig = false;
     },
+    /** 修改AI关键词按钮操作 */
+    handleAiKeyword(row) {
+      this.aiKeywordForm = {
+        tenantId: row.id,
+        aiKeyword: ''
+      };
+      this.aiKeywordConfigId = null;
+      this.openAiKeyword = true;
+      this.$nextTick(() => {
+        this.$refs.aiKeywordForm && this.$refs.aiKeywordForm.clearValidate();
+      });
+      // 获取已有AI关键词配置
+      getTenantConfigByKey('aiKeyword', row.id).then(response => {
+        if (response.data) {
+          this.aiKeywordConfigId = response.data.configId || null;
+          if (response.data.configValue) {
+            this.aiKeywordForm.aiKeyword = response.data.configValue;
+          }
+        }
+      });
+    },
+    /** 提交AI关键词 */
+    submitAiKeyword() {
+      this.$refs.aiKeywordForm.validate(valid => {
+        if (valid) {
+          editTenantConfig({
+            configId: this.aiKeywordConfigId,
+            id: this.aiKeywordForm.tenantId,
+            configKey: 'aiKeyword',
+            configName: 'ai配置',
+            configValue: this.aiKeywordForm.aiKeyword
+          }).then(response => {
+            this.msgSuccess("修改AI关键词成功");
+            this.openAiKeyword = false;
+          });
+        }
+      });
+    },
   }
 };
 </script>