<template>
  <el-dialog title="批量重置密码" :visible.sync="visible" top="4%">
    <el-alert :title="title" :closable="false" type="error" />
    <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 { batchResetPassword } from 'ecip-web/api/vue/user/sysrUserApi'

export default {
  name: 'UserResetPassword',
  data() {
    return {
      visible: false,
      saveLoading: false,
      userIds: [],
      superior: '',
      title: window._CONFIG['resetPwdMsg'] || '重置后用户第一次登录成功后需要修改密码'
    }
  },
  methods: {
    init(userIds) {
      this.visible = true
      this.userIds = userIds
      this.superior = null
      this.saveLoading = false
    },
    async save() {
      this.saveLoading = true
      await batchResetPassword(this.userIds)
      this.saveLoading = false
      this.$notify.success('批量重置用户密码成功!')
      this.visible = false
    }
  }
}
</script>

<style scoped>

</style>
