<template>
  <el-dialog title="批量设置用户租户" :visible.sync="visible" top="4%">
    <el-form>
      <el-form-item label="选择租户">
<!--        <ec-user-modal v-model="superior" placeholder="请选择直接上级，单选" />-->
        <ec-tenant
            v-model="tenantId"
            clearable
            filterable
            placeholder="请选择租户，单选"
            size="large"
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button v-loading="saveLoading" type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { saveUserTenant } from 'ecip-web/api/vue/user/sysrUserApi'

export default {
  name: 'UserTenant',
  data() {
    return {
      visible: false,
      saveLoading: false,
      userIds: [],
      tenantId: ''
    }
  },
  methods: {
    init(userIds) {
      this.visible = true
      this.userIds = userIds
      this.tenantId = null
      this.saveLoading = false
    },
    async save() {
      console.log('save tenant  ' + this.tenantId + ' ' + this.userIds)
      this.saveLoading = true
      await saveUserTenant(this.tenantId, this.userIds)
      this.saveLoading = false
      this.$notify.success('批量设置用户租户成功!')
      this.visible = false
    }
  }
}
</script>

<style scoped>

</style>
