<template>
  <el-dialog title="分发" :close-on-click-modal="false" append-to-body :visible.sync="visible" width="600px" @close="closeDialog">
    <el-form ref="dialogForm" :model="dialogForm" :rules="rules" label-width="110px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="clueMemo">
            <el-input v-model="dialogForm.clueMemo" type="textarea" :rows="20" maxlength="50000" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button plain @click="(visible = false)">取消</el-button>
      <el-button v-jclick type="primary" :disabled="!canSubmit" @click="dialogFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
  <script>
import { updateClue } from '@/api/zs/clue';

export default {
  name: 'MemoFormDialog',

  data() {
    return {
      visible: false,
      canSubmit: true,
      dialogForm: {},
      rules: {
        clueMemo: {
          required: true,
          message: '备注不能为空',
          trigger: 'blur'
        }
      },
    };
  },
  methods: {
    init(info = undefined) {
      this.visible = true;
      this.$nextTick(() => {
        this.resetDialogForm();
        this.$refs['dialogForm'].resetFields();
        if (info) {

          this.dialogForm = { ...info };
        }
      });
    },
    resetDialogForm() {
      this.dialogForm = {};
    },
    closeDialog() {
      this.$emit('update:dialog.batchUpdateVisible', false);
    },

    // 表单提交
    dialogFormSubmit() {
      this.$refs.dialogForm.validate((valid) => {
        if (valid) {
          this.canSubmit = false;
          // 校验完成，调接口
          updateClue(this.dialogForm)
            .then((resp) => {
              this.canSubmit = true;
              if (resp.code == 200) {
                this.$message.success('跟进成功');
                this.$emit('refreshDataList');
                this.visible = false;
              }
            })
            .catch(() => {
              this.canSubmit = true;
            });
        }
      });
    },

  }
};
  </script>
  
  