From 483b15c013e01647cf12f50602e4cc2374596733 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=87=AA=E5=B8=A6=E5=A4=A7=E4=BD=AC=E6=B0=94=E5=9C=BA?=
<188633308@qq.com>
Date: Tue, 1 Jun 2021 10:54:07 +0800
Subject: [PATCH] =?UTF-8?q?update=20=E5=AE=8C=E6=88=90=E7=89=87=E5=8C=BA?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Enum/{ZoneRole.cs => HouseManagerRole.cs} | 17 +-
Api/Ewide.Application/Ewide.Application.xml | 19 +-
.../HouseMember/HouseMemberService.cs | 4 +-
.../HouseSelector/HouseSelectorService.cs | 28 +-
.../HouseSafety/HouseZone/HouseZoneService.cs | 67 +++-
Api/Ewide.Core/Ewide.Core.xml | 59 +++-
Api/Ewide.Core/Extension/PageExtensions.cs | 2 +-
Api/Ewide.Core/Service/Org/Dto/OrgTreeNode.cs | 5 +
Api/Ewide.Core/Service/Org/SysOrgService.cs | 21 +-
.../business/houseSafety/houseZone.js | 4 +-
Web/src/pages/business/house/project/form.vue | 69 +++--
Web/src/pages/business/house/zone/form.vue | 221 ++++++++++++++
Web/src/pages/business/house/zone/index.vue | 286 ++++++++++++++++++
Web/src/pages/system/menu/form.vue | 2 +-
Web/src/util/format/index.js | 19 ++
Web/src/views/main/_layout/header/index.vue | 4 +-
Web/src/views/main/_layout/header/user.js | 4 +-
17 files changed, 756 insertions(+), 75 deletions(-)
rename Api/Ewide.Application/Enum/{ZoneRole.cs => HouseManagerRole.cs} (53%)
create mode 100644 Web/src/pages/business/house/zone/form.vue
create mode 100644 Web/src/pages/business/house/zone/index.vue
create mode 100644 Web/src/util/format/index.js
diff --git a/Api/Ewide.Application/Enum/ZoneRole.cs b/Api/Ewide.Application/Enum/HouseManagerRole.cs
similarity index 53%
rename from Api/Ewide.Application/Enum/ZoneRole.cs
rename to Api/Ewide.Application/Enum/HouseManagerRole.cs
index 5085b8f..bb0909b 100644
--- a/Api/Ewide.Application/Enum/ZoneRole.cs
+++ b/Api/Ewide.Application/Enum/HouseManagerRole.cs
@@ -6,8 +6,23 @@ using System.Threading.Tasks;
namespace Ewide.Application
{
- public enum ZoneRole
+ public enum HouseManagerRole
{
+ ///
+ /// 市住建部门
+ ///
+ CityManager,
+
+ ///
+ /// 区住建部门
+ ///
+ AreaManager,
+
+ ///
+ /// 街道管理员
+ ///
+ RoadManager,
+
///
/// 片区监管员
///
diff --git a/Api/Ewide.Application/Ewide.Application.xml b/Api/Ewide.Application/Ewide.Application.xml
index b42b0bd..140f79c 100644
--- a/Api/Ewide.Application/Ewide.Application.xml
+++ b/Api/Ewide.Application/Ewide.Application.xml
@@ -359,12 +359,27 @@
单位联系人电话
-
+
+
+ 市住建部门
+
+
+
+
+ 区住建部门
+
+
+
+
+ 街道管理员
+
+
+
片区监管员
-
+
房屋安全管理员
diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseMember/HouseMemberService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseMember/HouseMemberService.cs
index 1dc5c2e..ad44a3e 100644
--- a/Api/Ewide.Application/Service/HouseSafety/HouseMember/HouseMemberService.cs
+++ b/Api/Ewide.Application/Service/HouseSafety/HouseMember/HouseMemberService.cs
@@ -265,7 +265,7 @@ WHERE 1=1";
var roleIds = await _sysUserRoleRep.DetachedEntities.Where(p => userIds.Contains(p.SysUserId)).Select(p => p.SysRoleId).ToListAsync();
var _sysRoleRep = Db.GetRepository();
- var isExistZoneManager = await _sysRoleRep.DetachedEntities.AnyAsync(p => roleIds.Contains(p.Id) && p.Code == System.Enum.GetName(ZoneRole.ZoneManager).ToUnderScoreCase());
+ var isExistZoneManager = await _sysRoleRep.DetachedEntities.AnyAsync(p => roleIds.Contains(p.Id) && p.Code == System.Enum.GetName(HouseManagerRole.ZoneManager).ToUnderScoreCase());
// 存在片区监管员,返回安全员, 否则返回监管员
if (isExistZoneManager)
{
@@ -282,7 +282,7 @@ WHERE 1=1";
[NonAction]
private async Task> GetRoleRange()
{
- var codes = System.Enum.GetNames(typeof(ZoneRole)).Select(p => p.ToUnderScoreCase());
+ var codes = System.Enum.GetNames(typeof(HouseManagerRole)).Select(p => p.ToUnderScoreCase());
var _sysRoleRep = Db.GetRepository();
var roles = await _sysRoleRep.DetachedEntities.Where(p => codes.Contains(p.Code)).ToListAsync();
diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs
index a1d2a8d..70efcb5 100644
--- a/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs
+++ b/Api/Ewide.Application/Service/HouseSafety/HouseSelector/HouseSelectorService.cs
@@ -55,15 +55,13 @@ LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
LEFT JOIN bs_house_member_relation HM ON HC.Id = HM.HouseCodeId
INNER JOIN (SELECT * FROM sys_emp WHERE Id = @UserId) E ON HC.ZoneId = E.OrgId
-WHERE 1=1
- AND HM.Id IS NULL
- AND HC.Address LIKE @Address
- AND HC.HouseCode LIKE @HouseCode";
- return await _dapperRep.QueryPageData(sql, input, param: new
+WHERE HM.Id IS NULL";
+ return await _dapperRep.QueryPageDataDynamic(sql, input, param: new
{
- input.UserId,
- Address = "%" + input.Address + "%",
- HouseCode = "%" + input.HouseCode + "%"
+ input.UserId
+ }, filterFields: new[] {
+ nameof(BsHouseCode.Address) ,
+ nameof(BsHouseCode.CreatedTime)
});
}
@@ -82,15 +80,13 @@ LEFT JOIN bs_house_projectinfo Proj ON Proj.Id=HC.ProjectId
LEFT JOIN sys_area_code CA ON CA.Code = Proj.AreaCode
LEFT JOIN sys_area_code RA ON RA.AdCode = SUBSTR(CA.AdCode,1,9)
LEFT JOIN sys_area_code AA ON AA.AdCode = SUBSTR(CA.AdCode,1,6)
-INNER JOIN (SELECT * FROM bs_house_member_relation WHERE SysUserId = @UserId) HM ON HC.Id = HM.HouseCodeId
-WHERE 1=1
- AND HC.Address LIKE @Address
- AND HC.HouseCode LIKE @HouseCode";
- return await _dapperRep.QueryPageData(sql, input, param: new
+INNER JOIN (SELECT * FROM bs_house_member_relation WHERE SysUserId = @UserId) HM ON HC.Id = HM.HouseCodeId";
+ return await _dapperRep.QueryPageDataDynamic(sql, input, param: new
{
- input.UserId,
- Address = "%" + input.Address + "%",
- HouseCode = "%" + input.HouseCode + "%"
+ input.UserId
+ }, filterFields: new[] {
+ nameof(BsHouseCode.Address) ,
+ nameof(BsHouseCode.CreatedTime)
});
}
diff --git a/Api/Ewide.Application/Service/HouseSafety/HouseZone/HouseZoneService.cs b/Api/Ewide.Application/Service/HouseSafety/HouseZone/HouseZoneService.cs
index 966738c..88a09a5 100644
--- a/Api/Ewide.Application/Service/HouseSafety/HouseZone/HouseZoneService.cs
+++ b/Api/Ewide.Application/Service/HouseSafety/HouseZone/HouseZoneService.cs
@@ -1,10 +1,12 @@
using Ewide.Core;
+using Ewide.Core.Service;
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
@@ -18,15 +20,22 @@ namespace Ewide.Application.Service
[ApiDescriptionSettings(Name = "HouseZone", Order = 180)]
public class HouseZoneService : IHouseZoneService, IDynamicApiController, ITransient
{
+ private readonly IUserManager _userManager;
private readonly IRepository _sysOrgRep;
private readonly IRepository _sysEmpRep;
+ private readonly ISysOrgService _sysOrgService;
+
public HouseZoneService(
- IRepository sysOrgRep,
- IRepository sysEmpRep
+ IUserManager userManager,
+ IRepository sysOrgRep,
+ IRepository sysEmpRep,
+ ISysOrgService sysOrgService
)
{
+ _userManager = userManager;
_sysOrgRep = sysOrgRep;
_sysEmpRep = sysEmpRep;
+ _sysOrgService = sysOrgService;
}
///
@@ -57,7 +66,7 @@ namespace Ewide.Application.Service
///
///
///
- [HttpGet("houseZone/getByUser")]
+ [HttpGet("/houseZone/getByUser")]
public async Task GetZoneByUser([FromQuery][Required(ErrorMessage = "用户Id不能为空")] string userId)
{
var data = await _sysEmpRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == userId);
@@ -66,5 +75,57 @@ namespace Ewide.Application.Service
if(org == null) throw Oops.Oh("用户不在片区中");
return org.Id;
}
+
+ [HttpGet("/houseZone/autoIncrement")]
+ public async Task AutoIncrement([FromQuery] string code)
+ {
+ var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.AreaCode == code);
+ if (road == null) throw Oops.Oh("组织机构错误");
+ return await AutoIncrement(road);
+ }
+
+ [NonAction]
+ public async Task AutoIncrement(SysOrg road)
+ {
+ var maxZone = (await _sysOrgRep.DetachedEntities.Where(p => p.Pid == road.Id && p.Type == (int)OrgType.片区).MaxAsync(p => p.Code)) ?? "000";
+ return Convert.ToInt32(maxZone[^3..]) + 1;
+ }
+
+ [HttpPost("/houseZone/add")]
+ public async Task AddZone(AddOrgInput input)
+ {
+ /*
+ * 区县市限定所属区域/上级机构是否为当前区
+ * 街道自动获取所属区域/上级机构
+ * 自动生成唯一编码, 街道Code+三位编号
+ *
+ * 机构类型默认为片区
+ */
+
+ var org = await _userManager.GetUserOrgInfo();
+
+ var areaManager = Enum.GetName(HouseManagerRole.AreaManager).ToUnderScoreCase();
+ var roadManager = Enum.GetName(HouseManagerRole.RoadManager).ToUnderScoreCase();
+ var roles = await _userManager.GetUserRoleList();
+ if (roles.Any(p => p.Code == areaManager))
+ {
+ var road = await _sysOrgRep.DetachedEntities.FirstOrDefaultAsync(p => p.AreaCode == input.AreaCode);
+ if (!road.Pids.Contains(org.Id)) throw Oops.Oh("组织机构错误");
+
+ input.Pid = road.Id;
+ input.Code = road.Code + (await AutoIncrement(road)).ToString().PadLeft(3, '0');
+ }
+ else if (roles.Any(p => p.Code == roadManager))
+ {
+ input.Pid = org.Id;
+ input.AreaCode = org.AreaCode;
+
+ input.Code = org.Code + (await AutoIncrement(org)).ToString().PadLeft(3, '0');
+ }
+
+ input.Type = (int)OrgType.片区;
+
+ await _sysOrgService.AddOrg(input);
+ }
}
}
diff --git a/Api/Ewide.Core/Ewide.Core.xml b/Api/Ewide.Core/Ewide.Core.xml
index c2cc3e0..7d593bf 100644
--- a/Api/Ewide.Core/Ewide.Core.xml
+++ b/Api/Ewide.Core/Ewide.Core.xml
@@ -2734,12 +2734,17 @@
用户管理
-
+
获取用户信息
-
+
+
+
+
+ 获取用户信息
+
@@ -2749,6 +2754,51 @@
+
+
+ 获取用户员工信息
+
+
+
+
+
+ 获取用户部门信息
+
+
+
+
+
+
+ 获取用户部门信息
+
+
+
+
+
+ 获取用户角色Id列表
+
+
+
+
+
+
+ 获取用户角色Id列表
+
+
+
+
+
+ 获取用户角色列表
+
+
+
+
+
+
+ 获取用户角色列表
+
+
+
OAuth配置---此结构方便拓展
@@ -5607,6 +5657,11 @@
值
+
+
+ 类型
+
+
排序,越小优先级越高
diff --git a/Api/Ewide.Core/Extension/PageExtensions.cs b/Api/Ewide.Core/Extension/PageExtensions.cs
index 74c9d40..a47f185 100644
--- a/Api/Ewide.Core/Extension/PageExtensions.cs
+++ b/Api/Ewide.Core/Extension/PageExtensions.cs
@@ -33,7 +33,7 @@ namespace Ewide.Core.Extension
var hasSort = type.GetProperty("Sort") != null;
var hasCreatedTime = type.GetProperty("CreatedTime") != null;
- var defaultField = hasCreatedTime ? "CreatedTime" : hasSort ? "Sort" : hasId ? "Id" : "";
+ var defaultField = hasSort ? "Sort" : hasCreatedTime ? "CreatedTime" : hasId ? "Id" : "";
// 排序优先级 创建时间->序号->ID
var orderStr = string.IsNullOrEmpty(defaultField) ? "" : defaultField + (descSort ? " Desc" : " Asc");
diff --git a/Api/Ewide.Core/Service/Org/Dto/OrgTreeNode.cs b/Api/Ewide.Core/Service/Org/Dto/OrgTreeNode.cs
index 650f34b..279abe9 100644
--- a/Api/Ewide.Core/Service/Org/Dto/OrgTreeNode.cs
+++ b/Api/Ewide.Core/Service/Org/Dto/OrgTreeNode.cs
@@ -28,6 +28,11 @@ namespace Ewide.Core.Service
///
public string Value { get; set; }
+ ///
+ /// 类型
+ ///
+ public int Type { get; set; }
+
///
/// 排序,越小优先级越高
///
diff --git a/Api/Ewide.Core/Service/Org/SysOrgService.cs b/Api/Ewide.Core/Service/Org/SysOrgService.cs
index ee7be0e..54052b3 100644
--- a/Api/Ewide.Core/Service/Org/SysOrgService.cs
+++ b/Api/Ewide.Core/Service/Org/SysOrgService.cs
@@ -125,12 +125,10 @@ namespace Ewide.Core.Service
[HttpPost("/sysOrg/add")]
public async Task AddOrg(AddOrgInput input)
{
- if (!string.IsNullOrEmpty(input.Code))
- {
- var isExist = await _sysOrgRep.DetachedEntities.AnyAsync(u => u.Code == input.Code);
- if (isExist)
- throw Oops.Oh(ErrorCode.D2002);
- }
+ var isExist = await _sysOrgRep.DetachedEntities
+ .AnyAsync(u => (u.Pid == input.Pid && u.Name == input.Name) || (!string.IsNullOrEmpty(input.Code) && u.Code == input.Code));
+ if (isExist)
+ throw Oops.Oh(ErrorCode.D2002);
if (!_userManager.SuperAdmin)
{
@@ -239,12 +237,10 @@ namespace Ewide.Core.Service
if (!_userManager.SuperAdmin && (dataScopes.Count < 1 || !dataScopes.Contains(sysOrg.Id)))
throw Oops.Oh(ErrorCode.D2003);
- if (!string.IsNullOrEmpty(input.Code))
- {
- var isExist = await _sysOrgRep.DetachedEntities.AnyAsync(u => u.Code == input.Code && u.Id != sysOrg.Id);
- if (isExist)
- throw Oops.Oh(ErrorCode.D2002);
- }
+ var isExist = await _sysOrgRep.DetachedEntities
+ .AnyAsync(u => ((u.Pid == input.Pid && u.Name == input.Name) || (!string.IsNullOrEmpty(input.Code) && u.Code == input.Code)) && u.Id != sysOrg.Id);
+ if (isExist)
+ throw Oops.Oh(ErrorCode.D2002);
// 如果名称有变化,则修改对应员工的机构相关信息
if (!sysOrg.Name.Equals(input.Name))
@@ -309,6 +305,7 @@ namespace Ewide.Core.Service
Id = u.Id,
ParentId = u.Pid,
Title = u.Name,
+ Type = u.Type,
Value = u.Id.ToString(),
Weight = u.Sort
}).ToListAsync();
diff --git a/Web/src/common/api/requests/business/houseSafety/houseZone.js b/Web/src/common/api/requests/business/houseSafety/houseZone.js
index 9e90e3f..0406739 100644
--- a/Web/src/common/api/requests/business/houseSafety/houseZone.js
+++ b/Web/src/common/api/requests/business/houseSafety/houseZone.js
@@ -1,3 +1,5 @@
export default {
- houseZoneList: '/houseZone/list'
+ houseZoneList: '/houseZone/list',
+ houseZoneAutoIncrement: '/houseZone/autoIncrement',
+ houseZoneAdd: ['/houseZone/add', 'post']
}
\ No newline at end of file
diff --git a/Web/src/pages/business/house/project/form.vue b/Web/src/pages/business/house/project/form.vue
index 1054def..8689ece 100644
--- a/Web/src/pages/business/house/project/form.vue
+++ b/Web/src/pages/business/house/project/form.vue
@@ -11,25 +11,43 @@
@@ -37,6 +55,8 @@
\ No newline at end of file
diff --git a/Web/src/pages/business/house/zone/index.vue b/Web/src/pages/business/house/zone/index.vue
new file mode 100644
index 0000000..27b4db5
--- /dev/null
+++ b/Web/src/pages/business/house/zone/index.vue
@@ -0,0 +1,286 @@
+
+
+
+
+
+
+
+
+
+
+
+ 新增片区
+
+
+
+
+
+
+
+ 编辑
+
+
+
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Web/src/pages/system/menu/form.vue b/Web/src/pages/system/menu/form.vue
index 1697326..16b8c6a 100644
--- a/Web/src/pages/system/menu/form.vue
+++ b/Web/src/pages/system/menu/form.vue
@@ -102,7 +102,7 @@
-
+
diff --git a/Web/src/util/format/index.js b/Web/src/util/format/index.js
new file mode 100644
index 0000000..10e7281
--- /dev/null
+++ b/Web/src/util/format/index.js
@@ -0,0 +1,19 @@
+export const numberToChinese = (val) => {
+ const num = parseInt(val)
+ const changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
+ const unit = ['', '十', '百', '千', '万']
+ const getWan = (temp) => {
+ const strArr = temp.toString().split('').reverse()
+ let newNum = ''
+ for (var i = 0; i < strArr.length; i++) {
+ newNum = (i == 0 && strArr[i] == 0 ? '' : i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? '' : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i])) + newNum
+ }
+ return newNum
+ }
+ const overWan = Math.floor(num / 10000)
+ let noWan = num % 10000
+ if (noWan.toString().length < 4) noWan = '0' + noWan
+
+ const chinanum = overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(num)
+ return chinanum
+}
\ No newline at end of file
diff --git a/Web/src/views/main/_layout/header/index.vue b/Web/src/views/main/_layout/header/index.vue
index d51553d..06fd340 100644
--- a/Web/src/views/main/_layout/header/index.vue
+++ b/Web/src/views/main/_layout/header/index.vue
@@ -13,7 +13,6 @@
@@ -36,7 +36,6 @@
{
- doLogout()
+ onOk: async () => {
+ await doLogout()
},
onCancel() {
}