<template>
    <el-dialog title="用户编辑" :visible.sync="dialogFormVisible"  width="500px">
        <el-form :model="form">
            <el-form-item label="昵称：" :label-width="formLabelWidth">
                <span v-text="username"></span>
            </el-form-item>
            <el-form-item label="姓名：" :label-width="formLabelWidth">
                <el-input placeholder="姓名" v-model="form.identityCardName" size="small" style="width: 200px;" />
            </el-form-item>
            <el-form-item label="身份证号：" :label-width="formLabelWidth">
                <el-input placeholder="身份证号" v-model="form.identityCardNumber" size="small" style="width: 200px;" />
            </el-form-item>
            <el-form-item label="使用状态：" :label-width="formLabelWidth">
                <el-radio-group v-model="form.ifDisenable">
                    <el-radio label="0">正常</el-radio>
                    <el-radio label="1">封号</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="封号理由：" :label-width="formLabelWidth" v-show="form.ifDisenable=='1'">
                <el-input v-model="form.disenableReason" type="textarea"/>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="submit">确 定</el-button>
        </div>
    </el-dialog>
</template>

<script>
    import api from '@/api/member'
    export default {
        name: "user-edit",
        data() {
            return {
                dialogFormVisible: false,
                formLabelWidth: '120px',
                username: '',
                form: {
                    ifDisenable: '0',
                    disenableReason: '',
                    identityCardName:'',
                    identityCardNumber:''
                },
            }
        },
        methods: {
            open(data) {
                this.dialogFormVisible = true
                this.username = data.username
                this.form.id = data.id
                this.form.ifDisenable = data.ifDisenable ? '1' : '0'
                this.form.disenableReason = data.disenableReason;
                this.form.identityCardNumber = data.identityCardNumber;
                this.form.identityCardName = data.truename;
                console.log(data)
            },
            submit() {
                console.log(this.form)
                api.updateMember(this.form).then(res => {
                    console.log(res)
                    this.$message({
                        type: 'success',
                        message: '设置成功!'
                    })
                    this.$emit('getList')
                    this.dialogFormVisible = false
                }).catch(err => {
                    console.log(err)
                })
            }
        }
    }
</script>

<style scoped>

</style>
