fix(userManagement): 编辑传主键id与成员来源标注
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
48b75f37c9
commit
d59aad4f44
@@ -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
|
||||
|
||||
@@ -42,6 +42,8 @@ interface MemberItem {
|
||||
height: number
|
||||
sync: string
|
||||
syncClass: string
|
||||
/** 1=本人 2=自己添加 3=他人添加 */
|
||||
relationType: number | null
|
||||
}
|
||||
|
||||
/** 展示用分组 */
|
||||
@@ -144,6 +146,7 @@ Page({
|
||||
height: item.height,
|
||||
sync: item.syncStatus === 1 ? '已同步' : '待同步',
|
||||
syncClass: item.syncStatus === 1 ? 'done' : 'pending',
|
||||
relationType: item.relationType,
|
||||
})
|
||||
const self = list.find(m => m.relationType === 1)
|
||||
this.setData({
|
||||
@@ -383,7 +386,7 @@ Page({
|
||||
onTapEdit(e: WechatMiniprogram.TouchEvent) {
|
||||
const item = e.currentTarget.dataset.item as MemberItem
|
||||
const sn = targetDevice?.sn || ''
|
||||
wx.navigateTo({ url: `/pages/addUser/addUser?sn=${encodeURIComponent(sn)}&userId=${encodeURIComponent(item.userId)}` })
|
||||
wx.navigateTo({ url: `/pages/addUser/addUser?sn=${encodeURIComponent(sn)}&id=${encodeURIComponent(item.id)}` })
|
||||
},
|
||||
|
||||
/** 删除成员 */
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<view class="member-avatar {{ member.gender === '女' ? 'member-avatar--female' : 'member-avatar--male' }}"><image src="{{ member.gender === '女' ? '/images/woman.png' : '/images/man.png' }}" mode="aspectFit" /></view>
|
||||
<view class="member-info">
|
||||
<view class="member-name-row">
|
||||
<view class="member-name">{{ member.name }} <text>(他人添加)</text></view>
|
||||
<view class="member-name">{{ member.name }} <text>{{ member.relationType === 2 ? '(自己添加)' : '(他人添加)' }}</text></view>
|
||||
</view>
|
||||
<view class="member-sub">{{ member.gender }}·{{ member.age }}岁 丨 {{ member.height }}cm</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user