Ver Fonte

fix: device editing

Casper Dai há 3 anos atrás
pai
commit
1570efe80f

+ 3 - 1
src/store/modules/user.js

@@ -115,9 +115,11 @@ const actions = {
           const { data } = await getTenantsByQuery({ pageSize: 1, pageNum: 1 }, false)
           if (data.length) {
             commit('SET_TENANT', data[0])
+          } else {
+            commit('SET_TENANT', { path: '', label: '请选择租户' })
           }
         } catch (e) {
-          commit('SET_TENANT', { path: '', label: '-' })
+          commit('SET_TENANT', { path: '', label: '请选择租户' })
           console.log(e)
         }
       } else if (tenant?.length) {

+ 1 - 1
src/views/device/index.vue

@@ -52,7 +52,7 @@ export default {
         condition: { name: '' },
         list: getDevices,
         transform: this.transform,
-        transformData: this.transformTableData,
+        transformData: __SUB_DEVICE__ && this.transformTableData,
         filters: [
           { key: 'name', type: 'search', placeholder: '设备名称' }
         ],

+ 1 - 1
src/views/platform/tenant/device/components/Device.vue

@@ -119,7 +119,7 @@ export default {
         condition: { productId: void 0, name: '' },
         list: this.getDevicesByAdmin,
         transform: this.transform,
-        transformData: this.transformTableData,
+        transformData: __SUB_DEVICE__ && this.transformTableData,
         buttons: [
           { type: 'add', on: this.onAddDevice }
         ],

+ 1 - 1
src/views/realm/ai/ai-audit/index.vue

@@ -43,7 +43,7 @@ export default {
           ] }
         ],
         cols: [
-          { label: '审核类型', render: this.transformAuditType },
+          { label: '审核类型', render: this.transformAuditType, width: 100, align: 'center' },
           { prop: 'effectiveDate', label: '生效日期' },
           { prop: 'expiryDate', label: '结束日期' },
           { prop: 'initialAmount', label: '总次数' },

+ 6 - 4
src/views/realm/device/index.vue

@@ -82,7 +82,7 @@ export default {
         condition: { name: '' },
         list: getDevices,
         transform: this.transform,
-        transformData: this.transformTableData,
+        transformData: __SUB_DEVICE__ && this.transformTableData,
         filters: [
           { key: 'name', type: 'search', placeholder: '设备名称' }
         ],
@@ -204,7 +204,9 @@ export default {
         }
       })
     },
-    onEditDevice ({ id, name, longitude, latitude, address }) {
+    onEditDevice (device) {
+      const { id, name, longitude, latitude, address } = device
+      this.$device = device
       this.info = { id, name, longitude, latitude, address }
       this.$refs.editDialog.show()
     },
@@ -237,13 +239,13 @@ export default {
         })
         return
       }
-      if (Object.keys(this.info).every(key => this.info[key] === this.device[key])) {
+      if (Object.keys(this.info).every(key => this.info[key] === this.$device[key])) {
         done()
         return
       }
       updateDevice(this.info).then(() => {
         done()
-        Object.assign(this.device, this.info)
+        Object.assign(this.$device, this.info)
       })
     },
     onSettingDevice ({ id }) {

+ 3 - 2
src/views/screen/material/tag/index.vue

@@ -93,11 +93,12 @@ export default {
         })
         return
       }
+      tag.name = newVal
       updateAssetSubTag({
         id: tag.id,
         name: newVal
-      }).then(() => {
-        tag.name = newVal
+      }).catch(() => {
+        tag.name = oldVal
       })
     },
     onDel (tag) {