|
|
@@ -1,3 +1,4 @@
|
|
|
+import store from '@/store'
|
|
|
import request, { tenantRequest } from '@/utils/request'
|
|
|
import {
|
|
|
add,
|
|
|
@@ -100,33 +101,41 @@ export function deleteDevice ({ id, name, masterId }) {
|
|
|
}
|
|
|
|
|
|
export function getDevices (query, options) {
|
|
|
- const scope = addTenantOrOrg({})
|
|
|
- if (scope.tenant) {
|
|
|
- return getDevicesByAdmin({
|
|
|
- ...query,
|
|
|
- ...scope
|
|
|
- }, options)
|
|
|
+ return getDevicesByQuery(addTenantOrOrg(query), options)
|
|
|
+}
|
|
|
+
|
|
|
+export function getDevicesByQuery (query, options) {
|
|
|
+ const { tenant, org, ...params } = query
|
|
|
+ if (tenant || org && org === store.getters.tenant) {
|
|
|
+ return getDevicesByTenant(tenant || org, params, options)
|
|
|
}
|
|
|
+ return getDevicesByOrg(org, params, options)
|
|
|
+}
|
|
|
+
|
|
|
+export function getDevicesByTenant (tenant, query, options) {
|
|
|
const { pageNum: pageIndex, pageSize, ...params } = query
|
|
|
return tenantRequest({
|
|
|
- url: '/device/relation/page',
|
|
|
+ url: '/device/tenant/page',
|
|
|
method: 'GET',
|
|
|
params: {
|
|
|
- pageIndex, pageSize,
|
|
|
- ...params,
|
|
|
- ...scope
|
|
|
+ tenant,
|
|
|
+ pageIndex,
|
|
|
+ pageSize,
|
|
|
+ ...params
|
|
|
},
|
|
|
...options
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function getDevicesByAdmin (query, options) {
|
|
|
+export function getDevicesByOrg (org, query, options) {
|
|
|
const { pageNum: pageIndex, pageSize, ...params } = query
|
|
|
return tenantRequest({
|
|
|
- url: params.tenant ? '/device/tenant/page' : '/device/relation/page',
|
|
|
+ url: '/device/relation/page',
|
|
|
method: 'GET',
|
|
|
params: {
|
|
|
- pageIndex, pageSize,
|
|
|
+ org,
|
|
|
+ pageIndex,
|
|
|
+ pageSize,
|
|
|
...params
|
|
|
},
|
|
|
...options
|
|
|
@@ -313,19 +322,17 @@ export function deleteDeviceFromGroup (id, { id: deviceId, name }) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-export function getDeviceStatistics (productId) {
|
|
|
- return tenantRequest({
|
|
|
- url: '/device/listDeviceTotal',
|
|
|
- method: 'GET',
|
|
|
- params: addTenantOrOrg({ productId })
|
|
|
- })
|
|
|
+export function getDeviceStatistics () {
|
|
|
+ return getDeviceStatisticsByPath(store.getters.org)
|
|
|
}
|
|
|
|
|
|
-export function getDeviceStatisticsByCustom (query) {
|
|
|
+export function getDeviceStatisticsByPath (path) {
|
|
|
return tenantRequest({
|
|
|
url: '/device/listDeviceTotal',
|
|
|
method: 'GET',
|
|
|
- params: query
|
|
|
+ params: path === store.getters.tenant
|
|
|
+ ? { tenant: path }
|
|
|
+ : { org: path }
|
|
|
})
|
|
|
}
|
|
|
|