fix: 用户导入和修改密码问题修复
Former-commit-id: 4dbf903c8a3f8a81f837af92d941a81ca72b35f1
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
|||||||
UserFormData,
|
UserFormData,
|
||||||
UserInfo,
|
UserInfo,
|
||||||
UserPageResult,
|
UserPageResult,
|
||||||
UserQueryParam,
|
UserQueryParam
|
||||||
} from '@/types/api/system/user';
|
} from '@/types/api/system/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
export function getUserInfo(): AxiosPromise<UserInfo> {
|
export function getUserInfo(): AxiosPromise<UserInfo> {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users/me',
|
url: '/youlai-admin/api/v1/users/me',
|
||||||
method: 'get',
|
method: 'get'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ export function listUserPages(
|
|||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users/pages',
|
url: '/youlai-admin/api/v1/users/pages',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: queryParams,
|
params: queryParams
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ export function listUserPages(
|
|||||||
export function getUserFormData(userId: number): AxiosPromise<UserFormData> {
|
export function getUserFormData(userId: number): AxiosPromise<UserFormData> {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users/' + userId + '/form_data',
|
url: '/youlai-admin/api/v1/users/' + userId + '/form_data',
|
||||||
method: 'get',
|
method: 'get'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ export function addUser(data: any) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users',
|
url: '/youlai-admin/api/v1/users',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,21 +67,35 @@ export function updateUser(id: number, data: UserFormData) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users/' + id,
|
url: '/youlai-admin/api/v1/users/' + id,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data,
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择性修改用户
|
* 修改用户状态
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param data
|
* @param status
|
||||||
*/
|
*/
|
||||||
export function updateUserPart(id: number, data: any) {
|
export function updateUserStatus(id: number, status: number) {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users/' + id,
|
url: '/youlai-admin/api/v1/users/' + id + '/status',
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
data: data,
|
params: { status: status }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户密码
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param password
|
||||||
|
*/
|
||||||
|
export function updateUserPassword(id: number, password: string) {
|
||||||
|
return request({
|
||||||
|
url: '/youlai-admin/api/v1/users/' + id + '/password',
|
||||||
|
method: 'patch',
|
||||||
|
params: { password: password }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +107,7 @@ export function updateUserPart(id: number, data: any) {
|
|||||||
export function deleteUsers(ids: string) {
|
export function deleteUsers(ids: string) {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users/' + ids,
|
url: '/youlai-admin/api/v1/users/' + ids,
|
||||||
method: 'delete',
|
method: 'delete'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +120,7 @@ export function downloadTemplate() {
|
|||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/users/template',
|
url: '/youlai-admin/api/v1/users/template',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +135,7 @@ export function exportUser(queryParams: UserQueryParam) {
|
|||||||
url: '/youlai-admin/api/v1/users/_export',
|
url: '/youlai-admin/api/v1/users/_export',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: queryParams,
|
params: queryParams,
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +154,7 @@ export function importUser(deptId: number, roleIds: string, file: File) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data'
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
name: 'user',
|
name: 'user'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
watchEffect,
|
watchEffect,
|
||||||
onMounted,
|
onMounted,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
toRefs,
|
toRefs
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
// 导入API
|
// 导入API
|
||||||
@@ -22,10 +22,11 @@ import {
|
|||||||
deleteUsers,
|
deleteUsers,
|
||||||
addUser,
|
addUser,
|
||||||
updateUser,
|
updateUser,
|
||||||
updateUserPart,
|
updateUserStatus,
|
||||||
|
updateUserPassword,
|
||||||
downloadTemplate,
|
downloadTemplate,
|
||||||
exportUser,
|
exportUser,
|
||||||
importUser,
|
importUser
|
||||||
} from '@/api/system/user';
|
} from '@/api/system/user';
|
||||||
import { listSelectDepartments } from '@/api/system/dept';
|
import { listSelectDepartments } from '@/api/system/dept';
|
||||||
import { listRoleOptions } from '@/api/system/role';
|
import { listRoleOptions } from '@/api/system/role';
|
||||||
@@ -36,7 +37,7 @@ import {
|
|||||||
ElMessageBox,
|
ElMessageBox,
|
||||||
ElTree,
|
ElTree,
|
||||||
ElForm,
|
ElForm,
|
||||||
UploadFile,
|
UploadFile
|
||||||
} from 'element-plus';
|
} from 'element-plus';
|
||||||
import {
|
import {
|
||||||
Search,
|
Search,
|
||||||
@@ -47,13 +48,13 @@ import {
|
|||||||
Lock,
|
Lock,
|
||||||
Download,
|
Download,
|
||||||
Top,
|
Top,
|
||||||
UploadFilled,
|
UploadFilled
|
||||||
} from '@element-plus/icons-vue';
|
} from '@element-plus/icons-vue';
|
||||||
import {
|
import {
|
||||||
UserItem,
|
UserItem,
|
||||||
UserQueryParam,
|
UserQueryParam,
|
||||||
UserFormData,
|
UserFormData,
|
||||||
UserImportFormData,
|
UserImportFormData
|
||||||
} from '@/types/api/system/user';
|
} from '@/types/api/system/user';
|
||||||
|
|
||||||
import { Option, Dialog } from '@/types/common';
|
import { Option, Dialog } from '@/types/common';
|
||||||
@@ -81,7 +82,7 @@ const state = reactive({
|
|||||||
userList: [] as UserItem[],
|
userList: [] as UserItem[],
|
||||||
// 弹窗属性
|
// 弹窗属性
|
||||||
dialog: {
|
dialog: {
|
||||||
visible: false,
|
visible: false
|
||||||
} as Dialog,
|
} as Dialog,
|
||||||
deptName: undefined,
|
deptName: undefined,
|
||||||
// 部门树选项
|
// 部门树选项
|
||||||
@@ -93,18 +94,18 @@ const state = reactive({
|
|||||||
roleOptions: [] as Option[],
|
roleOptions: [] as Option[],
|
||||||
// 表单参数
|
// 表单参数
|
||||||
formData: {
|
formData: {
|
||||||
status: 1,
|
status: 1
|
||||||
} as UserFormData,
|
} as UserFormData,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10
|
||||||
} as UserQueryParam,
|
} as UserQueryParam,
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
username: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
username: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
||||||
nickname: [
|
nickname: [
|
||||||
{ required: true, message: '用户昵称不能为空', trigger: 'blur' },
|
{ required: true, message: '用户昵称不能为空', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
deptId: [{ required: true, message: '所属部门不能为空', trigger: 'blur' }],
|
deptId: [{ required: true, message: '所属部门不能为空', trigger: 'blur' }],
|
||||||
roleIds: [{ required: true, message: '用户角色不能为空', trigger: 'blur' }],
|
roleIds: [{ required: true, message: '用户角色不能为空', trigger: 'blur' }],
|
||||||
@@ -112,25 +113,25 @@ const state = reactive({
|
|||||||
{
|
{
|
||||||
pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/,
|
pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/,
|
||||||
message: '请输入正确的邮箱地址',
|
message: '请输入正确的邮箱地址',
|
||||||
trigger: 'blur',
|
trigger: 'blur'
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
mobile: [
|
mobile: [
|
||||||
{
|
{
|
||||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||||
message: '请输入正确的手机号码',
|
message: '请输入正确的手机号码',
|
||||||
trigger: 'blur',
|
trigger: 'blur'
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
importDialog: {
|
importDialog: {
|
||||||
title: '用户导出',
|
title: '用户搭配',
|
||||||
visible: false,
|
visible: false
|
||||||
} as Dialog,
|
} as Dialog,
|
||||||
importFormData: {} as UserImportFormData,
|
importFormData: {} as UserImportFormData,
|
||||||
excelFile: undefined as any,
|
excelFile: undefined as any,
|
||||||
excelFilelist: [] as File[],
|
excelFilelist: [] as File[]
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -147,7 +148,7 @@ const {
|
|||||||
roleOptions,
|
roleOptions,
|
||||||
importDialog,
|
importDialog,
|
||||||
importFormData,
|
importFormData,
|
||||||
excelFilelist,
|
excelFilelist
|
||||||
} = toRefs(state);
|
} = toRefs(state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +159,7 @@ watchEffect(
|
|||||||
deptTreeRef.value.filter(state.deptName);
|
deptTreeRef.value.filter(state.deptName);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
flush: 'post', // watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
|
flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ function filterDeptNode(value: string, data: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门树节点点击事件
|
* 部门树节点click
|
||||||
*/
|
*/
|
||||||
function handleDeptNodeClick(data: { [key: string]: any }) {
|
function handleDeptNodeClick(data: { [key: string]: any }) {
|
||||||
state.queryParams.deptId = data.value;
|
state.queryParams.deptId = data.value;
|
||||||
@@ -181,10 +182,10 @@ function handleDeptNodeClick(data: { [key: string]: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载角色数据
|
* 加载角色下拉列表
|
||||||
*/
|
*/
|
||||||
async function loadRoleOptions() {
|
async function loadRoleOptions() {
|
||||||
listRoleOptions().then((response) => {
|
listRoleOptions().then(response => {
|
||||||
state.roleOptions = response.data;
|
state.roleOptions = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -200,11 +201,11 @@ function handleStatusChange(row: { [key: string]: any }) {
|
|||||||
{
|
{
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return updateUserPart(row.id, { status: row.status });
|
return updateUserStatus(row.id, row.status);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
ElMessage.success(text + '成功');
|
ElMessage.success(text + '成功');
|
||||||
@@ -252,7 +253,7 @@ function resetPassword(row: { [key: string]: any }) {
|
|||||||
'重置密码',
|
'重置密码',
|
||||||
{
|
{
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(({ value }) => {
|
.then(({ value }) => {
|
||||||
@@ -260,10 +261,8 @@ function resetPassword(row: { [key: string]: any }) {
|
|||||||
ElMessage.warning('请输入新密码');
|
ElMessage.warning('请输入新密码');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
updateUserPart(row.id, {
|
updateUserPassword(row.id, value).then(() => {
|
||||||
password: value,
|
ElMessage.success('密码重置成功,新密码是:' + value);
|
||||||
}).then(() => {
|
|
||||||
ElMessage.success('修改成功,新密码是:' + value);
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
@@ -277,7 +276,7 @@ async function handleAdd() {
|
|||||||
await loadRoleOptions();
|
await loadRoleOptions();
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: '添加用户',
|
title: '添加用户',
|
||||||
visible: true,
|
visible: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +289,7 @@ async function handleUpdate(row: { [key: string]: any }) {
|
|||||||
await loadRoleOptions();
|
await loadRoleOptions();
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: '修改用户',
|
title: '修改用户',
|
||||||
visible: true,
|
visible: true
|
||||||
};
|
};
|
||||||
getUserFormData(userId).then(({ data }) => {
|
getUserFormData(userId).then(({ data }) => {
|
||||||
state.formData = data;
|
state.formData = data;
|
||||||
@@ -332,7 +331,7 @@ function handleDelete(row: { [key: string]: any }) {
|
|||||||
{
|
{
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
@@ -358,7 +357,7 @@ function cancel() {
|
|||||||
* 加载部门
|
* 加载部门
|
||||||
*/
|
*/
|
||||||
async function loadDeptOptions() {
|
async function loadDeptOptions() {
|
||||||
listSelectDepartments().then((response) => {
|
listSelectDepartments().then(response => {
|
||||||
state.deptOptions = response.data;
|
state.deptOptions = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -378,7 +377,7 @@ function loadGenderOptions() {
|
|||||||
function handleDownloadTemplate() {
|
function handleDownloadTemplate() {
|
||||||
downloadTemplate().then((response: any) => {
|
downloadTemplate().then((response: any) => {
|
||||||
const blob = new Blob([response.data], {
|
const blob = new Blob([response.data], {
|
||||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
||||||
});
|
});
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
const href = window.URL.createObjectURL(blob); // 下载链接
|
const href = window.URL.createObjectURL(blob); // 下载链接
|
||||||
@@ -430,7 +429,7 @@ function submitImportForm() {
|
|||||||
|
|
||||||
const deptId = state.importFormData.deptId;
|
const deptId = state.importFormData.deptId;
|
||||||
const roleIds = state.importFormData.roleIds.join(',');
|
const roleIds = state.importFormData.roleIds.join(',');
|
||||||
importUser(deptId, roleIds, state.excelFile).then((response) => {
|
importUser(deptId, roleIds, state.excelFile).then(response => {
|
||||||
ElMessage.success(response.data);
|
ElMessage.success(response.data);
|
||||||
closeImportDialog();
|
closeImportDialog();
|
||||||
handleQuery();
|
handleQuery();
|
||||||
@@ -455,7 +454,7 @@ function closeImportDialog() {
|
|||||||
function handleExport() {
|
function handleExport() {
|
||||||
exportUser(queryParams.value).then((response: any) => {
|
exportUser(queryParams.value).then((response: any) => {
|
||||||
const blob = new Blob([response.data], {
|
const blob = new Blob([response.data], {
|
||||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
||||||
});
|
});
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
const href = window.URL.createObjectURL(blob); // 下载的链接
|
const href = window.URL.createObjectURL(blob); // 下载的链接
|
||||||
@@ -768,6 +767,7 @@ onMounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!--用户导入弹窗-->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
:title="importDialog.title"
|
:title="importDialog.title"
|
||||||
v-model="importDialog.visible"
|
v-model="importDialog.visible"
|
||||||
@@ -783,7 +783,7 @@ onMounted(() => {
|
|||||||
>
|
>
|
||||||
<el-form-item label="部门" prop="deptId">
|
<el-form-item label="部门" prop="deptId">
|
||||||
<el-tree-select
|
<el-tree-select
|
||||||
v-model="formData.deptId"
|
v-model="importFormData.deptId"
|
||||||
placeholder="请选择部门"
|
placeholder="请选择部门"
|
||||||
:data="deptOptions"
|
:data="deptOptions"
|
||||||
filterable
|
filterable
|
||||||
|
|||||||
Reference in New Issue
Block a user