feat(ops): 设备与绑定接口接入运维模式路径区分
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
431be11ecd
commit
2afe598881
@@ -4,9 +4,15 @@ import type { RawDevice } from '../../lefu/types'
|
|||||||
import { post } from '../../utils/request/index'
|
import { post } from '../../utils/request/index'
|
||||||
import type { UserInfo } from '../../api/index'
|
import type { UserInfo } from '../../api/index'
|
||||||
|
|
||||||
/** 绑定设备 SN 到用户信息 */
|
/** 绑定设备 SN 到用户信息(运维模式走 ops/addDevice,普通模式走 v6/bindDevice) */
|
||||||
const bindDevice = (data: { sn: string; idCard: string; connectDeviceInfo?: string }) =>
|
const bindDevice = (data: { sn: string; idCard: string; connectDeviceInfo?: string }) =>
|
||||||
post('weighingScale/v6/bindDevice', data, { loading: false })
|
post(
|
||||||
|
getApp<IAppOption>().globalData.operationsEngineer
|
||||||
|
? 'weighingScale/ops/addDevice'
|
||||||
|
: 'weighingScale/v6/bindDevice',
|
||||||
|
data,
|
||||||
|
{ loading: false },
|
||||||
|
)
|
||||||
|
|
||||||
/** 渲染用的设备项(RawDevice 含复杂对象,不进 setData) */
|
/** 渲染用的设备项(RawDevice 含复杂对象,不进 setData) */
|
||||||
interface DeviceItem {
|
interface DeviceItem {
|
||||||
|
|||||||
@@ -16,13 +16,21 @@ interface ScaleDevice {
|
|||||||
status: false
|
status: false
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取体重设备列表 */
|
/** 获取体重设备列表(运维模式走 ops/listDevice,普通模式走 v6/list/device) */
|
||||||
const getDeviceList = () =>
|
const getDeviceList = () =>
|
||||||
get<ScaleDevice[]>('weighingScale/v6/list/device')
|
get<ScaleDevice[]>(
|
||||||
|
getApp<IAppOption>().globalData.operationsEngineer
|
||||||
|
? 'weighingScale/ops/listDevice'
|
||||||
|
: 'weighingScale/v6/list/device',
|
||||||
|
)
|
||||||
|
|
||||||
/** 取消配对:id 不传则解除所有设备绑定 */
|
/** 取消配对:id 不传则解除所有设备绑定(运维模式走 ops/deleteUser,普通模式走 v6/unbind) */
|
||||||
const unbindDevice = (id?: string) =>
|
const unbindDevice = (id?: string) => {
|
||||||
del(`weighingScale/v6/unbind${id ? `?id=${id}` : ''}`, {}, { loading: false })
|
const url = getApp<IAppOption>().globalData.operationsEngineer
|
||||||
|
? 'weighingScale/ops/deleteUser'
|
||||||
|
: 'weighingScale/v6/unbind'
|
||||||
|
return del(`${url}${id ? `?id=${id}` : ''}`, {}, { loading: false })
|
||||||
|
}
|
||||||
|
|
||||||
/** 展示用设备项 */
|
/** 展示用设备项 */
|
||||||
interface DeviceItem {
|
interface DeviceItem {
|
||||||
@@ -262,12 +270,14 @@ Page({
|
|||||||
onLongPressBanner() {
|
onLongPressBanner() {
|
||||||
getApp<IAppOption>().globalData.operationsEngineer = true
|
getApp<IAppOption>().globalData.operationsEngineer = true
|
||||||
this.setData({ operationsEngineer: true })
|
this.setData({ operationsEngineer: true })
|
||||||
|
this.loadDevices()
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 关闭运维模式 */
|
/** 关闭运维模式 */
|
||||||
onCloseOps() {
|
onCloseOps() {
|
||||||
getApp<IAppOption>().globalData.operationsEngineer = false
|
getApp<IAppOption>().globalData.operationsEngineer = false
|
||||||
this.setData({ operationsEngineer: false })
|
this.setData({ operationsEngineer: false })
|
||||||
|
this.loadDevices()
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 取消全部配对:解除所有设备绑定 */
|
/** 取消全部配对:解除所有设备绑定 */
|
||||||
|
|||||||
Reference in New Issue
Block a user