<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="tid" v-model="form.tid" placeholder="请输入从政务系统来的部门id"/>
                            <Field label="从政务系统来的部门name" prop="tname" v-model="form.tname" placeholder="请输入从政务系统来的部门name"/>
                            <Field label="部门名称" prop="name" v-model="form.name" placeholder="请输入部门名称"/>
                            <Field label="从政务系统来的别名" prop="simpleName" v-model="form.simpleName" placeholder="请输入从政务系统来的别名"/>
                            <Field label="部门简称" prop="deptAbb" v-model="form.deptAbb" placeholder="请输入部门简称"/>
                            <Field label="部门电话" prop="deptTelphone" v-model="form.deptTelphone" placeholder="请输入部门电话"/>
                            <Field label="部门编号" prop="deptNumber" v-model="form.deptNumber" placeholder="请输入部门编号"/>
                            <Field label="填单机展示 " prop="isAutotable" v-model="form.isAutotable" type="select" :enumData="dict.isAutotable" placeholder="请选择填单机展示 "/>
                            <Field label="预约展示 " prop="isOrder" v-model="form.isOrder" type="select" :enumData="dict.isOrder" placeholder="请选择预约展示 "/>
                            <Field label="背靠背展示 " prop="isBkb" v-model="form.isBkb" type="select" :enumData="dict.isBkb" placeholder="请选择背靠背展示 "/>
                            <Field label="办事指南展示 " prop="isWorkGuide" v-model="form.isWorkGuide" type="select" :enumData="dict.isWorkGuide" placeholder="请选择办事指南展示 "/>
                            <Field label="是否使用 " prop="usValid" v-model="form.usValid" type="select" :enumData="dict.usValid" placeholder="请选择是否使用 "/>
                            <Field label="部门电话是否展示 " prop="isSecphone" v-model="form.isSecphone" type="select" :enumData="dict.isSecphone" placeholder="请选择部门电话是否展示 "/>
                            <Field label="是否展示英文 " prop="isEnglish" v-model="form.isEnglish" type="select" :enumData="dict.isEnglish" 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:[
                    "isAutotable",
                    "isOrder",
                    "isBkb",
                    "isWorkGuide",
                    "usValid",
                    "isSecphone",
                    "isEnglish",
                ],
                // 表单校验
                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 = {
                    tid : null,
                    tname : null,
                    name : null,
                    simpleName : null,
                    siteId : null,
                    deptAbb : null,
                    deptTelphone : null,
                    deptNumber : null,
                    isAutotable : 1,
                    isOrder : 1,
                    isBkb : 1,
                    isWorkGuide : 1,
                    usValid : 1,
                    isSecphone : 1,
                    isEnglish : 1,
                    sort : 0,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
