<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="sign" v-model="form.sign" placeholder="请输入短信签名"/>
                            <Field label="剩余短信条数" prop="lastnum" v-model="form.lastnum" placeholder="请输入剩余短信条数"/>
                            <Field label="用户名" prop="username" v-model="form.username" placeholder="请输入用户名"/>
                            <Field label="短信开关 " prop="messageoff" v-model="form.messageoff" type="select" :enumData="dict.messageoff" placeholder="请选择短信开关 "/>
                            <Field label="短信平台 " prop="smsplatform" v-model="form.smsplatform" type="select" :enumData="dict.smsplatform" 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:[
                    "messageoff",
                    "smsplatform",
                ],
                // 表单校验
                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,
                    sign : null,
                    lastnum : null,
                    username : null,
                    messageoff : 1,
                    smsplatform : 1,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
