<template>
  <el-dialog class="client-data-dialog" title="客服反馈问题修改" :visible.sync="visible" :before-close="handleClose">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm">
      <el-form-item label="反馈类型" prop="feedType">
        <el-select v-model="ruleForm.feedType" label="反馈类型" placeholder="请选择" :disabled="true" style="width:80%">
          <el-option
              v-for="item in optionsFeedType"
              :key="item.value"
              :label="item.label"
              :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>


      <el-form-item label="反馈描述" prop="feedContent">
        <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入反馈内容"
            v-model="ruleForm.feedContent" :disabled="true" style="width:80%">
        </el-input>
      </el-form-item>

      <el-form-item label="处理意见" prop="feedContent">
        <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入处理意见"
            v-model="ruleForm.finishContent" style="width:80%">
        </el-input>
      </el-form-item>


      <el-form-item label="反馈状态" prop="feedStatus">
        <el-select v-model="ruleForm.feedStatus" label="反馈状态" placeholder="请选择">
          <el-option
              v-for="item in optionsStatus"
              :key="item.value"
              :label="item.label"
              :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="创建人" prop="creater">
        <el-col :span="18">
          <el-input v-model="ruleForm.creater" :disabled="true"></el-input>
        </el-col>
      </el-form-item>

    </el-form>
    <div slot="footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="submitClick('ruleForm')" :loading="ui.submitLoading">修改</el-button>
    </div>
  </el-dialog>
</template>

<script type="text/ecmascript-6">

export default {
  name: 'UpdateUserServiceDialog',
  props: {
    dialogVisible: {
      type: Boolean,
      required: true
    },
    feedNo: {
      type: String
    },
    feedType: {
      type: String
    },
    feedStatus: {
      type: String
    },
    feedContent: {
      type: String
    },
    creater: {
      type: String
    },
    finishContent: {
      type: String
    },

  },

  data() {

    return {
      ui: {
        submitLoading: false
      },
      visible: this.$props.dialogVisible,
      optionsStatus: [
        {
          value: 'YES',
          label: '已解决'
        },
        {
          value: 'NO',
          label: '未解决'
        }
      ],
      optionsFeedType: [
        {
          value: '内部投诉',
          label: '内部投诉'
        },
        {
          value: '还款问题',
          label: '还款问题'
        },
        {
          value: '系统问题',
          label: '系统问题'
        },
        {
          value: '借款咨询',
          label: '借款咨询'
        },
        {
          value: '账户问题',
          label: '账户问题'
        },
        {
          value: '银行卡签约问题',
          label: '银行卡签约问题'
        },
        {
          value: '其它',
          label: '其它'
        }
      ],

      ruleForm: {
        feedNo: '',
        feedType: '',
        feedStatus: '',
        feedContent: '',
        clientNo: '',
        creater: '',
        finishContent: '',
      },
      customerFeedList: [],

      rules: {
        finishContent: [
          {required: true, message: "请输入处理意见", trigger: 'blur'}
        ],
        feedStatus: [
          {required: true, message: '请选择反馈结果', trigger: 'blur'}
        ],
      },

    }
  },
  created() {

    this.ruleForm = {
      feedNo: this.feedNo,
      feedType: this.feedType,
      feedStatus: this.feedStatus,
      feedContent: this.feedContent,
      finishContent: this.finishContent,
      creater: this.creater,
    }
  },
  methods: {


    /** 提交点击 */
    submitClick() {
      this.$$post('/feed/updateFeedStatus', {
        feedNo: this.ruleForm.feedNo,
        dialogVisible: this.ruleForm.dialogVisible,
        feedStatus: this.ruleForm.feedStatus,
        finishContent: this.ruleForm.finishContent,
        creater: this.ruleForm.creater,
      }).then(res => {
        if (res.data.code != 200) {
          this.$message.error(res.data.msg);
          return
        }
        this.handleClose();
        this.$message({message: '成功', type: 'success'});
        window.location.reload();

      }).catch(error => {
        this.$message.error("修改客服反馈信息失败");
      })
    },

    /** 关闭处理 */
    handleClose() {
      this.visible = false;
      setTimeout(() => {
        this.$emit('update:dialogVisible', false)
      }, 300);
    }
  },

}
</script>
