修改 帳號管理、公司管理
This commit is contained in:
parent
9953e53f10
commit
a4fa913713
@ -80,7 +80,7 @@ namespace SolarPower.Controllers
|
||||
//if(mySimpleCompany.Id == 1)
|
||||
//{
|
||||
company.Function = @"
|
||||
<a href='javascript:;' class='btn btn-success btn-pills waves-effect waves-themed' data-toggle='modal' data-target='#companyrule'>權限池</a>
|
||||
<a href='javascript:;' class='btn btn-success btn-pills waves-effect waves-themed company-auth-btn'>權限池</a>
|
||||
<button type='button' class='btn btn-primary btn-pills waves-effect waves-themed edit-btn'>修改</button>
|
||||
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'>刪除</button>";
|
||||
//}
|
||||
@ -199,7 +199,7 @@ namespace SolarPower.Controllers
|
||||
Phone = post.Phone,
|
||||
Address = post.Address,
|
||||
RegisterUpperLimit= post.RegisterUpperLimit,
|
||||
CreatedBy = mySimpleUser.Id
|
||||
CreatedBy = myUser.Id
|
||||
};
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
@ -239,7 +239,7 @@ namespace SolarPower.Controllers
|
||||
Phone = post.Phone,
|
||||
Address = post.Address,
|
||||
RegisterUpperLimit = post.RegisterUpperLimit,
|
||||
UpdatedBy = mySimpleUser.Id,
|
||||
UpdatedBy = myUser.Id,
|
||||
};
|
||||
|
||||
|
||||
@ -311,5 +311,89 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得公司權限池
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> GetCompanyAuthByCompanyId(int id)
|
||||
{
|
||||
ApiResult<List<CompanyAuth>> apiResult = new ApiResult<List<CompanyAuth>>();
|
||||
|
||||
int totalRecords = 0; //總資料筆數
|
||||
int recFilter = 0; //過濾後資料筆數
|
||||
|
||||
List<CompanyAuth> companyAuths = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
companyAuths = await companyRepository.GetCompanyAuthByCompanyId(id);
|
||||
|
||||
totalRecords = companyAuths.Count();
|
||||
recFilter = companyAuths.Count();
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = companyAuths;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
var result = Json(new
|
||||
{
|
||||
recordsTotal = totalRecords,
|
||||
recordsFiltered = recFilter,
|
||||
data = apiResult
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得該公司剩餘可註冊的人數
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<int>> GetRemainingRegisterNumber(int id)
|
||||
{
|
||||
ApiResult<int> apiResult = new ApiResult<int>();
|
||||
|
||||
Company company = null;
|
||||
|
||||
try
|
||||
{
|
||||
company = await companyRepository.GetOneCompany(id);
|
||||
|
||||
if (company == null)
|
||||
{
|
||||
apiResult.Code = "9996";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
var registerNumber = await companyRepository.GetRegisterNumberByCompanyId(id);
|
||||
|
||||
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
apiResult.Data = company.RegisterUpperLimit - registerNumber;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ namespace SolarPower.Controllers
|
||||
private ICompanyRepository companyRepository => HttpContext?.RequestServices.GetService<ICompanyRepository>();
|
||||
private IOperatorLogRepository operatorLogRepository => HttpContext?.RequestServices.GetService<IOperatorLogRepository>();
|
||||
|
||||
protected SimpleUser mySimpleUser = null;
|
||||
protected MyUser myUser = null;
|
||||
protected SimpleCompany mySimpleCompany = null;
|
||||
public string controllerName;
|
||||
public string actionName;
|
||||
@ -59,10 +59,11 @@ namespace SolarPower.Controllers
|
||||
return;
|
||||
}
|
||||
|
||||
mySimpleUser = userRepository.GetOneNormalSimpleUserByAccount(myAccount);
|
||||
mySimpleCompany = companyRepository.GetOneNormalSimpleCompanyById(mySimpleUser.CompanyId);
|
||||
//取得當前登入使用者資訊
|
||||
myUser = userRepository.GetMyUserInfoByAccount(myAccount);
|
||||
myUser.Company = companyRepository.GetMyCompanyInfoById(myUser.CompanyId);
|
||||
|
||||
ViewBag.systemAdminName = mySimpleUser.Name;
|
||||
ViewBag.myUser = myUser;
|
||||
|
||||
#region 記錄人員操作紀錄
|
||||
var content = JsonConvert.SerializeObject(filterContext.ActionArguments);
|
||||
@ -72,7 +73,7 @@ namespace SolarPower.Controllers
|
||||
ControllerName = controllerName,
|
||||
ActionName = actionName,
|
||||
Parameter = content.CompareTo("{}") == 0? null : content,
|
||||
CreatedBy = mySimpleUser.Id,
|
||||
CreatedBy = myUser.Id,
|
||||
};
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
|
||||
@ -47,5 +47,440 @@ namespace SolarPower.Controllers
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色管理列表
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> RoleList(PostRoleFilter post)
|
||||
{
|
||||
ApiResult<List<RoleDateTable>> apiResult = new ApiResult<List<RoleDateTable>>();
|
||||
|
||||
int totalRecords = 0; //總資料筆數
|
||||
int recFilter = 0; //過濾後資料筆數
|
||||
|
||||
List<RoleDateTable> roles = null;
|
||||
|
||||
try
|
||||
{
|
||||
roles = await roleRepository.GetAllByFilterAsync(post);
|
||||
totalRecords = roles.Count();
|
||||
recFilter = roles.Count();
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = roles;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
var result = Json(new
|
||||
{
|
||||
recordsTotal = totalRecords,
|
||||
recordsFiltered = recFilter,
|
||||
data = apiResult
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得單一使用者
|
||||
/// </summary>
|
||||
/// <param name="guid"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<Role>> GetOneRole(int id)
|
||||
{
|
||||
ApiResult<Role> apiResult = new ApiResult<Role>();
|
||||
|
||||
Role role = null;
|
||||
|
||||
try
|
||||
{
|
||||
role = await roleRepository.GetOneRoleAsync(id);
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
apiResult.Code = "9994";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = role;
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增 / 修改 公司角色
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> SaveRole(PostRole post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
Role role = null;
|
||||
|
||||
try
|
||||
{
|
||||
role = await roleRepository.GetOneRoleAsync(post.Id);
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
|
||||
if (post.Id != 0)
|
||||
{
|
||||
apiResult.Code = "9994";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
#region 新增公司角色
|
||||
EDFunction edFunction = new EDFunction();
|
||||
|
||||
role = new Role()
|
||||
{
|
||||
CompanyId = post.SelectedCompanyId,
|
||||
Name = post.Name,
|
||||
Layer = 3,
|
||||
CreatedBy = myUser.Id,
|
||||
};
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"CompanyId",
|
||||
"Name",
|
||||
"Layer",
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await roleRepository.AddAsync(role, properties);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
#region 修改使用者
|
||||
UpdateRole update = new UpdateRole()
|
||||
{
|
||||
Id = post.Id,
|
||||
Name = post.Name,
|
||||
UpdatedBy = myUser.Id,
|
||||
};
|
||||
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"Name",
|
||||
"UpdatedBy",
|
||||
};
|
||||
|
||||
await roleRepository.UpdateRoleAsync(update, properties);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除單一公司角色
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> DeleteOneRole(int id)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
Role role = null;
|
||||
|
||||
try
|
||||
{
|
||||
role = await roleRepository.GetOneRoleAsync(id);
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
apiResult.Code = "9994";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await roleRepository.DeleteOne(role.Id);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得公司擁有的權限池
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> GetCompanyAuthPageList(int companyId)
|
||||
{
|
||||
ApiResult<List<CompanyAuthPage>> apiResult = new ApiResult<List<CompanyAuthPage>>();
|
||||
|
||||
int totalRecords = 0; //總資料筆數
|
||||
int recFilter = 0; //過濾後資料筆數
|
||||
|
||||
List<CompanyAuthPage> companyAuthPages = null;
|
||||
|
||||
try
|
||||
{
|
||||
companyAuthPages = await roleRepository.GetAllCompanyAuthPageAsync(companyId);
|
||||
totalRecords = companyAuthPages.Count();
|
||||
recFilter = companyAuthPages.Count();
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = companyAuthPages;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + companyId);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
var result = Json(new
|
||||
{
|
||||
recordsTotal = totalRecords,
|
||||
recordsFiltered = recFilter,
|
||||
data = apiResult
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 角色權限管理列表
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> RoleAuthList(PostRoleAuthFilter post)
|
||||
{
|
||||
ApiResult<List<RoleAuthDataTable>> apiResult = new ApiResult<List<RoleAuthDataTable>>();
|
||||
|
||||
int totalRecords = 0; //總資料筆數
|
||||
int recFilter = 0; //過濾後資料筆數
|
||||
|
||||
List<RoleAuthDataTable> roleAuths = null;
|
||||
|
||||
try
|
||||
{
|
||||
roleAuths = await roleRepository.GetAllAuthByRoleIdAsync(post.SelectedRoleId);
|
||||
totalRecords = roleAuths.Count();
|
||||
recFilter = roleAuths.Count();
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = roleAuths;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
var result = Json(new
|
||||
{
|
||||
recordsTotal = totalRecords,
|
||||
recordsFiltered = recFilter,
|
||||
data = apiResult
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得該公司角色尚未加入的權限
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ActionResult> GetRoleNotAuthPageList(PostRoleAuthFilter post)
|
||||
{
|
||||
ApiResult<List<AuthPage>> apiResult = new ApiResult<List<AuthPage>>();
|
||||
|
||||
int totalRecords = 0; //總資料筆數
|
||||
int recFilter = 0; //過濾後資料筆數
|
||||
|
||||
List<AuthPage> roleAuths = null;
|
||||
|
||||
try
|
||||
{
|
||||
roleAuths = await roleRepository.GetRoleNotAuthPageAsync(post);
|
||||
totalRecords = roleAuths.Count();
|
||||
recFilter = roleAuths.Count();
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = roleAuths;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
var result = Json(new
|
||||
{
|
||||
recordsTotal = totalRecords,
|
||||
recordsFiltered = recFilter,
|
||||
data = apiResult
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 儲存公司角色的權限
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> SaveRoleAuth(PostRoleAuth post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
Role role = null;
|
||||
|
||||
try
|
||||
{
|
||||
role = await roleRepository.GetOneRoleAsync(post.SelectedRoleId);
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
apiResult.Code = "9994";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
List<RoleAuth> roleAuths = new List<RoleAuth>();
|
||||
|
||||
foreach (var checkAuth in post.CheckAuths)
|
||||
{
|
||||
RoleAuth roleAuth = new RoleAuth();
|
||||
roleAuth.Id = role.Id;
|
||||
roleAuth.AuthCode = checkAuth;
|
||||
roleAuth.CreatedBy = myUser.Id;
|
||||
|
||||
roleAuths.Add(roleAuth);
|
||||
}
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"AuthCode",
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await roleRepository.AddRoleAuthAsync(roleAuths, properties);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<string>> DeleteOneRoleAuth(PostDeleteRoleAuth post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
Role role = null;
|
||||
|
||||
try
|
||||
{
|
||||
role = await roleRepository.GetOneRoleAsync(post.RoleId);
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
apiResult.Code = "9994";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await roleRepository.PurgeOneRoleAuthAsync(post.RoleId, post.AuthCode);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
var user = await userRepository.GetOneAsync(mySimpleUser.Id);
|
||||
var user = await userRepository.GetOneAsync(myUser.Id);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = user;
|
||||
@ -69,7 +69,7 @@ namespace SolarPower.Controllers
|
||||
User user = null;
|
||||
try
|
||||
{
|
||||
user = await userRepository.GetOneAsync(mySimpleUser.Id);
|
||||
user = await userRepository.GetOneAsync(myUser.Id);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
@ -83,7 +83,7 @@ namespace SolarPower.Controllers
|
||||
Name = post.Name,
|
||||
Email = post.Email,
|
||||
Phone = post.Phone,
|
||||
UpdatedBy = mySimpleUser.Id,
|
||||
UpdatedBy = myUser.Id,
|
||||
Id = user.Id
|
||||
};
|
||||
|
||||
@ -126,7 +126,7 @@ namespace SolarPower.Controllers
|
||||
User user = null;
|
||||
try
|
||||
{
|
||||
user = await userRepository.GetOneAsync(mySimpleUser.Id);
|
||||
user = await userRepository.GetOneAsync(myUser.Id);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
@ -154,7 +154,7 @@ namespace SolarPower.Controllers
|
||||
UpdatePassword update = new UpdatePassword()
|
||||
{
|
||||
Password = edFunction.GetSHA256Encryption(post.NewPassword),
|
||||
UpdatedBy = mySimpleUser.Id,
|
||||
UpdatedBy = myUser.Id,
|
||||
Id = user.Id
|
||||
};
|
||||
|
||||
@ -300,8 +300,9 @@ namespace SolarPower.Controllers
|
||||
Email = post.Email,
|
||||
Account = post.Account,
|
||||
Password = edFunction.GetSHA256Encryption(post.Account),
|
||||
RoleId = post.RoleId,
|
||||
Phone = post.Phone,
|
||||
CreatedBy = mySimpleUser.Id,
|
||||
CreatedBy = myUser.Id,
|
||||
};
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
@ -311,6 +312,7 @@ namespace SolarPower.Controllers
|
||||
"Email",
|
||||
"Account",
|
||||
"Password",
|
||||
"RoleId",
|
||||
"Phone",
|
||||
"CreatedBy",
|
||||
};
|
||||
@ -330,7 +332,7 @@ namespace SolarPower.Controllers
|
||||
Name = post.Name,
|
||||
Email = post.Email,
|
||||
Phone = post.Phone,
|
||||
UpdatedBy = mySimpleUser.Id,
|
||||
UpdatedBy = myUser.Id,
|
||||
};
|
||||
|
||||
|
||||
@ -338,7 +340,6 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
"Id",
|
||||
"Name",
|
||||
"Status",
|
||||
"Email",
|
||||
"Phone",
|
||||
"UpdatedBy",
|
||||
@ -364,7 +365,7 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除單一系統管理員
|
||||
/// 軟刪除單一使用者
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@ -80,4 +80,16 @@ namespace SolarPower.Models.Company
|
||||
public string Address { get; set; } //地址
|
||||
public int RegisterUpperLimit { get; set; } //註冊上限
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 公司權限池
|
||||
/// </summary>
|
||||
public class CompanyAuth
|
||||
{
|
||||
public string AuthCode { get; set; }
|
||||
public string MainName { get; set; }
|
||||
public string SubName { get; set; }
|
||||
public string ControlName { get; set; }
|
||||
public byte CheckAuth { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ namespace SolarPower.Models
|
||||
{
|
||||
{ "0000", "OK" },
|
||||
{ "0001", "傳入參數錯誤。" },
|
||||
{ "9994", "查無該公司角色"},
|
||||
{ "9995", "該統一編號已被使用。" },
|
||||
{ "9996", "查無該公司資訊。" },
|
||||
{ "9997", "帳號或密碼輸入錯誤。"},
|
||||
|
||||
@ -34,6 +34,12 @@ namespace SolarPower.Models
|
||||
public class MyUser
|
||||
{
|
||||
public int Id { get; set; } //編號
|
||||
public byte Status { get; set; } //狀態
|
||||
public string Name { get; set; } //姓名
|
||||
public byte IsGod { get; set; } //神級使用者
|
||||
public int CompanyId { get; set; } //公司編號
|
||||
public int RoleId { get; set; } //角色編號
|
||||
public string Email { get; set; }
|
||||
public MyCompany Company { get; set; } //公司資訊
|
||||
}
|
||||
|
||||
@ -42,6 +48,17 @@ namespace SolarPower.Models
|
||||
/// </summary>
|
||||
public class MyCompany
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public byte Status { get; set; } //狀態
|
||||
public string Name { get; set; } //名稱
|
||||
public string Logo { get; set; }
|
||||
}
|
||||
|
||||
//當前登入使用者的角色權限
|
||||
public class MyRole
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } //名稱
|
||||
public List<string> Auth { get; set; } //可操作頁面
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,15 @@ namespace SolarPower.Models.Role
|
||||
public byte Layer { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用者DataTable
|
||||
/// </summary>
|
||||
public class RoleDateTable : Role
|
||||
{
|
||||
public string CompanyName { get; set; }
|
||||
public string CreatorName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色下拉式選單
|
||||
/// </summary>
|
||||
@ -22,4 +31,84 @@ namespace SolarPower.Models.Role
|
||||
public string Text { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class PostRoleFilter
|
||||
{
|
||||
public int SelectedCompanyId { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class PostRole
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SelectedCompanyId { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateRole : Updated
|
||||
{
|
||||
public int SelectedCompanyId { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 賦予公司的權限池
|
||||
/// </summary>
|
||||
public class CompanyAuthPage
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int CompanyId { get; set; }
|
||||
public string AuthCode { get; set; }
|
||||
public string AuthPageMainName { get; set; }
|
||||
public string AuthPageSubName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色權限DataTable
|
||||
/// </summary>
|
||||
public class RoleAuth: Created
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string AuthCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色權限DataTable
|
||||
/// </summary>
|
||||
public class RoleAuthDataTable : RoleAuth
|
||||
{
|
||||
public string CompanyName { get; set; } //公司名稱
|
||||
public string RoleName { get; set; } //角色名稱
|
||||
public string AuthPageSubName { get; set; } //權限功能名稱
|
||||
public string CreatorName { get; set; } //建立者名稱
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色權限頁面搜尋條件
|
||||
/// </summary>
|
||||
public class PostRoleAuthFilter
|
||||
{
|
||||
public int SelectedCompanyId { get; set; }
|
||||
public int SelectedRoleId { get; set; }
|
||||
}
|
||||
|
||||
public class AuthPage
|
||||
{
|
||||
public string AuthCode { get; set; }
|
||||
public string MainName { get; set; }
|
||||
public string SubName { get; set; }
|
||||
}
|
||||
|
||||
public class PostRoleAuth
|
||||
{
|
||||
public int SelectedRoleId { get; set; }
|
||||
|
||||
public List<string> CheckAuths { get; set; }
|
||||
}
|
||||
|
||||
public class PostDeleteRoleAuth
|
||||
{
|
||||
public int RoleId { get; set; }
|
||||
public string AuthCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ namespace SolarPower.Models.User
|
||||
public string Password { get; set; } //密碼
|
||||
public string Email { get; set; } //信箱
|
||||
public string Phone { get; set; } //手機
|
||||
public int RoleId { get; set; } //角色編號
|
||||
public string Tel { get; set; } //市話
|
||||
}
|
||||
|
||||
@ -62,6 +63,7 @@ namespace SolarPower.Models.User
|
||||
public int CompanyId { get; set; } //公司編號
|
||||
public string Email { get; set; } //信箱
|
||||
public string Phone { get; set; } //手機
|
||||
public int RoleId { get; set; } //角色編號
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using Dapper;
|
||||
using SolarPower.Helper;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.Company;
|
||||
using SolarPower.Models.User;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -43,13 +45,13 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得狀態為正常的公司基本資料
|
||||
/// 取得當前使用者所在的公司資訊
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public SimpleCompany GetOneNormalSimpleCompanyById(int id)
|
||||
public MyCompany GetMyCompanyInfoById(int id)
|
||||
{
|
||||
SimpleCompany result;
|
||||
MyCompany result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
@ -57,7 +59,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var sql = $"SELECT * FROM {tableName} WHERE Deleted = 0 AND Status = @Status AND Id = @Id";
|
||||
|
||||
result = conn.QueryFirstOrDefault<SimpleCompany>(sql, new { Status = CompanyStatusEnum.Normal, Id = id });
|
||||
result = conn.QueryFirstOrDefault<MyCompany>(sql, new { Status = CompanyStatusEnum.Normal, Id = id });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -232,5 +234,64 @@ namespace SolarPower.Repository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得該公司的註冊人數
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> GetRegisterNumberByCompanyId(int companyId)
|
||||
{
|
||||
int result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT COUNT(*) FROM user WHERE Deleted = 0 AND Status = @Status AND CompanyId = @CompanyId";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<int>(sql, new { Status = UserStatusEnum.Normal, CompanyId = companyId });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<CompanyAuth>> GetCompanyAuthByCompanyId(int companyId)
|
||||
{
|
||||
List<CompanyAuth> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT
|
||||
ap.*,
|
||||
CASE WHEN cap_id.ComapnyId IS NOT NULL THEN 1 ELSE 0 END AS CheckAuth
|
||||
FROM auth_page ap
|
||||
LEFT JOIN (SELECT * FROM company_auth_page WHERE ComapnyId = @ComapnyId)
|
||||
cap_id ON ap.AuthCode = cap_id.AuthCode
|
||||
";
|
||||
|
||||
result = (await conn.QueryAsync<CompanyAuth>(sql, new { CompanyId = companyId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,6 +227,33 @@ namespace SolarPower.Repository.Implement
|
||||
return insertQuery.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 產生Insert語句,可選擇自己要加入資料表
|
||||
/// </summary>
|
||||
/// <param name="properties"></param>
|
||||
/// <param name="table_name">欲新增至目標資料表</param>
|
||||
/// <returns></returns>
|
||||
protected string GenerateInsertQueryWithCustomTable(List<string> properties, string table_name)
|
||||
{
|
||||
var insertQuery = new StringBuilder($"INSERT INTO {table_name} ");
|
||||
|
||||
insertQuery.Append("(");
|
||||
|
||||
properties.ForEach(prop => { insertQuery.Append($"{prop},"); });
|
||||
|
||||
insertQuery
|
||||
.Remove(insertQuery.Length - 1, 1)
|
||||
.Append(") VALUES (");
|
||||
|
||||
properties.ForEach(prop => { insertQuery.Append($"@{prop},"); });
|
||||
|
||||
insertQuery
|
||||
.Remove(insertQuery.Length - 1, 1)
|
||||
.Append(")");
|
||||
|
||||
return insertQuery.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 產生Update語句
|
||||
/// </summary>
|
||||
|
||||
@ -14,9 +14,14 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
public RoleRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
||||
{
|
||||
tableName = "Role";
|
||||
tableName = "role";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得下拉式公司角色選單,須為Deleted: 0
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<RoleSelectItemList>> GetRoleSelectOptionListAsync(int companyId)
|
||||
{
|
||||
List<RoleSelectItemList> result;
|
||||
@ -35,5 +40,265 @@ namespace SolarPower.Repository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得單一公司角色,須為Deleted: 0
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Role> GetOneRoleAsync(int id)
|
||||
{
|
||||
Role result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM {tableName} WHERE Deleted = 0 AND Id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<Role>(sql, new { Id = id });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過搜尋條件,查詢過濾後的使用者
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<RoleDateTable>> GetAllByFilterAsync(PostRoleFilter filter)
|
||||
{
|
||||
List<RoleDateTable> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT
|
||||
r.*,
|
||||
c.Name AS CompanyName,
|
||||
u.Name AS CreatorName
|
||||
FROM {tableName} r
|
||||
LEFT JOIN company c ON r.CompanyId = c.Id
|
||||
LEFT JOIN user u ON r.CreatedBy = u.Id
|
||||
WHERE r.Deleted = 0
|
||||
AND c.Deleted = 0
|
||||
AND r.CompanyId = @SelectedCompanyId";
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Name))
|
||||
{
|
||||
sql += @" AND Name LIKE CONCAT('%', @Name, '%')";
|
||||
}
|
||||
|
||||
result = (await conn.QueryAsync<RoleDateTable>(sql, filter)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改角色資料
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateRoleAsync(UpdateRole entity, List<string> properties)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = GenerateUpdateQuery(properties);
|
||||
|
||||
await conn.ExecuteAsync(sql, entity, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過角色編號,取得所有權限功能
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<RoleAuthDataTable>> GetAllAuthByRoleIdAsync(int roleId)
|
||||
{
|
||||
List<RoleAuthDataTable> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT
|
||||
ra.*,
|
||||
r.Name AS RoleName,
|
||||
c.Name AS CompanyName,
|
||||
u.Name AS CreatorName,
|
||||
ap.SubName AS AuthPageSubName
|
||||
FROM role_auth ra
|
||||
LEFT JOIN role r ON ra.Id = r.Id
|
||||
LEFT JOIN auth_page ap ON ra.AuthCode = ap.AuthCode
|
||||
LEFT JOIN user u ON ra.CreatedBy = u.Id
|
||||
LEFT JOIN company c ON r.CompanyId = c.Id
|
||||
WHERE r.Deleted = 0
|
||||
AND c.Deleted = 0
|
||||
AND r.Id = @SelectedRoleId";
|
||||
|
||||
result = (await conn.QueryAsync<RoleAuthDataTable>(sql, new { SelectedRoleId = roleId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得被賦予的權限池
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CompanyAuthPage>> GetAllCompanyAuthPageAsync(int companyId)
|
||||
{
|
||||
List<CompanyAuthPage> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT
|
||||
cap.*,
|
||||
ap.MainName AS AuthPageMainName,
|
||||
ap.SubName AS AuthPageSubName
|
||||
FROM company_auth_page cap
|
||||
LEFT JOIN auth_page ap ON cap.AuthCode = ap.AuthCode
|
||||
WHERE cap.CompanyId = @CompanyId";
|
||||
|
||||
result = (await conn.QueryAsync<CompanyAuthPage>(sql, new { CompanyId = companyId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查詢公司權限池裡面該角色尚未擁有的權限
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AuthPage>> GetRoleNotAuthPageAsync(PostRoleAuthFilter post)
|
||||
{
|
||||
List<AuthPage> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT ap2.AuthCode, ap2.MainName, ap2.SubName
|
||||
FROM
|
||||
(
|
||||
SELECT cap.ComapnyId, cap.AuthCode, ap.MainName, ap.SubName, ap.ControlName
|
||||
FROM company_auth_page cap
|
||||
LEFT JOIN auth_page ap ON cap.AuthCode = ap.AuthCode
|
||||
WHERE cap.ComapnyId = @CompanyId
|
||||
) ap2
|
||||
LEFT JOIN role_auth ra ON ap2.AuthCode = ra.AuthCode AND ra.Id = @RoleId
|
||||
WHERE ra.AuthCode IS NULL
|
||||
";
|
||||
|
||||
result = (await conn.QueryAsync<AuthPage>(sql, new { CompanyId = post.SelectedCompanyId, RoleId = post.SelectedRoleId})).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增角色權限
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddRoleAuthAsync(List<RoleAuth> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = $"INSERT INTO role_auth (Id, AuthCode, CreatedBy) VALUES (@Id, @AuthCode, @CreatedBy)";
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PurgeOneRoleAuthAsync(int roleId, string authCode)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"DELETE FROM role_auth WHERE Id = @RoleId AND AuthCode = @AuthCode";
|
||||
|
||||
await conn.ExecuteAsync(sql, new { RoleId = roleId, AuthCode = authCode }, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Dapper;
|
||||
using SolarPower.Helper;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.User;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
@ -109,9 +110,9 @@ namespace SolarPower.Repository.Implement
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public SimpleUser GetOneNormalSimpleUserByAccount(string account)
|
||||
public MyUser GetMyUserInfoByAccount(string account)
|
||||
{
|
||||
SimpleUser result;
|
||||
MyUser result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
@ -119,7 +120,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
var sql = $"SELECT * FROM {tableName} WHERE deleted = 0 AND status = @Status AND account = @Account";
|
||||
|
||||
result = conn.QueryFirstOrDefault<SimpleUser>(sql, new { Status = UserStatusEnum.Normal, Account = account });
|
||||
result = conn.QueryFirstOrDefault<MyUser>(sql, new { Status = UserStatusEnum.Normal, Account = account });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@ -254,7 +255,7 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
if (filter.SelectedCompanyId > 0)
|
||||
{
|
||||
sql += @" AND CompanyId = @SelectedCompanyId";
|
||||
sql += @" AND u.CompanyId = @SelectedCompanyId";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Name))
|
||||
@ -264,7 +265,7 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
if (filter.SelectedRoleId > 0)
|
||||
{
|
||||
sql += @" AND RoleId = @SelectedRoleId";
|
||||
sql += @" AND u.RoleId = @SelectedRoleId";
|
||||
}
|
||||
|
||||
result = (await conn.QueryAsync<UserDateTable>(sql, filter)).ToList();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using SolarPower.Models.Company;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.Company;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -10,11 +11,11 @@ namespace SolarPower.Repository.Interface
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 取得狀態為正常的公司
|
||||
/// 取得當前使用者所在的公司資訊
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
SimpleCompany GetOneNormalSimpleCompanyById(int id);
|
||||
MyCompany GetMyCompanyInfoById(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 修改公司資料
|
||||
@ -58,5 +59,19 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="taxIDNumber"></param>
|
||||
/// <returns></returns>
|
||||
Task<SimpleCompany> GetOneNormalSimpleCompanyByTaxIDNumber(string taxIDNumber);
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得該公司的註冊人數
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> GetRegisterNumberByCompanyId(int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得該公司的權限池
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<CompanyAuth>> GetCompanyAuthByCompanyId(int companyId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOne(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過Id,實際刪除單一筆資料
|
||||
/// </summary>
|
||||
|
||||
@ -14,5 +14,60 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<RoleSelectItemList>> GetRoleSelectOptionListAsync(int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 取得單一公司角色,須為Deleted: 0
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<Role> GetOneRoleAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過搜尋條件,查詢過濾後的角色
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<RoleDateTable>> GetAllByFilterAsync(PostRoleFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// 更新公司角色名稱
|
||||
/// </summary>
|
||||
/// <param name="update"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateRoleAsync(UpdateRole update, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 透過角色編號,取得所有權限功能
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<RoleAuthDataTable>> GetAllAuthByRoleIdAsync(int roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 透過公司編號,取得被賦予的權限池
|
||||
/// </summary>
|
||||
/// <param name="companyId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<CompanyAuthPage>> GetAllCompanyAuthPageAsync(int companyId);
|
||||
|
||||
/// <summary>
|
||||
/// 查詢公司權限池裡面該角色尚未擁有的權限
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<AuthPage>> GetRoleNotAuthPageAsync(PostRoleAuthFilter post);
|
||||
|
||||
/// <summary>
|
||||
/// 新增角色權限
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddRoleAuthAsync(List<RoleAuth> entity, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 實際刪除角色權限
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task PurgeOneRoleAuthAsync(int roleId, string authCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using SolarPower.Models.User;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.User;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -31,11 +32,11 @@ namespace SolarPower.Repository.Interface
|
||||
Task ChangePassword(string password, int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過Account,取得狀態為正常的使用者
|
||||
/// 透過Account,取得當前登入使用者資訊
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
SimpleUser GetOneNormalSimpleUserByAccount(string account);
|
||||
MyUser GetMyUserInfoByAccount(string account);
|
||||
|
||||
/// <summary>
|
||||
/// 取得單一使用者
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Logs\" />
|
||||
<Folder Include="wwwroot\upload\company_logo\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -132,7 +132,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!--/.公司資料-->
|
||||
|
||||
<!-- 公司權限池 -->
|
||||
<div class="modal fade" id="company-auth-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
@ -145,14 +145,17 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class="table table-bordered text-center">
|
||||
<tbody>
|
||||
<table id="company_auth_table" class="table table-bordered text-center">
|
||||
<thead>
|
||||
<thead class="thead-themed">
|
||||
<tr>
|
||||
<td>選擇</td>
|
||||
<td>編號</td>
|
||||
<td>功能大項</td>
|
||||
<td>功能名稱</td>
|
||||
<th>選擇</th>
|
||||
@*<th>編號</th>*@
|
||||
<th>功能大項</th>
|
||||
<th>功能名稱</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@ -164,10 +167,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.公司權限池 -->
|
||||
|
||||
@section Scripts{
|
||||
<script>
|
||||
var companyTable;
|
||||
var companyTable; var companyAuthTable;
|
||||
var selected_id = 0;
|
||||
|
||||
$(function () {
|
||||
@ -274,6 +278,92 @@
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 公司權限池列表 DataTable
|
||||
companyAuthTable = $("#company_auth_table").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
"deferLoading": 0,
|
||||
"serverSide": true,
|
||||
"order": [[1, "desc"]],
|
||||
"columns": [{
|
||||
"data": "authCode"
|
||||
}, {
|
||||
"data": "mainName"
|
||||
}, {
|
||||
"data": "subName"
|
||||
}],
|
||||
"columnDefs": [{
|
||||
'targets': 0,
|
||||
'searchable': false,
|
||||
'orderable': false,
|
||||
'className': 'dt-body-center',
|
||||
'render': function (data, type, full, meta) {
|
||||
var check_html = "";
|
||||
check_html += '<div class="custom-control custom-checkbox">';
|
||||
if (full.CheckAuth > 0) {
|
||||
check_html += '<input type="checkbox" class="custom-control-input" name="selectedAuthPage[]" id="auth-page-' + data + '" value="' + data + '" checked /> ';
|
||||
} else {
|
||||
check_html += '<input type="checkbox" class="custom-control-input" name="selectedAuthPage[]" id="auth-page-' + data + '" value="' + data + '" /> ';
|
||||
}
|
||||
check_html += '<label class="custom-control-label" for="auth-page-' + data + '" />';
|
||||
check_html += '</div>';
|
||||
return check_html;
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
"zeroRecords": "沒有符合的結果",
|
||||
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
||||
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
||||
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
||||
"infoPostFix": "",
|
||||
"search": "搜尋:",
|
||||
"paginate": {
|
||||
"first": "第一頁",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁",
|
||||
"last": "最後一頁"
|
||||
},
|
||||
"aria": {
|
||||
"sortAscending": ": 升冪排列",
|
||||
"sortDescending": ": 降冪排列"
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-authCode', data.authCode);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/Company/GetCompanyAuthByCompanyId",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.Id = selected_id;
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
data = rel.data.data;
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
this.data = [];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
});
|
||||
|
||||
//#region 搜尋公司列表
|
||||
@ -350,15 +440,10 @@
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code == "9999") {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
else if (rel.code == "9998") {
|
||||
toast_error(rel.msg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
$('#company-modal').modal('hide');
|
||||
@ -397,5 +482,16 @@
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 編輯公司權限池
|
||||
$('#company_table').on("click", "button.company-auth-btn", function () {
|
||||
|
||||
selected_id = $(this).parents('tr').attr('data-id');
|
||||
|
||||
companyAuthTable.ajax.reload();
|
||||
|
||||
$("#company-auth-modal").modal();
|
||||
});
|
||||
//#endregion
|
||||
</script>
|
||||
}
|
||||
@ -906,7 +906,7 @@
|
||||
<!-- Notifications Dropdown Menu -->
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link" data-toggle="dropdown" href="#">
|
||||
<i class="fas fa-user"></i> @ViewBag.systemAdminName
|
||||
<i class="fas fa-user"></i> @ViewBag.myUser.Name
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
|
||||
<a class="dropdown-item" id="btn-personal-info" href="javascript: void(0)" role="button">
|
||||
|
||||
@ -18,10 +18,10 @@
|
||||
<div class="panel-content">
|
||||
<div class="subheader">
|
||||
<h1 class="subheader-title">
|
||||
<img src="img/asus.png"> 華碩電腦
|
||||
<img src="img/asus.png" id="company-logo"><span id="company-name">華碩電腦</span>
|
||||
</h1>
|
||||
</div>
|
||||
<ul class="nav nav-tabs nav-tabs-clean" role="tablist">
|
||||
<ul class="nav nav-tabs nav-tabs-clean" id="tabs" role="tablist">
|
||||
<li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#tab-user-manager" role="tab">帳號管理</a></li>
|
||||
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-role-manager" role="tab">角色管理</a></li>
|
||||
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-role-auth" role="tab">角色權限</a></li>
|
||||
@ -199,11 +199,12 @@
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
var userTable;
|
||||
var selected_id = 0;
|
||||
var selected_company_id = 0;
|
||||
|
||||
var userTable; var roleTable; var roleAuthTable; var roleAuthNotJoinTable;
|
||||
var selected_id = 0, selected_role_id = 0, selected_company_id = 0;
|
||||
var selected_tab = "";
|
||||
$(function () {
|
||||
selected_tab = $('#tabs').find("li a.active").attr("href"); // 當前tab
|
||||
|
||||
//#region 預先載入公司下拉式選單select_option
|
||||
var url_company_select_option = "/Company/GetCompanySelectOptionList";
|
||||
$.get(url_company_select_option, function (rel) {
|
||||
@ -220,17 +221,64 @@
|
||||
|
||||
//預設查詢第一個
|
||||
$(".select_user_company").val($(".select_user_company option:first").val()).trigger('change');
|
||||
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 選擇公司角色下拉式選單select_option
|
||||
//#region 選擇公司後角色下拉式選單select_option
|
||||
$(".select_user_company").change(function () {
|
||||
|
||||
var select_option_with_tab = $(this).attr('data-tab');
|
||||
|
||||
if (selected_tab != select_option_with_tab) {
|
||||
//判斷是否為當前tab的 公司選單傳值被修改
|
||||
return;
|
||||
}
|
||||
|
||||
//變更其他tab裡面select_user_company的值
|
||||
switch (selected_tab) {
|
||||
case "#tab-user-manager":
|
||||
$("#select_company_role_roleManager_tab").val($(this).val()).trigger('change');
|
||||
$("#select_companyId_roleAuth_tab").val($(this).val()).trigger('change');
|
||||
break;
|
||||
case "#tab-role-manager":
|
||||
$("#select_user_company_userManager_tab").val($(this).val()).trigger('change');
|
||||
$("#select_companyId_roleAuth_tab").val($(this).val()).trigger('change');
|
||||
break;
|
||||
case "#tab-role-auth":
|
||||
$("#select_user_company_userManager_tab").val($(this).val()).trigger('change');
|
||||
$("#select_company_role_roleManager_tab").val($(this).val()).trigger('change');
|
||||
break;
|
||||
}
|
||||
|
||||
//查詢該公司的基本資料
|
||||
var url_company_info = "/Company/GetOneCompany"
|
||||
|
||||
var send_data = {
|
||||
Id: $(this).val()
|
||||
}
|
||||
|
||||
$.post(url_company_info, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
$("#company-logo").attr("src", rel.data.logo);
|
||||
$("#company-name").html(rel.data.name);
|
||||
|
||||
$("#company-modal").modal();
|
||||
}, 'json');
|
||||
|
||||
//更新當前剩餘可註冊使用者人數
|
||||
UpdateRegisterNumber($(this).val());
|
||||
|
||||
//查詢該公司的角色
|
||||
var url_company_role_select_option = "/Role/GetRoleSelectOptionList";
|
||||
|
||||
send_data = {
|
||||
CompanyId: $("#select_user_company_userManager_tab").val()
|
||||
CompanyId: $(this).val()
|
||||
}
|
||||
|
||||
$.get(url_company_role_select_option, send_data, function (rel) {
|
||||
@ -239,17 +287,27 @@
|
||||
return;
|
||||
}
|
||||
|
||||
$(".select_company_role").empty();
|
||||
$("#company_select").append($("<option />").val(0).text("全部"));
|
||||
//#region 帳號管理Tab - 角色下拉式選單(搜尋)
|
||||
if (rel.data.length > 0) {
|
||||
$("#select_company_role_userManager_tab").empty();
|
||||
$("#select_company_role_userManager_tab").append($("<option />").val(0).text("全部"));
|
||||
|
||||
$.each(rel.data, function (index, val) {
|
||||
$(".select_company_role").append($("<option />").val(val.value).text(val.text));
|
||||
$("#select_company_role_userManager_tab").append($("<option />").val(val.value).text(val.text));
|
||||
});
|
||||
|
||||
//預設查詢第一個
|
||||
$(".select_company_role").val($(".select_company_role option:first").val()).trigger('change');
|
||||
$("#select_company_role_userManager_tab").val($("#select_company_role_userManager_tab option:first").val()).trigger('change');
|
||||
} else {
|
||||
$("#select_company_role_userManager_tab").empty();
|
||||
$("#select_company_role_userManager_tab").append('<option value="0" disabled>請先新增角色</option>');
|
||||
|
||||
//#region user manager tab 人員基本資料新增/修改 modal
|
||||
$("#select_company_role_userManager_tab").val($("#select_company_role_userManager_tab option:first").val()).trigger('change');
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 帳號管理Tab - 人員基本資料新增/修改 modal
|
||||
if (rel.data.length > 0) {
|
||||
$('#user_role_modal').empty();
|
||||
|
||||
$.each(rel.data, function (index, val) {
|
||||
@ -258,11 +316,54 @@
|
||||
|
||||
//預設查詢第一個
|
||||
$("#user_role_modal").val($("#user_role_modal option:first").val()).trigger('change');
|
||||
} else {
|
||||
$("#user_role_modal").empty();
|
||||
$("#user_role_modal").append('<option value="0" disabled>請先新增角色</option>');
|
||||
|
||||
$("#user_role_modal").val($("#user_role_modal option:first").val()).trigger('change');
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 角色權限Tab - 角色下拉是選單(搜尋)
|
||||
if (rel.data.length > 0) {
|
||||
$("#select_roleId_roleAuth_tab").empty();
|
||||
|
||||
$.each(rel.data, function (index, val) {
|
||||
$("#select_roleId_roleAuth_tab").append($("<option />").val(val.value).text(val.text));
|
||||
});
|
||||
|
||||
//預設查詢第一個
|
||||
$("#select_roleId_roleAuth_tab").val($("#select_roleId_roleAuth_tab option:first").val()).trigger('change');
|
||||
} else {
|
||||
$("#select_roleId_roleAuth_tab").empty();
|
||||
$("#select_roleId_roleAuth_tab").append('<option value="0" disabled>請先新增角色</option>');
|
||||
|
||||
$("#select_roleId_roleAuth_tab").val($("#select_roleId_roleAuth_tab option:first").val()).trigger('change');
|
||||
}
|
||||
//#endregion
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 切換頁簽判斷被選中的tab
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
selected_tab = $(e.target).attr("href")
|
||||
|
||||
switch (selected_tab) {
|
||||
case "#tab-user-manager":
|
||||
userTable.ajax.reload();
|
||||
break;
|
||||
case "#tab-role-manager":
|
||||
roleTable.ajax.reload();
|
||||
break;
|
||||
case "#tab-role-auth":
|
||||
roleAuthTable.ajax.reload();
|
||||
break;
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 使用者列表 DataTable
|
||||
userTable = $("#user_table").DataTable({
|
||||
@ -273,6 +374,7 @@
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": false,
|
||||
"deferLoading": 0,
|
||||
"order": [[7, "desc"]],
|
||||
"columns": [{
|
||||
"data": "id"
|
||||
@ -318,15 +420,251 @@
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-guid', data.guid);
|
||||
$(row).attr('data-id', data.id);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/User/UserList",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.SelectedCompanyId = $('#select_user_company').val();
|
||||
d.SelectedCompanyId = $('#select_user_company_userManager_tab').val();
|
||||
d.Name = $('#user_name').val();
|
||||
d.SelectedRoleId = $('#select_user_role').val();
|
||||
d.SelectedRoleId = $('#select_company_role_userManager_tab').val();
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
data = rel.data.data;
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
this.data = [];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 角色管理列表 DataTable
|
||||
roleTable = $("#role_table").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": false,
|
||||
"deferLoading": 0,
|
||||
"order": [[4, "desc"]],
|
||||
"columns": [{
|
||||
"data": "id"
|
||||
}, {
|
||||
"data": "companyName"
|
||||
}, {
|
||||
"data": "name"
|
||||
}, {
|
||||
"data": "creatorName"
|
||||
}, {
|
||||
"data": "createdAt"
|
||||
}, {
|
||||
"data": null,
|
||||
"defaultContent": '<button class="btn btn-primary edit-btn">修改</button> <button class="btn btn-danger del-btn">刪除</button>'
|
||||
}
|
||||
],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
"zeroRecords": "沒有符合的結果",
|
||||
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
||||
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
||||
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
||||
"infoPostFix": "",
|
||||
"search": "搜尋:",
|
||||
"paginate": {
|
||||
"first": "第一頁",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁",
|
||||
"last": "最後一頁"
|
||||
},
|
||||
"aria": {
|
||||
"sortAscending": ": 升冪排列",
|
||||
"sortDescending": ": 降冪排列"
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-id', data.id);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/Role/RoleList",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.SelectedCompanyId = $('#select_company_role_roleManager_tab').val();
|
||||
d.Name = $('#role_name').val();
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
data = rel.data.data;
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
this.data = [];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 角色權限列表 DataTable
|
||||
roleAuthTable = $("#roleAuth_table").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": false,
|
||||
"deferLoading": 0,
|
||||
"order": [[5, "desc"]],
|
||||
"columns": [{
|
||||
"data": "id"
|
||||
}, {
|
||||
"data": "companyName"
|
||||
}, {
|
||||
"data": "roleName"
|
||||
}, {
|
||||
"data": "authPageSubName"
|
||||
}, {
|
||||
"data": "creatorName"
|
||||
}, {
|
||||
"data": "createdAt"
|
||||
}, {
|
||||
"data": null,
|
||||
"defaultContent": '<button class="btn btn-danger del-btn">刪除</button>'
|
||||
}
|
||||
],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
"zeroRecords": "沒有符合的結果",
|
||||
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
||||
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
||||
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
||||
"infoPostFix": "",
|
||||
"search": "搜尋:",
|
||||
"paginate": {
|
||||
"first": "第一頁",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁",
|
||||
"last": "最後一頁"
|
||||
},
|
||||
"aria": {
|
||||
"sortAscending": ": 升冪排列",
|
||||
"sortDescending": ": 降冪排列"
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-id-authCode', data.id + "_" + data.authCode);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/Role/RoleAuthList",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.SelectedCompanyId = $('#select_companyId_roleAuth_tab').val();
|
||||
d.SelectedRoleId = $('#select_roleId_roleAuth_tab').val();
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
data = rel.data.data;
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
this.data = [];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 角色未加入權限列表 DataTable
|
||||
roleAuthNotJoinTable = $("#roleAuth_NotJoin_table").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": false,
|
||||
"deferLoading": 0,
|
||||
"order": [[1, "desc"]],
|
||||
"columns": [{
|
||||
"data": "authCode"
|
||||
}, {
|
||||
"data": "mainName"
|
||||
}, {
|
||||
"data": "subName"
|
||||
}],
|
||||
"columnDefs": [{
|
||||
'targets': 0,
|
||||
'searchable': false,
|
||||
'orderable': false,
|
||||
'className': 'dt-body-center',
|
||||
'render': function (data, type, full, meta) {
|
||||
var check_html = "";
|
||||
check_html += '<div class="custom-control custom-checkbox">';
|
||||
check_html += '<input type="checkbox" class="custom-control-input" name="selectedAuthPage[]" id="auth-page-' + data + '" value="' + data + '" /> ';
|
||||
check_html += '<label class="custom-control-label" for="auth-page-' + data + '" />';
|
||||
check_html += '</div>';
|
||||
return check_html;
|
||||
}
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
"zeroRecords": "沒有符合的結果",
|
||||
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
||||
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
||||
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
||||
"infoPostFix": "",
|
||||
"search": "搜尋:",
|
||||
"paginate": {
|
||||
"first": "第一頁",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁",
|
||||
"last": "最後一頁"
|
||||
},
|
||||
"aria": {
|
||||
"sortAscending": ": 升冪排列",
|
||||
"sortDescending": ": 降冪排列"
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-id-authCode', data.id + "_" + data.authCode);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/Role/GetRoleNotAuthPageList",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.SelectedCompanyId = $('#select_companyId_roleAuth_tab').val();
|
||||
d.SelectedRoleId = $('#select_roleId_roleAuth_tab').val();
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
@ -347,28 +685,24 @@
|
||||
//#endregion
|
||||
});
|
||||
|
||||
//#region 帳號管理Tab
|
||||
|
||||
//#region 搜尋使用者列表
|
||||
function SearchUser() {
|
||||
userTable.ajax.reload();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 清除搜尋條件
|
||||
@*function ResetForm() {
|
||||
$("#system-admin-filter-form").trigger("reset");
|
||||
}*@
|
||||
//#endregion
|
||||
|
||||
//#region 新增系統管理員
|
||||
//#region 新增使用者
|
||||
function AddUser() {
|
||||
selected_id = 0;
|
||||
$("#user-modal .modal-title").html("人員基本資料 - 新增");
|
||||
$("#user-form").trigger("reset");
|
||||
$("#user_companyId_modal").val($("#select_user_company_userManager_tab").val());
|
||||
$("#user_account_modal").prop("disabled", false);
|
||||
$(".user_account_same_email_div").show();
|
||||
$("#user_account_same_email").prop("disabled", false);
|
||||
$(".user_password_form_row").show();
|
||||
$("#user-form").trigger("reset");
|
||||
|
||||
$("#user-modal").modal();
|
||||
}
|
||||
@ -419,6 +753,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
$("#user_companyId_modal").val(rel.data.companyId);
|
||||
$("#user_companyId_modal").prop("disabled", true);
|
||||
$("#user_name_modal").val(rel.data.name);
|
||||
$("#user_email_modal").val(rel.data.email);
|
||||
$("#user_account_modal").val(rel.data.account);
|
||||
@ -427,6 +763,7 @@
|
||||
$("#user_account_same_email").prop("disabled", true);
|
||||
$(".system_admin_password_form_row").hide();
|
||||
$("#user_phone_modal").val(rel.data.phone);
|
||||
$("#user_role_modal").val(rel.data.roleId);
|
||||
|
||||
$("#user-modal").modal();
|
||||
}, 'json');
|
||||
@ -437,9 +774,16 @@
|
||||
//#region 使用者表單驗證
|
||||
$("#user-form").validate({
|
||||
rules: {
|
||||
user_name_modal: {
|
||||
required: true,
|
||||
},
|
||||
user_email_modal: {
|
||||
required: true,
|
||||
email: true,
|
||||
},
|
||||
user_account_modal: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
//#endregion
|
||||
@ -452,7 +796,7 @@
|
||||
|
||||
var send_data = {
|
||||
Id: selected_id,
|
||||
CompanyId: $("#user_comapnyId_modal").val(),
|
||||
CompanyId: $("#user_companyId_modal").val(),
|
||||
Name: $("#user_name_modal").val(),
|
||||
Email: $("#user_email_modal").val(),
|
||||
Account: $("#user_account_modal").val(),
|
||||
@ -474,6 +818,9 @@
|
||||
toast_ok(rel.msg);
|
||||
$('#user-modal').modal('hide');
|
||||
|
||||
//更新當前剩餘可註冊使用者人數
|
||||
UpdateRegisterNumber($("#user_companyId_modal").val());
|
||||
|
||||
userTable.ajax.reload();
|
||||
}, 'json');
|
||||
}
|
||||
@ -492,6 +839,88 @@
|
||||
Id: selected_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
|
||||
//更新當前剩餘可註冊使用者人數
|
||||
UpdateRegisterNumber($("#select_user_company_userManager_tab").val());
|
||||
|
||||
userTable.ajax.reload();
|
||||
}, 'json');
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 更新公司當前剩餘註冊數量
|
||||
function UpdateRegisterNumber(companyId) {
|
||||
|
||||
var url = "/Company/GetRemainingRegisterNumber"
|
||||
|
||||
var send_data = {
|
||||
Id: companyId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
$("#remaining-number").html(rel.data);
|
||||
if (rel.data <= 0) {
|
||||
$("#addUser-btn").hide();
|
||||
} else {
|
||||
$("#addUser-btn").show();
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 角色管理Tab
|
||||
|
||||
//#region 搜尋角色列表
|
||||
function SearchRole() {
|
||||
roleTable.ajax.reload();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 新增公司角色
|
||||
function AddRole() {
|
||||
selected_role_id = 0;
|
||||
$("#role-modal .modal-title").html("人員基本資料 - 新增");
|
||||
$("#role-form").trigger("reset");
|
||||
$("#role_companyId_modal").val($("#select_company_role_roleManager_tab").val());
|
||||
$("#user_account_modal").prop("disabled", false);
|
||||
$(".user_account_same_email_div").show();
|
||||
$("#user_account_same_email").prop("disabled", false);
|
||||
$(".user_password_form_row").show();
|
||||
|
||||
|
||||
$("#user-modal").modal();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 編輯公司角色
|
||||
$('#role_table').on("click", "button.edit-btn", function () {
|
||||
|
||||
$("#role-modal .modal-title").html("角色資料 - 編輯");
|
||||
|
||||
selected_role_id = $(this).parents('tr').attr('data-id');
|
||||
|
||||
//取得單一公司角色資料
|
||||
var url = "/Role/GetOneRole/";
|
||||
|
||||
var send_data = {
|
||||
id: selected_role_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code == "9999") {
|
||||
toast_error(rel.msg);
|
||||
@ -502,10 +931,155 @@
|
||||
return;
|
||||
}
|
||||
|
||||
userTable.ajax.reload();
|
||||
$("#role_companyId_modal").val(rel.data.companyId);
|
||||
$("#role_companyId_modal").prop("disabled", true);
|
||||
$("#role_name_modal").val(rel.data.name);
|
||||
|
||||
$("#role-modal").modal();
|
||||
}, 'json');
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 公司角色表單驗證
|
||||
$("#role-form").validate({
|
||||
rules: {
|
||||
role_name_modal: {
|
||||
role_companyId_modal: true,
|
||||
},
|
||||
role_name_modal: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 儲存公司角色
|
||||
function SaveRole() {
|
||||
|
||||
if ($("#role-form").valid()) {
|
||||
var url = "/Role/SaveRole";
|
||||
|
||||
var send_data = {
|
||||
Id: selected_role_id,
|
||||
CompanyId: $("#role_companyId_modal").val(),
|
||||
Name: $("#role_name_modal").val(),
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
$('#role-modal').modal('hide');
|
||||
|
||||
roleTable.ajax.reload();
|
||||
}, 'json');
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 刪除公司角色
|
||||
$('#role_table').on("click", "button.del-btn", function () {
|
||||
|
||||
selected_role_id = $(this).parents('tr').attr('data-id');
|
||||
|
||||
//取得單一系統管理員
|
||||
var url = "/Role/DeleteOneRole/";
|
||||
|
||||
var send_data = {
|
||||
Id: selected_role_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
roleTable.ajax.reload();
|
||||
}, 'json');
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 角色權限Tab
|
||||
|
||||
//#region 搜尋角色權限列表
|
||||
function SearchRoleAuth() {
|
||||
roleAuthTable.ajax.reload();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 新增角色權限
|
||||
function AddRoleAuth() {
|
||||
roleAuthNotJoinTable.ajax.reload();
|
||||
|
||||
$("#role-auth-modal").modal();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 儲存角色權限
|
||||
function SaveRoleAuth() {
|
||||
|
||||
//取得被選擇的角色權限
|
||||
var checkAuths = $("input[name='selectedAuthPage[]']:checked").map(function () {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
|
||||
var url = "/Role/SaveRoleAuth";
|
||||
|
||||
var send_data = {
|
||||
SelectedRoleId: $("#select_roleId_roleAuth_tab").val(),
|
||||
CheckAuths: checkAuths
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
$("#role-auth-modal").modal('hide');
|
||||
|
||||
roleAuthTable.ajax.reload();
|
||||
}, 'json');
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 刪除公司角色權限
|
||||
$('#roleAuth_table').on("click", "button.del-btn", function () {
|
||||
|
||||
var row_id_authCode = $(this).parents('tr').attr('data-id-authCode');
|
||||
|
||||
var split_arr = row_id_authCode.split("_");
|
||||
|
||||
//取得單一系統管理員
|
||||
var url = "/Role/DeleteOneRoleAuth/";
|
||||
|
||||
var send_data = {
|
||||
RoleId: split_arr[0],
|
||||
AuthCode: split_arr[1]
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
roleAuthTable.ajax.reload();
|
||||
}, 'json');
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
</script>
|
||||
}
|
||||
|
||||
@ -2,12 +2,7 @@
|
||||
<div class="panel-toolbar ml-2">
|
||||
<div class="d-flex position-relative ml-auto" style="max-width: 8rem;">
|
||||
<div class="form-group">
|
||||
<select class="form-control" id="example-select">
|
||||
<option>客戶公司</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
<option>4</option>
|
||||
<option>5</option>
|
||||
<select class="form-control select_user_company" id="select_companyId_roleAuth_tab" data-tab="#tab-role-auth">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -15,62 +10,70 @@
|
||||
<div class="panel-toolbar ml-2">
|
||||
<div class="d-flex position-relative ml-auto" style="max-width: 8rem;">
|
||||
<div class="form-group">
|
||||
<select class="form-control" id="example-select">
|
||||
<option>角色名稱</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
<option>4</option>
|
||||
<option>5</option>
|
||||
<select class="form-control select_company_role" id="select_roleId_roleAuth_tab">
|
||||
<option value="0" disabled>請先選擇公司</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-sm waves-effect waves-themed ml-2">搜尋</button>
|
||||
<button type="button" class="btn btn-primary btn-sm waves-effect waves-themed ml-2" onclick="SearchRoleAuth()">搜尋</button>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3" data-toggle="modal" data-target="#companyrule"><span class="fal fa-plus mr-1"></span> 加入可用功能</a>
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3" onclick="AddRoleAuth()"><span class="fal fa-plus mr-1"></span> 加入可用功能</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<!-- datatable start -->
|
||||
<table class="table table-bordered table-hover m-0 text-center">
|
||||
<table id="roleAuth_table" class="table table-bordered table-hover m-0 text-center">
|
||||
<thead class="thead-themed">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>公司</th>
|
||||
<th>角色</th>
|
||||
<th>功能名稱</th>
|
||||
<th>建立人</th>
|
||||
<th>建立時間</th>
|
||||
<th>建立人/th>
|
||||
<th>功能</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">1</th>
|
||||
<td>華碩</td>
|
||||
<td>機房運維</td>
|
||||
<td>帳號管理</td>
|
||||
<td>2021-06-01 09:36</td>
|
||||
<td>王小明</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-danger btn-pills waves-effect waves-themed">刪除</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">2</th>
|
||||
<td>華碩</td>
|
||||
<td>機房運維</td>
|
||||
<td>報表查詢 - 逆變器歷史資料</td>
|
||||
<td>2021-06-01 09:36</td>
|
||||
<td>王小明</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-danger btn-pills waves-effect waves-themed">刪除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal 角色權限 -->
|
||||
<div class="modal fade" id="role-auth-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
角色權限 - 新增
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table id="roleAuth_NotJoin_table" class="table table-bordered table-hover m-0 text-center">
|
||||
<thead class="thead-themed">
|
||||
<tr>
|
||||
<th>選擇</th>
|
||||
<th>功能大項</th>
|
||||
<th>功能名稱</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="SaveRoleAuth()">確定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.角色權限 -->
|
||||
@ -2,27 +2,27 @@
|
||||
<div class="panel-toolbar ml-2">
|
||||
<div class="d-flex position-relative ml-auto" style="max-width: 8rem;">
|
||||
<div class="form-group">
|
||||
<select class="form-control select_user_company" id="select_user_company_rolemanager_tab" name="select_user_company_rolemanager_tab">
|
||||
<select class="form-control select_user_company" id="select_company_role_roleManager_tab" name="select_user_company_rolemanager_tab" data-tab="#tab-role-manager">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-toolbar ml-2">
|
||||
<div class="d-flex position-relative ml-auto" style="max-width: 8rem;">
|
||||
<input type="text" class="form-control form-control-sm" placeholder="角色名稱">
|
||||
<input type="text" class="form-control form-control-sm" id="role_name" name="role_name" placeholder="角色名稱">
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary btn-sm waves-effect waves-themed ml-2">搜尋</button>
|
||||
<button type="button" class="btn btn-primary btn-sm waves-effect waves-themed ml-2" onclick="SearchRole()">搜尋</button>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3" data-toggle="modal" data-target="#addpeople"><span class="fal fa-plus mr-1"></span> 新增</a>
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3" onclick="AddUser()"><span class="fal fa-plus mr-1"></span> 新增</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<!-- datatable start -->
|
||||
<table class="table table-bordered table-hover m-0 text-center">
|
||||
<table id="role_table" class="table table-bordered table-hover m-0 text-center">
|
||||
<thead class="thead-themed">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
@ -34,29 +34,42 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">1</th>
|
||||
<td><a href="javascript:;">FIC</a></td>
|
||||
<td>平台管理員</td>
|
||||
<td>王小明</td>
|
||||
<td>2021-06-01 09:36</td>
|
||||
<td>
|
||||
<a href="javascript:;" type="button" class="btn btn-primary btn-pills waves-effect waves-themed" data-toggle="modal" data-target="#addpeople">修改</a>
|
||||
<button type="button" class="btn btn-danger btn-pills waves-effect waves-themed">刪除</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">2</th>
|
||||
<td><a href="javascript:;">FIC</a></td>
|
||||
<td>平台運維</td>
|
||||
<td>王小明</td>
|
||||
<td>2021-06-01 09:36</td>
|
||||
<td>
|
||||
<a href="javascript:;" type="button" class="btn btn-primary btn-pills waves-effect waves-themed" data-toggle="modal" data-target="#addpeople">修改</a>
|
||||
<button type="button" class="btn btn-danger btn-pills waves-effect waves-themed">刪除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal 角色資料 -->
|
||||
<div class="modal fade" id="role-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
角色資料 - 新增
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="role-form" id="role-form">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="role_companyId_modal">公司</label>
|
||||
<input type="text" id="role_companyId_modal" name="role_companyId_modal" class="form-control" disabled>
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_name_modal"><span class="text-danger">*</span>名稱</label>
|
||||
<input type="text" id="role_name_modal" name="role_name_modal" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="SaveRole()">確定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.Modal 人員基本資料 -->
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div class="panel-toolbar ml-2">
|
||||
<div class="d-flex position-relative ml-auto" style="max-width: 8rem;">
|
||||
<div class="form-group">
|
||||
<select class="form-control select_user_company" id="select_user_company_userManager_tab" name="select_user_company_usermanager_tab">
|
||||
<select class="form-control select_user_company" id="select_user_company_userManager_tab" name="select_user_company_usermanager_tab" data-tab="#tab-user-manager">
|
||||
<option value="0" selected>請選擇公司</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -16,7 +16,7 @@
|
||||
<div class="panel-toolbar ml-2">
|
||||
<div class="d-flex position-relative ml-auto" style="max-width: 8rem;">
|
||||
<div class="form-group">
|
||||
<select class="form-control select_company_role" id="select_company_role_usermanager_tab">
|
||||
<select class="form-control select_company_role" id="select_company_role_userManager_tab">
|
||||
<option value="0" selected>請先選擇公司</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3" data-toggle="modal" data-target="#addpeople" onclick="AddUser()"><span class="fal fa-plus mr-1"></span>新增</a> 可再增加 7 個帳號
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3" id="addUser-btn" onclick="AddUser()"><span class="fal fa-plus mr-1"></span>新增</a> 可再增加 <span id="remaining-number"></span> 個帳號
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -53,7 +53,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Modal 人員基本資料 -->
|
||||
<div class="modal fade" id="user-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal fade" id="user-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -67,9 +67,9 @@
|
||||
<div class="modal-body">
|
||||
<form class="user-form" id="user-form">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-6" style="display:none">
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_companyId_modal">公司</label>
|
||||
<input type="text" id="user_companyId_modal" name="user_companyId_modal" class="form-control">
|
||||
<input type="text" id="user_companyId_modal" name="user_companyId_modal" class="form-control" disabled>
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_name_modal"><span class="text-danger">*</span>姓名</label>
|
||||
@ -94,7 +94,7 @@
|
||||
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="user_password_modal">密碼</label>
|
||||
<input type="password" id="user_password_modal" name="user_password_modal" class="form-control disabled" placeholder="由系統產生">
|
||||
<input type="password" id="user_password_modal" name="user_password_modal" class="form-control" placeholder="由系統產生" disabled>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-6">
|
||||
|
||||
BIN
SolarPower/wwwroot/upload/company_logo/20210611090212.png
Normal file
BIN
SolarPower/wwwroot/upload/company_logo/20210611090212.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 907 B |
Loading…
Reference in New Issue
Block a user