<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="功能点">
        <el-select v-model="ruleForm.pointName" label="功能点" placeholder="请选择">
            <el-option
            v-for="item in optionsCustomer"
            :key="item.code"
            :label="item.label"
            :value="item.value" >
            </el-option>
        </el-select>
      </el-form-item>

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

      <el-form-item label="问题标题" prop="pointTitle">
        <el-col :span="18">
          <el-input v-model="ruleForm.pointTitle" :disabled="true"></el-input>
        </el-col>
      </el-form-item>

       <el-form-item label="问题描述" prop="problemDescription">

        <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
        v-model="ruleForm.problemDescription" style="width:60%">
        </el-input>
      </el-form-item>

      <el-form-item label="状态">
        <el-select v-model="ruleForm.pointStatus" label="状态" placeholder="请选择">
            <el-option
            v-for="item in operatStatus"
            :key="item.value"
            :label="item.label"
            :value="item.value">
            </el-option>
        </el-select>
      </el-form-item>
     
      <el-form-item label="解决方式" prop="pointSolve">
         <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
        v-model="ruleForm.pointSolve" style="width:60%">
        </el-input>
      </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
      },
      pointName: {
        type: String
      },
      pointTitle: {
        type: String
      },
      problemDescription: {
        type: String
      },
      pointSolve: {
        type: String
      },
      id: {
        type: Number
      },
      creator: {
        type: String
      },
      pointStatus: {
        type: String
      },
     
    },

    data() {
      /*请选择功能点*/
      var validatepointFeatures = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请选择功能点'));
        }
      };
      /*请输入问题标题*/
      var validateqtitle = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入问题标题'));
        }
      };
      /*请输入问题描述*/
      var validateqdescription = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入问题描述'));
        }
      };
     
      var validatesolve = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入解决方式'));
        }
      };
      var validatenumber = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('id不能为空'));
        }
      };
      var validatestatus = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('状态值有问题'));
        }
      };
      var validatecode = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('状态值有问题'));
        }
      };
      return {
        ui: {
          submitLoading: false
        },
        visible: this.$props.dialogVisible,
        operat: [],
        operatStatus: [{
            value: 'FOLLOWEDUP',
            label: '待跟进'
            },  {
            value: 'FOLLOWEDING',
            label: '跟进中'
          }, {
            value: 'FINISHED',
            label: '已解决'
          }],
        ruleForm: {
          pointTitle: '',
          problemDescription:'',
          pointStatus:'FOLLOWEDUP',          
          pointSolve:'',
          id:'',
        },
        rules: {
          pointName: [
            { validator: validatepointFeatures, trigger: 'blur' }
          ],
          pointTitle: [
            { validator: validateqtitle, trigger: 'blur' }
          ],
          problemDescription: [
            { validator: validateqdescription, trigger: 'blur' }
          ],
          pointSolve: [
            { validator: validatesolve, trigger: 'blur' }
          ],
          pointStatus: [
            { validator: validatestatus, trigger: 'blur' }
          ],
        },
          optionsCustomer: [{
            value: '内部投诉',
            label: '内部投诉'
            },  {
            value: '还款问题',
            label: '还款问题'
          }, {
            value: '系统问题',
            label: '系统问题'
          }, {
            value: '借款咨询',
            label: '借款咨询'
          }, {
            value: '账户问题',
            label: '账户问题'
          }, {
            value: '其它',
            label: '其它'
          }],
      }
    },
    created() {
      console.log(this)
      console.log(3454545)
      this.ruleForm = {
        dialogVisible: this.dialogVisible,
        id: this.id,
        creator: this.creator,
        pointName: this.pointName,
        pointTitle: this.pointTitle,
        problemDescription: this.problemDescription,
        pointSolve: this.pointSolve,
        pointStatus: this.pointStatus,
      }
    },
    methods: {
      /** 提交点击 */
      async submitClick(formName) {
            this.$$post('/customer/editQuestion', {
              id: this.ruleForm.id,
              dialogVisible: this.ruleForm.dialogVisible,
              pointStatus: this.ruleForm.pointStatus,
              pointName: this.ruleForm.pointName,
              creator: this.ruleForm.creator,
              pointTitle: this.ruleForm.pointTitle,
              pointSolve: this.ruleForm.pointSolve,
              problemDescription: this.ruleForm.problemDescription,
              clientNo: localStorage.getItem("clientNo")
            })
              .then(res => {
                if (res.data.code != 200) {
                  this.$message.error(res.data.msg);
                  return
                }
                this.$message({message: '修改成功', type: 'success'});
                this.handleClose();
                setTimeout(function () {
                  this.visible = false;
                }, 500)

              })
              .catch(err => {
                alert("error!")
              })
      },

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