Selaa lähdekoodia

feat: doc manage

zhangjie 1 kuukausi sitten
vanhempi
commit
d7d27175d8

+ 7 - 0
src/constants/navs.js

@@ -40,6 +40,13 @@ export const navs = [
     url: "OcrManage",
     privilege: "OCR_SUPPLIER_VIEW",
   },
+  {
+    id: "8",
+    parentId: "1",
+    name: "DOC供应商",
+    url: "DocManage",
+    privilege: "DOC_SUPPLIER_VIEW",
+  },
   {
     id: "7",
     parentId: "1",

+ 17 - 0
src/constants/privilege.js

@@ -223,6 +223,23 @@ export const privilegeConfig = [
       },
     ],
   },
+  {
+    title: "DOC供应商",
+    options: [
+      {
+        permission: "DOC_SUPPLIER_VIEW",
+        name: "DOC供应商管理",
+      },
+      {
+        permission: "DOC_SUPPLIER_INSERT",
+        name: "DOC供应商新增",
+      },
+      {
+        permission: "DOC_SUPPLIER_EDIT",
+        name: "DOC供应商修改",
+      },
+    ],
+  },
   {
     title: "大模型供应商",
     options: [

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

@@ -293,6 +293,23 @@ export const orgTestApi = (datas) => {
   return $post("/api/admin/ocr/supplier/test", formData);
 };
 
+// doc-manage
+export const docListQuery = () => {
+  return $postParam("/api/admin/doc/supplier/list");
+};
+
+export const docInsertOrUpdate = (datas) => {
+  const url = datas.id
+    ? "/api/admin/doc/supplier/update"
+    : "/api/admin/doc/supplier/insert";
+  return $postParam(url, datas, {
+    paramsSerializer: qsRepeatParams,
+  });
+};
+export const docSupplierDetail = (params) => {
+  return $postParam("/api/admin/doc/supplier/detail", params);
+};
+
 export const modelSupplierListQuery = () => {
   return $postParam("/api/admin/llm/supplier/list");
 };

+ 139 - 0
src/modules/admin/doc-manage/DocManage.vue

@@ -0,0 +1,139 @@
+<template>
+  <div class="ocr-manage">
+    <div
+      class="part-box part-box-filter part-box-flex"
+      style="padding-bottom: 20px"
+    >
+      <el-button
+        v-if="checkPrivilege('OCR_SUPPLIER_INSERT')"
+        type="success"
+        @click="toAdd"
+        >新增</el-button
+      >
+      <span v-else></span>
+      <el-tooltip effect="dark" content="刷新" placement="bottom">
+        <el-button icon="el-icon-refresh-right" @click="toPage"></el-button>
+      </el-tooltip>
+    </div>
+    <div class="part-box part-box-pad">
+      <el-table ref="TableList" :data="dataList" v-loading="loading">
+        <el-table-column prop="id" label="ID"></el-table-column>
+        <el-table-column prop="name" label="名称"> </el-table-column>
+        <el-table-column prop="qps" label="QPS限流"> </el-table-column>
+        <el-table-column prop="enable" label="状态">
+          <span
+            slot-scope="scope"
+            :class="scope.row.enable ? 'color-success' : 'color-danger'"
+            >{{ scope.row.enable | ableTypeFilter }}</span
+          >
+        </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="160">
+          <span slot-scope="scope">{{
+            scope.row.updateTime | timestampFilter
+          }}</span>
+        </el-table-column>
+        <el-table-column
+          v-if="checkPrivilege('OCR_SUPPLIER_EDIT')"
+          class-name="action-column"
+          label="操作"
+          :width="150"
+          fixed="right"
+        >
+          <template slot-scope="scope">
+            <el-button
+              v-if="checkPrivilege('OCR_SUPPLIER_EDIT')"
+              class="btn-primary"
+              type="text"
+              @click="toEdit(scope.row)"
+              >编辑</el-button
+            >
+            <el-button
+              :class="scope.row.enable ? 'btn-danger' : 'btn-primary'"
+              type="text"
+              @click="toEnable(scope.row)"
+              >{{ scope.row.enable ? "禁用" : "启用" }}</el-button
+            >
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    <modify-doc
+      ref="ModifyDoc"
+      :instance="curRow"
+      @modified="getList"
+      :readonly="dialogReadonly"
+    ></modify-doc>
+  </div>
+</template>
+
+<script>
+import { docListQuery, docInsertOrUpdate } from "../api";
+import ModifyDoc from "./ModifyDoc.vue";
+
+export default {
+  name: "org-manage",
+  components: { ModifyDoc },
+  data() {
+    return {
+      dataList: [],
+      curRow: {},
+      loading: false,
+      dialogReadonly: false,
+    };
+  },
+  created() {
+    this.initData();
+  },
+  methods: {
+    initData() {
+      this.toPage();
+    },
+    async getList() {
+      this.loading = true;
+      const data = await docListQuery();
+      this.dataList = data;
+      this.loading = false;
+    },
+    toPage() {
+      this.getList();
+    },
+    toAdd() {
+      this.dialogReadonly = false;
+      this.curRow = {};
+      this.$refs.ModifyDoc.open();
+    },
+    toEdit(row) {
+      this.dialogReadonly = false;
+      this.curRow = row;
+      this.$refs.ModifyDoc.open();
+    },
+    async toEnable(row) {
+      const action = row.enable ? "禁用" : "启用";
+      const confirm = await this.$confirm(
+        `确定要${action}DOC【${row.name}】吗?`,
+        "提示",
+        {
+          type: "warning",
+        }
+      ).catch(() => {});
+
+      if (confirm !== "confirm") return;
+
+      const enable = !row.enable;
+      await docInsertOrUpdate({
+        id: row.id,
+        enable,
+      }).finally(() => {
+        this.loading = false;
+      });
+      row.enable = enable;
+      this.$message.success("操作成功!");
+    },
+  },
+};
+</script>

+ 211 - 0
src/modules/admin/doc-manage/ModifyDoc.vue

@@ -0,0 +1,211 @@
+<template>
+  <el-dialog
+    class="modify-ocr"
+    :visible.sync="modalIsShow"
+    :title="title"
+    top="10vh"
+    width="500px"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    @open="visibleChange"
+  >
+    <el-form
+      ref="modalFormComp"
+      :model="modalForm"
+      :rules="rules"
+      label-width="110px"
+      :disabled="readonly"
+    >
+      <el-form-item prop="name" label="名称:">
+        <el-input
+          v-model.trim="modalForm.name"
+          placeholder="请输入名称"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="url" label="访问地址:">
+        <el-input
+          v-model.trim="modalForm.url"
+          placeholder="请输入访问地址"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="key" label="访问key:">
+        <el-input
+          v-model.trim="modalForm.key"
+          placeholder="请输入访问key"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="secret" label="访问secret:">
+        <el-input
+          v-model.trim="modalForm.secret"
+          placeholder="请输入访问secret"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="clientClass" label="实现类名称:">
+        <el-input
+          :disabled="isEdit"
+          v-model.trim="modalForm.clientClass"
+          placeholder="请输入实现类名称"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="qps" label="QPS限流:">
+        <el-input
+          v-model.trim="modalForm.qps"
+          placeholder="请输入QPS限流"
+          clearable
+        ></el-input>
+      </el-form-item>
+      <el-form-item prop="enable" label="状态:">
+        <el-switch
+          v-model="modalForm.enable"
+          active-color="#13ce66"
+          inactive-color="#ff4949"
+          :active-text="modalForm.enable ? '启用' : '禁用'"
+        >
+        </el-switch>
+      </el-form-item>
+    </el-form>
+    <div slot="footer">
+      <el-button type="danger" @click="cancel" plain>取消</el-button>
+      <el-button type="primary" :disabled="isSubmit" @click="submit"
+        >确认</el-button
+      >
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import { docInsertOrUpdate, docSupplierDetail } from "../api";
+
+const initModalForm = {
+  id: "",
+  name: "",
+  url: "",
+  key: "",
+  secret: "",
+  clientClass: "",
+  qps: "",
+  enable: "",
+};
+
+export default {
+  name: "modify-ocr",
+  props: {
+    instance: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+    readonly: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  computed: {
+    isEdit() {
+      return !!this.instance.id;
+    },
+    title() {
+      return (
+        "DOC供应商" + (this.readonly ? "详情" : this.isEdit ? "编辑" : "新增")
+      );
+    },
+  },
+  data() {
+    return {
+      modalIsShow: false,
+      isSubmit: false,
+      modalForm: {},
+      rules: {
+        name: [
+          {
+            required: true,
+            message: "请输入名称",
+          },
+        ],
+        url: [
+          {
+            required: true,
+            message: "请输入访问地址",
+          },
+        ],
+        key: [
+          {
+            required: true,
+            message: "请输入访问key",
+          },
+        ],
+        secret: [
+          {
+            required: true,
+            message: "请输入访问secret",
+          },
+        ],
+        clientClass: [
+          {
+            required: true,
+            message: "请输入实现类名称",
+          },
+        ],
+        qps: [
+          {
+            required: true,
+            message: "请输入QPS限流",
+          },
+        ],
+      },
+    };
+  },
+  methods: {
+    getDetail(id) {
+      docSupplierDetail({ id }).then((res) => {
+        this.modalForm = this.$objAssign(initModalForm, res || {});
+      });
+    },
+    initData(val) {
+      if (val.id) {
+        this.getDetail(val.id);
+      } else {
+        this.modalForm = { ...initModalForm };
+      }
+      this.$nextTick(() => {
+        this.$refs.modalFormComp.clearValidate();
+      });
+    },
+    visibleChange() {
+      this.initData(this.instance);
+    },
+    cancel() {
+      this.modalIsShow = false;
+    },
+    open() {
+      this.modalIsShow = true;
+    },
+    async submit() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      if (this.isSubmit) return;
+      this.isSubmit = true;
+
+      const datas = { ...this.modalForm };
+      if (this.isEdit) {
+        delete datas.chatClientClass;
+      }
+      const data = await docInsertOrUpdate(datas).catch(() => {});
+      this.isSubmit = false;
+      if (!data) return;
+
+      this.$message.success((this.isEdit ? "修改" : "新增") + "成功!");
+      this.cancel();
+      this.$emit("modified");
+    },
+  },
+};
+</script>

+ 6 - 0
src/modules/admin/router.js

@@ -3,6 +3,7 @@ import UserManage from "./user/UserManage.vue";
 import OrgManage from "./org/OrgManage.vue";
 import WeChatAppManage from "./wx/WeChatAppManage.vue";
 import OcrManage from "./ocr/OcrManage.vue";
+import DocManage from "./doc-manage/DocManage.vue";
 import ModelSupplierManage from "./big-model/ModelSupplierManage.vue";
 
 export default [
@@ -31,6 +32,11 @@ export default [
     name: "OcrManage",
     component: OcrManage,
   },
+  {
+    path: "doc-manage",
+    name: "DocManage",
+    component: DocManage,
+  },
   {
     path: "model-supplier-manage",
     name: "ModelSupplierManage",