| | |
| | | <template> |
| | | <div class="updateUser"> |
| | | <!-- <header> |
| | | <div class="headerTitle">{{updateFlag ? '修改用户部门信息' :'查看用户信息'}}</div> |
| | | </header> --> |
| | | <div class="createUser" v-if="showFlag"> |
| | | <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="store" :rules="createUserRules" |
| | | 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> |
| | | <!-- 用户密码 --> |
| | | <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" |
| | | :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-form-item class="optionItem" label="店铺类型:" prop="type"> |
| | | <el-select v-model="store.type" placeholder="请选择店铺类型"> |
| | | <el-option value="1"> |
| | | <el-tree ref="tree" :check-strictly="true" :data="shopTypeList" :props="defaultProps" |
| | | show-checkbox @check-change="handleCheck" :default-checked-keys="[selectOrg.orgsid[0]]" default-expand-all node-key="id"> |
| | | </el-tree> |
| | | </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="optionItems" label="店铺名称:" prop="storeName"> |
| | | <el-input v-model="store.storeName" placeholder="请填写店铺名称"></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 class="optionItem" label="负责人:" prop="owner"> |
| | | <el-input v-model="store.owner" placeholder="请填写店铺负责人名字"></el-input> |
| | | </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> |
| | | </div> |
| | | <!-- 店铺描述 --> |
| | | <el-form-item class="optionItem" label="店铺描述:" prop="storeDesc"> |
| | | <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" maxlength="300" show-word-limit |
| | | v-model="store.storeDesc" placeholder="输入店铺描述"></el-input> |
| | | <!-- <el-input type="textarea" v-model="user.storedesc" placeholder="输入部门描述"></el-input> --> |
| | | </el-form-item> |
| | | <!-- 联系方式 --> |
| | | <el-form-item class="optionItem" label="联系方式:" prop="contact"> |
| | | <el-input v-model="store.contact" placeholder="请填写店铺联系方式"></el-input> |
| | | </el-form-item> |
| | | <!-- 店铺地址 --> |
| | | <el-form-item class="optionItem" label="店铺地址:" prop="storeAddress"> |
| | | <el-input v-model="store.storeAddress" placeholder="请填写店铺详细地址"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | </div> |
| | | </main> |
| | | <footer> |
| | | <div class="optionBtn"> |
| | | <el-button class="btn reset" @click="handleBack">取消</el-button> |
| | | <el-button type="primary" class="btn submit" @click="handleUser">确定</el-button> |
| | | </div> |
| | | </footer> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import { getCodeList } from '@/utils/helper' |
| | | export default { |
| | | data() { |
| | | const validateNickname = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写用户名称")); |
| | | callback(new Error("负责人不能为空")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validatePass = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写登录密码")); |
| | | callback(); |
| | | } else { |
| | | const rep = /^\w+$/; |
| | | if (!rep.test(value)) { |
| | | callback(new Error("密码只能是以数字、26个英文字母或者下划线组成的字符串")); |
| | | } |
| | | callback(); |
| | | } |
| | | }; |
| | | const validateTruename = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写用户姓名")); |
| | | callback(new Error('店铺地址不能为空')); |
| | | } else { |
| | | const rep = /^[\u4E00-\u9FA5]{2,4}$/; |
| | | if (!rep.test(value)) { |
| | | callback("请输入正确的用户姓名"); |
| | | } |
| | | callback() |
| | | } |
| | | }; |
| | | const validatePhone = (rule, value, callback) => { |
| | |
| | | const rep = /(^1[3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/ |
| | | if (!rep.test(value)) { |
| | | callback("请输入正确的手机号码"); |
| | | } else { |
| | | 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(); |
| | | } else { |
| | | callback(new Error('店铺名称不能为空')) |
| | | } |
| | | }; |
| | | const validateType = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写登录密码")); |
| | | callback(new Error('门店类型不能为空')); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validateDepartment = (rule, value, callback) => { |
| | | const validateDesc = (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: '', |
| | | store: { |
| | | }, |
| | | createUserRules: { |
| | | nickName: [ |
| | | owner: [ |
| | | { required: true, trigger: "blur", validator: validateNickname }, |
| | | ], |
| | | password: [ |
| | | storetype: [ |
| | | { |
| | | required: true, trigger: 'change', validator: validateType, |
| | | } |
| | | ], |
| | | idcardinfo: [ |
| | | { required: true, trigger: "blur", validator: validatePass }, |
| | | ], |
| | | username: [ |
| | | storeAddress: [ |
| | | { required: true, trigger: "blur", validator: validateTruename }, |
| | | ], |
| | | // gender: [ |
| | | // { required: true, trigger: "blur" }, |
| | | // ], |
| | | isDy: [ |
| | | { required: true, trigger: "blur" }, |
| | | ], |
| | | mobile: [ |
| | | contact: [ |
| | | { required: true, trigger: "blur", validator: validatePhone }, |
| | | ], |
| | | email: [ |
| | | { required: false, trigger: "blur", validator: validateMail }, |
| | | storeName: [ |
| | | { required: true, trigger: "blur", validator: validateMail }, |
| | | ], |
| | | // role: [ |
| | | // { required: true, trigger: "blur", validator: validateRole }, |
| | | // ], |
| | | userType: [ |
| | | { required: true, trigger: "blur", validator: validateType }, |
| | | storeDesc: [ |
| | | { required: false, trigger: "blur", validator: validateDesc }, |
| | | ], |
| | | 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 } |
| | | shopTypeList: [ |
| | | |
| | | ], |
| | | typeList: [] |
| | | defaultProps: { |
| | | children: 'children', |
| | | label: 'name', |
| | | }, |
| | | selectOrg: { |
| | | orgsid: [] |
| | | }, |
| | | showFlag:false |
| | | } |
| | | }, |
| | | created() { |
| | | const that = this; |
| | | this.user = JSON.parse(JSON.stringify(that.userInfo)); |
| | | // 获取角色列表 |
| | | // this.$axios.get('') |
| | | // 获取用户类型列表 |
| | | // this.$axios.get('sccg/admin/list',{userType:0}).then(res=>{ |
| | | // console.log(res); |
| | | // }) |
| | | // 获取全部部门列表 |
| | | this.$axios.get('sccg/depart/page').then(res => { |
| | | that.typeList = res.data.records; |
| | | }) |
| | | const { userInfo } = this; |
| | | // console.log(userInfo) |
| | | this.store = userInfo |
| | | this.getShopTypeList(); |
| | | // console.log(this.store) |
| | | }, |
| | | methods: { |
| | | handleUser() { |
| | | const { user } = this; |
| | | this.$axios.post('sccg/depart/status', { |
| | | id: user.departmentId, |
| | | status: user.status ? 1 : 0, |
| | | }).then(res => { |
| | | console.log(res); |
| | | // 获取字典 |
| | | async getShopTypeList() { |
| | | let arr = await getCodeList('16'); |
| | | this.selectOrg.orgsid[0] = this.store.type |
| | | console.log(this.selectOrg.orgsid) |
| | | arr.forEach(item=>{ |
| | | item.id === this.store.type ? this.store.type = item.name : '暂无分类' |
| | | }) |
| | | this.showFlag = true |
| | | this.shopTypeList = this.createShopTypeTree(arr); |
| | | }, |
| | | createShopTypeTree(arr) { |
| | | if (arr.length && arr.length !== 0) { |
| | | // 获取顶级菜单 |
| | | let treeRoot = arr.filter(item => { |
| | | return item.parentId === 0 |
| | | }) |
| | | console.log(treeRoot); |
| | | // 添加child |
| | | treeRoot.forEach(item => { |
| | | item.children = [] |
| | | arr.forEach(child => { |
| | | if (child.parentId === item.id) { |
| | | item.children.push(child) |
| | | } |
| | | }) |
| | | }) |
| | | return treeRoot; |
| | | } |
| | | }, |
| | | handleCheck(data, checked) { |
| | | // console.log(data) |
| | | this.store.type = data.name; |
| | | // 获取当前选择的id在数组中的索引 |
| | | const indexs = this.selectOrg.orgsid.indexOf(data.id) |
| | | // 如果不存在数组中,并且数组中已经有一个id并且checked为true的时候,代表不能再次选择。 |
| | | if (indexs < 0 && this.selectOrg.orgsid.length === 1 && checked) { |
| | | this.$message({ |
| | | message: '只能选择一个部门!', |
| | | type: 'warning', |
| | | showClose: true |
| | | }) |
| | | // 设置已选择的节点为false 很重要 |
| | | this.$refs.tree.setChecked(data, false) |
| | | } else if (this.selectOrg.orgsid.length === 0 && checked) { |
| | | // 发现数组为空 并且是已选择 |
| | | // 防止数组有值,首先清空,再push |
| | | this.selectOrg.orgsid = [] |
| | | this.selectOrg.orgsid.push(data.id) |
| | | } else if ( |
| | | indexs >= 0 && |
| | | this.selectOrg.orgsid.length === 1 && |
| | | !checked |
| | | ) { |
| | | // 再次直接进行赋值为空操作 |
| | | this.selectOrg.orgsid = [] |
| | | this.store.storetype = '' |
| | | } |
| | | }, |
| | | handleUser() { |
| | | const { store } = this; |
| | | this.$refs.user.validate((valid) => { |
| | | console.log(valid); |
| | | if (valid) { |
| | | this.$axios({ |
| | | method: 'put', |
| | | url: 'sccg/store/storeinfo/update', |
| | | data: { |
| | | contact: store.contact, |
| | | idcardinfo: store.idCardInfo, |
| | | owner: store.owner, |
| | | storeAddress: store.storeAddress, |
| | | storeName: store.storeName, |
| | | id: store.id, |
| | | storePhoto: store.storePhoto, |
| | | storeScore: store.storeScore, |
| | | type:this.selectOrg.orgsid[0] |
| | | } |
| | | }) |
| | | .then(res => { |
| | | console.log(res); |
| | | if (res.code === 200) { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '修改成功', |
| | | }) |
| | | this.$emit('changeDialog', { flag: false }); |
| | | } else { |
| | | this.$message({ |
| | | type: 'error', |
| | | message: res.message, |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | return false; |
| | | } |
| | | }) |
| | | }, |
| | | handleBack() { |
| | | this.$emit('changeDialog', { flag: false }) |
| | | } |
| | | }, |
| | | props: ['userInfo', 'updateFlag'] |
| | | props: ['userInfo', 'changeDialog'] |
| | | } |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | .updateUser { |
| | | .createUser { |
| | | border-radius: 1px; |
| | | background-color: #09152f; |
| | | |
| | | // header { |
| | | // display: flex; |
| | | // justify-content: center; |
| | | // height: 60px; |
| | | // line-height: 60px; |
| | | // padding: 0 20px; |
| | | // border: 1px solid #fff; |
| | | // .headerTitle { |
| | | // color: #4b9bb7; |
| | | // font-weight: 600; |
| | | // } |
| | | |
| | | // .headerTip span { |
| | | // color: #ff3b6c; |
| | | // } |
| | | |
| | | // .headerTip label { |
| | | // color: #4b9bb7; |
| | | // } |
| | | // } |
| | | padding-bottom: 50px; |
| | | |
| | | main { |
| | | // border: 1px solid #fff; |
| | | text-align: left; |
| | | padding: 0 55px; |
| | | background-color: #09152f; |
| | | padding-bottom: 50px; |
| | | // .mainTitle { |
| | | // color: #4b9bb7; |
| | | // font-weight: 600; |
| | | // line-height: 100px; |
| | | // font-size: 14px; |
| | | // } |
| | | padding-top: 20px; |
| | | |
| | | .mainContent { |
| | | display: flex; |
| | | justify-content: center; |
| | | padding-top: 50px; |
| | | margin-top: 50px; |
| | | |
| | | &::v-deep .el-form-item__label { |
| | | color: #4b9bb7; |
| | | } |
| | | |
| | | &::v-deep .el-input__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | } |
| | | |
| | | &::v-deep .el-textarea__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | } |
| | | |
| | | .el-form-item__content { |
| | | width: 400px; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | .optionBtn { |
| | | display: flex; |
| | | margin-top: 20px; |
| | | |
| | | .btn { |
| | | padding: 12px 50px; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | .updateUser::v-deep .el-form-item__label { |
| | | color: #4b9bb7; |
| | | } |
| | | footer { |
| | | border-top: 1px solid #4b9bb7; |
| | | display: flex; |
| | | justify-content: flex-end; |
| | | padding: 0 20px; |
| | | |
| | | .updateUser::v-deep .el-input__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | .optionBtn { |
| | | display: flex; |
| | | margin-top: 20px; |
| | | |
| | | .btn { |
| | | padding: 12px 50px; |
| | | } |
| | | } |
| | | } |
| | | |
| | | ::v-deep .el-textarea__inner { |
| | | background-color: #09152f; |
| | | border: 1px solid #17324c; |
| | | } |
| | | |
| | | ::v-deep .el-input__count { |
| | | background-color: #09152f; |
| | | } |
| | | } |
| | | </style> |