Commit 4536b4cb authored by 张伯涛's avatar 张伯涛

用户模块代码回滚

parent ccbeba61
...@@ -11,9 +11,9 @@ import { ...@@ -11,9 +11,9 @@ import {
RoleListGetResultModel, RoleListGetResultModel,
} from '../../demo/model/systemModel'; } from '../../demo/model/systemModel';
import { defHttp } from '@/utils/http/axios'; import { defHttp } from '@/utils/http/axios';
import { UploadFileParams } from '#/axios'; import {UploadFileParams} from "#/axios";
import { AxiosProgressEvent } from 'axios'; import {AxiosProgressEvent} from "axios";
import { UploadApiResult } from '@/api/sys/model/uploadModel'; import {UploadApiResult} from "@/api/sys/model/uploadModel";
enum Api { enum Api {
addUser = '/system/user/add', addUser = '/system/user/add',
...@@ -34,17 +34,15 @@ export const getAccountList = (params: AccountParams) => ...@@ -34,17 +34,15 @@ export const getAccountList = (params: AccountParams) =>
/** 用户列表导出*/ /** 用户列表导出*/
export const exportUserList = (params: AccountParams) => export const exportUserList = (params: AccountParams) =>
defHttp.get<AccountListGetResultModel>({ url: Api.exportApi, params, responseType: 'blob' }); defHttp.get<AccountListGetResultModel>({ url: Api.exportApi, params , responseType: 'blob'});
/** 用户导入模板下载*/ /** 用户导入模板下载*/
export const downImportTemplate = () => export const downImportTemplate = () =>
defHttp.get<any>({ url: Api.importTemplateApi, responseType: 'blob' }); defHttp.get<any>({ url: Api.importTemplateApi, responseType: 'blob'});
/** 用户导入*/ /** 用户导入*/
export const userImport = ( export const userImport = (params: UploadFileParams,
params: UploadFileParams, onUploadProgress: (progressEvent: AxiosProgressEvent) => void,) =>
onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
) =>
defHttp.uploadFile<UploadApiResult>( defHttp.uploadFile<UploadApiResult>(
{ {
url: Api.userImportApi, url: Api.userImportApi,
...@@ -54,7 +52,7 @@ export const userImport = ( ...@@ -54,7 +52,7 @@ export const userImport = (
); );
/** 用户删除*/ /** 用户删除*/
export const deleteUser = (params?: any) => export const deleteUser = (params?: any) =>
defHttp.delete<any>({ url: Api.deleteUserApi + params.id }); defHttp.delete<any>({ url: Api.deleteUserApi +params.id });
/** 用户add*/ /** 用户add*/
export const addUserApi = (params: any) => export const addUserApi = (params: any) =>
...@@ -65,7 +63,8 @@ export const addUserApi = (params: any) => ...@@ -65,7 +63,8 @@ export const addUserApi = (params: any) =>
}); });
/** 获取用户详情信息*/ /** 获取用户详情信息*/
export const UserDetailApi = (params: any) => defHttp.get<any>({ url: Api.userDetail + params }); export const UserDetailApi = (params: any) =>
defHttp.get<any>({ url: Api.userDetail + params, });
/** 用户信息编辑*/ /** 用户信息编辑*/
export const UserUpdataApi = (params: any) => export const UserUpdataApi = (params: any) =>
......
...@@ -4,19 +4,18 @@ ...@@ -4,19 +4,18 @@
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, unref, reactive } from 'vue'; import {ref, computed, unref, reactive} from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal'; import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form'; import { BasicForm, useForm } from '@/components/Form';
import { accountFormSchema } from './account.data'; import { accountFormSchema } from './account.data';
import { getDeptList } from '@/api/system/dept/dept'; import { getDeptList } from '@/api/system/dept/dept';
import { addUserApi, UserDetailApi, UserUpdataApi } from '@/api/system/dict/dict'; import {addUserApi,UserDetailApi,UserUpdataApi} from '@/api/system/user/user'
import { encryptTwo } from '../../../../src/utils/jsencrypt.js'; import { encryptTwo } from '../../../../src/utils/jsencrypt.js'
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const isUpdate = ref(true); const isUpdate = ref(true);
const rowId = ref(''); const rowId = ref('');
//获取接口数据并放在下拉框里(这里是打开了一个弹框) //获取接口数据并放在下拉框里(这里是打开了一个弹框)
...@@ -39,28 +38,28 @@ ...@@ -39,28 +38,28 @@
// 获取行数据的id // 获取行数据的id
rowId.value = data.record.businessId; rowId.value = data.record.businessId;
// 通过id获取行详情信息 // 通过id获取行详情信息
UserDetailApi(rowId.value).then((res) => { UserDetailApi(rowId.value).then(res => {
const form = res.data; const form = res.data
// 数据处理反显用户角色 // 数据处理反显用户角色
if (res.data.roleIds) { if(res.data.roleIds) {
const roleData = res.data.roleIds.split(','); const roleData = res.data.roleIds.split(',')
form.roleList = []; form.roleList = []
roleData.forEach((item) => { roleData.forEach(item => {
const id = Number(item); const id = Number(item)
form.roleList.push(id); form.roleList.push(id)
}); })
} else { }else {
form.roleList = []; form.roleList = []
} }
// 塞值 // 塞值
setFieldsValue({ setFieldsValue({
...form, ...form,
}); });
}); })
} }
const treeData = await getDeptList(); const treeData = await getDeptList();
const treeList = handleTree(treeData.data, 'businessId', undefined, undefined, undefined); const treeList = handleTree(treeData.data, 'businessId',undefined,undefined,undefined)
updateSchema([ updateSchema([
{ {
field: 'username', field: 'username',
...@@ -77,7 +76,7 @@ ...@@ -77,7 +76,7 @@
{ {
field: 'deptId', field: 'deptId',
componentProps: { componentProps: {
treeData: treeList, treeData: treeList
}, },
}, },
]); ]);
...@@ -86,31 +85,23 @@ ...@@ -86,31 +85,23 @@
const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号')); const getTitle = computed(() => (!unref(isUpdate) ? '新增账号' : '编辑账号'));
function handleTree(data, id, parentId, children, rootId) { function handleTree(data, id, parentId, children, rootId) {
id = id || 'id'; id = id || 'id'
parentId = parentId || 'parentId'; parentId = parentId || 'parentId'
children = children || 'children'; children = children || 'children'
rootId = rootId = rootId || Math.min.apply(Math, data.map(item => { return item[parentId] })) || 0
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆 // 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data)); const cloneData = JSON.parse(JSON.stringify(data))
// 循环所有项 // 循环所有项
const treeData = cloneData.filter((father) => { const treeData = cloneData.filter(father => {
const branchArr = cloneData.filter((child) => { const branchArr = cloneData.filter(child => {
// 返回每一项的子级数组 // 返回每一项的子级数组
return father[id] === child[parentId]; return father[id] === child[parentId]
}); })
branchArr.length > 0 ? (father.children = branchArr) : ''; branchArr.length > 0 ? father.children = branchArr : ''
// 返回第一层 // 返回第一层
return father[parentId] === rootId; return father[parentId] === rootId
}); })
return treeData !== '' ? treeData : data; return treeData !== '' ? treeData : data
} }
async function handleSubmit() { async function handleSubmit() {
...@@ -120,16 +111,16 @@ ...@@ -120,16 +111,16 @@
// TODO custom api // TODO custom api
console.log(values); console.log(values);
// 编辑 // 编辑
if (unref(isUpdate)) { if(unref(isUpdate)) {
values.businessId = rowId.value; values.businessId = rowId.value
UserUpdataApi(values).then((res) => { UserUpdataApi(values).then(res => {
if (res.code === 200) { if(res.code === 200){
createMessage.success('编辑成功'); createMessage.success('编辑成功');
closeModal(); closeModal();
emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } }); emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } });
} }
}); })
} else { }else {
const paramsAdd = { const paramsAdd = {
username: values.username, username: values.username,
password: encryptTwo(values.password), password: encryptTwo(values.password),
...@@ -142,15 +133,15 @@ ...@@ -142,15 +133,15 @@
flag: values.flag, flag: values.flag,
deptId: values.deptId, deptId: values.deptId,
roleList: values.roleList, roleList: values.roleList,
remarks: values.remarks, remarks: values.remarks
}; }
addUserApi(paramsAdd).then((res) => { addUserApi(paramsAdd).then(res => {
if (res.code === 200) { if(res.code === 200){
createMessage.success('新增成功'); createMessage.success('新增成功');
closeModal(); closeModal();
emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } }); emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } });
} }
}); })
} }
} finally { } finally {
setModalProps({ confirmLoading: false }); setModalProps({ confirmLoading: false });
......
...@@ -15,16 +15,10 @@ ...@@ -15,16 +15,10 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
<<<<<<< HEAD
import { onMounted, ref } from 'vue';
import {BasicTree, TreeItem} from '@/components/Tree';
import { getDeptList } from '@/api/demo/system';
=======
import {nextTick, onMounted, ref, unref} from 'vue'; import {nextTick, onMounted, ref, unref} from 'vue';
import {BasicTree, TreeActionType, TreeItem} from '@/components/Tree'; import {BasicTree, TreeActionType, TreeItem} from '@/components/Tree';
import { getDeptList } from '@/api/system/dept/dept'; import { getDeptList } from '@/api/system/dept/dept';
import {Nullable} from "@vben/types"; import {Nullable} from "@vben/types";
>>>>>>> b3d6d396d0434e4564cca7cb9fb11d703fa96f52
defineOptions({ name: 'DeptTree' }); defineOptions({ name: 'DeptTree' });
......
import { getAllRoleList } from '@/api/system/role/role'; import {getAllRoleList} from '@/api/system/role/role';
import { BasicColumn, FormSchema } from '@/components/Table'; import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue'; import {h} from "vue";
import { Tag, Switch } from 'ant-design-vue'; import {Tag} from "ant-design-vue";
import { useMessage } from '@/hooks/web/useMessage'; import { Switch } from 'ant-design-vue';
import { changeFlagApi } from '@/api/system/dict/dicts'; import {useMessage} from "@/hooks/web/useMessage";
// 引入开关组件 import {changeFlagApi} from "@/api/system/user/user"; // 引入开关组件
type CheckedType = boolean | string | number; type CheckedType = boolean | string | number;
/** /**
* transform mock data * transform mock data
...@@ -64,12 +64,12 @@ export const columns: BasicColumn[] = [ ...@@ -64,12 +64,12 @@ export const columns: BasicColumn[] = [
const params = { const params = {
businessId: record.businessId, businessId: record.businessId,
flag: newStatus, flag: newStatus,
}; }
changeFlagApi(params) changeFlagApi(params)
.then(() => { .then(() => {
record.flag = newStatus; record.flag = newStatus;
const text = record.flag === '1' ? '启用' : '停用'; const text = record.flag === '1' ? '启用' : '停用'
createMessage.success(text + `成功`); createMessage.success( text + `成功`);
}) })
.catch(() => { .catch(() => {
// createMessage.error('操作失败'); // createMessage.error('操作失败');
...@@ -126,7 +126,7 @@ export const resetPasswordFormSchema: any[] = [ ...@@ -126,7 +126,7 @@ export const resetPasswordFormSchema: any[] = [
required: true, required: true,
// ifShow: false, // ifShow: false,
}, },
]; ]
export const accountFormSchema: any[] = [ export const accountFormSchema: any[] = [
{ {
field: 'username', field: 'username',
...@@ -164,11 +164,13 @@ export const accountFormSchema: any[] = [ ...@@ -164,11 +164,13 @@ export const accountFormSchema: any[] = [
field: 'name', field: 'name',
label: '姓名', label: '姓名',
component: 'Input', component: 'Input',
}, },
{ {
field: 'nickName', field: 'nickName',
label: '昵称', label: '昵称',
component: 'Input', component: 'Input',
}, },
{ {
field: 'sex', field: 'sex',
...@@ -231,11 +233,12 @@ export const accountFormSchema: any[] = [ ...@@ -231,11 +233,12 @@ export const accountFormSchema: any[] = [
api: getAllRoleList, api: getAllRoleList,
labelField: 'roleName', labelField: 'roleName',
valueField: 'businessId', valueField: 'businessId',
resultField: 'data', resultField:'data',
}, },
required: true, required: true,
}, },
{ {
label: '备注', label: '备注',
field: 'remarks', field: 'remarks',
......
...@@ -20,7 +20,7 @@ import { BasicModal, useModalInner } from '@/components/Modal'; ...@@ -20,7 +20,7 @@ import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicUpload } from '@/components/Upload'; import { BasicUpload } from '@/components/Upload';
import { downloadByData } from '@/utils/file/download'; import { downloadByData } from '@/utils/file/download';
import { Tag, Row, Col, Upload, Button,Checkbox } from 'ant-design-vue'; import { Tag, Row, Col, Upload, Button,Checkbox } from 'ant-design-vue';
import {downImportTemplate,userImport} from '@/api/system/dict/dicts' import {downImportTemplate,userImport} from '@/api/system/user/user'
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { reactive,unref,onDeactivated,onMounted } from 'vue'; import { reactive,unref,onDeactivated,onMounted } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table'; import { BasicTable, useTable, TableAction } from '@/components/Table';
import {getAccountList, deleteUser,exportUserList} from '@/api/system/dict/dicts'; import {getAccountList, deleteUser,exportUserList} from '@/api/system/user/user';
import { PageWrapper } from '@/components/Page'; import { PageWrapper } from '@/components/Page';
import DeptTree from './DeptTree.vue'; import DeptTree from './DeptTree.vue';
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
...@@ -123,6 +123,7 @@ ...@@ -123,6 +123,7 @@
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
console.log(record); console.log(record);
deleteUser({ id: record.businessId }); deleteUser({ id: record.businessId });
createMessage.success('删除成功!');
reload(); reload();
} }
/** 导出按钮*/ /** 导出按钮*/
......
<template> <template>
<BasicModal <BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" minHeight="50">
v-bind="$attrs"
@register="registerModal"
:title="getTitle"
@ok="handleSubmit"
minHeight="50"
>
<BasicForm @register="registerForm" /> <BasicForm @register="registerForm" />
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, unref, reactive } from 'vue'; import {ref, computed, unref, reactive} from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal'; import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form'; import { BasicForm, useForm } from '@/components/Form';
import { accountFormSchema, resetPasswordFormSchema } from './account.data'; import {accountFormSchema, resetPasswordFormSchema} from './account.data';
import { getDeptList } from '@/api/system/dept/dept'; import { getDeptList } from '@/api/system/dept/dept';
import { resetUserPwd } from '@/api/system/dict/dicts'; import {resetUserPwd} from '@/api/system/user/user'
import { encryptTwo } from '../../../../src/utils/jsencrypt.js'; import { encryptTwo } from '../../../../src/utils/jsencrypt.js'
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
defineOptions({ name: 'AccountModal' });
defineOptions({ name: 'AccountModal' }); const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { span: 24 },
schemas: resetPasswordFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
rowId.value = data.record.businessId;
});
const emit = defineEmits(['success', 'register']); const getTitle = computed(() => ('修改密码'));
const { createMessage } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { span: 24 },
schemas: resetPasswordFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
rowId.value = data.record.businessId;
});
const getTitle = computed(() => '修改密码');
async function handleSubmit() { async function handleSubmit() {
try { try {
const values = await validate(); const values = await validate();
setModalProps({ confirmLoading: true }); setModalProps({ confirmLoading: true });
// TODO custom api // TODO custom api
const params = { const params = {
businessId: rowId.value, businessId: rowId.value,
password: encryptTwo(values.newPassword), password: encryptTwo(values.newPassword),
}; }
resetUserPwd(params).then((res) => { resetUserPwd(params).then(res => {
if (res.code === 200) { if(res.code === 200){
createMessage.success('修改成功'); createMessage.success('修改成功');
closeModal(); closeModal();
emit('success', { values: { ...values, id: rowId.value } }); emit('success', { values: { ...values, id: rowId.value } });
} }
}); })
} finally {
setModalProps({ confirmLoading: false }); } finally {
} setModalProps({ confirmLoading: false });
} }
}
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment