|
|
@@ -0,0 +1,85 @@
|
|
|
+<template>
|
|
|
+ <PagingTable url="/apiUser" :where="where" ref="table">
|
|
|
+ <!-- <template #filter>
|
|
|
+ <EnumSelect :enum="UserRole" v-model="where.roles"></EnumSelect>
|
|
|
+ <ElButton :icon="Plus" @click="onEdit()">添加</ElButton>
|
|
|
+ </template> -->
|
|
|
+ <ElTableColumn prop="id" label="#" width="80" />
|
|
|
+ <ElTableColumn prop="name" label="公司名称" min-width="120" />
|
|
|
+ <ElTableColumn prop="userId" label="用户id" min-width="120" />
|
|
|
+ <ElTableColumn prop="desc" label="描述文本" min-width="120" />
|
|
|
+ <!-- <ElTableColumn prop="type" label="类型" min-width="120" /> -->
|
|
|
+ <ElTableColumn prop="code" label="apiCode" />
|
|
|
+ <ElTableColumn label="操作" align="center" width="120">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <ElButton @click="onEdit(row)">编辑</ElButton>
|
|
|
+ </template>
|
|
|
+ </ElTableColumn>
|
|
|
+ </PagingTable>
|
|
|
+ <EditDialog v-model="showEditDialog" :model="model" :rules="rules" :on-submit="submit" @success="table.refresh()">
|
|
|
+ <ElFormItem prop="name" label="名称">
|
|
|
+ <ElInput v-model="model.name" placeholder="请输入名称" />
|
|
|
+ </ElFormItem>
|
|
|
+ <ElFormItem prop="desc" label="描述">
|
|
|
+ <ElInput v-model="model.desc" placeholder="请输入描述" />
|
|
|
+ </ElFormItem>
|
|
|
+ <ElFormItem prop="code" label="apiCode">
|
|
|
+ <ElInput v-model="model.code" placeholder="apiCode" />
|
|
|
+ </ElFormItem>
|
|
|
+ <el-upload
|
|
|
+ class="upload-demo"
|
|
|
+ drag
|
|
|
+ v-model:file-list="fileList"
|
|
|
+ action="https://gpt.izouma.com/api/chat-pdf/upload"
|
|
|
+ accept="application/pdf"
|
|
|
+ :on-success="onSuccess"
|
|
|
+ >
|
|
|
+ <el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
|
|
+ <div class="el-upload__text">将文件拖入框内或点击此处上传</div>
|
|
|
+ </el-upload>
|
|
|
+ </EditDialog>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { ref } from 'vue'
|
|
|
+import PagingTable from '@/components/PagingTable.vue'
|
|
|
+import { useTimeFormatter } from '@/utils/formatter'
|
|
|
+import { Plus } from '@vicons/tabler'
|
|
|
+import EditDialog from '@/components/EditDialog.vue'
|
|
|
+import { setupEditDialog } from '@/utils/editDialog'
|
|
|
+import EnumSelect from '@/components/EnumSelect.vue'
|
|
|
+import { UserRole } from '@/enums'
|
|
|
+import { http } from '@/plugins/http'
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
+import { useClipboard } from '@vueuse/core'
|
|
|
+
|
|
|
+const fileList = []
|
|
|
+const where = ref({})
|
|
|
+const timeFormatter = useTimeFormatter()
|
|
|
+const table = ref(null)
|
|
|
+const model = ref({})
|
|
|
+const name = ''
|
|
|
+const filename = ''
|
|
|
+http.get(`/auth/admin/getRole`).then((res) => {
|
|
|
+ if (res === 'api') {
|
|
|
+ http.get('/admin/users/get').then((res) => {
|
|
|
+ where.value = { userId: res.id }
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
+const { showEditDialog, onEdit } = setupEditDialog(model)
|
|
|
+function onSuccess(res, file) {
|
|
|
+ console.log(res, file)
|
|
|
+ model.value.code = res.name
|
|
|
+}
|
|
|
+async function submit() {
|
|
|
+ await http.put('/apiUser/' + model.value.id, model.value)
|
|
|
+ ElMessage.success('保存成功')
|
|
|
+}
|
|
|
+function getToken(row) {
|
|
|
+ http.get(`/auth/admin/user/${row.id}/token`).then((res) => {
|
|
|
+ const { copy } = useClipboard({ legacy: true })
|
|
|
+ copy(res.access_token)
|
|
|
+ ElMessage.success('复制成功')
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|