<!--
 * @Title: 
 * @Description: 
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
    <div>
        <el-row>
            <el-col :span="24">
                <basic-container>
                    <avue-form :option="formOption" v-model="dataForm" @submit="submit" />
                </basic-container>
            </el-col>
        </el-row>
    </div>
</template>
<script>
import { add } from "@/api/baseinfo/serviceperson.js";
export default {
    data() {
        return {
            form: {},
            query: {},
            loading: true,
            dataForm: {
                name: '',
                deptId: '',
                account: '',
                realName: '',
                phone: '',
                roleId: 0,
            },
            formOption: {
                labelWidth: 150,
                submitBtn: true,
                emptyBtn: true,
                column: [
                    {
                        label: "机构名称",
                        prop: "name",
                        span: 24,
                        disabled: true,
                    },
                    {
                        label: '用户角色类别',
                        prop: 'roleId',
                        type: 'radio',
                        props: {
                            label: 'name',
                            value: 'code'
                        },
                        span: 24,
                        dicData: [{
                            name: '旗县管理员',
                            code: '1'
                        }, {
                            name: '企业管理员',
                            code: '2'
                        }],
                        rules: [
                            {
                                required: true,
                                message: "请选择用户角色类别",
                                trigger: "click",
                            },
                        ],

                    },
                    {
                        label: "登录帐号",
                        prop: "account",
                        span: 24,
                        tip: "密码默认为帐号+@8282",
                        tipPlacement: 'right-end',
                        rules: [
                            {
                                required: true,
                                message: "请录入登录帐号",
                                trigger: "click",
                            },
                        ],
                    },
                    {
                        label: "用户名称",
                        prop: "realName",
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: "请录入用户名称",
                                trigger: "click",
                            },
                        ],
                    },
                    {
                        label: "联系电话",
                        prop: "phone",
                        span: 24,
                    },
                ]
            }
        };
    },

    props: {
        visible: {
            type: [Boolean],
            default: false,
        },
        orgId: {
            type: [String],
            required: true
        },
        orgName: {
            type: [String],
            required: true
        },
    },
    name: 'addOrgAdminView',
    created() {
        this.init();
    },
    methods: {
        init() {
            this.dataForm['name'] = this.orgName;
            this.dataForm['deptId'] = this.orgId;
        },
        submit(from, done) {
            console.log(JSON.stringify(from));
            add(from).then(() => {
                this.$message({
                    type: "success",
                    message: "提交成功!"
                });

                this.$emit("update:visible", false);
                this.$emit("fevent");
                done();
            }, error => {
                console.log(error);
                done();
            });
        },
    },
};
</script>
<style lang="scss" scoped></style>
