<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="窗口名称" prop="name" v-model="form.name" placeholder="请输入窗口名称"/>
                            <Field label="英语窗口名" prop="englishName" v-model="form.englishName" placeholder="请输入英语窗口名"/>
                            <Field label="区域" prop="region" v-model="form.region" placeholder="请输入区域"/>
                            <Field label="英语区域" prop="englishRegion" v-model="form.englishRegion" placeholder="请输入英语区域"/>
                            <Field label="窗口编号" prop="fromnum" v-model="form.fromnum" placeholder="请输入窗口编号"/>
                            <Field label="红旗窗口 " prop="hongqi" v-model="form.hongqi" type="select" :enumData="dict.hongqi" placeholder="请选择红旗窗口 "/>
                            <Field label="备注" prop="summary" v-model="form.summary" type="textarea" placeholder="请输入备注"/>
                            <Field label="楼栋" prop="building" v-model="form.building" type="select" :enumData="dict.building" placeholder="请选择楼栋"/>
                            <Field label="楼层" prop="level" v-model="form.level" type="select" :enumData="dict.level" 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:[
                    "hongqi",
                    "building",
                    "level",
                ],
                // 表单校验
                rules: {
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl =this.pageInfo.editUrl;;
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改站点部门窗口";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl = this.pageInfo.addUrl;
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增站点部门窗口";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl =this.pageInfo.viewUrl;;
                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,
                    siteName : null,
                    deptId : null,
                    deptName : null,
                    name : null,
                    englishName : null,
                    region : null,
                    englishRegion : null,
                    fromnum : null,
                    hongqi : 1,
                    summary : null,
                    building : 1,
                    level : 1,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
