<template>
    <!-- 弹出框表单 -->
    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                                            <Field label="主动关怀约束Id" prop="careId" v-model="form.careId" placeholder="请输入主动关怀约束Id"/>
                            <Field label="反馈人ID" prop="feedbackId" v-model="form.feedbackId" placeholder="请输入反馈人ID"/>
                            <Field label="反馈人姓名" prop="feedbackName" v-model="form.feedbackName" placeholder="请输入反馈人姓名"/>
                            <Field label="反馈内容" prop="feedback" v-model="form.feedback" type="textarea" placeholder="请输入反馈内容"/>
                            <Field label="跟踪时间" prop="feedbackTime" v-model="form.feedbackTime" type="date" />
                            <Field label="创建方式" prop="createMethod" v-model="form.createMethod" placeholder="请输入创建方式"/>

            </el-row>

        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" v-if="pageInfo.type !== 'view'" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    import dialogShow from "./dialogshow";
    export default {
        mixins: [form],
        components: {
            dialogShow ,
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "主动关怀服务追踪",
                // 是否显示弹出层
                open: false,
                toString:[
                ],
                // 表单校验
                rules: {
                    feedbackName: [
                        {required: true,message: "请输入反馈人姓名", trigger: "blur" },
                        {max: 50,message: "最多只能录入50个字符",trigger: "blur",},
                    ],
                    feedback: [
                        {required: true,message: "请输入反馈内容", trigger: "blur" },
                        {max: 1024,message: "最多只能录入1024个字符",trigger: "blur",},
                    ],
                    feedbackTime: [
                        {required: true,message: "请选择跟踪时间" },
                    ],
                    createMethod: [
                        {required: true,message: "请输入创建方式", trigger: "blur" },
                        {max: 50,message: "最多只能录入50个字符",trigger: "blur",},
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="care/constraint/track/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改主动关怀服务追踪";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "care/constraint/track/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增主动关怀服务追踪";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="care/constraint/track/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "主动关怀服务追踪详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                this.open = true;
            },

            afterSubmit(data) {
                this.open = false;
                this.$emit("ok");
            },

            // 表单重置
            reset() {
                this.form = {
                    careId : null,
                    feedbackId : null,
                    feedbackName : "",
                    feedback : "",
                    feedbackTime : null,
                    createMethod : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
