瀏覽代碼

新需求开发

刘洋 11 月之前
父節點
當前提交
50978ded39

+ 11 - 1
src/components/NormalSelect.vue

@@ -12,7 +12,7 @@
       v-for="item in optionList"
       :key="item[valueStr]"
       :value="item[valueStr]"
-      :label="item[labelStr]"
+      :label="item['label']"
     >
     </el-option>
   </el-select>
@@ -38,6 +38,10 @@ export default {
       type: Object,
       default: () => {},
     },
+    transLabel: {
+      type: Function,
+      default: null,
+    },
   },
   data() {
     return {
@@ -64,6 +68,12 @@ export default {
         : this.params;
       const res = await this.func(params);
       this.optionList = this.page ? res?.records || [] : res || [];
+      this.optionList = this.optionList.map((item) => {
+        item.label = this.transLabel
+          ? this.transLabel(item)
+          : item[this.labelStr];
+        return item;
+      });
       this.$emit("getOptions", this.optionList);
       if (this.init && this.optionList?.length) {
         this.selected = this.optionList[0][this.valueStr];

+ 4 - 0
src/modules/admin/api.js

@@ -345,3 +345,7 @@ export const orgSetInsertOrUpdate = (datas, isEdit) => {
 export const orgSetAddCount = (datas) => {
   return $postParam("/api/admin/llm/org_config/update/permit_count", datas);
 };
+
+export const promptDelete = (datas) => {
+  return $postParam("/api/admin/llm/model/prompt_template/delete", datas);
+};

+ 48 - 11
src/modules/admin/big-model/ModelManage/CueWordTpl/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="model-manage">
     <el-dialog
-      :title="`${supplierInfo.name} - ${curRow.name}`"
+      :title="`${supplierInfo.name}`"
       class="page-dialog"
       :visible.sync="modalIsShow"
       :close-on-click-modal="false"
@@ -12,6 +12,14 @@
     >
       <div class="part-box part-box-filter part-box-flex">
         <el-form ref="FilterForm" label-position="left" inline>
+          <el-form-item label="模型列表:">
+            <NormalSelect
+              v-model="modelId"
+              :init="true"
+              :func="modelListQuery"
+              :params="modelSelectParams"
+            ></NormalSelect>
+          </el-form-item>
           <el-form-item label="应用类型:">
             <NormalSelect
               v-model="appType"
@@ -53,6 +61,12 @@
                 @click="toEdit(scope.row)"
                 >编辑</el-button
               >
+              <el-button
+                class="btn-primary"
+                type="text"
+                @click="deleteItem(scope.row)"
+                >删除</el-button
+              >
             </template>
           </el-table-column>
         </el-table>
@@ -61,7 +75,7 @@
     <ModifyTpl
       :instance="curCueWordRow"
       ref="ModifyTpl"
-      :modelId="curRow.id"
+      :modelId="modelId"
       @modified="getList"
       :appType="appType"
     ></ModifyTpl>
@@ -69,7 +83,12 @@
 </template>
 
 <script>
-import { cueWordListQuery, appTypeList } from "../../../api";
+import {
+  cueWordListQuery,
+  appTypeList,
+  modelListQuery,
+  promptDelete,
+} from "../../../api";
 import NormalSelect from "@/components/NormalSelect.vue";
 
 import ModifyTpl from "./ModifyTpl.vue";
@@ -77,12 +96,6 @@ export default {
   name: "CueWordTpl",
   components: { NormalSelect, ModifyTpl },
   props: {
-    curRow: {
-      type: Object,
-      default() {
-        return {};
-      },
-    },
     supplierInfo: {
       type: Object,
       default() {
@@ -90,14 +103,21 @@ export default {
       },
     },
   },
+  computed: {
+    modelSelectParams() {
+      return { supplierId: this.supplierInfo?.id };
+    },
+  },
   data() {
     return {
+      modelListQuery,
       appTypeList,
       modalIsShow: false,
       loading: false,
       dataList: [],
       curCueWordRow: {},
       appType: "",
+      modelId: "",
       appTypeOptions: [],
     };
   },
@@ -116,7 +136,7 @@ export default {
     },
     getList() {
       this.loading = true;
-      cueWordListQuery({ modelId: this.curRow.id, appType: this.appType }).then(
+      cueWordListQuery({ modelId: this.modelId, appType: this.appType }).then(
         (res) => {
           this.dataList = res || [];
           this.loading = false;
@@ -136,10 +156,27 @@ export default {
       this.curCueWordRow = row;
       this.$refs.ModifyTpl.open();
     },
+    async deleteItem(item) {
+      const confirm = await this.$confirm(`确定要删除该模板吗?`, "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (confirm !== "confirm") return;
+      const res = await promptDelete({
+        id: item.id,
+      }).catch(() => {});
+      if (!res) return;
+      this.$message.success("删除成功!");
+      this.getList();
+    },
   },
   watch: {
     appType(val) {
-      if (val) {
+      if (val && this.modelId) {
+        this.getList();
+      }
+    },
+    modelId(val) {
+      if (val && this.appType) {
         this.getList();
       }
     },

+ 10 - 10
src/modules/admin/big-model/ModelManage/index.vue

@@ -55,12 +55,12 @@
                 @click="toEdit(scope.row)"
                 >编辑</el-button
               >
-              <el-button
+              <!-- <el-button
                 class="btn-primary"
                 type="text"
                 @click="toCueWord(scope.row)"
                 >提示词模板</el-button
-              >
+              > -->
             </template>
           </el-table-column>
         </el-table>
@@ -72,22 +72,22 @@
       @modified="getList"
       :supplierInfo="curRow"
     ></ModifyModel>
-    <CueWordTpl
+    <!-- <CueWordTpl
       :curRow="curModel"
       ref="CueWordTpl"
       @modified="getList"
       :supplierInfo="curRow"
-    ></CueWordTpl>
+    ></CueWordTpl> -->
   </div>
 </template>
 
 <script>
 import { modelListQuery } from "../../api";
 import ModifyModel from "./ModifyModel.vue";
-import CueWordTpl from "./CueWordTpl/index.vue";
+// import CueWordTpl from "./CueWordTpl/index.vue";
 export default {
   name: "ModelManage",
-  components: { ModifyModel, CueWordTpl },
+  components: { ModifyModel },
   props: {
     curRow: {
       type: Object,
@@ -129,10 +129,10 @@ export default {
       this.curModel = row;
       this.$refs.ModifyModel.open();
     },
-    toCueWord(row) {
-      this.curModel = row;
-      this.$refs.CueWordTpl.open();
-    },
+    // toCueWord(row) {
+    //   this.curModel = row;
+    //   this.$refs.CueWordTpl.open();
+    // },
   },
 };
 </script>

+ 24 - 2
src/modules/admin/big-model/ModelSupplierManage.vue

@@ -47,7 +47,7 @@
           "
           class-name="action-column"
           label="操作"
-          width="120"
+          width="220"
           fixed="right"
         >
           <template slot-scope="scope">
@@ -65,6 +65,12 @@
               @click="toModelManage(scope.row)"
               >模型管理</el-button
             >
+            <el-button
+              class="btn-primary"
+              type="text"
+              @click="toCueWord(scope.row)"
+              >提示词模板</el-button
+            >
           </template>
         </el-table-column>
       </el-table>
@@ -76,6 +82,13 @@
     ></modify-supplier>
     <ModelManage ref="ModelManage" :curRow="curRow"></ModelManage>
     <OrgSet ref="OrgSet"></OrgSet>
+
+    <CueWordTpl
+      :key="curWordDialogKey"
+      ref="CueWordTpl"
+      @modified="getList"
+      :supplierInfo="curRow"
+    ></CueWordTpl>
   </div>
 </template>
 
@@ -84,15 +97,17 @@ import { modelSupplierListQuery } from "../api";
 import ModifySupplier from "./ModifySupplier.vue";
 import ModelManage from "./ModelManage/index.vue";
 import OrgSet from "./OrgSet/index.vue";
+import CueWordTpl from "./ModelManage/CueWordTpl/index.vue";
 
 export default {
   name: "model-supplier",
-  components: { ModifySupplier, ModelManage, OrgSet },
+  components: { ModifySupplier, ModelManage, OrgSet, CueWordTpl },
   data() {
     return {
       dataList: [],
       curRow: {},
       loading: false,
+      curWordDialogKey: Math.random() + "",
     };
   },
   created() {
@@ -123,6 +138,13 @@ export default {
     orgSet() {
       this.$refs.OrgSet.open();
     },
+    toCueWord(row) {
+      this.curRow = row;
+      this.curWordDialogKey = Math.random() + "";
+      setTimeout(() => {
+        this.$refs.CueWordTpl.open();
+      }, 30);
+    },
   },
 };
 </script>

+ 8 - 4
src/modules/admin/big-model/OrgSet/index.vue

@@ -14,23 +14,24 @@
         <el-form ref="FilterForm" label-position="left" inline>
           <el-form-item label="机构:">
             <NormalSelect
-              v-model="filter.orgId"
+              v-model="filter.orgCode"
               valueStr="code"
               :func="orgQuery"
               filterable
               page
               placeholder="请选择机构"
               clearable
+              :transLabel="transLabel"
             ></NormalSelect>
           </el-form-item>
-          <el-form-item label="机构名称前缀:">
+          <!-- <el-form-item label="机构名称前缀:">
             <el-input
               style="width: 180px"
               v-model.trim="filter.orgNameStartWith"
               placeholder="机构名称前缀"
               clearable
             ></el-input>
-          </el-form-item>
+          </el-form-item> -->
           <el-form-item label="应用类型:">
             <NormalSelect
               v-model="filter.appType"
@@ -166,7 +167,7 @@ export default {
       curOrgSet: {},
       filter: {
         orgCode: "",
-        orgNameStartWith: "",
+        // orgNameStartWith: "",
         appType: "",
         modelId: "",
       },
@@ -177,6 +178,9 @@ export default {
     };
   },
   methods: {
+    transLabel(item) {
+      return `${item.name}(${item.code})`;
+    },
     getAppTypeOptions(arr) {
       this.appTypeOptions = arr;
     },