<template>
  <div class="app-container">
    <div class="form">
      <h2>反馈处理</h2>
      <el-form ref="formRef" label-width="100px" :rules="formRules" :model="formData">
        <el-form-item label="机构名称：">
          {{ feedbackData.clubName }}
        </el-form-item>
        <el-form-item label="手机号：">{{ feedbackData.mobile }}</el-form-item>
        <el-form-item label="反馈内容：">
          <div style="overflow-wrap:anywhere;text-align:justify">{{ feedbackData.content }}</div>
        </el-form-item>
        <el-form-item label="处理状态：">
          <span v-if="feedbackData.handleStatus===0" class="status danger">未处理</span>
          <span v-if="feedbackData.handleStatus===1" class="status success">已处理</span>
        </el-form-item>
        <el-form-item label="处理结果：" prop="handleResult">
          <el-input v-model="formData.handleResult" type="textarea" placeholder="请添加处理结果" />
        </el-form-item>
        <el-form-item>
          <el-button type="info" @click="$_back">返回</el-button>
          <el-button type="primary" @click="submit">提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { getFeedbackDetail, handleFeedback } from '@/api/auth'
export default {
  data() {
    return {
      feedbackId: '',
      formData: {
        handleResult: ''
      },
      formRules: {
        handleResult: { required: true, message: '处理结果不能为空', tigger: 'blur' }
      },
      feedbackData: {}
    }
  },
  created() {
    this.feedbackId = this.$route.query.feedbackId
    this.getDetail()
  },
  methods: {
    // 提交处理信息
    submit() {
      this.$refs.formRef.validate(valid => {
        if (!valid) return
        handleFeedback({ feedbackId: this.feedbackId, handleResult: this.formData.handleResult })
          .then(res => {
            if (res.code !== 0) return
            this.$message({
              message: res.data,
              duration: 500,
              type: 'success'
            })
            this.$store.dispatch('tagsView/delView', this.$route)
            this.$router.back()
          })
      })
    },
    // 获取反馈信息
    getDetail() {
      getFeedbackDetail({ feedbackId: this.feedbackId }).then(res => {
        console.log(res)
        this.feedbackData = res.data
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.form{
  width: 800px;
  margin: 30px auto;
  .el-button{
    width: 120px;
  }
  h2{
    text-align: center;
    margin-bottom: 45px;
    color: #444;
  }
}
</style>
