
<template>
  <sm-user-dialog
    :show.sync="dialogShow"
    @select="onSubmit"
    :query="userQuery"
    :multiple="false"
  />
</template>
<script>
import SmUserDialog from '@/components/Business/SmUser/smUserDialog.vue'
import { SmUserType } from '@/utils/constants'
import { bindInvestor } from '@/api/system/device'

export default {
  name: "DeviceBindInvestor",
  components: { SmUserDialog },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    row: {
      type: Object,
      default: () => {
        return {}
      },
    }
  },
  computed: {
    SmUserType() {
      return SmUserType
    },
    dialogShow: {
      get() {
        return this.show;
      },
      set(val) {
        this.$emit('update:show', val);
      }
    },
    userQuery() {
      return {
        type: SmUserType.INVESTOR,
        agentId: this.row.agentId
      }
    }
  },
  data() {
    return {
    }
  },
  methods: {
    onSubmit(user) {
      bindInvestor(this.row.deviceId, user.userId).then(res => {
        if (res.code === 200) {
          this.$message.success("绑定成功");
          this.dialogShow = false;
          this.$emit('success');
        }
      })
    }
  }

}

</script>

<style scoped lang="scss">

</style>
