fix(userManagement): 编辑传主键id与成员来源标注

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-25 19:20:30 +08:00
co-authored by Claude Opus 4.7
parent 48b75f37c9
commit d59aad4f44
3 changed files with 14 additions and 11 deletions
+9 -9
View File
@@ -29,7 +29,7 @@ const getUserInfoById = (id: string) =>
/** 目标设备 SN(由 userManagement 跳转传入) */
let targetSn = ''
/** 编辑的用户 id(空表示新增) */
let editUserId = ''
let editId = ''
Page({
data: {
@@ -58,10 +58,10 @@ Page({
onLoad(options: Record<string, string>) {
targetSn = decodeURIComponent(options.sn || '')
editUserId = decodeURIComponent(options.userId || '')
this.setData({ isEdit: !!editUserId })
if (editUserId) {
this._loadEditUser(editUserId)
editId = decodeURIComponent(options.id || '')
this.setData({ isEdit: !!editId })
if (editId) {
this._loadEditUser(editId)
}
},
@@ -344,7 +344,7 @@ Page({
const userInfo = wx.getStorageSync('userInfo') as Record<string, any> | null
// 编辑:以详情接口返回为 base;新增:员工用查询结果、家庭用身份证查询结果
const baseSpread = editUserId
const baseSpread = editId
? (this.data.rawUser ?? {})
: (userType === 'employee'
? (this.data.employeeQueryResult ?? {})
@@ -364,13 +364,13 @@ Page({
weight: isNaN(weightNum) ? 0 : weightNum,
mode: getApp<IAppOption>().globalData.operationsEngineer ? 'ops' : 'normal',
}
if (editUserId) {
payload.id = editUserId
if (editId) {
payload.id = editId
}
addUser(payload)
.then(() => {
wx.showToast({ title: editUserId ? '保存成功' : '添加成功', icon: 'success' })
wx.showToast({ title: editId ? '保存成功' : '添加成功', icon: 'success' })
// 调用上一个页面(userManagement)刷新成员列表
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2] as any