瀏覽代碼

fix: device management

Casper Dai 3 年之前
父節點
當前提交
af2f681998

+ 3 - 3
src/views/realm/device/Group.vue

@@ -16,7 +16,7 @@
 
 <script>
 import {
-  getDevicesByAdmin,
+  getDevices,
   getSubDevices,
   activateDevice,
   deactivateDevice
@@ -28,8 +28,8 @@ export default {
     return {
       schema: {
         keepalive: true,
-        condition: { name: '', tenant: this.$store.getters.tenant },
-        list: getDevicesByAdmin,
+        condition: { name: '' },
+        list: getDevices,
         transform: this.transform,
         transformData: this.transformTableData,
         filters: [

+ 2 - 2
src/views/realm/device/Tenant.vue

@@ -21,8 +21,8 @@
         </el-tabs>
         <component
           :is="active"
-          v-if="group"
-          :group="group"
+          :key="active"
+          :tenant="group.path"
         />
       </div>
     </template>

+ 23 - 7
src/views/realm/device/components/Device.vue

@@ -96,15 +96,14 @@ import {
 export default {
   name: 'Device',
   props: {
-    group: {
-      type: Object,
+    tenant: {
+      type: String,
       required: true
     }
   },
   data () {
     const productSelectSchema = {
-      remote: getProducts,
-      condition: { tenant: this.group.path },
+      remote: this.getProducts,
       pagination: true,
       value: 'id',
       label: 'name'
@@ -117,8 +116,8 @@ export default {
       productSelectSchema,
       schema: {
         keepalive: true,
-        condition: { productId: void 0, name: '', tenant: this.group.path },
-        list: getDevicesByAdmin,
+        condition: { productId: void 0, name: '' },
+        list: this.getDevicesByAdmin,
         transform: this.transform,
         transformData: this.transformTableData,
         buttons: [
@@ -168,7 +167,24 @@ export default {
       return this.isSub ? '新增备份设备' : '新增设备'
     }
   },
+  watch: {
+    group () {
+      this.$refs.table.pageTo(1)
+    }
+  },
   methods: {
+    getProducts (params) {
+      return getProducts({
+        tenant: this.tenant,
+        ...params
+      })
+    },
+    getDevicesByAdmin (params) {
+      return getDevicesByAdmin({
+        tenant: this.tenant,
+        ...params
+      })
+    },
     transform (data) {
       return {
         ...data,
@@ -210,7 +226,7 @@ export default {
         longitude: '',
         latitude: '',
         address: '',
-        tenant: this.group.path
+        tenant: this.tenant
       }
       this.$refs.editDialog.show()
     },

+ 22 - 9
src/views/realm/device/components/Product.vue

@@ -78,15 +78,14 @@ import {
 export default {
   name: 'Procut',
   props: {
-    group: {
-      type: Object,
+    tenant: {
+      type: String,
       required: true
     }
   },
   data () {
     const productTypeSelectSchema = {
-      condition: { tenant: this.group.path },
-      remote: getProductTypes,
+      remote: this.getProductTypes,
       pagination: true,
       value: 'id',
       label: 'name'
@@ -105,8 +104,8 @@ export default {
       loaded: false,
       productTypeSelectSchema,
       schema: {
-        condition: { productTypeId: void 0, tenant: this.group.path },
-        list: getProducts,
+        condition: { productTypeId: void 0 },
+        list: this.getProducts,
         buttons: [
           { type: 'add', on: this.onAdd }
         ],
@@ -133,9 +132,6 @@ export default {
     }
   },
   computed: {
-    tenant () {
-      return this.group.path
-    },
     dialogTitle () {
       return this.isAdd ? `新增屏幕配置` : `编辑屏幕配置`
     },
@@ -143,7 +139,24 @@ export default {
       return this.isAdd ? this.typeOptions : [{ value: this.currObj.productTypeId, label: this.$currObj.productTypeName }]
     }
   },
+  watch: {
+    group () {
+      this.$refs.table.pageTo(1)
+    }
+  },
   methods: {
+    getProductTypes (params) {
+      return getProductTypes({
+        tenant: this.tenant,
+        ...params
+      })
+    },
+    getProducts (params) {
+      return getProducts({
+        tenant: this.tenant,
+        ...params
+      })
+    },
     onAdd () {
       this.isAdd = true
       this.productTypeSelectSchema.option = null

+ 15 - 7
src/views/realm/device/components/ProductType.vue

@@ -41,8 +41,8 @@ import {
 export default {
   name: 'ProductType',
   props: {
-    group: {
-      type: Object,
+    tenant: {
+      type: String,
       required: true
     }
   },
@@ -51,8 +51,8 @@ export default {
       isAdd: false,
       currObj: {},
       schema: {
-        condition: { name: '', tenant: this.group.path },
-        list: getProductTypes,
+        condition: { name: '' },
+        list: this.getProductTypes,
         buttons: [
           { type: 'add', on: this.onAdd }
         ],
@@ -68,14 +68,22 @@ export default {
     }
   },
   computed: {
-    tenant () {
-      return this.group.path
-    },
     dialogTitle () {
       return this.isAdd ? `新增屏幕类型` : `编辑屏幕类型`
     }
   },
+  watch: {
+    tenant () {
+      this.$refs.table.pageTo(1)
+    }
+  },
   methods: {
+    getProductTypes (params) {
+      return getProductTypes({
+        tenant: this.tenant,
+        ...params
+      })
+    },
     onAdd () {
       this.isAdd = true
       this.currObj = {