<template>
    <div>
        <div class="flexBox box">
            <div class="fileBox">
                <div class="til">头像</div>
                <div class="photo">
                    <img :src="imgSrc" width="100%" height="100%" />
                </div>
                <div class="uploadBox">
                    <el-button type="primary" plain icon="el-icon-upload2"
                        >上传文件</el-button
                    >
                </div>
            </div>
            <el-form
                ref="form"
                :model="form"
                :rules="rules"
                label-width="108px"
            >
                <el-form-item label="账户名称:" prop="name" v-show="isEdited">
                    <el-input
                        placeholder="请输入"
                        maxlength="30"
                        v-autoTrim="{ obj: form, key: 'name' }"
                        v-model="form.name"
                    >
                    </el-input>
                </el-form-item>
                <el-form-item label="账户名称:" prop="name" v-show="!isEdited">
                    {{ form.name }}
                </el-form-item>

                <el-form-item label="账户类型:" prop="des" v-show="isEdited">
                    <el-select v-model="form.des">
                        <el-option
                            v-for="item in list"
                            :label="item.caption"
                            :value="item.code"
                            :key="item.code"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="账户类型:" prop="des" v-show="!isEdited">
                    {{ form.name }}
                </el-form-item>

                <el-form-item label="所属公司:" prop="x" v-show="isEdited">
                    <el-input
                        placeholder="请输入"
                        maxlength="15"
                        v-autoTrim="{ obj: form, key: 'x' }"
                        v-model="form.x"
                    >
                    </el-input>
                </el-form-item>
                <el-form-item label="所属公司:" prop="x" v-show="!isEdited">
                    {{ form.name }}
                </el-form-item>

                <el-form-item label="联系人:" prop="x" v-show="isEdited">
                    <el-input
                        placeholder="请输入"
                        maxlength="15"
                        v-autoTrim="{ obj: form, key: 'x' }"
                        v-model="form.x"
                    >
                    </el-input>
                </el-form-item>
                <el-form-item label="联系人:" prop="x" v-show="!isEdited">
                    {{ form.name }}
                </el-form-item>

                <el-form-item label="联系方式:" prop="x" v-show="isEdited">
                    <el-input
                        placeholder="请输入"
                        maxlength="15"
                        v-autoTrim="{ obj: form, key: 'x' }"
                        v-model="form.x"
                    >
                    </el-input>
                </el-form-item>
                <el-form-item label="联系方式:" prop="x" v-show="!isEdited">
                    {{ form.name }}
                </el-form-item>

                <el-form-item label="密码:" prop="x" v-show="isEdited">
                    <el-input
                        placeholder="请输入"
                        type="password"
                        maxlength="15"
                        v-autoTrim="{ obj: form, key: 'x' }"
                        v-model="form.x"
                    >
                    </el-input>
                </el-form-item>

                <el-form-item label="确认密码:" prop="x" v-show="isEdited">
                    <el-input
                        placeholder="请输入"
                        type="password"
                        maxlength="15"
                        v-autoTrim="{ obj: form, key: 'x' }"
                        v-model="form.x"
                    >
                    </el-input>
                </el-form-item>

                <el-form-item label="状态:" prop="y" v-show="isEdited">
                    <el-radio v-model="form.z" label="1">启用</el-radio>
                    <el-radio v-model="form.z" label="2">停用</el-radio>
                </el-form-item>
                <el-form-item label="状态:" prop="y" v-show="!isEdited">
                    {{ form.name }}
                </el-form-item>

                <div class="btns" v-show="isEdited">
                    <el-button type="primary">保存</el-button>
                    <el-button type="primary" plain @click="cancelForm"
                        >取消</el-button
                    >
                </div>
            </el-form>
            <div class="editBox">
                <el-button
                 v-show="isEdited"
                    type="primary"
                    icon="el-icon-edit-outline"
                    @click="editForm"
                    >编辑</el-button
                >
            </div>
        </div>

        <el-dialog
            title="编辑"
            :visible.sync="dialogVisible"
            width="690px"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form
                ref="formA"
                :model="formA"
                :rules="rulesA"
                label-width="108px"
            >
                <el-form-item
                    label="手机验证码:"
                    prop="name"
                    class="getCodeBox"
                >
                    <el-input
                        placeholder="请输入"
                        maxlength="30"
                        class="name"
                        v-autoTrim="{ obj: form, key: 'name' }"
                        v-model="formA.name"
                    >
                        <el-button slot="append" type="primary"
                            >获取验证码</el-button
                        >
                    </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer">
                <el-button type="primary" @click="dialogVisible = false"
                    >确 定</el-button
                >
                <el-button @click="dialogVisible = false">取 消</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
//import  from '';

export default {
    name: "addAccount", // 创建账户
    components: {},
    data() {
        return {
            list: [],
            isEdited: true,
            imgSrc: require("@/assets/common/image/photoF.png"),
            form: {
                name: "创建账户",
                des: "",
                x: "",
                y: "1",
                z: "2",
            },
            rules: {
                name: [{ required: true, message: "请输入", trigger: "blur" }],
                des: [{ required: true, message: "请输入", trigger: "blur" }],
                x: [{ required: true, message: "请输入", trigger: "blur" }],
                y: [{ required: true, message: "请选择", trigger: "change" }],
                z: [{ required: true, message: "请选择", trigger: "change" }],
            },
            formA: {
                name: "",
            },
            rulesA: {
                name: [{ required: true, message: "请输入", trigger: "blur" }],
            },
            dialogVisible: false,
        };
    },

    computed: {},

    methods: {
        editForm() {
            this.isEdited = true;
            this.dialogVisible = true;
        },
        cancelForm() {
            this.isEdited = false;
            this.dialogVisible = false;
        },
    },

    // mounted: {},
};
</script>

<style lang='less' scoped>
.flexBox.box {
    padding-top: 45px;
}

.el-form {
    flex: 1;
    padding-bottom: 45px;

    /deep/ .el-input,
    .el-select {
        width: 100%;
    }
}

.fileBox {
    text-align: right;
    padding: 0 5% 0 10%;

    .til {
        width: 210px;
        padding-bottom: 10px;
        margin: 0 auto;
        text-align: left;
    }

    .photo {
        display: inline-block;
        width: 210px;
        height: 210px;
        line-height: 210px;
        border-radius: 50%;
        overflow: hidden;

        // img {
        //     vertical-align: middle;
        // }
    }
}

.uploadBox {
    padding-top: 30px;
    text-align: center;
}

.editBox {
    width: 15%;
    padding-left: 4%;
    text-align: left;
}

.btns {
    padding-top: 30px;
    text-align: center;
}

.getCodeBox {
    .el-button {
        background-color: @themeColor;
        color: #ffffff;
    }

    /deep/ .el-input-group__append {
        border: 1px solid transparent;
    }
}
</style>