|
@@ -27,7 +27,7 @@
|
|
|
|
|
|
<div class="body-layer" style="padding-top: 8px">
|
|
|
<div class="body-but">
|
|
|
- <el-button type="primary" @click="newAddclick">新增用户{{newShow}}</el-button>
|
|
|
+ <el-button type="primary" @click="newAddclick">新增用户</el-button>
|
|
|
<!-- <h3 style="visibility: hidden;">用户列表</h3> -->
|
|
|
</div>
|
|
|
|
|
@@ -96,7 +96,7 @@
|
|
|
<el-form ref="form" :model="form" label-width="90px" class="user-from">
|
|
|
<el-form-item label="用户姓名" class="mandatory" v-show="operRoleId">
|
|
|
<el-input
|
|
|
- v-model="search.state.nickName"
|
|
|
+ v-model="editName"
|
|
|
placeholder="请输入"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
@@ -116,20 +116,12 @@
|
|
|
placeholder="请输入"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="用户角色" class="roleName">
|
|
|
- <el-select v-model="newData.roleId" placeholder="Select">
|
|
|
- <el-option
|
|
|
- v-for="item in roleIdOptions"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
+ <el-form-item label="用户角色" class="roleName mandatory">
|
|
|
+ <com-role v-model="newData.roleId" style="width: 100%" allText="请选择" hideAll :notDefault="true" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="用户账号" class="mandatory">
|
|
|
<el-input
|
|
|
- v-model="newData.phone"
|
|
|
+ v-model="newData.userName"
|
|
|
placeholder="请输入11位手机号码作为用户账号"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
@@ -153,15 +145,15 @@ import comDialog from "@/components/dialog";
|
|
|
import comHead from "@/components/head";
|
|
|
import comCompany from "@/components/company-select";
|
|
|
import comPagination from "@/components/pagination";
|
|
|
-// import roleCompany from "@/components/role-select";
|
|
|
+import roleCompany from "@/components/role-select";
|
|
|
import auth from "@/state/viewAuth";
|
|
|
import user from "@/state/user";
|
|
|
import axios from "axios";
|
|
|
-import { encryption } from "@/util";
|
|
|
-import { PSW, PHONE } from "@/constant/REG";
|
|
|
+// import { encryption } from "@/util";
|
|
|
+// import { PSW, PHONE } from "@/constant/REG";
|
|
|
import { ADMIN_USER_ID } from "@/constant";
|
|
|
|
|
|
-import { getUserList, updateUser, changeUserStatus } from "@/request/config";
|
|
|
+import { getUserList, updateUser, changeUserStatus,userAdd } from "@/request/config";
|
|
|
import { getApp } from "../../app";
|
|
|
|
|
|
export default {
|
|
@@ -192,10 +184,10 @@ export default {
|
|
|
};
|
|
|
const newAddclick = () =>{
|
|
|
data.newShow = true
|
|
|
- console.log('newShow = true',data.newShow)
|
|
|
}
|
|
|
const data = reactive({
|
|
|
newShow: false,
|
|
|
+ editName:'',//修改编辑用户名称
|
|
|
newData:{
|
|
|
userName: "",
|
|
|
userId: "",
|
|
@@ -217,62 +209,87 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
async newSubmit(){
|
|
|
- await this.$confirm('每个组织只能创建一个总管理员~', '新增用户')
|
|
|
+ if (!this.newData.nickName) {
|
|
|
+ return this.$message.error("请输入用户姓名", "提示");
|
|
|
+ }
|
|
|
+ if (!this.newData.roleId) {
|
|
|
+ return this.$message.error("请选择用户角色", "提示");
|
|
|
+ }
|
|
|
+ if (!this.newData.userName) {
|
|
|
+ return this.$message.error("请选择用户账户", "提示");
|
|
|
+ }
|
|
|
+ if (!this.newData.psw) {
|
|
|
+ return this.$message.error("请输入登录密码", "提示");
|
|
|
+ }
|
|
|
+ await axios.post(userAdd, {
|
|
|
+ ...this.newData
|
|
|
+ });
|
|
|
+ this.$message({message: '新增成功', type: 'success'});
|
|
|
+ // await this.$confirm('每个组织只能创建一个总管理员~', '新增用户')
|
|
|
console.log('newData',this.newData)
|
|
|
},
|
|
|
async operItem() {
|
|
|
- const updatePhone = this.oper.state.__oldData
|
|
|
- ? this.oper.state.__oldData.userName !== this.oper.state.userName
|
|
|
- : true;
|
|
|
-
|
|
|
- if (updatePhone && !PHONE.REG.test(this.oper.state.userName)) {
|
|
|
- return this.$message.error(PHONE.tip, "提示");
|
|
|
- }
|
|
|
- if (this.oper.state.password !== this.oper.state.confirmPwd) {
|
|
|
- return this.$message.error("两次密码不一致!", "提示");
|
|
|
+ if (!this.editName) {
|
|
|
+ return this.$message.error("请输入用户名称", "提示");
|
|
|
}
|
|
|
+ console.log('state.oper',this.oper);
|
|
|
+ await axios.post(userAdd, {
|
|
|
+ id:this.oper.state.id,
|
|
|
+ nickName:this.editName,
|
|
|
+ });
|
|
|
+ this.$message({message: '编辑成功', type: 'success'});
|
|
|
+ // const updatePhone = this.oper.state.__oldData
|
|
|
+ // ? this.oper.state.__oldData.userName !== this.oper.state.userName
|
|
|
+ // : true;
|
|
|
|
|
|
- if (!this.oper.state.roleId) {
|
|
|
- return this.$message.error("请选择用户角色", "提示");
|
|
|
- }
|
|
|
+ // if (updatePhone && !PHONE.REG.test(this.oper.state.userName)) {
|
|
|
+ // return this.$message.error(PHONE.tip, "提示");
|
|
|
+ // }
|
|
|
+ // if (this.oper.state.password !== this.oper.state.confirmPwd) {
|
|
|
+ // return this.$message.error("两次密码不一致!", "提示");
|
|
|
+ // }
|
|
|
|
|
|
- if (
|
|
|
- !this.operRoleId &&
|
|
|
- !(await this.$confirm(
|
|
|
- "用户被启用后,可正常登录使用。确定要启用吗?",
|
|
|
- "提示"
|
|
|
- ))
|
|
|
- ) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ // if (!this.oper.state.roleId) {
|
|
|
+ // return this.$message.error("请选择用户角色", "提示");
|
|
|
+ // }
|
|
|
|
|
|
- if (this.oper.state.id) {
|
|
|
- let updateState = {
|
|
|
- ...this.oper.state,
|
|
|
- password: void 0,
|
|
|
- confirmPwd: void 0,
|
|
|
- updatePwd: void 0,
|
|
|
- userId: this.oper.state.id,
|
|
|
- };
|
|
|
- if (!updatePhone) {
|
|
|
- delete updateState.userName;
|
|
|
- }
|
|
|
- let state = { ...this.oper.state };
|
|
|
- await this.oper.update(updateState);
|
|
|
- await this.changeUserStatus(state, true);
|
|
|
- } else if (this.oper.state.password === this.oper.state.confirmPwd) {
|
|
|
- if (PSW.REG.test(this.oper.state.password)) {
|
|
|
- let cryPsw = encryption(this.oper.state.password);
|
|
|
- this.oper.insert({
|
|
|
- ...this.oper.state,
|
|
|
- password: cryPsw,
|
|
|
- confirmPwd: cryPsw,
|
|
|
- updatePwd: void 0,
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$message.error(PSW.tip, "提示");
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (
|
|
|
+ // !this.operRoleId &&
|
|
|
+ // !(await this.$confirm(
|
|
|
+ // "用户被启用后,可正常登录使用。确定要启用吗?",
|
|
|
+ // "提示"
|
|
|
+ // ))
|
|
|
+ // ) {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (this.oper.state.id) {
|
|
|
+ // let updateState = {
|
|
|
+ // ...this.oper.state,
|
|
|
+ // password: void 0,
|
|
|
+ // confirmPwd: void 0,
|
|
|
+ // updatePwd: void 0,
|
|
|
+ // userId: this.oper.state.id,
|
|
|
+ // };
|
|
|
+ // if (!updatePhone) {
|
|
|
+ // delete updateState.userName;
|
|
|
+ // }
|
|
|
+ // let state = { ...this.oper.state };
|
|
|
+ // await this.oper.update(updateState);
|
|
|
+ // await this.changeUserStatus(state, true);
|
|
|
+ // } else if (this.oper.state.password === this.oper.state.confirmPwd) {
|
|
|
+ // if (PSW.REG.test(this.oper.state.password)) {
|
|
|
+ // let cryPsw = encryption(this.oper.state.password);
|
|
|
+ // this.oper.insert({
|
|
|
+ // ...this.oper.state,
|
|
|
+ // password: cryPsw,
|
|
|
+ // confirmPwd: cryPsw,
|
|
|
+ // updatePwd: void 0,
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // this.$message.error(PSW.tip, "提示");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
},
|
|
|
async changeUserStatus(row, d) {
|
|
|
// if (!d && (!row.roleId && !row.status)) {
|
|
@@ -300,7 +317,7 @@ export default {
|
|
|
"com-dialog": comDialog,
|
|
|
"com-head": comHead,
|
|
|
"com-company": comCompany,
|
|
|
- // "com-role": roleCompany,
|
|
|
+ "com-role": roleCompany,
|
|
|
"com-pagination": comPagination,
|
|
|
},
|
|
|
};
|