<template>
  <div class="app-container">
    <div class="head">
      编辑设备
      <el-button type="primary" size="mini" style="margin-left: 20px;" @click="back">返回</el-button>
    </div>
    <edit-device :obj="obj" style="margin-left: 40px;" @finish="back" @back="back" />
  </div>
</template>

<script>
import EditDevice from './components/edit'

export default {
  components: { EditDevice },
  data() {
    return {
      obj: null
    }
  },
  mounted() {
    this.initData()
  },
  methods: {
    back() {
      this.$router.go(-1)
    },
    initData() {
      if (this.$route.query && this.$route.query.obj) {
        try {
          this.obj = JSON.parse(decodeURIComponent(this.$route.query.obj))
          delete this.obj.tenantMachineAppId
          delete this.obj.tenantName
          delete this.obj.tenantServiceAddress
          delete this.obj.tenantServiceAppId
          delete this.obj.groupId
          delete this.obj.sceneName
        } catch (e) {
          this.obj = null
        }
      }
    }
  }
}
</script>

<style scoped>
.head {
  margin-left: 16px;
  font-weight: 600;
  font-size: 18px;
  color: #333333;
}
</style>
