diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml index 909ebcf..b42afd7 100644 --- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml +++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml @@ -1312,34 +1312,9 @@ 1男2女 - + - 手机号 - - - - - 员工IC卡 - - - - - 头像 - - - - - 入职时间 - - - - - 身份证 - - - - - 1在职2出差3离职 + 1启用 2禁用 @@ -1347,16 +1322,11 @@ 超管 - + 角色Id - - - 是否删除 - - 名 称 :模块菜单表 @@ -7677,9 +7647,9 @@ 主键 - + - 设备名称 + 账号名称 @@ -8104,6 +8074,11 @@ 描 述 : + + + 模块编号 + + 名 称 :授权模块输出 @@ -8180,16 +8155,6 @@ 描 述 : - - - 主键 - - - - - 排序 - - 员工姓名 @@ -8197,45 +8162,15 @@ - 1男2女 - - - - - 手机号 - - - - - 员工IC卡 - - - - - 头像 - - - - - 入职时间 - - - - - 离职时间 - - - - - 身份证 + 0男1女 - + - 1在职2出差3离职 + 0启用 1禁用 - + 角色Id @@ -8340,45 +8275,15 @@ - 1男2女 - - - - - 手机号 + 0男1女 - + - 员工IC卡 + 0启用 1禁用 - - - 头像 - - - - - 入职时间 - - - - - 离职时间 - - - - - 身份证 - - - - - 1在职2出差3离职 - - - + 角色Id @@ -8443,11 +8348,6 @@ [模块信息]添加入参 - - - 主键 - - [模块信息]修改入参 @@ -8918,6 +8818,27 @@ + + + 编辑员工 + + + + + + + 查询员工 + + + + + + + 删除员工 + + + + 名 称 : diff --git a/backend/BPA.MES.Base.Application/Entitys/Sys/EmployeeEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Sys/EmployeeEntity.cs index 0e3594c..66b70f5 100644 --- a/backend/BPA.MES.Base.Application/Entitys/Sys/EmployeeEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/Sys/EmployeeEntity.cs @@ -20,38 +20,10 @@ [SugarColumn(IsNullable = true)] public int Gender { get; set; } /// - /// 手机号 + /// 1启用 2禁用 /// [SugarColumn(IsNullable = false)] - public string Phone { get; set; } - /// - /// 员工IC卡 - /// - [SugarColumn(IsNullable = true)] - public string ICCard { get; set; } - /// - /// 头像 - /// - [SugarColumn(IsNullable = true)] - public string Header { get; set; } - - [SugarColumn(IsNullable = false)] - public DateTime JoinDate { get; set; } - /// - /// 入职时间 - /// - [SugarColumn(IsNullable = true)] - public DateTime? OutDate { get; set; } - /// - /// 身份证 - /// - [SugarColumn(IsNullable = true)] - public string IdCard { get; set; } - /// - /// 1在职2出差3离职 - /// - [SugarColumn(IsNullable = false)] - public int Stutas { get; set; } + public int Status { get; set; } /// /// 超管 /// @@ -60,10 +32,7 @@ /// /// 角色Id /// - public string TB_RoleId { get; set; } - /// - /// 是否删除 - /// - public bool IsDeleted { get; set; } + public string RoleId { get; set; } + } } diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AccountInput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AccountInput.cs index 60aebc1..787a57e 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AccountInput.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AccountInput.cs @@ -87,8 +87,8 @@ namespace BPA.MES.Base.Application /// public string? Id { get; set; } /// - /// 设备名称 + /// 账号名称 /// - public string Name { get; set; } + public string Account { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemOutput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemOutput.cs index 8334c97..3a49ef3 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemOutput.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/AuthorModuleItemOutput.cs @@ -8,5 +8,10 @@ /// public class AuthorModuleItemOutput { + /// + /// 模块编号 + /// + public string Id { get; set; } + } } diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs index c665bbc..7b6669c 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeInput.cs @@ -8,63 +8,23 @@ /// public class EmployeeInput { - /// - /// 主键 - /// - public string Id { get; set; } - /// - /// 排序 - /// - public int Sort { get; set; } /// /// 员工姓名 /// public string Name { get; set; } /// - /// 1男2女 + /// 0男1女 /// - public int Gender { get; set; } /// - /// 手机号 - /// - - public string Phone { get; set; } - /// - /// 员工IC卡 + /// 0启用 1禁用 /// - - public string ICCard { get; set; } - /// - /// 头像 - /// - - public string Header { get; set; } - /// - /// 入职时间 - /// - - public DateTime JoinDate { get; set; } - - /// - /// 离职时间 - /// - public DateTime? OutDate { get; set; } - /// - /// 身份证 - /// - - public string IdCard { get; set; } - /// - /// 1在职2出差3离职 - /// - - public int Stutas { get; set; } + public int Status { get; set; } /// /// 角色Id /// - public string TB_RoleId { get; set; } + public string RoleId { get; set; } /// /// 是否存在账号 /// diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeOutput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeOutput.cs index be0e839..3373c3a 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeOutput.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/EmployeeOutput.cs @@ -21,42 +21,18 @@ /// public string Name { get; set; } /// - /// 1男2女 + /// 0男1女 /// public int Gender { get; set; } /// - /// 手机号 + /// 0启用 1禁用 /// - public string Phone { get; set; } - /// - /// 员工IC卡 - /// - public string ICCard { get; set; } - /// - /// 头像 - /// - public string Header { get; set; } - /// - /// 入职时间 - /// - public DateTime JoinDate { get; set; } - /// - /// 离职时间 - /// - public DateTime? OutDate { get; set; } - /// - /// 身份证 - /// - public string IdCard { get; set; } - /// - /// 1在职2出差3离职 - /// - public int Stutas { get; set; } + public int Status { get; set; } /// /// 角色Id /// - public string TB_RoleId { get; set; } + public string RoleId { get; set; } /// /// 是否存在账号 /// diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/ModuleInput.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/ModuleInput.cs index cad95fe..102ed2b 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/ModuleInput.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Dtos/ModuleInput.cs @@ -49,10 +49,7 @@ namespace BPA.MES.Base.Application /// public class ModuleAddInput : ModuleInput { - /// - /// 主键 - /// - public string Id { get; set; } + } /// /// [模块信息]修改入参 diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs index f2d5a1a..d6e4f71 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Services/AuthorizeService.cs @@ -69,7 +69,7 @@ public async Task GetUserInfo() { string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; - var user = await db.Queryable().LeftJoin((t, x) => t.TB_RoleId == x.Id) + var user = await db.Queryable().LeftJoin((t, x) => t.RoleId == x.Id) .Where((t, x) => t.Id == userId).Select((t, x) => new { RoleName = x.Name, @@ -157,7 +157,7 @@ } if (category == 2) { - return user.TB_RoleId; + return user.RoleId; } else { @@ -177,6 +177,7 @@ public async Task> AccountPageList(AccountQueryPageInput input) { var entity = await _dbContext.Queryable() + .WhereIF(!string.IsNullOrEmpty(input.Account),x=>x.Account==input.Account) .ToPagedListAsync(input.PageIndex,input.PageSize); SqlSugarPagedList output = entity.Adapt>(); return output; @@ -259,7 +260,7 @@ [HttpGet] public async Task RemoveRole(string input) { - return await db.Updateable().Where(t => t.Id == input).ExecuteCommandHasChangeAsync(); + return await db.Deleteable().Where(t => t.Id == input).ExecuteCommandHasChangeAsync(); } [HttpGet] public async Task GetRole(string input) @@ -289,8 +290,9 @@ public async Task AddModule(ModuleAddInput input) { input.ParentId = input.ParentId ?? string.Empty; - input.Id = null; - return (await db.Insertable(input.Adapt()).ExecuteCommandAsync()) > 0; + var entity = input.Adapt(); + await db.Insertable(entity).IgnoreColumns(true).ExecuteCommandAsync(); + return true; } [HttpPost] @@ -315,7 +317,7 @@ await RemoveModule(item.Id); } } - await _dbContext.Updateable().Where(it => it.Id == input).ExecuteCommandAsync(); + await _dbContext.Deleteable().Where(it => it.Id == input).ExecuteCommandAsync(); } [HttpPost] public async Task> GetTreeGrid(ModuleTreeQueryInput input) @@ -332,12 +334,12 @@ if (modules.HasVal()) { - foreach (var item in modules.Where(it => it.Category == 1)) + foreach (var item in modules.Where(it=>it.ParentId=="").ToList()) { - item.Children = modules.Where(it => it.ParentId == item.Id && it.Category == 2).OrderBy(it => it.Sort).ToList(); + item.Children = modules.Where(it => it.ParentId == item.Id ).OrderBy(it => it.Sort).ToList(); foreach (var view in item.Children) { - view.Children = modules.Where(it => it.ParentId == view.Id && it.Category == 3).OrderBy(it => it.Sort).ToList(); + view.Children = modules.Where(it => it.ParentId == view.Id ).OrderBy(it => it.Sort).ToList(); } list.Add(item); @@ -392,45 +394,34 @@ #region 授权模板详情 [HttpGet] - public async Task> GetModuleByTemplateId(string input) + public async Task> GetModuleByTemplateId(string input) { - List result = new List(); - var modules = await db.Queryable().ToListAsync(); - var roots = modules.Adapt>(); - db.ThenMapper(roots, item => - { - item.HasPermission = db.Queryable().Where(m => m.TB_TemplateId == input && m.TB_ModuleId == item.Id).Any(); - }); - if (roots.HasVal()) - { - foreach (var item in roots.Where(it => it.Category == 1)) - { - item.Childrens = roots.Where(it => it.ParentId == item.Id && it.Category == 2).OrderBy(it => it.Name).ToList(); - - foreach (var view in item.Childrens) - { - view.Childrens = roots.Where(it => it.ParentId == view.Id && it.Category == 3).OrderBy(it => it.Name).ToList(); - } - - result.Add(item); - } - } - return result; + var entity =await db.Queryable().Where(m => m.TB_TemplateId == input).ToListAsync(); + return entity; } [HttpPost] public async Task EditTemplateItem(AuthorModuleItemUpdateInput input) { var temp = await db.Queryable().FirstAsync(t => t.Id == input.TB_TemplateId && t.IsDeleted == false); - await db.Updateable().SetColumns(T => T.IsDeleted == true) - .Where(t => t.TB_TemplateId == input.TB_TemplateId).ExecuteCommandHasChangeAsync(); - var entity = input.TB_ModuleIds.Distinct().ToList().ConvertAll(t => new AuthorizeTemplateItemEntity + try { - TB_ModuleId = t, - TB_TemplateId = input.TB_TemplateId - }); - var res = await db.Insertable(entity).ExecuteCommandAsync(); - return res > 0; + db.Ado.BeginTran(); + await db.Deleteable() + .Where(t => t.TB_TemplateId == input.TB_TemplateId).ExecuteCommandAsync(); + var entity = input.TB_ModuleIds.Distinct().ToList().ConvertAll(t => new AuthorizeTemplateItemEntity + { + TB_ModuleId = t, + TB_TemplateId = input.TB_TemplateId + }); + await db.Insertable(entity).ExecuteCommandAsync(); + db.Ado.CommitTran(); + return true; + } + catch (Exception ex) + { + throw Oops.Bah(ex.Message); + } } [HttpPost] public async Task> GetAuthorizeObjects(AuthorizeInput input) @@ -457,7 +448,6 @@ { var temp = await db.Queryable() .Where(t => t.IsAdmin == false) - .Where(t => t.IsDeleted == false) .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), t => t.Name.Contains(input.Keyword)) .OrderBy(t => t.Name) .ToListAsync(); @@ -548,6 +538,7 @@ var model = input.Adapt(); //默认123456 model.Pwd = "123456".ToMD5Encrypt(); + model.EmployeeId = input.TB_Employee_Id; return await db.Insertable(model).ExecuteCommandAsync() > 0; } } @@ -571,35 +562,36 @@ { var model = input.Adapt(); model.IsAdmin = false; - var temp = await db.Queryable().FirstAsync(t => t.Name.Equals(input.Name) && t.Phone.Equals(input.Phone) && t.IsDeleted == false); - if (temp != null) throw Oops.Bah("该员工已经存在"); - return await db.Insertable(model).ExecuteCommandAsync() > 0; + return await db.Insertable(model).IgnoreColumns(true).ExecuteCommandAsync() > 0; } + /// + /// 编辑员工 + /// + /// + /// [HttpPost] public async Task EditEmployee(EmployeeUpdateInput input) { var temp = await db.Queryable().FirstAsync(t => t.Id == input.Id); - temp.Header = input.Header; - temp.IdCard = input.IdCard; - temp.Gender = input.Gender; - temp.JoinDate = input.JoinDate; - temp.OutDate = input.OutDate; temp.Name = input.Name; - temp.Phone = input.Phone; - temp.Stutas = input.Stutas; + temp.Status = input.Status; return await db.Updateable(temp).ExecuteCommandHasChangeAsync(); } + /// + /// 查询员工 + /// + /// + /// [HttpPost] public async Task> QueryEmployee(EmployeeQueryPageInput input) { var entity = await db.Queryable() - .WhereIF(!string.IsNullOrEmpty(input.Keyword), t => t.Name.Contains(input.Keyword) || t.Phone.Contains(input.Keyword)) - .WhereIF(input.Status > 0, t => t.Stutas == input.Status).WhereIF(input.Gender > 0, t => t.Gender == input.Gender) - .WhereIF(input.JoinDate.HasValue, t => t.JoinDate <= input.JoinDate.Value) + .WhereIF(!string.IsNullOrEmpty(input.Keyword), t => t.Name.Contains(input.Keyword)) + .WhereIF(input.Status > 0, t => t.Status == input.Status).WhereIF(input.Gender > 0, t => t.Gender == input.Gender) .Where(t => t.IsAdmin == false) - .Where(t => t.IsDeleted == false) + .Select(t => new EmployeeOutput() { Id = t.Id.SelectAll(), @@ -609,30 +601,27 @@ .ToPagedListAsync(input.PageIndex, input.PageSize); return entity; } + /// + /// 删除员工 + /// + /// + /// [HttpGet] public async Task RemoveEmployee([FromQuery] string employeeId) { - bool result = false; - var entity =await db.Queryable().FirstAsync(x=>x.EmployeeId== employeeId); - try { db.Ado.BeginTran(); await db.Deleteable().Where(t => t.Id == employeeId).ExecuteCommandAsync(); - if (entity!=null) - { - entity.EmployeeId = string.Empty; - await db.Updateable(entity).IgnoreColumns(true).ExecuteCommandAsync(); - } + await db.Deleteable().Where(t => t.EmployeeId == employeeId).ExecuteCommandAsync(); db.Ado.CommitTran(); - result = true; + return true; } catch (Exception ex) { db.Ado.RollbackTran(); throw Oops.Bah("删除失败!"); } - return result; } [HttpGet] public async Task> EmployeeList() diff --git a/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs b/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs index e8c073e..e2fc37d 100644 --- a/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs +++ b/backend/BPA.MES.Base.Application/Services/SystemService/Services/IAuthorizeService.cs @@ -53,7 +53,7 @@ public interface IAuthorizeService #endregion #region 授权模板详情 - Task> GetModuleByTemplateId(string input); + Task> GetModuleByTemplateId(string input); Task EditTemplateItem(AuthorModuleItemUpdateInput input); Task> GetAuthorizeObjects(AuthorizeInput input); Task RemoveAuthorize(AuthorizeInput input); diff --git a/frontend/config/routes.ts b/frontend/config/routes.ts index cb86266..72103d0 100644 --- a/frontend/config/routes.ts +++ b/frontend/config/routes.ts @@ -6,7 +6,7 @@ path: '/system', name: '系统管理', routes: [ - { path: '/system/account', name: '账号管理', component: './system/account' }, + // { path: '/system/account', name: '账号管理', component: './system/account' }, { path: '/system/user', name: '人员管理', component: './system/user' }, { path: '/system/role', name: '角色管理', component: './system/role' }, { path: '/system/module', name: '模块管理', component: './system/module' }, diff --git a/frontend/src/api/AuthTemplate.ts b/frontend/src/api/AuthTemplate.ts index c88c159..d27449d 100644 --- a/frontend/src/api/AuthTemplate.ts +++ b/frontend/src/api/AuthTemplate.ts @@ -112,7 +112,7 @@ export default { * @param templateId */ GetModules(templateId: string) { - return request(`/api/authorize/GetModuleByTemplateId/${templateId}`, { + return request(`/api/authorize/getmodulebytemplateid/${templateId}`, { method: 'GET' }); } diff --git a/frontend/src/api/Role.ts b/frontend/src/api/Role.ts index 3341f45..59f30f3 100644 --- a/frontend/src/api/Role.ts +++ b/frontend/src/api/Role.ts @@ -3,7 +3,7 @@ import { request } from '@umijs/max'; export default { //创建角色 CreateRole(parms: RolelTypes.RoleType) { - return request('/api/authorize/AddRole', { + return request('/api/authorize/addrole', { method: 'POST', data: { ...parms, @@ -13,14 +13,14 @@ export default { //删除角色 DeleteRole(id: string) { - return request(`/api/authorize/RemoveRole/${id}`, { + return request(`/api/authorize/removerole/${id}`, { method: 'GET' }); }, //修改角色 ModifyRole(parms: RolelTypes.RoleType) { - return request('/api/authorize/EditRole', { + return request('/api/authorize/editrole', { method: 'POST', data: { ...parms, @@ -31,7 +31,7 @@ export default { //获取角色列表 GetRoleList() { - return request('/api/authorize/GetRoleList', { + return request('/api/authorize/getroleList', { method: 'GET', }); }, @@ -42,7 +42,7 @@ export default { * @returns */ GetRolePagedList(parms: RolelTypes.RolePageParams) { - return request('/api/authorize/QueryRole', { + return request('/api/authorize/queryrole', { method: 'POST', data: { ...parms, diff --git a/frontend/src/api/accountService.ts b/frontend/src/api/accountService.ts index 0263d02..b27da2e 100644 --- a/frontend/src/api/accountService.ts +++ b/frontend/src/api/accountService.ts @@ -4,7 +4,7 @@ import { request } from '@umijs/max'; export default { //创建 Add(parms: Account.TBAccountDTO) { - return request('/api/authorize/add', { + return request('/api/authorize/addaccount', { method: 'POST', data: { ...parms, @@ -40,7 +40,7 @@ export default { * @param parms * @returns */ - PagedList(parms: Account.TBAccountDTO) { + PagedList(parms: Account.Page) { return request('/api/authorize/accountpagelist', { method: 'POST', data: { diff --git a/frontend/src/pages/system/account/index.tsx b/frontend/src/pages/system/account/index.tsx index 0876cb1..1d1ef39 100644 --- a/frontend/src/pages/system/account/index.tsx +++ b/frontend/src/pages/system/account/index.tsx @@ -38,33 +38,33 @@ typeForm.setFieldsValue(copyFormData); }} > - 编辑 + 重置密码 , - { + // { - const EnablejsonData: Account.TBAccountDTO = { - id: record.id, - name: '', - code: '' - }; - AccountAPI.Del(EnablejsonData).then((r) => { - if (r.statusCode === 200) { - message.success(r.statusCode === 200 ? '删除成功' : r.message); - actionRef.current?.reload(); - } - }); - }} - onCancel={() => { - message.info('已取消删除'); - }} - okText="确认" - cancelText="关闭" - > - - , + // const EnablejsonData: Account.TBAccountDTO = { + // id: record.id, + // name: '', + // code: '' + // }; + // AccountAPI.Del(EnablejsonData).then((r) => { + // if (r.statusCode === 200) { + // message.success(r.statusCode === 200 ? '删除成功' : r.message); + // actionRef.current?.reload(); + // } + // }); + // }} + // onCancel={() => { + // message.info('已取消删除'); + // }} + // okText="确认" + // cancelText="关闭" + // > + // + // , ], }, ]; @@ -113,12 +113,10 @@ actionRef={actionRef} cardBordered request={async (params = {}) => { - const jsonData: DeviceTypes.Page = { + const jsonData: Account.Page = { pageIndex: params.current || 1, pageSize: params.pageSize || 10, - name: params.name || '', - id: '', - code: '' + account: params.account || '', }; const response = await AccountAPI.PagedList(jsonData); if (response.statusCode === 200) { @@ -140,20 +138,8 @@ pageSize: 10, }} dateFormatter="string" - headerTitle="设备列表" - toolBarRender={() => [ - , - ]} + headerTitle="账号列表" + toolBarRender={false} /> { const response = await authTempAPI.GetModules(values.id); setIsLoading(false); if (response.statusCode === 200) { + console.log(' response.data', response.data); + const selectKeys: string[] = []; response.data.forEach((item: AuthTemplateTypes.ModuleType) => { - if (item.hasPermission) { - if (item.childrens.length > 0) { - item.childrens.forEach((cItem: AuthTemplateTypes.ModuleType) => { - if (cItem.hasPermission) { - selectKeys.push(cItem.id); - if (cItem.childrens.length > 0) { - cItem.childrens.forEach((fItem: AuthTemplateTypes.ModuleType) => { - selectKeys.push(fItem.id); - }) - } - } - }); - } - } + // if (item.hasPermission) { + selectKeys.push(item.tB_ModuleId); + // if (item.childrens.length > 0) { + // item.childrens.forEach((cItem: AuthTemplateTypes.ModuleType) => { + // if (cItem.hasPermission) { + // selectKeys.push(cItem.id); + // if (cItem.childrens.length > 0) { + // cItem.childrens.forEach((fItem: AuthTemplateTypes.ModuleType) => { + // selectKeys.push(fItem.id); + // }) + // } + // } + // }); + // } + // } }); console.log('selectKeys', selectKeys); setSelectTempRowKeys(selectKeys); diff --git a/frontend/src/pages/system/user/index.tsx b/frontend/src/pages/system/user/index.tsx index b16fbea..4a02acb 100644 --- a/frontend/src/pages/system/user/index.tsx +++ b/frontend/src/pages/system/user/index.tsx @@ -8,7 +8,6 @@ import md5 from 'js-md5' import { PlusOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components'; -import Password from 'antd/es/input/Password'; const DatePicker: any = TDatePicker; @@ -19,17 +18,13 @@ const User: React.FC = () => { const [isAccountVisible, setIsAccountVisible] = useState(false); const [currentPerson, setCurrentPerson] = useState({ - phone: '', - joinDate: '', - outDate: '', - idCard: '', - stutas: 1, - tB_RoleId: '', + status: 1, + roleId: '', gender: 1, id: '', sort: 1, name: '', - iCCard: '' + isAccount: false }); const [form] = Form.useForm(); const [formAccount] = Form.useForm(); @@ -47,24 +42,6 @@ const User: React.FC = () => { dataIndex: 'account', key: 'account', }, - { - title: '电话', - search: false, - dataIndex: 'phone', - key: 'phone' - }, - { - title: 'IC卡', - search: false, - dataIndex: 'icCard', - key: 'icCard' - }, - { - title: '身份证', - search: false, - dataIndex: 'idCard', - key: 'idCard' - }, { title: '性别', dataIndex: 'gender', @@ -72,19 +49,16 @@ const User: React.FC = () => { valueType: 'select', valueEnum: { 0: { - text: '全部' - }, - 1: { text: '男' }, - 2: { + 1: { text: '女', } }, render: (_, record) => ( <> { - record.gender === 1 ? + record.gender === 0 ?
@@ -96,32 +70,6 @@ const User: React.FC = () => { ) }, - { - title: '入职时间', - dataIndex: 'joinDate', - key: 'joinDate', - valueType: 'date', - render: (_, record) => (<> - { - (() => { - return
{moment(record.joinDate).format('yyyy-MM-DD')}
- })() - } - ) - }, - { - title: '离职时间', - dataIndex: 'outDate', - search: false, - key: 'outDate', - render: (_, record) => (<> - { - (() => { - return record.outDate === null ? '-' :
{moment(record.outDate).format('yyyy-MM-DD')}
- })() - } - ) - }, { title: '角色', search: false, @@ -131,7 +79,7 @@ const User: React.FC = () => { <> { (() => { - const role = roleList.find(item => item.id === record.tB_RoleId); + const role = roleList.find(item => item.id === record.roleId); if (role) { return
{role.name}
} else { @@ -144,32 +92,29 @@ const User: React.FC = () => { }, { title: '状态', - dataIndex: 'stutas', - key: 'stutas', + dataIndex: 'status', + key: 'status', valueType: 'select', valueEnum: { 0: { - text: '全部' - }, - 1: { text: '在职' }, - 2: { + 1: { text: '出差', }, - 3: { + 2: { text: '离职', } }, render: (_, record) => ( <> { - record.stutas === 1 ? + record.status === 0 ?
在职
: - (record.stutas === 2 ?
+ (record.status === 1 ?
出差
:
离职 @@ -185,53 +130,60 @@ const User: React.FC = () => { key: 'action', render: (_, record) => ( - { - - { - setIsAccountVisible(true); - formAccount.setFieldValue('tB_Employee_Id', record.id); - formAccount.setFieldValue('account', record.account!); - }}>账户设置 - + { + + { + setIsAccountVisible(true); + formAccount.setFieldValue('tB_Employee_Id', record.id); + formAccount.setFieldValue('account', record.account!); + }}>设置登录账号 + } - { - const response = await userAPI.RestoreAccount(record.id!); - if (response.data === true) { - message.success('成功!'); - } else { - message.error(response.msg || '重置失败'); - } - }}>重置密码 + { + const response = await userAPI.RestoreAccount(record.id!); + if (response.data === true) { + message.success('成功!'); + } else { + message.error(response.msg || '重置失败'); + } + }} + onCancel={() => { + message.info('已取消删除'); + }} + okText="确认" + cancelText="关闭" + > + 重置密码 + { setIsPersonDetailVisible(true); setCurrentPerson(record); const tempRecord = JSON.parse(JSON.stringify(record)); - tempRecord.joinDate = moment(record.joinDate) - if (record.outDate !== null) { - tempRecord.outDate = moment(record.outDate) - } form.setFieldsValue(tempRecord); - }}>查看详情 + }}>编辑 { - const response = await userAPI.RemoveUser(record.id!); - if (response.data === true) { - message.success('删除成功!'); - actionRef.current?.reload(); - } else { - message.error(response.msg || '删除失败'); - } - }} - onCancel={() => { - message.info('已取消删除'); - }} - okText="确认" - cancelText="关闭" - > - - + key="del" + title="确定要删除此条数据吗?" + onConfirm={async () => { + const response = await userAPI.RemoveUser(record.id!); + if (response.data === true) { + message.success('删除成功!'); + actionRef.current?.reload(); + } else { + message.error(response.msg || '删除失败'); + } + }} + onCancel={() => { + message.info('已取消删除'); + }} + okText="确认" + cancelText="关闭" + > + + ), }, @@ -239,17 +191,12 @@ const User: React.FC = () => { const onAddPerson = () => { setCurrentPerson({ - phone: '', - joinDate: '', - outDate: '', - idCard: '', - stutas: 1, - tB_RoleId: '', + status: 1, + roleId: '', gender: 1, id: '', sort: 1, - name: '', - iCCard: '' + name: '' }); form.resetFields(); setIsPersonDetailVisible(true); @@ -266,14 +213,18 @@ const User: React.FC = () => { message.error(response.msg || '获取角色列表失败'); } } - + useEffect(() => { + if (isPersonDetailVisible) { + onFetchRoleList(); + } + }, [isPersonDetailVisible]) /** * 新增/更新人员信息 */ const onFinishPerson = async (user: UserTypes.PersonnelType) => { if (user.id) { const response = await userAPI.ModifyUser(user); - if (response.data===true) { + if (response.data === true) { message.success('更新用户信息成功!'); setIsPersonDetailVisible(false); } else { @@ -289,7 +240,7 @@ const User: React.FC = () => { } } actionRef.current?.reload(); - onFetchRoleList(); + } /** * 绑定用户账户 @@ -307,7 +258,7 @@ const User: React.FC = () => { } } - + useEffect(() => { onFetchRoleList(); @@ -321,8 +272,7 @@ const User: React.FC = () => { cardBordered request={async (params = {}) => { const response = await userAPI.GetUserPagedList({ - keyword: params.name, - joinDate: params.joinDate, + name: params.name, status: params.status, pageIndex: params.current || 1, pageSize: params.pageSize || 10, @@ -369,14 +319,6 @@ const User: React.FC = () => { - - - - { - - - - - 在职 - 出差 - 离职 + 在职 + 出差 + 离职 - - - - - - - -