mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
Merge branch 'main' of github.com:maxkb-dev/maxkb
This commit is contained in:
commit
65d991040d
|
|
@ -153,7 +153,7 @@ const getAccessToken: (applicaiton_id: string, loading?: Ref<boolean>) => Promis
|
|||
applicaiton_id,
|
||||
loading
|
||||
) => {
|
||||
return get(`${prefix}/${applicaiton_id}/access-token`, undefined, loading)
|
||||
return get(`${prefix}/${applicaiton_id}/access_token`, undefined, loading)
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { Result } from '@/request/Result'
|
|||
import { get, post, del, put } from '@/request/index'
|
||||
import type { datasetData } from '@/api/type/dataset'
|
||||
import type { pageRequest } from '@/api/type/common'
|
||||
import { type Ref } from 'vue'
|
||||
const prefix = '/dataset'
|
||||
|
||||
/**
|
||||
|
|
@ -23,8 +24,8 @@ const getDateset: (param: pageRequest) => Promise<Result<any>> = (param) => {
|
|||
* 获取全部数据集
|
||||
* @param 参数
|
||||
*/
|
||||
const getAllDateset: () => Promise<Result<any[]>> = () => {
|
||||
return get(`${prefix}`)
|
||||
const getAllDateset: (loading?: Ref<boolean>) => Promise<Result<any[]>> = (loading) => {
|
||||
return get(`${prefix}`, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,51 +1,90 @@
|
|||
<template>
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12" v-for="data in dataList" class="mb-16">
|
||||
<el-card
|
||||
shadow="hover"
|
||||
class="card"
|
||||
:class="modelValue.includes(toModelValue(data)) ? 'active' : ''"
|
||||
@click="checked(data)"
|
||||
>
|
||||
<slot v-bind="{ ...data, checked: modelValue.includes(toModelValue(data)) }"></slot>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-card
|
||||
shadow="hover"
|
||||
class="card-checkbox cursor"
|
||||
:class="modelValue.includes(toModelValue) ? 'active' : ''"
|
||||
@click="checked"
|
||||
>
|
||||
<div class="flex-between">
|
||||
<div class="flex align-center">
|
||||
<slot name="icon">
|
||||
<AppAvatar class="mr-12" shape="square" :size="32">
|
||||
<img src="@/assets/icon_document.svg" style="width: 58%" alt="" />
|
||||
</AppAvatar>
|
||||
</slot>
|
||||
<slot></slot>
|
||||
</div>
|
||||
<input class="checkbox" type="checkbox" id="checkbox" :checked="modelValue.includes(toModelValue)" />
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
const props = defineProps<{
|
||||
dataList: Array<any>
|
||||
data: any
|
||||
|
||||
modelValue: Array<any>
|
||||
|
||||
valueField?: string
|
||||
}>()
|
||||
|
||||
const toModelValue = (data: any) => {
|
||||
return props.valueField ? data[props.valueField] : data
|
||||
}
|
||||
const toModelValue = computed(() => (props.valueField ? props.data[props.valueField] : props.data))
|
||||
|
||||
// const isChecked = computed({
|
||||
// get: () => props.modelValue.includes(toModelValue.value)),
|
||||
// set: (val) => val
|
||||
// })
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const checked = (data: any) => {
|
||||
const checked = () => {
|
||||
const value = props.modelValue ? props.modelValue : []
|
||||
if (value.includes(toModelValue(data))) {
|
||||
if (props.modelValue.includes(toModelValue.value)) {
|
||||
emit(
|
||||
'update:modelValue',
|
||||
value.filter((item) => item !== toModelValue(data))
|
||||
value.filter((item) => item !== toModelValue.value)
|
||||
)
|
||||
} else {
|
||||
emit('update:modelValue', [...value, toModelValue(data)])
|
||||
emit('update:modelValue', [...value, toModelValue.value])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.active {
|
||||
--el-card-border-color: rgba(51, 112, 255, 1);
|
||||
}
|
||||
.card {
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
.card-checkbox {
|
||||
&.active {
|
||||
border: 1px solid var(--el-color-primary);
|
||||
}
|
||||
input.checkbox[type='checkbox'] {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
background-color: white;
|
||||
color: #000;
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
visibility: visible;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
border: var(--el-border);
|
||||
border-radius: var(--el-border-radius-small);
|
||||
box-sizing: content-box;
|
||||
content: '';
|
||||
}
|
||||
|
||||
&:checked::after {
|
||||
content: '✓';
|
||||
color: #ffffff;
|
||||
border-color: var(--el-color-primary);
|
||||
background: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ watch(
|
|||
|
||||
.active {
|
||||
border-radius: 4px;
|
||||
background: rgba(51, 112, 255, 0.1);
|
||||
color: #3370ff;
|
||||
background: var(--el-color-primary-light-9);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
.item {
|
||||
cursor: pointer;
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ const activeText = computed(() => {
|
|||
color: rgba(100, 106, 115, 1);
|
||||
.active {
|
||||
margin-left: 3px;
|
||||
color: rgba(51, 112, 255, 1);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ const activeText = computed(() => {
|
|||
color: rgba(100, 106, 115, 1);
|
||||
.active {
|
||||
margin-left: 3px;
|
||||
color: rgba(51, 112, 255, 1);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
|
|||
import type { datasetData } from '@/api/type/dataset'
|
||||
import type { UploadUserFile } from 'element-plus'
|
||||
import datasetApi from '@/api/dataset'
|
||||
import { type Ref } from 'vue'
|
||||
|
||||
export interface datasetStateTypes {
|
||||
baseInfo: datasetData | null
|
||||
|
|
@ -21,10 +22,10 @@ const useDatasetStore = defineStore({
|
|||
saveDocumentsFile(file: UploadUserFile[]) {
|
||||
this.documentsFiles = file
|
||||
},
|
||||
async asyncGetAllDateset() {
|
||||
async asyncGetAllDateset(loading?: Ref<boolean>) {
|
||||
return new Promise((resolve, reject) => {
|
||||
datasetApi
|
||||
.getAllDateset()
|
||||
.getAllDateset(loading)
|
||||
.then((data) => {
|
||||
resolve(data)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<el-switch />
|
||||
</div>
|
||||
<el-row class="mt-16">
|
||||
<el-col :span="12">
|
||||
<el-col :span="24">
|
||||
<el-text type="info">公开访问链接</el-text>
|
||||
<div class="mt-4">
|
||||
<span class="vertical-middle lighter">
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<!-- <el-col :span="12">
|
||||
<el-text type="info">API访问凭据</el-text>
|
||||
<div class="mt-4">
|
||||
<span class="vertical-middle lighter">
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
</el-button>
|
||||
</span>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-col> -->
|
||||
</el-row>
|
||||
<div class="mt-16">
|
||||
<el-button type="primary"> 演示 </el-button>
|
||||
|
|
@ -89,7 +89,7 @@ function openDialog() {
|
|||
}
|
||||
function getAccessToken() {
|
||||
application.asyncGetAccessToken(id, loading).then((res) => {
|
||||
shareUrl.value = application.location + res.data
|
||||
shareUrl.value = application.location + res?.data?.access_token
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,14 @@
|
|||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<AddDatasetDialog ref="AddDatasetDialogRef" @addData="addDataset" :data="datasetList" />
|
||||
{{ datasetLoading }}
|
||||
<AddDatasetDialog
|
||||
ref="AddDatasetDialogRef"
|
||||
@addData="addDataset"
|
||||
:data="datasetList"
|
||||
@refresh="refresh"
|
||||
:loading="datasetLoading"
|
||||
/>
|
||||
</LayoutContainer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
|
@ -183,6 +190,7 @@ const applicationFormRef = ref<FormInstance>()
|
|||
const AddDatasetDialogRef = ref()
|
||||
|
||||
const loading = ref(false)
|
||||
const datasetLoading = ref(false)
|
||||
const exampleList = ref(['', ''])
|
||||
const applicationForm = ref<ApplicationFormType>({
|
||||
name: '',
|
||||
|
|
@ -250,21 +258,14 @@ function getDetail() {
|
|||
}
|
||||
|
||||
function getDataset() {
|
||||
loading.value = true
|
||||
if (id) {
|
||||
applicationApi.getApplicationDataset(id, loading).then((res) => {
|
||||
applicationApi.getApplicationDataset(id, datasetLoading).then((res) => {
|
||||
datasetList.value = res.data
|
||||
})
|
||||
} else {
|
||||
dataset
|
||||
.asyncGetAllDateset()
|
||||
.then((res: any) => {
|
||||
datasetList.value = res.data?.filter((v) => v.user_id === user.userInfo?.id)
|
||||
loading.value = false
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false
|
||||
})
|
||||
dataset.asyncGetAllDateset(datasetLoading).then((res: any) => {
|
||||
datasetList.value = res.data?.filter((v) => v.user_id === user.userInfo?.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,6 +295,10 @@ function getProvider() {
|
|||
})
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
getDataset()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getProvider()
|
||||
getModel()
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
<template>
|
||||
<el-dialog title="添加关联数据集" v-model="dialogVisible" width="600">
|
||||
<CardCheckbox value-field="id" :data-list="data" v-model="checkList">
|
||||
<template #default="scope">
|
||||
<div class="title flex-between">
|
||||
<div class="flex align-center">
|
||||
<AppAvatar class="mr-12" shape="square" :size="32">
|
||||
<img src="@/assets/icon_document.svg" style="width: 58%" alt="" />
|
||||
</AppAvatar>
|
||||
<h4 class="ellipsis-1">{{ scope.name }}</h4>
|
||||
</div>
|
||||
<input type="checkbox" id="check1" :checked="scope.checked" />
|
||||
</div>
|
||||
</template>
|
||||
</CardCheckbox>
|
||||
|
||||
<template #header="{ close, titleId, titleClass }">
|
||||
<div class="my-header flex">
|
||||
<h4 :id="titleId" :class="titleClass">添加关联数据集</h4>
|
||||
<el-button link class="ml-16" @click="refresh">
|
||||
<el-icon class="mr-4"><Refresh /></el-icon>刷新
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<el-row :gutter="12" v-loading="loading">
|
||||
<el-col :span="12" v-for="(item, index) in data" :key="index" class="mb-16">
|
||||
<CardCheckbox value-field="id" :data="item" v-model="checkList">
|
||||
{{ item.name }}
|
||||
</CardCheckbox>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click.prevent="dialogVisible = false"> 取消 </el-button>
|
||||
|
|
@ -29,19 +30,18 @@ const props = defineProps({
|
|||
data: {
|
||||
type: Array<any>,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
loading: Boolean
|
||||
})
|
||||
|
||||
const emit = defineEmits(['addData'])
|
||||
const emit = defineEmits(['addData', 'refresh'])
|
||||
|
||||
const loading = ref(false)
|
||||
const dialogVisible = ref<boolean>(false)
|
||||
const checkList = ref([])
|
||||
|
||||
watch(dialogVisible, (bool) => {
|
||||
if (!bool) {
|
||||
checkList.value = []
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -54,6 +54,10 @@ const submitHandle = () => {
|
|||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
const refresh = () => {
|
||||
emit('refresh')
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scope></style>
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ defineExpose({ open, close })
|
|||
line-height: 24px;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: rgba(51, 112, 255, 1);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
.active-breadcrumb {
|
||||
|
|
|
|||
Loading…
Reference in New Issue