<template>
  <div class="app-container">
    <div v-loading.fullscreen.lock="loadingFull" />
    <el-form ref="form" label-width="120px" :model="form" :rules="formRules">
      <el-form-item label="代理手机号:" prop="mobile">
        <el-input v-model="form.mobile" type="text" placeholder="代理手机号" style="width: 700px" />
      </el-form-item>
      <el-form-item label="邀请代理id:">
        <el-input v-model="form.ids" type="textarea" :autosize="{ minRows: 4, maxRows: 99}" placeholder="例: [1111,2222,3333,4444,5555]" style="width: 700px" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="toRecoveryUser">恢复</el-button>
        <el-button type="primary" @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import * as apis from '@/api/developer/recovery'
export default {
  data() {
    return {
      loadingFull: false,
      form: {
        mobile: '',
        ids: ''
      },
      formRules: {
        mobile: [
          { required: true, message: '请输入代理手机号', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    resetForm() {
      this.form = {
        mobile: '',
        ids: ''
      }
      this.$refs.form.resetFields()
    },
    toRecoveryUser() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.loadingFull = true
          apis.userRecovery(this.form).then(res => {
            this.loadingFull = false
            if (res.code === 200) {
              this.$message.success('数据恢复成功')
              this.resetForm()
            } else {
              this.$message.error(res.message || '数据恢复失败')
            }
          }).catch(() => {
            this.loadingFull = false
            this.$message.error('数据恢复失败')
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>

</style>
