fix(app): allow remark-only edit in accounts

This commit is contained in:
2025-12-14 00:38:07 +08:00
parent 69443c2de6
commit 757de96fd9
15 changed files with 49 additions and 38 deletions

View File

@@ -243,16 +243,21 @@ function openEdit(acc) {
async function submitEdit() {
if (!editForm.id) return
if (!editForm.password.trim()) {
ElMessage.error('请输入新密码')
const newPassword = editForm.password.trim()
const remarkText = editForm.remark.trim()
if (!newPassword && remarkText === editForm.originalRemark) {
ElMessage.info('没有修改')
editOpen.value = false
return
}
try {
const res = await updateAccount(editForm.id, { password: editForm.password, remember: true })
if (res?.account) normalizeAccountPayload(res.account)
if (newPassword) {
const res = await updateAccount(editForm.id, { password: newPassword, remember: true })
if (res?.account) normalizeAccountPayload(res.account)
}
const remarkText = editForm.remark.trim()
if (remarkText !== editForm.originalRemark) {
await updateAccountRemark(editForm.id, { remark: remarkText })
normalizeAccountPayload({ id: editForm.id, remark: remarkText })
@@ -613,8 +618,14 @@ onBeforeUnmount(() => {
<el-form-item label="账号">
<el-input v-model="editForm.username" disabled />
</el-form-item>
<el-form-item label="新密码(必填">
<el-input v-model="editForm.password" type="password" show-password placeholder="请输入新密码" autocomplete="off" />
<el-form-item label="新密码(可选">
<el-input
v-model="editForm.password"
type="password"
show-password
placeholder="留空表示不修改密码"
autocomplete="off"
/>
</el-form-item>
<el-form-item label="备注可选最多200字">
<el-input v-model="editForm.remark" type="textarea" :rows="3" maxlength="200" show-word-limit placeholder="例如:部门/用途" />