feat: 数据集
This commit is contained in:
parent
9f9d65a74b
commit
a1a312d109
@ -1,6 +1,6 @@
|
|||||||
import { Result } from '@/request/Result'
|
import { Result } from '@/request/Result'
|
||||||
import { get, post, del, put } from '@/request/index'
|
import { get, post, del, put } from '@/request/index'
|
||||||
import type { datasetListRequest } from '@/api/type/dataset'
|
import type { datasetListRequest, datasetData } from '@/api/type/dataset'
|
||||||
|
|
||||||
const prefix = '/dataset'
|
const prefix = '/dataset'
|
||||||
|
|
||||||
@ -9,19 +9,22 @@ const prefix = '/dataset'
|
|||||||
* @param 参数 {
|
* @param 参数 {
|
||||||
"current_page": "string",
|
"current_page": "string",
|
||||||
"page_size": "string",
|
"page_size": "string",
|
||||||
"search_text": "string",
|
"name": "string",
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const getDateset: (param: datasetListRequest) => Promise<Result<any[]>> = (param) => {
|
const getDateset: (param: datasetListRequest) => Promise<Result<any>> = (param) => {
|
||||||
return get(`${prefix}`, param)
|
return get(
|
||||||
|
`${prefix}/${param.current_page}/${param.page_size}`,
|
||||||
|
param.name && { name: param.name }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部数据集
|
* 获取全部数据集
|
||||||
* @param 参数 search_text
|
* @param 参数 name
|
||||||
*/
|
*/
|
||||||
const getAllDateset: (param?: String) => Promise<Result<any[]>> = (param) => {
|
const getAllDateset: (param?: string) => Promise<Result<any[]>> = (param) => {
|
||||||
return get(`${prefix}`, param && { search_text: param })
|
return get(`${prefix}`, param && { name: param })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +48,6 @@ const delDateset: (dataset_id: String) => Promise<Result<boolean>> = (dataset_id
|
|||||||
{
|
{
|
||||||
"content": "string",
|
"content": "string",
|
||||||
"title": "string",
|
"title": "string",
|
||||||
"is_active": true,
|
|
||||||
"problem_list": [
|
"problem_list": [
|
||||||
{
|
{
|
||||||
"id": "string",
|
"id": "string",
|
||||||
@ -58,10 +60,34 @@ const delDateset: (dataset_id: String) => Promise<Result<boolean>> = (dataset_id
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
const postDateset: (data: any) => Promise<Result<any>> = (data) => {
|
const postDateset: (data: datasetData) => Promise<Result<any>> = (data) => {
|
||||||
return post(`${prefix}`, data)
|
return post(`${prefix}`, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据集详情
|
||||||
|
* @param 参数 dataset_id
|
||||||
|
*/
|
||||||
|
const getDatesetDetail: (dataset_id: string) => Promise<Result<any>> = (dataset_id) => {
|
||||||
|
return get(`${prefix}/${dataset_id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据集信息
|
||||||
|
* @param 参数
|
||||||
|
* dataset_id, document_id,
|
||||||
|
* {
|
||||||
|
"name": "string",
|
||||||
|
"desc": true
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const putDateset: (dataset_id: string, data: any) => Promise<Result<any>> = (
|
||||||
|
dataset_id,
|
||||||
|
data: any
|
||||||
|
) => {
|
||||||
|
return put(`${prefix}/${dataset_id}`, data)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分段预览(上传文档)
|
* 分段预览(上传文档)
|
||||||
* @param 参数 file:file,limit:number,patterns:array,with_filter:boolean
|
* @param 参数 file:file,limit:number,patterns:array,with_filter:boolean
|
||||||
@ -82,6 +108,32 @@ const getDocument: (dataset_id: string, name?: string) => Promise<Result<any>> =
|
|||||||
return get(`${prefix}/${dataset_id}/document`, name && { name })
|
return get(`${prefix}/${dataset_id}/document`, name && { name })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建文档
|
||||||
|
* @param 参数
|
||||||
|
* {
|
||||||
|
"name": "string",
|
||||||
|
"paragraphs": [
|
||||||
|
{
|
||||||
|
"content": "string",
|
||||||
|
"title": "string",
|
||||||
|
"problem_list": [
|
||||||
|
{
|
||||||
|
"id": "string",
|
||||||
|
"content": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const postDocument: (dataset_id: string, data: any) => Promise<Result<any>> = (
|
||||||
|
dataset_id,
|
||||||
|
data
|
||||||
|
) => {
|
||||||
|
return post(`${prefix}/${dataset_id}/document`, data)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改文档
|
* 修改文档
|
||||||
* @param 参数
|
* @param 参数
|
||||||
@ -115,8 +167,11 @@ export default {
|
|||||||
getAllDateset,
|
getAllDateset,
|
||||||
delDateset,
|
delDateset,
|
||||||
postDateset,
|
postDateset,
|
||||||
|
getDatesetDetail,
|
||||||
|
putDateset,
|
||||||
postSplitDocument,
|
postSplitDocument,
|
||||||
getDocument,
|
getDocument,
|
||||||
|
postDocument,
|
||||||
putDocument,
|
putDocument,
|
||||||
delDocument
|
delDocument
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
interface datasetListRequest {
|
interface datasetListRequest {
|
||||||
current_page: number
|
current_page: number
|
||||||
page_size: number
|
page_size: number
|
||||||
search_text: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface datasetData {
|
interface datasetData {
|
||||||
|
|||||||
@ -10,8 +10,8 @@
|
|||||||
class="w-240 mr-12"
|
class="w-240 mr-12"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<el-button type="primary" @click="submitHandle">创建</el-button>
|
<el-button type="primary" @click="submitHandle" :disabled="loading">创建</el-button>
|
||||||
<el-button @click="showInput = false">取消</el-button>
|
<el-button @click="showInput = false" :disabled="loading">取消</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else @click="quickCreateHandel" class="w-full">
|
<div v-else @click="quickCreateHandel" class="w-full">
|
||||||
<el-button type="primary" link>
|
<el-button type="primary" link>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, nextTick, watch } from 'vue'
|
import { ref, nextTick, watch, computed } from 'vue'
|
||||||
defineOptions({ name: 'AppTable' })
|
defineOptions({ name: 'AppTable' })
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -53,9 +53,13 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
const emit = defineEmits(['changePage', 'sizeChange', 'creatQuick'])
|
const emit = defineEmits(['changePage', 'sizeChange', 'creatQuick'])
|
||||||
|
|
||||||
|
const paginationConfig = computed(() => props.paginationConfig)
|
||||||
|
|
||||||
const pageSizes = [10, 20, 50, 100]
|
const pageSizes = [10, 20, 50, 100]
|
||||||
|
|
||||||
const quickInputRef = ref()
|
const quickInputRef = ref()
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
const showInput = ref(false)
|
const showInput = ref(false)
|
||||||
const inputValue = ref('')
|
const inputValue = ref('')
|
||||||
|
|
||||||
@ -66,8 +70,12 @@ watch(showInput, (bool) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function submitHandle() {
|
function submitHandle() {
|
||||||
|
loading.value = true
|
||||||
emit('creatQuick', inputValue.value)
|
emit('creatQuick', inputValue.value)
|
||||||
showInput.value = false
|
setTimeout(() => {
|
||||||
|
showInput.value = false
|
||||||
|
loading.value = false
|
||||||
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
function quickCreateHandel() {
|
function quickCreateHandel() {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export const routes: Array<RouteRecordRaw> = [
|
|||||||
path: '/',
|
path: '/',
|
||||||
name: 'home',
|
name: 'home',
|
||||||
component: () => import('@/layout/app-layout/index.vue'),
|
component: () => import('@/layout/app-layout/index.vue'),
|
||||||
redirect: '/setting',
|
redirect: '/dataset',
|
||||||
children: [
|
children: [
|
||||||
// {
|
// {
|
||||||
// path: '/first',
|
// path: '/first',
|
||||||
|
|||||||
@ -14,26 +14,41 @@
|
|||||||
</el-step>
|
</el-step>
|
||||||
</el-steps>
|
</el-steps>
|
||||||
</template>
|
</template>
|
||||||
<div class="create-dataset__main flex">
|
<div class="create-dataset__main flex" v-loading="loading">
|
||||||
<div class="create-dataset__component">
|
<div class="create-dataset__component">
|
||||||
<component :is="steps[active].component" :ref="steps[active]?.ref" />
|
<component :is="steps[active].component" :ref="steps[active]?.ref" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="create-dataset__footer text-right border-t">
|
<div class="create-dataset__footer text-right border-t">
|
||||||
<el-button @click="router.go(-1)">取 消</el-button>
|
<el-button @click="router.go(-1)" :disabled="loading">取 消</el-button>
|
||||||
<el-button @click="prev" v-if="active === 1">上一步</el-button>
|
<el-button @click="prev" v-if="active === 1" :disabled="loading">上一步</el-button>
|
||||||
<el-button @click="next" type="primary" v-if="active === 0">下一步</el-button>
|
<el-button @click="next" type="primary" v-if="active === 0" :disabled="loading"
|
||||||
<el-button @click="next" type="primary" v-if="active === 1">开始导入</el-button>
|
>下一步</el-button
|
||||||
|
>
|
||||||
|
<el-button @click="submit" type="primary" v-if="active === 1" :disabled="loading">
|
||||||
|
开始导入
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import StepFirst from './step/StepFirst.vue'
|
import StepFirst from './step/StepFirst.vue'
|
||||||
import StepSecond from './step/StepSecond.vue'
|
import StepSecond from './step/StepSecond.vue'
|
||||||
|
import datasetApi from '@/api/dataset'
|
||||||
|
import type { datasetData } from '@/api/type/dataset'
|
||||||
|
import { MsgSuccess } from '@/utils/message'
|
||||||
|
import useStore from '@/stores'
|
||||||
|
const { dataset } = useStore()
|
||||||
|
const baseInfo = computed(() => dataset.baseInfo)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
const {
|
||||||
|
params: { type },
|
||||||
|
query: { id }
|
||||||
|
} = route as any
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
{
|
{
|
||||||
@ -42,14 +57,16 @@ const steps = [
|
|||||||
component: StepFirst
|
component: StepFirst
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ref: 'SetRulesRef',
|
ref: 'StepSecondRef',
|
||||||
name: '设置分段规则',
|
name: '设置分段规则',
|
||||||
component: StepSecond
|
component: StepSecond
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const StepFirstRef = ref()
|
const StepFirstRef = ref()
|
||||||
|
const StepSecondRef = ref()
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
const active = ref(0)
|
const active = ref(0)
|
||||||
|
|
||||||
async function next() {
|
async function next() {
|
||||||
@ -60,6 +77,39 @@ async function next() {
|
|||||||
const prev = () => {
|
const prev = () => {
|
||||||
active.value = 0
|
active.value = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function submit() {
|
||||||
|
loading.value = true
|
||||||
|
const documents = [] as any[]
|
||||||
|
StepSecondRef.value.segmentList.map((item: any) => {
|
||||||
|
documents.push({
|
||||||
|
name: item.name,
|
||||||
|
paragraphs: item.content
|
||||||
|
})
|
||||||
|
})
|
||||||
|
const obj = { ...baseInfo.value, documents } as datasetData
|
||||||
|
if (id) {
|
||||||
|
datasetApi
|
||||||
|
.postDocument(id, documents)
|
||||||
|
.then((res) => {
|
||||||
|
MsgSuccess('提交成功')
|
||||||
|
router.push({ path: `/dataset/${id}/document` })
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
datasetApi
|
||||||
|
.postDateset(obj)
|
||||||
|
.then((res) => {
|
||||||
|
MsgSuccess('提交成功')
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.create-dataset {
|
.create-dataset {
|
||||||
|
|||||||
@ -3,7 +3,9 @@
|
|||||||
<div class="main-calc-height">
|
<div class="main-calc-height">
|
||||||
<div class="p-24">
|
<div class="p-24">
|
||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
<el-button type="primary" @click="router.push({ path: '/dataset/upload' })"
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="router.push({ path: '/dataset/upload', query: { id: datasetId } })"
|
||||||
>上传文档</el-button
|
>上传文档</el-button
|
||||||
>
|
>
|
||||||
<el-input
|
<el-input
|
||||||
@ -11,6 +13,7 @@
|
|||||||
placeholder="按 文档名称 搜索"
|
placeholder="按 文档名称 搜索"
|
||||||
prefix-icon="Search"
|
prefix-icon="Search"
|
||||||
class="w-240"
|
class="w-240"
|
||||||
|
@change="getList"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<app-table
|
<app-table
|
||||||
@ -22,6 +25,7 @@
|
|||||||
@changePage="handleCurrentChange"
|
@changePage="handleCurrentChange"
|
||||||
@cell-mouse-enter="cellMouseEnter"
|
@cell-mouse-enter="cellMouseEnter"
|
||||||
@cell-mouse-leave="cellMouseLeave"
|
@cell-mouse-leave="cellMouseLeave"
|
||||||
|
@creatQuick="creatQuickHandle"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
>
|
>
|
||||||
<el-table-column prop="name" label="文件名称" min-width="280">
|
<el-table-column prop="name" label="文件名称" min-width="280">
|
||||||
@ -69,7 +73,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="name" label="操作" align="center">
|
<el-table-column prop="name" label="操作" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span>
|
<span v-if="row.status === 2">
|
||||||
<el-tooltip effect="dark" content="刷新" placement="top">
|
<el-tooltip effect="dark" content="刷新" placement="top">
|
||||||
<el-button type="primary" text>
|
<el-button type="primary" text>
|
||||||
<el-icon><RefreshRight /></el-icon>
|
<el-icon><RefreshRight /></el-icon>
|
||||||
@ -99,8 +103,9 @@ import { datetimeFormat } from '@/utils/time'
|
|||||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { params } = route
|
const {
|
||||||
const { datasetId } = params as any
|
params: { datasetId }
|
||||||
|
} = route as any
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
@ -113,6 +118,21 @@ const paginationConfig = reactive({
|
|||||||
total: 0
|
total: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 快速创建空白文档
|
||||||
|
function creatQuickHandle(val: string) {
|
||||||
|
loading.value = true
|
||||||
|
const obj = { name: val }
|
||||||
|
datasetApi
|
||||||
|
.postDocument(datasetId, obj)
|
||||||
|
.then((res) => {
|
||||||
|
getList()
|
||||||
|
MsgSuccess('创建成功')
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function deleteDocument(row: any) {
|
function deleteDocument(row: any) {
|
||||||
MsgConfirm(
|
MsgConfirm(
|
||||||
`是否删除文档:${row.name} ?`,
|
`是否删除文档:${row.name} ?`,
|
||||||
@ -137,6 +157,7 @@ function deleteDocument(row: any) {
|
|||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新名称或状态
|
||||||
function updateData(documentId: string, data: any) {
|
function updateData(documentId: string, data: any) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
datasetApi
|
datasetApi
|
||||||
|
|||||||
@ -1,14 +1,65 @@
|
|||||||
<template>
|
<template>
|
||||||
<LayoutContainer header="设置">
|
<LayoutContainer header="设置">
|
||||||
<div class="main-calc-height">
|
<div class="main-calc-height dataset-setting">
|
||||||
<div class="p-24">
|
<div class="p-24" v-loading="loading">
|
||||||
<BaseForm />
|
<BaseForm ref="BaseFormRef" :data="detail" />
|
||||||
|
<div class="text-right">
|
||||||
|
<el-button @click="submit" type="primary"> 保存 </el-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
import BaseForm from '@/views/dataset/component/BaseForm.vue'
|
import BaseForm from '@/views/dataset/component/BaseForm.vue'
|
||||||
|
import datasetApi from '@/api/dataset'
|
||||||
|
import { MsgSuccess } from '@/utils/message'
|
||||||
|
const route = useRoute()
|
||||||
|
const {
|
||||||
|
params: { datasetId }
|
||||||
|
} = route as any
|
||||||
|
|
||||||
|
const BaseFormRef = ref()
|
||||||
|
const loading = ref(false)
|
||||||
|
const detail = ref({})
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
if (await BaseFormRef.value?.validate()) {
|
||||||
|
loading.value = true
|
||||||
|
datasetApi
|
||||||
|
.postDocument(datasetId, BaseFormRef.value.form)
|
||||||
|
.then((res) => {
|
||||||
|
MsgSuccess('保存成功')
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDetail() {
|
||||||
|
loading.value = true
|
||||||
|
datasetApi
|
||||||
|
.getDatesetDetail(datasetId)
|
||||||
|
.then((res) => {
|
||||||
|
detail.value = res.data
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getDetail()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped></style>
|
<style lang="scss" scoped>
|
||||||
|
.dataset-setting {
|
||||||
|
width: 70%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -22,8 +22,20 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted, computed, watch } from 'vue'
|
||||||
const form = reactive({
|
import useStore from '@/stores'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
data: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const { dataset } = useStore()
|
||||||
|
const baseInfo = computed(() => dataset.baseInfo)
|
||||||
|
|
||||||
|
const form = ref<any>({
|
||||||
name: '',
|
name: '',
|
||||||
desc: ''
|
desc: ''
|
||||||
})
|
})
|
||||||
@ -33,6 +45,21 @@ const rules = reactive({
|
|||||||
desc: [{ required: true, message: '请输入数据集描述', trigger: 'blur' }]
|
desc: [{ required: true, message: '请输入数据集描述', trigger: 'blur' }]
|
||||||
})
|
})
|
||||||
const FormRef = ref()
|
const FormRef = ref()
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.data,
|
||||||
|
(value) => {
|
||||||
|
if (JSON.stringify(value) !== '{}') {
|
||||||
|
form.value.name = value.name
|
||||||
|
form.value.desc = value.desc
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// 初始化立即执行
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// 表单校验
|
// 表单校验
|
||||||
function validate() {
|
function validate() {
|
||||||
if (!FormRef.value) return
|
if (!FormRef.value) return
|
||||||
@ -41,7 +68,11 @@ function validate() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {})
|
onMounted(() => {
|
||||||
|
if (baseInfo.value) {
|
||||||
|
form.value = baseInfo.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
validate,
|
validate,
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
<EditSegmentDialog ref="EditSegmentDialogRef" @updateContent="updateContent" />
|
<EditSegmentDialog ref="EditSegmentDialogRef" @updateContent="updateContent" />
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted, watch } from 'vue'
|
||||||
import type { TabsPaneContext } from 'element-plus'
|
import type { TabsPaneContext } from 'element-plus'
|
||||||
import EditSegmentDialog from './EditSegmentDialog.vue'
|
import EditSegmentDialog from './EditSegmentDialog.vue'
|
||||||
import { filesize, getImgUrl } from '@/utils/utils'
|
import { filesize, getImgUrl } from '@/utils/utils'
|
||||||
@ -65,7 +65,18 @@ const activeName = ref(0)
|
|||||||
const currentPIndex = ref(null) as any
|
const currentPIndex = ref(null) as any
|
||||||
const currentCIndex = ref(null) as any
|
const currentCIndex = ref(null) as any
|
||||||
|
|
||||||
const newData = ref(props.data)
|
const newData = ref<any[]>([])
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.data,
|
||||||
|
(value) => {
|
||||||
|
newData.value = value
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// 初始化立即执行
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
function editHandle(item: any, index: number, cIndex: number) {
|
function editHandle(item: any, index: number, cIndex: number) {
|
||||||
currentPIndex.value = index
|
currentPIndex.value = index
|
||||||
@ -90,11 +101,11 @@ function updateContent(data: any) {
|
|||||||
emit('update:data', newData.value)
|
emit('update:data', newData.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {})
|
|
||||||
|
|
||||||
const handleClick = (tab: TabsPaneContext, event: Event) => {
|
const handleClick = (tab: TabsPaneContext, event: Event) => {
|
||||||
// console.log(tab, event)
|
// console.log(tab, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {})
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.segment-tabs {
|
.segment-tabs {
|
||||||
|
|||||||
@ -48,11 +48,14 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted, computed } from 'vue'
|
||||||
import type { UploadProps } from 'element-plus'
|
import type { UploadProps } from 'element-plus'
|
||||||
import { filesize, getImgUrl } from '@/utils/utils'
|
import { filesize, getImgUrl } from '@/utils/utils'
|
||||||
import { MsgError } from '@/utils/message'
|
import { MsgError } from '@/utils/message'
|
||||||
const form = reactive({
|
import useStore from '@/stores'
|
||||||
|
const { dataset } = useStore()
|
||||||
|
const documentsFiles = computed(() => dataset.documentsFiles)
|
||||||
|
const form = ref({
|
||||||
fileList: [] as any
|
fileList: [] as any
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -61,7 +64,6 @@ const rules = reactive({
|
|||||||
})
|
})
|
||||||
const FormRef = ref()
|
const FormRef = ref()
|
||||||
|
|
||||||
|
|
||||||
// const beforeUploadHandle: UploadProps['beforeUpload'] = (rawFile) => {
|
// const beforeUploadHandle: UploadProps['beforeUpload'] = (rawFile) => {
|
||||||
// const type = fileType(rawFile?.name)
|
// const type = fileType(rawFile?.name)
|
||||||
// console.log(type)
|
// console.log(type)
|
||||||
@ -75,7 +77,7 @@ const FormRef = ref()
|
|||||||
// return true
|
// return true
|
||||||
// }
|
// }
|
||||||
function deleteFlie(index: number) {
|
function deleteFlie(index: number) {
|
||||||
form.fileList.splice(index, 1)
|
form.value.fileList.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单校验
|
// 表单校验
|
||||||
@ -85,7 +87,11 @@ function validate() {
|
|||||||
return valid
|
return valid
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
onMounted(() => {})
|
onMounted(() => {
|
||||||
|
if (documentsFiles.value) {
|
||||||
|
form.value.fileList = documentsFiles.value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
validate,
|
validate,
|
||||||
|
|||||||
@ -2,7 +2,13 @@
|
|||||||
<div class="dataset-list-container p-24">
|
<div class="dataset-list-container p-24">
|
||||||
<div class="flex-between">
|
<div class="flex-between">
|
||||||
<h3>数据集</h3>
|
<h3>数据集</h3>
|
||||||
<el-input v-model="filterText" placeholder="搜索内容" prefix-icon="Search" class="w-240" />
|
<el-input
|
||||||
|
v-model="pageConfig.name"
|
||||||
|
@change="search"
|
||||||
|
placeholder="按 名称 搜索"
|
||||||
|
prefix-icon="Search"
|
||||||
|
class="w-240"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-loading.fullscreen.lock="loading">
|
<div v-loading.fullscreen.lock="loading">
|
||||||
<el-row
|
<el-row
|
||||||
@ -54,7 +60,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted, reactive } from 'vue'
|
||||||
import datasetApi from '@/api/dataset'
|
import datasetApi from '@/api/dataset'
|
||||||
import type { datasetListRequest } from '@/api/type/dataset'
|
import type { datasetListRequest } from '@/api/type/dataset'
|
||||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
@ -63,17 +69,21 @@ import { numberFormat } from '@/utils/utils'
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const filterText = ref('')
|
|
||||||
const datasetList = ref<any[]>([])
|
const datasetList = ref<any[]>([])
|
||||||
const disabledScroll = ref(false)
|
const disabledScroll = ref(false)
|
||||||
const pageConfig = ref<datasetListRequest>({
|
const pageConfig = reactive<datasetListRequest>({
|
||||||
current_page: 1,
|
current_page: 1,
|
||||||
page_size: 20,
|
page_size: 20,
|
||||||
search_text: ''
|
name: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
function loadDataset() {}
|
function loadDataset() {}
|
||||||
|
|
||||||
|
function search() {
|
||||||
|
pageConfig.current_page = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
function deleteDateset(row: any) {
|
function deleteDateset(row: any) {
|
||||||
MsgConfirm(
|
MsgConfirm(
|
||||||
`是否删除数据集:${row.name} ?`,
|
`是否删除数据集:${row.name} ?`,
|
||||||
@ -101,9 +111,9 @@ function deleteDateset(row: any) {
|
|||||||
function getList() {
|
function getList() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
datasetApi
|
datasetApi
|
||||||
.getDateset(pageConfig.value)
|
.getDateset(pageConfig)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
datasetList.value = res.data
|
datasetList.value = res.data?.records
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
@ -2,31 +2,48 @@
|
|||||||
<el-scrollbar>
|
<el-scrollbar>
|
||||||
<div class="upload-document p-24">
|
<div class="upload-document p-24">
|
||||||
<!-- 基本信息 -->
|
<!-- 基本信息 -->
|
||||||
<BaseForm ref="BaseFormRef" />
|
<BaseForm ref="BaseFormRef" v-if="isCreate" />
|
||||||
<!-- 上传文档 -->
|
<!-- 上传文档 -->
|
||||||
<UploadComponent ref="UploadComponentRef" />
|
<UploadComponent ref="UploadComponentRef" />
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import BaseForm from '@/views/dataset/component/BaseForm.vue'
|
import BaseForm from '@/views/dataset/component/BaseForm.vue'
|
||||||
import UploadComponent from '@/views/dataset/component/UploadComponent.vue'
|
import UploadComponent from '@/views/dataset/component/UploadComponent.vue'
|
||||||
|
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { dataset } = useStore()
|
const { dataset } = useStore()
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const {
|
||||||
|
params: { type }
|
||||||
|
} = route
|
||||||
|
const isCreate = type === 'create'
|
||||||
const BaseFormRef = ref()
|
const BaseFormRef = ref()
|
||||||
const UploadComponentRef = ref()
|
const UploadComponentRef = ref()
|
||||||
|
|
||||||
// submit
|
// submit
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
if ((await BaseFormRef.value.validate()) && (await UploadComponentRef.value.validate())) {
|
if (isCreate) {
|
||||||
// stores保存数据
|
if ((await BaseFormRef.value?.validate()) && (await UploadComponentRef.value.validate())) {
|
||||||
dataset.saveBaseInfo(BaseFormRef.value.form)
|
// stores保存数据
|
||||||
dataset.saveDocumentsFile(UploadComponentRef.value.form.fileList)
|
dataset.saveBaseInfo(BaseFormRef.value.form)
|
||||||
return true
|
dataset.saveDocumentsFile(UploadComponentRef.value.form.fileList)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false
|
if (await UploadComponentRef.value.validate()) {
|
||||||
|
// stores保存数据
|
||||||
|
dataset.saveDocumentsFile(UploadComponentRef.value.form.fileList)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="p-24 border-l">
|
<el-col :span="12" class="p-24 border-l">
|
||||||
<div>
|
<div v-loading="loading">
|
||||||
<h4 class="title-decoration-1 mb-8">分段预览</h4>
|
<h4 class="title-decoration-1 mb-8">分段预览</h4>
|
||||||
<SegmentPreview v-model:data="segmentList" />
|
<SegmentPreview v-model:data="segmentList" />
|
||||||
</div>
|
</div>
|
||||||
@ -116,14 +116,14 @@ function splitDocument() {
|
|||||||
fd.append('file', item?.raw)
|
fd.append('file', item?.raw)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (radio.value === '2') {
|
||||||
Object.keys(form).forEach((key) => {
|
Object.keys(form).forEach((key) => {
|
||||||
fd.append(key, form[key])
|
fd.append(key, form[key])
|
||||||
})
|
})
|
||||||
|
}
|
||||||
DatasetApi.postSplitDocument(fd)
|
DatasetApi.postSplitDocument(fd)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
segmentList.value = res
|
segmentList.value = res.data
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -131,7 +131,13 @@ function splitDocument() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {})
|
onMounted(() => {
|
||||||
|
splitDocument()
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
segmentList
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.set-rules {
|
.set-rules {
|
||||||
|
|||||||
@ -63,8 +63,9 @@ import type { FormInstance, FormRules } from 'element-plus'
|
|||||||
import UserApi from '@/api/user'
|
import UserApi from '@/api/user'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { params } = route
|
const {
|
||||||
const { code, email } = params
|
params: { code, email }
|
||||||
|
} = route
|
||||||
const resetPasswordForm = ref<ResetPasswordRequest>({
|
const resetPasswordForm = ref<ResetPasswordRequest>({
|
||||||
password: '',
|
password: '',
|
||||||
re_password: '',
|
re_password: '',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user