<template>
  <div>
    <el-dialog
      v-loading="loading"
      :show-close="false"
      :close-on-click-modal="false"
      :visible.sync="isShow"
      :title="`审核：${curObj.real_name}--(推荐人${curObj.referrer})`"
      :fullscreen="false"
      width="360px"
      custom-class="xl-dialog"
      center
    >
      <base-form ref="ruleForm" :data="formData" :is-inline="false" label-width="100px">
        <div slot="footer">
          <el-button class="xl-form-btn t2" @click="close">关 闭</el-button>
          <el-button class="xl-form-btn t1" @click="close('confirm')">确定</el-button>
        </div>
      </base-form>
    </el-dialog>
  </div>
</template>
<script>
export default {
  components: {},
  mixins: [...mixins],
  props: {
    isShow: Boolean,
    curObj: Object
  },
  inject: ['parentData'],
  data() {
    return {
      formData: [],
      loading: true,
      cObj: {},
      isShowMap: false
    }
  },
  watch: {
    isShow: function(val) {
      if (val) {
        this.getDef()
      }
    },
  },
  methods: {
    getDef(fieldStr) {
      let params = { ...this.curObj }
      if (fieldStr === 'changeStr') {
        const oldform = this.$refs.ruleForm.baseForm
        params = {...this.curObj, ...oldform}
      } else {
        params.auth_state = '1'
      }
      this.formData = [
        { label: '处理', key: 'auth_state', rules: 1, type: 'select', class: 'c-2', options: [{val: '1', key: '通过'}, {val: '3', key: '拒绝'}] },
      ]
      this.setDefaultValue(params)
    },
    groupTypeChange () {
      this.getDef('changeStr')
    },
    close(str) {
      if (str === 'confirm') {
        this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
          if (valid) {
            const oldform = this.$refs.ruleForm.baseForm
            let newForm = { ...oldform }
            if (this.curObj.id) {
              newForm.id = this.curObj.id
            }
            this.$emit('close', newForm)
          }
        })
      } else {
        this.$emit('close')
        this.setDefaultValue()
      }
    },
  }
}
</script>
<style lang="scss" scoped>
</style>
