|
|
@@ -8,8 +8,9 @@ import {
|
|
|
send,
|
|
|
confirmAndSend,
|
|
|
addTenant,
|
|
|
- addScope,
|
|
|
- addUser
|
|
|
+ addTenantOrOrg,
|
|
|
+ addUser,
|
|
|
+ addOrg
|
|
|
} from './base'
|
|
|
import {
|
|
|
AssetType,
|
|
|
@@ -20,7 +21,7 @@ export function getRatiosWithUser () {
|
|
|
return tenantRequest({
|
|
|
url: '/device/resolutionRatio',
|
|
|
method: 'GET',
|
|
|
- params: addScope({})
|
|
|
+ params: addTenantOrOrg({})
|
|
|
}).then(({ data }) => {
|
|
|
return {
|
|
|
data: Object.keys(data).map(key => {
|
|
|
@@ -93,77 +94,75 @@ export function deleteDevice ({ id, name }) {
|
|
|
}
|
|
|
|
|
|
export function getDevices (query, options) {
|
|
|
+ const scope = addTenantOrOrg({})
|
|
|
+ if (scope.tenant) {
|
|
|
+ return getDevicesByAdmin({
|
|
|
+ ...query,
|
|
|
+ ...scope
|
|
|
+ }, options)
|
|
|
+ }
|
|
|
const { pageNum: pageIndex, pageSize, ...params } = query
|
|
|
return tenantRequest({
|
|
|
url: '/device/relation/page',
|
|
|
method: 'GET',
|
|
|
- params: addScope({
|
|
|
+ params: {
|
|
|
pageIndex, pageSize,
|
|
|
- ...params
|
|
|
- }),
|
|
|
+ ...params,
|
|
|
+ ...scope
|
|
|
+ },
|
|
|
...options
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function getDevicesByAdmin (query) {
|
|
|
+export function getDevicesByAdmin (query, options) {
|
|
|
const { pageNum: pageIndex, pageSize, ...params } = query
|
|
|
return tenantRequest({
|
|
|
- url: '/device/relation/page',
|
|
|
+ url: params.tenant ? '/device/tenant/page' : '/device/relation/page',
|
|
|
method: 'GET',
|
|
|
params: {
|
|
|
pageIndex, pageSize,
|
|
|
...params
|
|
|
- }
|
|
|
+ },
|
|
|
+ ...options
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function getDevicesByRelation (query) {
|
|
|
+export function getBoundDevices (query, options) {
|
|
|
const { pageNum: pageIndex, pageSize, ...params } = query
|
|
|
- return tenantRequest({
|
|
|
- url: '/device/queryRelation/page',
|
|
|
+ return send({
|
|
|
+ url: '/device/allocate/page',
|
|
|
method: 'GET',
|
|
|
params: {
|
|
|
pageIndex, pageSize,
|
|
|
...params
|
|
|
- }
|
|
|
+ },
|
|
|
+ ...options
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function bindDeviceToObject (deviceId, org, user) {
|
|
|
- return request({
|
|
|
- url: `/device/relation/${deviceId}/save`,
|
|
|
+export function bindDeviceToObject (deviceId, org) {
|
|
|
+ return send({
|
|
|
+ url: '/device/allocate/department',
|
|
|
method: 'POST',
|
|
|
- data: {
|
|
|
- org,
|
|
|
- user
|
|
|
- }
|
|
|
+ data: { deviceId, org }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function unbindDevice ({ deviceRelaId, name }) {
|
|
|
+export function unbindDevice ({ deviceRelationId, name }) {
|
|
|
return confirmAndSend('移除', name, {
|
|
|
- url: `/device/relation/${deviceRelaId}/remove`,
|
|
|
+ url: `/device/allocate/${deviceRelationId}`,
|
|
|
method: 'DELETE'
|
|
|
})
|
|
|
}
|
|
|
|
|
|
export function unbindDevices (params) {
|
|
|
return request({
|
|
|
- url: '/device/relation/batchRemove',
|
|
|
+ url: '/device/allocate/department',
|
|
|
method: 'DELETE',
|
|
|
params
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function updateBindDevices (user, org) {
|
|
|
- return send({
|
|
|
- url: '/device/relation/update',
|
|
|
- method: 'POST',
|
|
|
- params: { user },
|
|
|
- data: { org }
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
export function activateDevice ({ id, name }) {
|
|
|
return confirmAndSend('激活', name, {
|
|
|
url: '/device/batch/activate',
|
|
|
@@ -281,7 +280,7 @@ export function addDeviceGroup (data) {
|
|
|
return add({
|
|
|
url: '/deviceGroup',
|
|
|
method: 'POST',
|
|
|
- data
|
|
|
+ data: addOrg(data, false)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -316,7 +315,7 @@ export function getDevicesByGroup (id) {
|
|
|
return tenantRequest({
|
|
|
url: `/deviceGroup/${id}/device`,
|
|
|
method: 'GET',
|
|
|
- params: addScope({})
|
|
|
+ params: addTenantOrOrg({})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -324,7 +323,7 @@ export function getDeviceTree () {
|
|
|
return tenantRequest({
|
|
|
url: '/deviceGroup/deviceTree',
|
|
|
method: 'GET',
|
|
|
- params: addUser(addScope({}))
|
|
|
+ params: addUser(addTenantOrOrg({}))
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -348,7 +347,7 @@ export function getDeviceStatistics (productId) {
|
|
|
return tenantRequest({
|
|
|
url: '/device/listDeviceTotal',
|
|
|
method: 'GET',
|
|
|
- params: addScope({ productId })
|
|
|
+ params: addTenantOrOrg({ productId })
|
|
|
})
|
|
|
}
|
|
|
|