<template>
  <el-dialog class="contact-dialog"
             title="添加联系小计" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">

    <div class="input">
      <el-form :label-width="'100px'">
        <el-form-item label="联系内容:">
          <el-select v-model="contactOpt" placeholder="联系内容" @change="dateChange">
            <el-option v-for="item in contactOpts" :key="item.value" :label="item.name"
                       :value="item.value"></el-option>
          </el-select>
          <el-input style="padding-top: 10px" type="textarea" row="3" v-model="operateDesc"></el-input>
        </el-form-item>
      </el-form>
    </div>

    <div slot="footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button @click="reset">重 置</el-button>
      <el-button type="primary" @click="submitClick">保 存</el-button>
    </div>
  </el-dialog>
</template>

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


  export default {
    name: 'ContactDialog',
    props: {
      dialogVisible: {
        type: Boolean
      },
      loanNo: {
        type: String,
      },
      type: {
        tpye: String,
        required: true,
      },
      clientNo: {
        type: String,
      }
    },
    data() {
      return {
        contact: {},
        operateDesc: '',
        visible: this.$props.dialogVisible,
        contactOpt: '',
        contactOpts: [
          {value: '电话关机', name: '电话关机'},
          {value: '设置成暂时无法接通', name: '设置成暂时无法接通'},
          {value: '接通不需要', name: '接通不需要'},
          {value: '额度低', name: '额度低'},
          {value: '期限短', name: '期限短'},
          {value: '利率高', name: '利率高'},
          {value: '暂时不需要后期跟进', name: '暂时不需要后期跟进'},
          {value: '已加微信', name: '已加微信'},
        ]
      }
    },
    methods: {
      submitClick() {

        var url = ''
        if (this.type == 'Sale') {
          url = '/clientContact/addBySale'
        } else if (this.type == 'Collect') {
          url = '/clientContact/addByCollect'
        } else if (this.type == 'Check') {
          url = '/clientContact/addByCheck'
        }
        this.$$post(url, {clientNo: this.clientNo, loanNo: this.loanNo, operateDesc: this.operateDesc}).then(res => {
          if (res.data.code < 1) {
            this.$message.error(res.data.msg);
            return
          }
          this.$message({message: '操作成功', type: 'success'});
          this.handleClose();
        })

      },
      dateChange() {

        this.operateDesc = this.operateDesc + this.contactOpt + ";"

      },
      reset(){
        this.contactOpt =''
        this.operateDesc =''
      },
      /** 关闭处理 */
      handleClose() {
        this.visible = false;
        setTimeout(() => {
          this.$emit('update:dialogVisible', false)
        }, 100);
        // window.location.reload();
      }
    }
  }
</script>
<style lang="stylus" rel="stylesheet/stylus">

  .client-contact-dialog {
    .input {
      width 60%
      margin auto
    }
  }

</style>
