118 lines
3.4 KiB
TypeScript
118 lines
3.4 KiB
TypeScript
import http from '@/utils/httpRequest'
|
||
import type { ManageListResponse, ManageResponse, ManagePageParams } from './types'
|
||
|
||
/**
|
||
* 终端/设备信息
|
||
*/
|
||
export interface DeviceInfo {
|
||
id: number
|
||
storeOrgId: number
|
||
mac: string
|
||
deviceSn: string
|
||
wifiMac?: string
|
||
deviceUid?: string
|
||
androidId?: string
|
||
manufacturer?: string
|
||
model?: string
|
||
brand?: string
|
||
identifierStrategy?: string
|
||
deviceName: string
|
||
deviceModel: string
|
||
verCode?: string
|
||
verName?: string
|
||
androidVersion?: string
|
||
roomNo: string
|
||
lastHeartbeat?: string
|
||
remark: string
|
||
status: string
|
||
createdAt: string
|
||
updatedAt: string
|
||
/** 非表字段,后端 join 返回 */
|
||
storeName?: string
|
||
channelOrgId?: number
|
||
channelName?: string
|
||
agentOrgName?: string
|
||
/** 设备来源:PLATFORM-平台 / PARTNER-第三方接口注册 */
|
||
source?: string
|
||
/** 合作伙伴UUID(source=PARTNER 时) */
|
||
partnerId?: string
|
||
}
|
||
|
||
/**
|
||
* 终端列表查询参数
|
||
*/
|
||
export interface DeviceListParams extends ManagePageParams {
|
||
storeOrgId?: number
|
||
status?: string
|
||
deviceName?: string
|
||
mac?: string
|
||
/** 设备来源:PLATFORM / PARTNER */
|
||
source?: string
|
||
/** 合作伙伴UUID(source=PARTNER 时筛选) */
|
||
partnerId?: string
|
||
}
|
||
|
||
/**
|
||
* 终端保存/更新数据
|
||
*/
|
||
export interface DeviceSaveData {
|
||
id?: number
|
||
storeOrgId: number
|
||
mac?: string
|
||
wifiMac?: string
|
||
deviceUid?: string
|
||
deviceSn?: string
|
||
deviceName?: string
|
||
deviceModel?: string
|
||
roomNo?: string
|
||
remark?: string
|
||
}
|
||
|
||
/** 终端分页列表 */
|
||
export function getDeviceList(params?: DeviceListParams): Promise<ManageListResponse<DeviceInfo>> {
|
||
return http.get(http.adornUrl('/manage/device/list'), { params: http.adornParams(params || {}) }).then(res => res.data)
|
||
}
|
||
|
||
/** 终端详情 */
|
||
export function getDeviceInfo(id: number): Promise<ManageResponse<{ device?: DeviceInfo }>> {
|
||
return http.get(http.adornUrl(`/manage/device/info/${id}`), { params: http.adornParams() }).then(res => res.data)
|
||
}
|
||
|
||
/** 新增/修改终端 */
|
||
export function saveOrUpdateDevice(data: DeviceSaveData): Promise<ManageResponse> {
|
||
const url = data.id ? '/manage/device/update' : '/manage/device/save'
|
||
return http.post(http.adornUrl(url), http.adornData(data)).then(res => res.data)
|
||
}
|
||
|
||
/** 删除终端(批量软删除) */
|
||
export function deleteDevice(ids: number[]): Promise<ManageResponse> {
|
||
return http.post(http.adornUrl('/manage/device/delete'), http.adornData(ids, false)).then(res => res.data)
|
||
}
|
||
|
||
/** 绑定门店(query 参数传 deviceId 和 storeOrgId) */
|
||
export function bindDeviceStore(deviceId: number, storeOrgId: number): Promise<ManageResponse> {
|
||
return http.post(
|
||
http.adornUrl('/manage/device/bindStore'),
|
||
http.adornData({}),
|
||
{ params: http.adornParams({ deviceId, storeOrgId }) }
|
||
).then(res => res.data)
|
||
}
|
||
|
||
/** 解绑设备(换场所):清门店关联 + 作废 sign + 释放天卡权益 */
|
||
export function unbindDeviceOrg(deviceId: number): Promise<ManageResponse> {
|
||
return http.post(
|
||
http.adornUrl('/manage/daycard/device/unbind-org'),
|
||
http.adornData({}),
|
||
{ params: http.adornParams({ deviceId }) }
|
||
).then(res => res.data)
|
||
}
|
||
|
||
/** 退天卡:仅退卡,不解绑门店 */
|
||
export function unbindDayCard(deviceId: number): Promise<ManageResponse> {
|
||
return http.post(
|
||
http.adornUrl('/manage/daycard/device/unbind'),
|
||
http.adornData({}),
|
||
{ params: http.adornParams({ deviceId }) }
|
||
).then(res => res.data)
|
||
}
|