<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="number" v-model="form.number" placeholder="请输入工号"/>
                            <Field label="职务" prop="userpost" v-model="form.userpost" placeholder="请输入职务"/>
                            <Field label="职称" prop="posttitle" v-model="form.posttitle" placeholder="请输入职称"/>
                            <Field label="政治面貌 " prop="politicalstatus" v-model="form.politicalstatus" type="select" :enumData="dict.politicalstatus" placeholder="请选择政治面貌 "/>
                            <Field label="党员 " prop="dangyuan" v-model="form.dangyuan" type="select" :enumData="dict.dangyuan" placeholder="请选择党员 "/>
                            <Field label="电话" prop="phone" v-model="form.phone" placeholder="请输入电话"/>
                            <Field label="手机" prop="mobile" v-model="form.mobile" placeholder="请输入手机"/>
                            <Field label="星级" prop="starlevel" v-model="form.starlevel" type="select" :enumData="dict.starlevel" placeholder="请选择星级"/>
                            <Field label="个人简介" prop="summary" v-model="form.summary" type="textarea" placeholder="请输入个人简介"/>
                            <Field label="照片"><imageUpload v-model="form.photoPath" prePath="/file/preview"/></Field>
                            <Field label="岗位职责" prop="duty" v-model="form.duty" type="textarea" placeholder="请输入岗位职责"/>
                            <Field label="服务承诺" prop="promise" v-model="form.promise" type="textarea" placeholder="请输入服务承诺"/>
                            <Field label="办理事项" prop="business" v-model="form.business" type="textarea" placeholder="请输入办理事项"/>
                            <Field label="是否在线" prop="online" v-model="form.online" type="select" :enumData="dict.online" 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";
    import ImageUpload from '@/components/ImageUpload';
    export default {
        mixins: [form],
        components: {
            dialogShow ,
            ImageUpload,
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "工作人员",
                // 是否显示弹出层
                open: false,
                toString:[
                    "politicalstatus",
                    "dangyuan",
                    "starlevel",
                    "online",
                ],
                // 表单校验
                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 = {
                    systemUserId : null,
                    deptId : null,
                    deptName : null,
                    windowId : null,
                    windowName : null,
                    siteId : null,
                    siteName : null,
                    name : null,
                    number : null,
                    userpost : null,
                    posttitle : null,
                    politicalstatus : 0,
                    dangyuan : 0,
                    phone : null,
                    mobile : null,
                    starlevel : null,
                    summary : null,
                    photoPath : null,
                    duty : null,
                    promise : null,
                    business : null,
                    online : 1,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
