feat(userManagement): 成员编辑删除与运维模式接口区分

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-25 19:06:03 +08:00
co-authored by Claude Opus 4.7
parent 2afe598881
commit 48b75f37c9
3 changed files with 120 additions and 16 deletions
@@ -1,4 +1,4 @@
import { get, post } from '../../utils/request/index'
import { get, post, del } from '../../utils/request/index'
import { leFuService } from '../../lefu/index'
import type { SyncUserData } from '../../lefu/index'
import { calcAge } from '../../utils/idCard/index'
@@ -50,14 +50,23 @@ interface GroupItem {
members: MemberItem[]
}
/** 获取设备成员列表 */
/** 获取设备成员列表(运维模式走 ops/getDeviceUsers,普通模式走 v3/selectUserBySn/user */
const getDeviceMembers = (sn: string, userId: string) =>
get<SysUserDevice[]>('weighingScale/v3/selectUserBySn/user', { sn, userId })
get<SysUserDevice[]>(
getApp<IAppOption>().globalData.operationsEngineer
? 'weighingScale/ops/getDeviceUsers'
: 'weighingScale/v3/selectUserBySn/user',
{ sn, userId },
)
/** 标记用户已同步到设备 */
const markSynced = (data: { sn: string; list: string[] }) =>
post('weighingScale/v6/markSynced', data, { loading: false })
/** 删除设备成员 */
const deleteMember = (id: string) =>
del('weighingScale/v2/del/user', { id }, { loading: false })
/** equipment 页传入的目标设备 */
let targetDevice: { sn: string; deviceId: string; name: string; connected: boolean; connectDeviceInfo: string } | null = null
@@ -370,6 +379,36 @@ Page({
wx.navigateTo({ url: `/pages/addUser/addUser?sn=${encodeURIComponent(sn)}` })
},
/** 编辑成员:跳转 addUser 编辑模式 */
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)}` })
},
/** 删除成员 */
onTapDelete(e: WechatMiniprogram.TouchEvent) {
const item = e.currentTarget.dataset.item as MemberItem
wx.showModal({
title: '删除用户',
content: `是否确认删除「${item.name}」?`,
cancelText: '取消',
confirmText: '删除',
confirmColor: '#F24439',
success: (res) => {
if (!res.confirm) return
deleteMember(item.id)
.then(() => {
wx.showToast({ title: '删除成功', icon: 'success' })
this._loadMembers()
})
.catch(() => {
wx.showToast({ title: '删除失败,请重试', icon: 'none' })
})
},
})
},
/** 一键添加本人 */
onTapAddSelf() {
// 一键添加本人(待接入)