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