mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
perf: 快速修改文档名称和问题,支持回车保存
This commit is contained in:
parent
bc57f17337
commit
7be349c937
|
|
@ -21,6 +21,8 @@
|
|||
autofocus
|
||||
:maxlength="maxlength || '-'"
|
||||
:show-word-limit="maxlength ? true : false"
|
||||
@blur="isEdit = false"
|
||||
@keyup.enter="submit"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
|
|
@ -64,6 +66,10 @@ const loading = ref(false)
|
|||
watch(isEdit, (bool) => {
|
||||
if (!bool) {
|
||||
writeValue.value = ''
|
||||
} else {
|
||||
nextTick(() => {
|
||||
inputRef.value?.focus()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -80,10 +86,6 @@ function editNameHandle() {
|
|||
isEdit.value = true
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
inputRef.value?.focus()
|
||||
})
|
||||
})
|
||||
onMounted(() => {})
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
<el-table-column prop="name" label="文件名称" min-width="280">
|
||||
<template #default="{ row }">
|
||||
<ReadWrite
|
||||
@change="editName"
|
||||
@change="editName($event, row.id)"
|
||||
:data="row.name"
|
||||
:showEditIcon="row.id === currentMouseId"
|
||||
/>
|
||||
|
|
@ -354,12 +354,12 @@ function changeState(bool: Boolean, row: any) {
|
|||
currentMouseId.value && updateData(row.id, obj, str)
|
||||
}
|
||||
|
||||
function editName(val: string) {
|
||||
function editName(val: string, id: string) {
|
||||
if (val) {
|
||||
const obj = {
|
||||
name: val
|
||||
}
|
||||
currentMouseId.value && updateData(currentMouseId.value, obj, '修改成功')
|
||||
updateData(id, obj, '修改成功')
|
||||
} else {
|
||||
MsgError('文件名称不能为空!')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
<el-table-column prop="content" label="问题" min-width="280">
|
||||
<template #default="{ row }">
|
||||
<ReadWrite
|
||||
@change="editName"
|
||||
@change="editName($event, row.id)"
|
||||
:data="row.content"
|
||||
:showEditIcon="row.id === currentMouseId"
|
||||
:maxlength="256"
|
||||
|
|
@ -121,7 +121,7 @@ import useStore from '@/stores'
|
|||
|
||||
const route = useRoute()
|
||||
const {
|
||||
params: { id }
|
||||
params: { id } // 知识库id
|
||||
} = route as any
|
||||
|
||||
const { problem } = useStore()
|
||||
|
|
@ -216,12 +216,12 @@ function deleteProblem(row: any) {
|
|||
.catch(() => {})
|
||||
}
|
||||
|
||||
function editName(val: string) {
|
||||
function editName(val: string, problemId: string) {
|
||||
if (val) {
|
||||
const obj = {
|
||||
content: val
|
||||
}
|
||||
problemApi.putProblems(id, currentMouseId.value, obj, loading).then(() => {
|
||||
problemApi.putProblems(id, problemId, obj, loading).then(() => {
|
||||
getList()
|
||||
MsgSuccess('修改成功')
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue