<template>
    <el-dialog class="client-data-dialog" title="添加跟踪信息 " width="30%" :visible.sync="visible" :before-close="handleClose">
        <el-form :model="ruleForm" ref="ruleForm"  label-width="80px" class="demo-ruleForm">
            <el-form-item label="跟踪内容" prop="operaterDesc">
                <el-col :span="20"><el-input v-model="ruleForm.operaterDesc" placeholder="请输入跟踪信息"></el-input></el-col>
            </el-form-item>
        </el-form>
        <div slot="footer">
            <el-button @click="handleClose">取 消</el-button>
            <el-button type="primary" @click="addCollectLog('ruleForm')">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    export default {
        name: "AddCollectLogDialog",
        props: {
            dialogVisible: {
                type: Boolean,
                required: true
            },
            collNo: {
                type: String
            },
        },

        data() {
            return {
                ui: {
                    submitLoading: false
                },
                visible: this.$props.dialogVisible,

                ruleForm: {
                    collNo: '',
                    operateType: '',
                    operaterDesc: '',
                },
            }
        },

        created() {
            this.ruleForm = {
                collNo: this.collNo
            }
        },

        methods: {
            /** 提交点击 */
            addCollectLog() {
                this.$$post(`/collect/createLog`,{collNo: this.ruleForm.collNo, operateType: 'FOLLOW', operaterDesc:this.ruleForm.operaterDesc,
                }).then(res => {
                    if (res.data.code < 1) {
                        this.$message.error(res.data.msg);
                        return
                    }
                    this.$message({message: '操作成功', type: 'success'});
                    this.handleClose();
                    window.location.reload();
                })
            },

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

<style scoped>

</style>