<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="isBusiness" v-model="form.isBusiness" disabled  type="radio" :enumData="dict.isBusiness" placeholder="请选择业务类型"/>
                    <Field label="业务名称" prop="name" v-model="form.name" placeholder="请输入业务名称"/>
                  
                    <Field label="是否允许预约" prop="canorder" v-model="form.canorder" type="radio" :enumData="dict.canorder" placeholder="请选择是否允许预约"/>
                    <Field label="是否允许取号" prop="cantake" v-model="form.cantake" type="radio" :enumData="dict.cantake" placeholder="请选择是否允许取号"/>
                    <Field label="大厅情况展示 " prop="datashow" v-model="form.datashow" type="radio" :enumData="dict.datashow" placeholder="请选择大厅情况展示 "/>
                    <Field label="类型 " prop="businessType" v-model="form.businessType" type="radio" :enumData="dict.businessType" placeholder="请选择业务类型 "/>
                    <Field label="英语业务名" prop="englishname" v-model="form.englishname" placeholder="请输入英语业务名"/>
                    <Field label="流水编号" prop="flownum" v-model="form.flownum" placeholder="请输入流水编号如A、B"/>
                   <Field :span="24" label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    export default {
        mixins: [form],
        components: {
        },
        data() {
            return {
                businessOptions: [],
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "站点业务",
                // 是否显示弹出层
                open: false,
                toString:[
                    "isBusiness",
                    "canorder",
                    "cantake",
                    "datashow",
                    "status",
                    "businessType",
                ],
                // 表单校验
                rules: {
                }
            };
        },

        methods: {
            beforeRender(data) {
                if(!data.entity.id){
                data.entity.isBusiness=this.form.isBusiness
                }

            return data
            },
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl =this.pageInfo.editUrl;;
                this.getData();
                this.title = "修改站点业务";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = this.pageInfo.addUrl;
                this.getData();
                if(row.id){
                    console.log(1111)
                    this.form.parentId=row.id
                    this.form.isBusiness=1
                }
                console.log("form",this.form)
                this.title = "新增站点业务";
            },
            /** 查看*/
            view(row) {
                this.query = { id: row.id };
                this.urls.currUrl =this.pageInfo.viewUrl;;
                this.getData();
                this.title = "站点业务详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                if(Object.keys(data.entity).length>0){
                    console.log(data.entity)
                    this.open = true;
                }
            },
            afterSubmit(data) {
                this.open = false;
                this.$emit("ok");
            },

            // 表单重置
            reset() {
                this.form = {
                    parentId : 0,

                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
