perf: 快速修改文档名称和问题,支持回车保存

This commit is contained in:
wangdan-fit2cloud 2024-04-22 14:59:51 +08:00 committed by GitHub
parent bc57f17337
commit 7be349c937
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 12 deletions

View File

@ -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>

View File

@ -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('文件名称不能为空!')
}

View File

@ -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('修改成功')
})