This commit is contained in:
张良(004796)
2024-03-12 19:02:06 +08:00
parent 09e0e2748e
commit 55c04e1d1b

View File

@@ -155,14 +155,13 @@
<script>
import { listUser, getUser, delUser, addUser, updateUser } from "@/api/xq/user";
import { genderList, userStatusList } from '@/constant/statusMap'
import { resetUserMobile, resetUserPassword } from '@/api/cai/user'
export default {
name: "User",
data() {
return {
userStatusList,genderList,
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
@@ -177,10 +176,6 @@ export default {
total: 0,
// 用户管理表格数据
userList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
@@ -205,49 +200,6 @@ export default {
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: undefined,
usercode: undefined,
nickname: undefined,
type: undefined,
password: undefined,
mobile: undefined,
avatar: undefined,
avatarState: undefined,
gender: undefined,
age: undefined,
birthday: undefined,
height: undefined,
weight: undefined,
somatotype: undefined,
zodiac: undefined,
sign: undefined,
residence: undefined,
address: undefined,
residenceCity: undefined,
education: undefined,
marriage: undefined,
profession: undefined,
annualIncome: undefined,
companyNature: undefined,
forPersonals: undefined,
remark: undefined,
createTime: undefined,
updateTime: undefined,
status: undefined,
inviteId: undefined,
inviteCode: undefined,
imToken: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
@@ -266,46 +218,43 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加用户管理";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const id = row.id || this.ids
getUser(id).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改用户管理";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.id != null) {
updateUser(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
/** 重置密码按钮操作 */
handleResetPwd(row) {
this.$prompt('请输入"' + row.usercode + '"的新密码', "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnClickModal: false,
inputPattern: /^.{5,20}$/,
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间"
}).then(({ value }) => {
resetUserPassword({
userId: row.id,
password: value,
}).then(response => {
this.$modal.msgSuccess("修改成功,新密码是:" + value);
});
} else {
addUser(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
}).catch(() => {});
},
handleResetMobile(row){
this.$prompt('请输入"' + row.nickname + '"的新手机号', "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnClickModal: false,
inputPattern: /^1[0-9]{10}$/,
inputErrorMessage: "请输入正确格式的手机号"
}).then(({ value }) => {
resetUserMobile({
id: row.id,
mobile: value,
}).then(response => {
this.getList()
this.$modal.msgSuccess("修改成功,新手机号是:" + value);
});
}).catch(() => {});
},
/** 删除按钮操作 */
handleDelete(row) {
@@ -322,12 +271,36 @@ export default {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('xq/user/export', {
...this.queryParams
}, `user_${new Date().getTime()}.xlsx`)
handleCommand(command, row) {
switch (command) {
case "handleDelete":
this.handleDelete(row);
break;
case "handleResetPwd":
this.handleResetPwd(row);
break;
case "handleResetMobile":
this.handleResetMobile(row);
break;
case "handleUserForbid":
this.handleUserForbid(row);
break;
case "handleUserResetAvatar":
this.handleUserResetAvatar(row);
break;
case "handleUserResetNickname":
this.handleUserResetNickname(row);
break;
case "handleUserBindInvite":
this.handleUserBindInvite(row);
break;
case "handleUserUnBindInvite":
this.handleUserUnBindInvite(row);
break;
default:
break;
}
},
}
};
</script>