feat: 修改文档
This commit is contained in:
parent
6cf411eec1
commit
9f9d65a74b
@ -99,6 +99,17 @@ const putDocument: (dataset_id: string, document_id: string, data: any) => Promi
|
|||||||
return put(`${prefix}/${dataset_id}/document/${document_id}`, data)
|
return put(`${prefix}/${dataset_id}/document/${document_id}`, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除文档
|
||||||
|
* @param 参数 dataset_id, document_id,
|
||||||
|
*/
|
||||||
|
const delDocument: (dataset_id: string, document_id: string) => Promise<Result<boolean>> = (
|
||||||
|
dataset_id,
|
||||||
|
document_id
|
||||||
|
) => {
|
||||||
|
return del(`${prefix}/${dataset_id}/document/${document_id}`)
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getDateset,
|
getDateset,
|
||||||
getAllDateset,
|
getAllDateset,
|
||||||
@ -106,5 +117,6 @@ export default {
|
|||||||
postDateset,
|
postDateset,
|
||||||
postSplitDocument,
|
postSplitDocument,
|
||||||
getDocument,
|
getDocument,
|
||||||
putDocument
|
putDocument,
|
||||||
|
delDocument
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,9 +56,10 @@ const putMemberPermissions: (member_id: String, body: any) => Promise<Result<any
|
|||||||
member_id,
|
member_id,
|
||||||
body
|
body
|
||||||
) => {
|
) => {
|
||||||
return put(`${prefix}/${member_id}`, undefined, body)
|
return put(`${prefix}/${member_id}`, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getTeamMember,
|
getTeamMember,
|
||||||
postCreatTeamMember,
|
postCreatTeamMember,
|
||||||
|
|||||||
@ -12,12 +12,12 @@
|
|||||||
<div class="flex align-center" v-if="isEdit">
|
<div class="flex align-center" v-if="isEdit">
|
||||||
<el-input ref="inputRef" v-model="writeValue" placeholder="请输入"></el-input>
|
<el-input ref="inputRef" v-model="writeValue" placeholder="请输入"></el-input>
|
||||||
<span class="ml-4">
|
<span class="ml-4">
|
||||||
<el-button type="primary" text @click="submit">
|
<el-button type="primary" text @click="submit" :disabled="loading">
|
||||||
<el-icon><Select /></el-icon>
|
<el-icon><Select /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<el-button text @click="isEdit = false">
|
<el-button text @click="isEdit = false" :disabled="loading">
|
||||||
<el-icon><CloseBold /></el-icon>
|
<el-icon><CloseBold /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
@ -41,6 +41,7 @@ const props = defineProps({
|
|||||||
const emit = defineEmits(['change'])
|
const emit = defineEmits(['change'])
|
||||||
const isEdit = ref(false)
|
const isEdit = ref(false)
|
||||||
const writeValue = ref('')
|
const writeValue = ref('')
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
watch(isEdit, (bool) => {
|
watch(isEdit, (bool) => {
|
||||||
if (!bool) {
|
if (!bool) {
|
||||||
@ -49,8 +50,12 @@ watch(isEdit, (bool) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
|
loading.value = true
|
||||||
emit('change', writeValue.value)
|
emit('change', writeValue.value)
|
||||||
|
setTimeout(() => {
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
|
loading.value = false
|
||||||
|
}, 200)
|
||||||
}
|
}
|
||||||
function editNameHandle(row: any) {
|
function editNameHandle(row: any) {
|
||||||
writeValue.value = props.data
|
writeValue.value = props.data
|
||||||
|
|||||||
@ -149,8 +149,8 @@ export const put: (
|
|||||||
params?: unknown,
|
params?: unknown,
|
||||||
data?: unknown,
|
data?: unknown,
|
||||||
loading?: NProgress | Ref<boolean>
|
loading?: NProgress | Ref<boolean>
|
||||||
) => Promise<Result<any>> = (url, params, data, loading) => {
|
) => Promise<Result<any>> = (url, data, params, loading) => {
|
||||||
return promise(request({ url: url, method: 'put', params, data }), loading)
|
return promise(request({ url: url, method: 'put', data, params }), loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<LayoutContainer header="文档">
|
<LayoutContainer header="文档">
|
||||||
<div class="main-calc-height">
|
<div class="main-calc-height">
|
||||||
<div class="p-24" v-loading="loading">
|
<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' })"
|
||||||
>上传文档</el-button
|
>上传文档</el-button
|
||||||
@ -22,6 +22,7 @@
|
|||||||
@changePage="handleCurrentChange"
|
@changePage="handleCurrentChange"
|
||||||
@cell-mouse-enter="cellMouseEnter"
|
@cell-mouse-enter="cellMouseEnter"
|
||||||
@cell-mouse-leave="cellMouseLeave"
|
@cell-mouse-leave="cellMouseLeave"
|
||||||
|
v-loading="loading"
|
||||||
>
|
>
|
||||||
<el-table-column prop="name" label="文件名称" min-width="280">
|
<el-table-column prop="name" label="文件名称" min-width="280">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@ -53,7 +54,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="name" label="启动状态">
|
<el-table-column prop="name" label="启动状态">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-switch v-model="row.is_active" />
|
<el-switch v-model="row.is_active" @change="changeState($event, row)" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="create_time" label="创建时间" width="170">
|
<el-table-column prop="create_time" label="创建时间" width="170">
|
||||||
@ -77,7 +78,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="ml-4">
|
<span class="ml-4">
|
||||||
<el-tooltip effect="dark" content="删除" placement="top">
|
<el-tooltip effect="dark" content="删除" placement="top">
|
||||||
<el-button type="primary" text>
|
<el-button type="primary" text @click="deleteDocument(row)">
|
||||||
<el-icon><Delete /></el-icon>
|
<el-icon><Delete /></el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
@ -95,12 +96,11 @@ import { useRouter, useRoute } from 'vue-router'
|
|||||||
import datasetApi from '@/api/dataset'
|
import datasetApi from '@/api/dataset'
|
||||||
import { toThousands } from '@/utils/utils'
|
import { toThousands } from '@/utils/utils'
|
||||||
import { datetimeFormat } from '@/utils/time'
|
import { datetimeFormat } from '@/utils/time'
|
||||||
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { params } = route
|
const { params } = route
|
||||||
const { datasetId } = params
|
const { datasetId } = params as any
|
||||||
|
|
||||||
const inputRef = ref()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
@ -113,7 +113,58 @@ const paginationConfig = reactive({
|
|||||||
total: 0
|
total: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
function editName(val: string) {}
|
function deleteDocument(row: any) {
|
||||||
|
MsgConfirm(
|
||||||
|
`是否删除文档:${row.name} ?`,
|
||||||
|
`此文档下的 ${row.paragraph_count} 个分段都会被删除,请谨慎操作。`,
|
||||||
|
{
|
||||||
|
confirmButtonText: '删除',
|
||||||
|
confirmButtonClass: 'danger'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
loading.value = true
|
||||||
|
datasetApi
|
||||||
|
.delDocument(datasetId, row.id)
|
||||||
|
.then(() => {
|
||||||
|
MsgSuccess('删除成功')
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateData(documentId: string, data: any) {
|
||||||
|
loading.value = true
|
||||||
|
datasetApi
|
||||||
|
.putDocument(datasetId, documentId, data)
|
||||||
|
.then((res) => {
|
||||||
|
const index = documentData.value.findIndex((v) => v.id === documentId)
|
||||||
|
documentData.value.splice(index, 1, res.data)
|
||||||
|
MsgSuccess('修改成功')
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeState(bool: Boolean, row: any) {
|
||||||
|
const obj = {
|
||||||
|
is_active: bool
|
||||||
|
}
|
||||||
|
currentMouseId.value && updateData(row.id, obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
function editName(val: string) {
|
||||||
|
const obj = {
|
||||||
|
name: val
|
||||||
|
}
|
||||||
|
currentMouseId.value && updateData(currentMouseId.value, obj)
|
||||||
|
}
|
||||||
|
|
||||||
function cellMouseEnter(row: any) {
|
function cellMouseEnter(row: any) {
|
||||||
currentMouseId.value = row.id
|
currentMouseId.value = row.id
|
||||||
|
|||||||
@ -74,7 +74,7 @@ function editHandle(item: any, index: number, cIndex: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deleteHandle(item: any, index: number, cIndex: number) {
|
function deleteHandle(item: any, index: number, cIndex: number) {
|
||||||
MsgConfirm(`是否删除分段:${item.title}?`, `删除后将不会存入数据集,对本地文档无影响。`, {
|
MsgConfirm(`是否删除分段:${item.title} ?`, `删除后将不会存入数据集,对本地文档无影响。`, {
|
||||||
confirmButtonText: '删除',
|
confirmButtonText: '删除',
|
||||||
confirmButtonClass: 'danger'
|
confirmButtonClass: 'danger'
|
||||||
})
|
})
|
||||||
|
|||||||
@ -76,7 +76,7 @@ function loadDataset() {}
|
|||||||
|
|
||||||
function deleteDateset(row: any) {
|
function deleteDateset(row: any) {
|
||||||
MsgConfirm(
|
MsgConfirm(
|
||||||
`是否删除数据集:${row.name}?`,
|
`是否删除数据集:${row.name} ?`,
|
||||||
`此数据集关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`,
|
`此数据集关联 ${row.char_length} 个应用,删除后无法恢复,请谨慎操作。`,
|
||||||
{
|
{
|
||||||
confirmButtonText: '删除',
|
confirmButtonText: '删除',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user