Prechádzať zdrojové kódy

fix(account): unable to assign department when creating account

Casper Dai 2 rokov pred
rodič
commit
2f994eb73c

+ 11 - 2
src/api/device.js

@@ -340,13 +340,14 @@ export function getDeviceStatistics () {
   return getDeviceStatisticsByPath(store.getters.org)
 }
 
-export function getDeviceStatisticsByPath (path) {
+export function getDeviceStatisticsByPath (path, options) {
   return tenantRequest({
     url: '/device/listDeviceTotal',
     method: 'GET',
     params: path === store.getters.tenant
       ? { tenant: path }
-      : { org: path }
+      : { org: path },
+    ...options
   })
 }
 
@@ -580,3 +581,11 @@ export function getDevicesWithPower (params) {
     params
   })
 }
+
+export function getDepartmentDeviceTree (query) {
+  return tenantRequest({
+    url: '/admin/department/device/list',
+    method: 'GET',
+    params: query
+  })
+}

+ 3 - 2
src/api/statistics.js

@@ -45,10 +45,11 @@ export function getAdCollect (query = {}) {
   })
 }
 
-export function triggetOnlineDurationSnap () {
+export function triggetOnlineDurationSnap (params) {
   return request({
     url: '/deviceOnlineInfoDetail/syncDeviceOnlineSummary',
-    method: 'GET'
+    method: 'GET',
+    params
   })
 }
 

+ 1 - 1
src/views/realm/user/Account.vue

@@ -281,7 +281,7 @@ export default {
         ...this.user,
         ...(
           this.$department.id
-            ? { id: this.$department.id, departmentName: this.$department.name }
+            ? { departmentId: this.$department.id, departmentName: this.$department.name }
             : { departmentName: '顶层部门' }
         )
       }).then(() => {

+ 14 - 1
src/views/test-api.vue

@@ -81,6 +81,15 @@
             设备汇总
           </button>
         </div>
+        <span class="c-sibling-item--v far u-font-size--sm u-bold">数据</span>
+        <div class="c-sibling-item--v l-grid--info mini">
+          <button
+            class="o-button"
+            @click="onGetDepartmentDeviceTree"
+          >
+            部门设备树
+          </button>
+        </div>
       </div>
       <div class="l-flex__none c-sibling-item far u-width--lg u-font-size--sm u-overflow-y--auto">
         <pre
@@ -106,6 +115,7 @@ import {
   getAdReport,
   getAdCollect
 } from '@/api/statistics'
+import { getDepartmentDeviceTree } from '@/api/device'
 
 export default {
   name: 'TestApi',
@@ -154,7 +164,7 @@ export default {
       }
     },
     onTriggerOnlineDurationSnap () {
-      triggetOnlineDurationSnap().then(() => {
+      triggetOnlineDurationSnap({ endDate: parseTime(new Date(), '{y}-{m}-{d}') }).then(() => {
         this.$message({
           type: 'success',
           message: '触发完成'
@@ -213,6 +223,9 @@ export default {
     },
     onGetAdCollectForDevice () {
       this.checkDevice() && getAdCollect({ deviceId: this.deviceId }).then(this.onData)
+    },
+    onGetDepartmentDeviceTree () {
+      getDepartmentDeviceTree({ tenant: this.$store.getters.tenant }).then(this.onData)
     }
   }
 }