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

  

     <el-form-item label="问题标题" prop="pointTitle">
        <el-input v-model="ruleForm.pointTitle" placeholder="请输入内容"></el-input>
     </el-form-item>

      <el-form-item label="问题描述" prop="problemDescription">
        <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
        v-model="ruleForm.problemDescription" style="width:80%">
        </el-input>
      </el-form-item>
     
      <el-form-item label="状态" prop="pointStatus">
          <el-select v-model="ruleForm.pointStatus" label="功能点" placeholder="下拉选择">
            <el-option
            v-for="item in options"
            :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:80%">
        </el-input>
      </el-form-item>
      
      <el-form-item label="创建人" prop="creator">
          <p>{{this.ruleForm.creator}}</p>
      </el-form-item> 
    </el-form>

    <div slot="footer" style="margin-right:30px">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="submitForm('ruleForm')">新 增</el-button>
    </div>
  </el-dialog>
</template>

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


  export default {
    name: 'AddUserServiceDialog',
    props: {
      dialogVisible: {
        type: Boolean,
        required: true,
      },
       clientNo: {
          type: String
      },
    },
    data() {
      /*请选择功能点*/
      var validatepointFeatures = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请选择功能点'));
        }
      };
      /*请输入问题描述*/
      var validateqdescription = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入问题描述'));
        }
      };
      var validatestatus = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入问题描述'));
        }
      };
      var validatesolve = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入问题描述'));
        }
      };
      return {
        ui: {
          submitLoading: false
        },
        visible: this.$props.dialogVisible,
        operat: [],
        restaurants: [],
        loanoptions: [],
        state: '',
        ruleForm: {
          pointName: '',
          pointTitle: '',
          clientNo: '',
          problemDescription:'',
          pointStatus:'FOLLOWEDUP',          
          pointSolve:'',
          creator: ''
        },
        rules: {
          pointName: [
            { validator: validatepointFeatures, trigger: 'blur' }
          ],
          problemDescription: [
            { validator: validateqdescription, trigger: 'blur' }
          ],
          pointStatus: [
            { validator: validatestatus, trigger: 'blur' }
          ],
           pointSolve: [
            { validator: validatesolve, trigger: 'blur' }
          ]
        },
         options: [{
            value: 'FOLLOWEDUP',
            label: '待跟进'
            },  {
            value: 'FOLLOWEDING',
            label: '跟进中'
          }, {
            value: 'FINISHED',
            label: '已解决'
          }],
          optionsCustomer: [{
            value: '内部投诉',
            label: '内部投诉'
            },  {
            value: '还款问题',
            label: '还款问题'
          }, {
            value: '系统问题',
            label: '系统问题'
          }, {
            value: '借款咨询',
            label: '借款咨询'
          }, {
            value: '账户问题',
            label: '账户问题'
          }, {
            value: '其它',
            label: '其它'
          }],
        }
    },
    created() {
        this.ruleForm = {
            clientNo: this.clientNo,
            creator: localStorage.getItem("userName"),
        }
        
    },
    methods: {
      /** 提交点击 */
      submitForm(formName) {
          this.$$post('/customer/addQuestion', {
              creator : localStorage.getItem("userName"),
              pointName: this.ruleForm.pointName,
              problemDescription : this.ruleForm.problemDescription ,
              pointSolve: this.ruleForm.pointSolve,
              pointStatus : this.ruleForm.pointStatus ,
              pointTitle: this.ruleForm.pointTitle,
              clientNo: this.ruleForm.clientNo
          })
            .then(res => {
              if (res.data.code != 200) {
                this.$message.error(res.data.message);
                return
              }
              this.$message({message: '新增成功', type: 'success'});
              this.handleClose();
            })
            .catch(err => {
              alert("error!")
            })
         
      },
      createFilter(queryString) {
        return (restaurant) => {
          return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      },
      handleIconClick(ev) {
        console.log(ev);
      },

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

<style>

</style>
