<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            :destroy-on-close="true"
            size="50%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                            <Field :span="20" label="标题" prop="title" v-model="form.title" type="textarea" placeholder="请输入标题"/>
<!--                            <Field :span="20" label="公告内容"><editor v-model="form.noticeContent" :min-height="256"/></Field>
                           --> <Field label="公告文件"><fileUpload v-model="form.filePath" :fileType="fileType"  :fileName="form.fileName" @getFileName="getFileName"  prePath="/file/fileupload"/></Field>
                            <Field :span="20" label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>

            </el-row>

            <form-buttons @submit='submitForm' v-if="pageInfo.type!='view'" noCancelBtn />
        </el-form>

    </el-drawer>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    export default {
        name: "NoticeDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("notice")
        },
        data() {
            return {
              fileType:['png', 'jpg', 'jpeg', 'mp4', 'avi'],
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "通知公告",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                ],
                toDate:[
                ],
                // 表单校验
                rules: {
                    title: [
                        {required: true,message: "请输入标题", trigger: "blur" },
                        {max: 256,message: "最多只能录入256个字符",trigger: "blur",},
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
          getFileName(fileName) {
            this.form.fileName = fileName;
          },
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="notice/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改通知公告";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "notice/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增通知公告";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="notice/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 = {
                    title : "",
                    noticeContent : "",
                    filePath : "",
                    fileName : "",
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
