| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="角色" prop="roleIds"> |
| | | <el-select v-model="rt" placeholder="请选择角色" @change="getRole"> |
| | | <el-option :key="-1" :label="无" :value="-1">无</el-option> |
| | | |
| | | <el-option |
| | | v-for="item in roleOptions" |
| | | :key="item.roleId" |
| | |
| | | </el-col> |
| | | |
| | | </el-row> |
| | | <el-row> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="家庭号"> |
| | | <el-select v-model="fid" placeholder="请选择家庭号"> |
| | | <el-option :key="-1" :label="无" |
| | | value="无">无</el-option> |
| | | |
| | | <el-option |
| | | v-for="item in famiInfo" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | |
| | | ></el-option> |
| | | </el-select> |
| | | |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="邮箱" prop="email"> |
| | | <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName"> |
| | | <el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password"> |
| | | <el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="用户性别"> |
| | |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="手机号码" prop="phonenumber"> |
| | | <el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" /> |
| | | <el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName"> |
| | | <el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password"> |
| | | <el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="家庭号"> |
| | | <el-select v-model="fid" placeholder="请选择家庭号" @change="handleChange"> |
| | | |
| | | <el-option |
| | | key="-1" |
| | | label="无" |
| | | value="-1" |
| | | ></el-option> |
| | | <el-option |
| | | v-for="item in famiInfo" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | |
| | | ></el-option> |
| | | </el-select> |
| | | |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | </el-row> |
| | | |
| | | <el-row v-if="isshowMar"> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否本家" prop="isMyFamily"> |
| | | <el-select v-model="form.isMyFamily" placeholder="请输入是否本家" @change="handleFamily"> |
| | | |
| | | |
| | | <el-option |
| | | key=1 |
| | | label="是" |
| | | value=1 |
| | | ></el-option> |
| | | <el-option |
| | | key=0 |
| | | label="否" |
| | | value=0 |
| | | ></el-option> |
| | | </el-select> |
| | | |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | </el-row> |
| | | <el-row v-if="isshowMri"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="配偶信息" prop="spouseId"> |
| | | <el-select v-model="form.spouseId" placeholder="请选择配偶信息"> |
| | | <el-option |
| | | v-for="item in allInfo" |
| | | :key="item.userId" |
| | | :label="item.nickName" |
| | | :value="item.userId" |
| | | ></el-option> |
| | | </el-select> |
| | | |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listUser, getUser, delUser, updateUserInfo,addUser, updateUser, getAllFamilys,resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user"; |
| | | import { getIndividual,getInfoByFid, |
| | | getAllInfo,listUser, getUser, delUser, |
| | | updateUserInfo,addUser, updateUser, getAllFamilys,resetUserPwd, |
| | | changeUserStatus, deptTreeSelect } from "@/api/system/user"; |
| | | import { getToken } from "@/utils/auth"; |
| | | import Treeselect from "@riophae/vue-treeselect"; |
| | | import "@riophae/vue-treeselect/dist/vue-treeselect.css"; |
| | |
| | | showSearch: true, |
| | | // 总条数 |
| | | total: 0, |
| | | isshowMri: false, |
| | | isshowMar: false, |
| | | // 用户表格数据 |
| | | userList: null, |
| | | // 弹出层标题 |
| | |
| | | // 角色选项 |
| | | roleOptions: [], |
| | | // 表单参数 |
| | | |
| | | motherInfo:[], |
| | | fathorInfo:[], |
| | | allInfo:[], |
| | | faid: 0, |
| | | maid: 0, |
| | | form: {}, |
| | | defaultProps: { |
| | | children: "children", |
| | |
| | | roleIds: [ |
| | | { required: true, message: "用户角色不能为空", trigger: "blur" } |
| | | ], |
| | | isMyFamily: [ |
| | | { required: true, message: "是否外嫁不能为空", trigger: "blur" } |
| | | ], |
| | | deptId: [ |
| | | { required: true, message: "用户角色不能为空", trigger: "blur" } |
| | | ], |
| | | |
| | | spouseId: [ |
| | | { required: true, message: "配偶信息不能为空", trigger: "blur" } |
| | | ], |
| | | password: [ |
| | | { required: true, message: "用户密码不能为空", trigger: "blur" }, |
| | | { min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' } |
| | |
| | | this.getList(); |
| | | this.getFamlilyInfo(); |
| | | this.getDeptTree(); |
| | | //拿到自己定义的用户信息 |
| | | // this.getAllIn(); |
| | | this.getConfigKey("sys.user.initPassword").then(response => { |
| | | this.initPassword = response.msg; |
| | | }); |
| | | }, |
| | | methods: { |
| | | handleChange() |
| | | { |
| | | // alert(this.fid) |
| | | if(this.fid=="无") |
| | | this.fid = "-1" |
| | | if(this.fid!="-1") |
| | | { |
| | | //查询不是本家的时候,可以选择的配偶信息 |
| | | alert(this.fid) |
| | | |
| | | getInfoByFid(this.fid).then(response=>{ |
| | | console.log("--------------------") |
| | | console.log(response.data) |
| | | this.allInfo = response.data |
| | | }) |
| | | this.isshowMar = true |
| | | } |
| | | else{ |
| | | this.isshowMar = false |
| | | } |
| | | }, |
| | | handleFamily() |
| | | { |
| | | alert(this.form.isMyFamily) |
| | | if(this.form.isMyFamily=="0") |
| | | this.isshowMri = true |
| | | }, |
| | | getAllIn(){ |
| | | // alert(123) |
| | | getAllInfo().then(response => { |
| | | // this.allInfo = response.data; |
| | | // console.log(response.data) |
| | | // alert(982) |
| | | }) |
| | | }, |
| | | getRole(){ |
| | | this.form.roleIds = [] |
| | | //alert(123) |
| | |
| | | getFamlilyInfo(){ |
| | | let _this = this |
| | | getAllFamilys().then(response => { |
| | | //console.log(response.data) |
| | | _this.famiInfo = response.data |
| | | // console.log(response.data) |
| | | // alert(response.data[0]) |
| | | _this.famiInfo= response.data.filter(function(item){ |
| | | return item.name !== "一号家庭"; |
| | | }); |
| | | |
| | | |
| | | }) |
| | | }, |
| | | /** 查询用户列表 */ |
| | |
| | | // 取消按钮 |
| | | cancel() { |
| | | this.open = false; |
| | | this.fid = "无" |
| | | this.isshowMar = false |
| | | this.isshowMri = false |
| | | this.reset(); |
| | | }, |
| | | // 表单重置 |
| | |
| | | this.reset(); |
| | | getUser().then(response => { |
| | | this.postOptions = response.posts; |
| | | this.roleOptions = response.roles; |
| | | // this.roleOptions = response.roles; |
| | | this.roleOptions= [] |
| | | this.roleOptions.push(response.roles[1]) |
| | | this.roleOptions.push(response.roles[3]) |
| | | this.open = true; |
| | | this.title = "添加用户"; |
| | | this.form.password = this.initPassword; |
| | |
| | | handleUpdate(row) { |
| | | this.reset(); |
| | | const userId = row.userId || this.ids; |
| | | // alert(userId) |
| | | |
| | | // this.fid = response.data.familyId |
| | | //alert(this.fid) |
| | | getUser(userId).then(response => { |
| | | this.form = response.data; |
| | | console.log(response.data) |
| | | this.postOptions = response.posts; |
| | | this.roleOptions = response.roles; |
| | | // alert(response.roleIds.length) |
| | | if(response.roleIds.length!=0) |
| | | this.rt = response.roleIds[0] |
| | | let _this = this |
| | | |
| | | getIndividual(userId).then(response => { |
| | | // alert(123) |
| | | console.log(response.data) |
| | | if(response.data!=undefined) |
| | | { |
| | | _this.fid = response.data.familyId; |
| | | } |
| | | } |
| | | ); |
| | | this.$set(this.form, "postIds", response.postIds); |
| | | this.$set(this.form, "roleIds", response.roleIds); |
| | | this.open = true; |
| | |
| | | |
| | | // alert(this.form.roleIds) |
| | | let ps = true |
| | | // alert(this.rt) |
| | | // alert(this.fid) |
| | | // alert(this.rt) |
| | | // alert(this.fid) |
| | | if(this.fid=="无") |
| | | this.fid = -1 |
| | | let _this = this |
| | | if(this.rt===2 && (this.fid!="无")) |
| | | if(this.rt===2 && (this.fid!=-1)) |
| | | { |
| | | ps = false |
| | | |
| | | } |
| | | if(this.rt!=2&&this.fid==-1) |
| | | { |
| | | this.$modal.msgSuccess("家庭成员,必须要拥有家庭号!"); |
| | | return |
| | | } |
| | | // alert(ps) |
| | | if(ps) |
| | | { |
| | | let fm = {} |
| | | fm.userId = _this.form.userId |
| | | |
| | | if(_this.fid==="无") |
| | | fm.familyId= -1 |
| | | else |
| | | fm.familyId = _this.fid |
| | | this.form.familyId = fm.familyId |
| | | |
| | | if (valid) { |
| | | if (this.form.userId != undefined) { |
| | | updateUser(this.form).then(response => { |
| | | |
| | | let fm = {} |
| | | fm.userId = _this.form.userId |
| | | |
| | | if(_this.fid==="无") |
| | | fm.familyId= -1 |
| | | else |
| | | fm.familyId = _this.fid |
| | | |
| | | updateUserInfo(fm).then(response=>{ |
| | | this.$modal.msgSuccess("修改成功"); |
| | | this.open = false; |
| | | this.getList(); |
| | | _this.rt = undefined |
| | | _this.fid = "无" |
| | | this.isshowMar = false |
| | | this.isshowMri = false |
| | | }) |
| | | }); |
| | | } else { |
| | | // alert(this.form.ismarry) |
| | | // alert(987) |
| | | addUser(this.form).then(response => { |
| | | this.$modal.msgSuccess("新增成功"); |
| | | this.open = false; |
| | | this.getList(); |
| | | _this.rt = undefined |
| | | _this.fid = "无" |
| | | this.isshowMar = false |
| | | this.isshowMri = false |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | else{ |
| | | this.$modal.msgSuccess("普通角色不能拥有家庭号!"); |
| | | // _this.rt = undefined |
| | | _this.fid = "无" |
| | | _this.isshowMar = false |
| | | } |
| | | }); |
| | | }, |