<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="siteId" v-model="form.siteId" placeholder="请输入站点Id，来源基础服务平台"/>
                            <Field label="题目总数" prop="projectTotalCount" v-model="form.projectTotalCount" placeholder="请输入题目总数"/>
                            <Field label="昨日新增项目数量" prop="projectAddCount" v-model="form.projectAddCount" placeholder="请输入昨日新增项目数量"/>
                            <Field label="学习人数数量" prop="studyPersonCount" v-model="form.studyPersonCount" placeholder="请输入学习人数数量"/>
                            <Field label="学习率" prop="studyPersonRatio" v-model="form.studyPersonRatio" placeholder="请输入学习率"/>
                            <Field label="未学习人数数量" prop="unStudyPersonCount" v-model="form.unStudyPersonCount" placeholder="请输入未学习人数数量"/>
                            <Field label="未学习率" prop="unStudyPersonRatio" v-model="form.unStudyPersonRatio" placeholder="请输入未学习率"/>
                            <Field label="今日消息推送数量" prop="pushTotalCount" v-model="form.pushTotalCount" placeholder="请输入今日消息推送数量"/>
                            <Field label="昨日新增减少数量" prop="pushAddCount" v-model="form.pushAddCount" placeholder="请输入昨日新增减少数量"/>
                            <Field label="年" prop="year" v-model="form.year" placeholder="请输入年"/>
                            <Field label="月" prop="month" v-model="form.month" placeholder="请输入月"/>
                            <Field label="日" prop="day" v-model="form.day" 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: {
                    unStudyPersonCount: [
                        {required: true,message: "请输入未学习人数数量", trigger: "blur" },
                    ],
                    unStudyPersonRatio: [
                        {required: true,message: "请输入未学习率",trigger: "blur" },
                    ],
                    pushTotalCount: [
                        {required: true,message: "请输入今日消息推送数量", trigger: "blur" },
                    ],
                    pushAddCount: [
                        {required: true,message: "请输入昨日新增减少数量", trigger: "blur" },
                    ],
                    year: [
                        {required: true,message: "请输入年", trigger: "blur" },
                    ],
                    month: [
                        {required: true,message: "请输入月", trigger: "blur" },
                    ],
                    day: [
                        {required: true,message: "请输入日", trigger: "blur" },
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="study/stat/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改学习统计";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "study/stat/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增学习统计";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="study/stat/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 = {
                    siteId : null,
                    projectTotalCount : 0,
                    projectAddCount : 0,
                    studyPersonCount : 0,
                    studyPersonRatio : BigDecimal.valueOf(0.00),
                    unStudyPersonCount : 0,
                    unStudyPersonRatio : BigDecimal.valueOf(0.00),
                    pushTotalCount : 0,
                    pushAddCount : 0,
                    year : null,
                    month : null,
                    day : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
