CzRger пре 2 месеци
родитељ
комит
93ee15da67

+ 141 - 0
src/views/manage/app/api-key.vue

@@ -0,0 +1,141 @@
+<template>
+  <CzrDialog
+    :show="show"
+    :title="titleCpt"
+    @onClose="$emit('update:show', false)"
+    @onSubmit="onSubmit"
+    width="33rem"
+    :loading="state.loading"
+  >
+    <div class="bm-form">
+      <CzrForm ref="ref_form" layout="y">
+        <CzrFormColumn
+          required
+          :span="24"
+          label="密钥"
+          v-model:param="state.name"
+        />
+      </CzrForm>
+    </div>
+  </CzrDialog>
+</template>
+
+<script setup lang="ts">
+import {
+  computed,
+  getCurrentInstance,
+  nextTick,
+  reactive,
+  ref,
+  watch,
+} from 'vue'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
+import { useRouter } from 'vue-router'
+import { CopyDocument } from '@element-plus/icons-vue'
+import CzrDialog from '@/components/czr-ui/CzrDialog.vue'
+import CzrForm from '@/components/czr-ui/CzrForm.vue'
+import { copy } from '@/utils/czr-util'
+
+const router = useRouter()
+const AppStore = useAppStore()
+const DictionaryStore = useDictionaryStore()
+const DialogStore = useDialogStore()
+const emit = defineEmits(['update:show', 'refresh'])
+const { proxy } = getCurrentInstance()
+const props = defineProps({
+  show: { default: false },
+  transfer: <any>{},
+})
+const state: any = reactive({
+  loading: false,
+  form: {},
+})
+const ref_form = ref()
+const titleCpt = computed(() => {
+  let t = '密钥'
+  switch (props.transfer.mode) {
+    case 'add':
+      t = '创建'
+      break
+    case 'edit':
+      t = '编辑' + t
+      break
+    case 'view':
+      t = '查看' + t
+      break
+  }
+  return t
+})
+const isViewCpt = computed(() => props.transfer?.mode === 'view')
+watch(
+  () => props.show,
+  (n) => {
+    if (n) {
+      initDictionary()
+      state.form = {}
+      if (props.transfer.mode !== 'add') {
+        initData()
+      }
+      nextTick(() => {
+        ref_form.value.reset()
+      })
+    }
+  },
+)
+const initData = () => {
+  // state.loading = true
+  // pluginDetail(props.transfer.id)
+  //   .then(({ data }: any) => {
+  //     state.form = data
+  //   })
+  //   .catch(() => {})
+  //   .finally(() => {
+  //     state.loading = false
+  //   })
+}
+const onSubmit = () => {
+  ref_form.value
+    .submit()
+    .then(() => {
+      DialogStore.confirm({
+        content: `请确认是否提交?`,
+        onSubmit: () => {
+          state.loading = true
+          // if (props.transfer.mode === 'add') {
+          //   pluginAddInstance(state.form)
+          //     .then(() => {
+          //       ElMessage.success(`${titleCpt.value}成功!`)
+          //       emit('update:show', false)
+          //       emit('refresh')
+          //     })
+          //     .catch(() => {})
+          //     .finally(() => {
+          //       state.loading = false
+          //     })
+          // } else {
+          //   pluginUpdateInstance(state.form)
+          //     .then(() => {
+          //       ElMessage.success(`${titleCpt.value}成功!`)
+          //       emit('refresh')
+          //     })
+          //     .catch(() => {})
+          //     .finally(() => {
+          //       state.loading = false
+          //     })
+          // }
+        },
+      })
+    })
+    .catch((e) => {
+      ElMessage({
+        message: e[0].message,
+        grouping: true,
+        type: 'warning',
+      })
+    })
+}
+const initDictionary = () => {}
+</script>
+
+<style lang="scss" scoped></style>

+ 173 - 9
src/views/manage/app/detail.vue

@@ -35,8 +35,9 @@
               :raw-content="true"
               placement="top"
             >
-              <SvgIcon name="czr_tip" size="14" class="ml-2" /> </el-tooltip
-          ></template>
+              <SvgIcon name="czr_tip" size="14" class="ml-2" />
+            </el-tooltip>
+          </template>
         </CzrFormColumn>
         <CzrFormColumn
           :span="24"
@@ -56,21 +57,80 @@
           :limit="1"
           :delRule="(file) => true"
         />
-        <!--        <template>-->
         <CzrFormColumn
-          required
           :span="24"
           label="公开访问URL"
-          v-model:param="state.form.name"
+          v-model:param="state.form.url1"
           :disabled="true"
         >
+          <template #label>
+            公开访问URL
+            <div class="ml-auto" @click.capture.stop="onSwitchUrl">
+              <a-switch v-model:checked="state.form.enabled1" size="small" />
+            </div>
+          </template>
           <template #suffix>
-            <CopyDocument class="w-4 cursor-pointer" />
+            <CopyDocument
+              class="w-4 cursor-pointer"
+              @click="onCopy(state.form.url1)"
+            />
           </template>
         </CzrFormColumn>
-        <!--        </template>-->
+        <CzrFormColumn
+          :span="24"
+          label="后端访问API"
+          v-model:param="state.form.url2"
+          :disabled="true"
+        >
+          <template #label>
+            公开访问URL
+            <div class="ml-auto" @click.capture.stop="onSwitchApi">
+              <a-switch v-model:checked="state.form.enabled2" size="small" />
+            </div>
+          </template>
+          <template #suffix>
+            <CopyDocument
+              class="w-4 cursor-pointer"
+              @click="onCopy(state.form.url2)"
+            />
+          </template>
+        </CzrFormColumn>
+        <div class="__czr-title_1 mb-2">
+          API密钥
+          <CzrButton title="新增" type="add" class="ml-auto" @click="onAdd" />
+        </div>
+        <div class="max-h-[300px] w-full">
+          <CzrTable
+            v-loading="state.query.loading"
+            :data="state.query.result.data"
+            :head="state.query.head"
+            :no-foot="true"
+            :full="true"
+          >
+            <template #caozuo-column-value="{ scope }">
+              <div class="__czr-table-operations">
+                <CzrButton
+                  type="table"
+                  title="复制"
+                  @click="onCopy(scope.row.key)"
+                />
+                <CzrButton
+                  type="table"
+                  title="编辑"
+                  @click="onEdit(scope.row)"
+                />
+                <CzrButton type="table-del" @click="onDel(scope.row)" />
+              </div>
+            </template>
+          </CzrTable>
+        </div>
       </CzrForm>
     </div>
+    <apiKey
+      v-model:show="state.apiKey.show"
+      :transfer="state.apiKey.transfer"
+      @refresh="onApi"
+    />
   </CzrDialog>
 </template>
 
@@ -87,7 +147,8 @@ import { ElMessage, ElMessageBox } from 'element-plus'
 import { useAppStore, useDialogStore, useDictionaryStore } from '@/stores'
 import { useRouter } from 'vue-router'
 import { CopyDocument } from '@element-plus/icons-vue'
-import CzrDialog from '@/components/czr-ui/CzrDialog.vue'
+import { copy } from '@/utils/czr-util'
+import apiKey from './api-key.vue'
 
 const router = useRouter()
 const AppStore = useAppStore()
@@ -103,6 +164,45 @@ const state: any = reactive({
   loading: false,
   form: {},
   icon: [],
+  query: {
+    loading: false,
+    head: [
+      { value: 'p1', label: '密钥', show: true },
+      {
+        value: 'createTime',
+        label: '创建时间',
+        show: true,
+        width: 180,
+        datetime: true,
+      },
+      {
+        value: 'updateTime',
+        label: '最后使用',
+        show: true,
+        width: 180,
+      },
+      {
+        value: 'p1',
+        label: '备注',
+        show: true,
+      },
+      {
+        value: 'caozuo',
+        label: '操作',
+        show: true,
+        width: 200,
+        fixed: 'right',
+        popover: false,
+      },
+    ],
+    result: {
+      data: [],
+    },
+  },
+  apiKey: {
+    show: false,
+    transfer: {},
+  },
 })
 const ref_form = ref()
 const titleCpt = computed(() => {
@@ -126,11 +226,17 @@ watch(
   (n) => {
     if (n) {
       initDictionary()
-      state.form = {}
+      state.form = {
+        url1: 'http://8.130.72.63:18079/big-model-web/knowledge',
+        enabled1: false,
+        url2: 'http://8.130.72.63:18079/big-model-web/knowledge',
+        enabled2: true,
+      }
       state.icon = []
       if (props.transfer.mode !== 'add') {
         initData()
       }
+      onApi()
       nextTick(() => {
         ref_form.value.reset()
       })
@@ -189,6 +295,64 @@ const onSubmit = () => {
       })
     })
 }
+const onCopy = (str) => {
+  copy(str)
+  ElMessage.success('复制成功!')
+}
+const onSwitchUrl = () => {
+  if (state.form.enabled1) {
+    DialogStore.confirm({
+      title: '停用确认',
+      content: `请确认是否停用公开访问URL?`,
+      onSubmit: () => {
+        ElMessage.success('停用成功!')
+      },
+      onCancel: () => {},
+    })
+  } else {
+    ElMessage.success('启用成功!')
+  }
+}
+const onSwitchApi = () => {
+  if (state.form.enabled2) {
+    DialogStore.confirm({
+      title: '停用确认',
+      content: `请确认是否停用后端访问API?`,
+      onSubmit: () => {
+        ElMessage.success('停用成功!')
+      },
+      onCancel: () => {},
+    })
+  } else {
+    ElMessage.success('启用成功!')
+  }
+}
+const onAdd = () => {
+  state.apiKey.transfer = {
+    mode: 'add',
+  }
+  state.apiKey.show = true
+}
+const onEdit = (row) => {
+  state.apiKey.transfer = {
+    mode: 'edit',
+    id: row.id,
+  }
+  state.apiKey.show = true
+}
+const onDel = (row) => {
+  DialogStore.confirm({
+    title: '删除确认',
+    content: `请确认是否删除密钥?`,
+    onSubmit: () => {
+      ElMessage.success('删除成功!')
+    },
+    onCancel: () => {},
+  })
+}
+const onApi = () => {
+  state.query.result.data = [{}, {}, {}]
+}
 const initDictionary = () => {}
 </script>
 

+ 0 - 1
src/views/manage/knowledge/documents/document/index.vue

@@ -71,7 +71,6 @@
         <template #table>
           <CzrTable
             v-loading="state.query.loading"
-            ref="ref_cusTable"
             :data="state.query.result.data"
             :head="state.query.head"
             :total="state.query.result.total"

+ 0 - 1
src/views/manage/knowledge/documents/qa/index.vue

@@ -34,7 +34,6 @@
       <template #table>
         <CzrTable
           v-loading="state.query.loading"
-          ref="ref_cusTable"
           :data="state.query.result.data"
           :head="state.query.head"
           :total="state.query.result.total"

+ 0 - 1
src/views/manage/knowledge/documents/test/index.vue

@@ -35,7 +35,6 @@
           <div class="flex-1">
             <CzrTable
               v-loading="state.query.loading"
-              ref="ref_cusTable"
               :data="state.query.result.data"
               :head="state.query.head"
               :total="state.query.result.total"

+ 0 - 1
src/views/manage/model/statistic/index.vue

@@ -116,7 +116,6 @@
             <div class="flex-1">
               <CzrTable
                 v-loading="state.statistic.table.query.loading"
-                ref="ref_cusTable"
                 :data="state.statistic.table.query.result.data"
                 :head="state.statistic.table.query.head"
                 :no-foot="true"