“dzb”
2022-09-20 0c966cb74acac1a1cc3bcaaa579019f1177d3e36
src/views/systemSetting/baseSetting/role/updateUser/index.vue
@@ -1,101 +1,31 @@
<template>
    <div class="updateUser">
        <header>
            <div class="headerTitle">{{updateFlag ? '修改用户部门信息' :'查看用户信息'}}</div>
            <div class="headerTitle">{{updateFlag ? '修改角色信息' :'查看角色信息'}}</div>
        </header>
        <main>
            <div class="mainTitle">基础信息</div>
            <div class="mainContent">
                <el-form ref="user" label-width="140px" autoComplete="on" :model="user" :rules="createUserRules"
                <el-form ref="user" label-width="140px" autoComplete="on" :model="role" :rules="createRoleRules"
                    label-position="right">
                    <!-- 用户名称 -->
                    <el-form-item class="optionItem" label="用户名称:" prop="username">
                        <el-input v-model="user.username" placeholder="填写用户名称" :disabled="true"></el-input>
                    <!-- 角色名称 -->
                    <el-form-item class="optionItem" label="用户名称:" prop="name">
                        <el-input v-model="role.name" placeholder="请填写角色名称" :disabled="!updateFlag"></el-input>
                    </el-form-item>
                    <!-- 用户密码 -->
                    <el-form-item class="optionItems" label="用户密码:" prop="password">
                        <el-input v-model="user.password" type="password" placeholder="请输入用户密码" :disabled="true">
                        </el-input>
                    </el-form-item>
                    <!-- 所属用户姓名 -->
                    <!-- <el-form-item class="optionItem" label="所属用户姓名:" prop="true_name">
                        <el-input v-model="user.true_name" placeholder="请填写用户姓名"></el-input>
                    </el-form-item> -->
                    <!-- 性别 -->
                    <!-- <el-form-item class="optionItem" label="性别:" prop="gender">
                        <el-radio-group v-model="user.gender">
                            <el-radio :label="1">男</el-radio>
                            <el-radio :label="2">女</el-radio>
                        </el-radio-group>
                    </el-form-item> -->
                    <!-- 是否党员 -->
                    <el-form-item class="optionItem" label="是否党员:" prop="isDy">
                        <el-radio-group v-model="user.isDy" disabled>
                            <el-radio :label="1">是</el-radio>
                            <el-radio :label="0">否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <!-- 所属手机号码 -->
                    <el-form-item class="optionItem" label="所属手机号码:" prop="mobile">
                        <el-input v-model="user.mobile" placeholder="请填写手机号码" :disabled="true"></el-input>
                    </el-form-item>
                    <!-- 邮箱地址 -->
                    <el-form-item class="optionItem" label="邮箱地址:" prop="email">
                        <el-input v-model="user.email" placeholder="请填写邮箱地址" :disabled="true"></el-input>
                    </el-form-item>
                    <!-- 选择角色 -->
                    <!-- <el-form-item class="optionItem" label="选择角色:" prop="role">
                        <el-select v-model="user.role" placeholder="请选择所属角色">
                            <el-option v-for="item in roleList" :key="item.name" :label="item.name" :value="item.value"
                    <!-- 角色类型 -->
                    <el-form-item class="optionItems" label="角色类型:" prop="status">
                        <el-select v-model="role.status" placeholder="请选择用户类型" :disabled="!updateFlag">
                            <el-option v-for="item in typeList" :key="item.name" :label="item.name" :value="item.value"
                                :disabled="item.disabled">
                            </el-option>
                        </el-select>
                    </el-form-item> -->
                    <!-- 用户类型 -->
                    <el-form-item class="optionItem" label="用户类型:" prop="userType">
                        <el-select v-model="user.userType" placeholder="请选择用户类型" disabled>
                            <el-option v-for="item in typeList" :key="item.name" :label="item.name" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!-- 座机/分机 -->
                    <!-- <el-form-item class="optionItem" label="座机/分机:" prop="zj">
                        <div class="optionHandleSp">
                            <el-input class="areaNumber" v-model="user.zj.areaNumber" placeholder="电话区号">
                            </el-input>
                            <el-input class="telNumber" v-model="user.zj.phoneNumber" placeholder="电话号码">
                            </el-input>
                            <el-input class="moreNumber" v-model="user.zj.moreNumber" placeholder="分机号码">
                            </el-input>
                        </div>
                    </el-form-item> -->
                    <!-- 所属部门 -->
                    <el-form-item class="optionItem" label="所属部门:" prop="departmentId">
                        <el-select v-model="user.department" placeholder="请选择所属部门" :disabled="!updateFlag">
                            <el-option v-for="item in typeList" :key="item.name" :label="item.departName"
                                :value="item.id">
                            </el-option>
                        </el-select>
                    <!-- 角色描述 -->
                    <el-form-item class="optionItem" label="角色描述:" prop="description">
                        <el-input v-model="role.description" placeholder="请输入描述内容200字以内" :disabled="!updateFlag"></el-input>
                    </el-form-item>
                    <!-- 当前职务 -->
                    <el-form-item class="optionItem" label="当前职务:" prop="jobTitle">
                        <el-select v-model="user.work" placeholder="请选择当前职务" disabled>
                            <el-option v-for="item in typeList" :key="item.name" :label="item.name" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!-- 填写所属mac地址 -->
                    <!-- <el-form-item class="optionItem" label="填写所属mac地址:" prop="mac">
                        <el-input v-model="user.mac" placeholder="请填写所属mac地址"></el-input>
                    </el-form-item> -->
                    <!-- 填写所属ip地址 -->
                    <!-- <el-form-item class="optionItem" label="填写所属ip地址:" prop="ip">
                        <el-input v-model="user.ip" placeholder="请填写所属ip地址"></el-input>
                    </el-form-item> -->
                    <el-form-item v-if="updateFlag">
                        <div class="optionBtn">
                            <el-button type="primary" class="btn submit" @click.native.prevent="handleUser">提交
                            </el-button>
                        <el-button type="primary" class="btn submit" @click.native.prevent="handleUser">确认</el-button>
                        </div>
                    </el-form-item>
                </el-form>
@@ -132,130 +62,22 @@
                }
            }
        };
        const validatePhone = (rule, value, callback) => {
            if (!value) {
                callback(new Error("请填写手机号码"));
            } else {
                const rep = /(^1[3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/
                if (!rep.test(value)) {
                    callback("请输入正确的手机号码");
                }
            }
        };
        const validateMail = (rule, value, callback) => {
            if (value) {
                const rep = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
                if (!rep.test(value)) {
                    callback(new Error("请输入正确的邮箱"))
                }
            }
        };
        const validateRole = (rule, value, callback) => {
            if (!value) {
                callback(new Error("请填写登录密码"));
            } else {
                callback();
            }
        };
        const validateType = (rule, value, callback) => {
            if (!value) {
                callback(new Error("请填写登录密码"));
            } else {
                callback();
            }
        };
        const validateDepartment = (rule, value, callback) => {
            if (!value) {
                callback(new Error("请填写登录密码"));
            } else {
                callback();
            }
        };
        const validateWork = (rule, value, callback) => {
            if (!value) {
                callback(new Error("请填写登录密码"));
            } else {
                callback();
            }
        };
        const validateMac = (rule, value, callback) => {
            if (!value) {
                callback(new Error("请填写登录密码"));
            } else {
                callback();
            }
        };
        const validateIp = (rule, value, callback) => {
            if (!value) {
                callback(new Error("请填写登录密码"));
            } else {
                callback();
            }
        };
        return {
            user: {
                nickName: '',
                password: '',
                username: '',
                // gender: 1,
                isDy: 1,
                mobile: '',
                email: '',
                // role: null,
                userType: null,
                zj: {
                    areaNumber: '',
                    phoneNumber: "",
                    moreNumber: "",
                },
                departmentId: null,
                jobTitle: null,
                // mac: '',
                // ip: '',
            role: {
                name: '',
                status: '',
                description: '',
            },
            createUserRules: {
                nickName: [
            createRoleRules: {
                name: [
                    { required: true, trigger: "blur", validator: validateNickname },
                ],
                password: [
                    { required: true, trigger: "blur", validator: validatePass },
                status: [
                    { required: false, trigger: "blur", validator: validatePass },
                ],
                username: [
                    { required: true, trigger: "blur", validator: validateTruename },
                description: [
                    { required: false, trigger: "blur", validator: validateTruename },
                ],
                // gender: [
                //     { required: true, trigger: "blur" },
                // ],
                isDy: [
                    { required: true, trigger: "blur" },
                ],
                mobile: [
                    { required: true, trigger: "blur", validator: validatePhone },
                ],
                email: [
                    { required: false, trigger: "blur", validator: validateMail },
                ],
                // role: [
                //     { required: true, trigger: "blur", validator: validateRole },
                // ],
                userType: [
                    { required: true, trigger: "blur", validator: validateType },
                ],
                zj: [
                    { required: false, trigger: "blur" },
                ],
                departmentId: [
                    { required: true, trigger: "blur", validator: validateDepartment },
                ],
                jobTitle: [
                    { required: true, trigger: "blur", validator: validateWork },
                ],
                // mac: [
                //     { required: false, trigger: "blur", validator: validateMac },
                // ],
                // ip: [
                //     { required: false, trigger: "blur", validator: validateIp },
                // ],
            },
            roleList: [
                { name: '角色1', value: 1 }, { name: '角色2', value: 2 }
@@ -265,7 +87,8 @@
    },
    created() {
        const that = this;
        this.user = JSON.parse(JSON.stringify(that.userInfo));
        this.userInfo.status ? this.userInfo.status = 1: this.userInfo.status = 0;
        this.role = JSON.parse(JSON.stringify(that.userInfo));
        // 获取角色列表
        // this.$axios.get('')
        // 获取用户类型列表
@@ -323,17 +146,10 @@
        padding: 0 55px;
        background-color: #09152f;
        padding-bottom: 50px;
        .mainTitle {
            color: #4b9bb7;
            font-weight: 600;
            line-height: 100px;
            font-size: 14px;
        }
        .mainContent {
            display: flex;
            justify-content: center;
            margin-top: 50px    ;
            .el-form-item__content {
                width: 400px;