Merge branch 'master' into Willy
This commit is contained in:
commit
2b40a22615
@ -97,7 +97,53 @@ namespace SolarPower.Controllers
|
|||||||
|
|
||||||
|
|
||||||
//取得當前使用者可以查看的電站
|
//取得當前使用者可以查看的電站
|
||||||
ViewBag.myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
|
var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
|
||||||
|
ViewBag.myPowerStationSummaries = myPowerStationSummaries;
|
||||||
|
|
||||||
|
if (controllerName == "PowerStation" && actionName == "Edit")
|
||||||
|
{
|
||||||
|
//電站資訊的各電站
|
||||||
|
string stationId_param = filterContext.HttpContext.Request.Query["stationId"];
|
||||||
|
|
||||||
|
int stationId = stationId_param == "new" ? 0 : int.Parse(stationId_param);
|
||||||
|
|
||||||
|
|
||||||
|
if (stationId > 0)
|
||||||
|
{
|
||||||
|
var hasSubTagNum = false;
|
||||||
|
int i = 0;
|
||||||
|
foreach(var myPowerStationSummary in myPowerStationSummaries)
|
||||||
|
{
|
||||||
|
if (hasSubTagNum)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int j = 0;
|
||||||
|
foreach(var myPowerStation in myPowerStationSummary.MyPowerStations)
|
||||||
|
{
|
||||||
|
if(myPowerStation.PowerStationId == stationId)
|
||||||
|
{
|
||||||
|
ViewData["SubNum"] = i;
|
||||||
|
ViewData["TagNum"] = j;
|
||||||
|
hasSubTagNum = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//電站管理的新增電站
|
||||||
|
ViewData["SubNum"] = myPowerStationSummaries.Count();
|
||||||
|
ViewData["TagNum"] = 0;
|
||||||
|
}
|
||||||
|
}else if(controllerName == "PowerStation" && actionName == "Index")
|
||||||
|
{
|
||||||
|
ViewData["SubNum"] = myPowerStationSummaries.Count();
|
||||||
|
ViewData["TagNum"] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ViewBag.auths = auth_arr;
|
ViewBag.auths = auth_arr;
|
||||||
|
|
||||||
|
|||||||
@ -663,6 +663,37 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ApiResult<string>> DeleteOneOperationRecode(int id)
|
||||||
|
{
|
||||||
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationRecode = await operationRepository.GetOneOperationRecodeAsync(id);
|
||||||
|
|
||||||
|
if (operationRecode == null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9989";
|
||||||
|
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
await operationRepository.DeleteOneOperationRecodeAsync(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>
|
||||||
/// 儲存運維作業記錄檔案
|
/// 儲存運維作業記錄檔案
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -399,6 +399,34 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteOneOperationRecodeAsync(int id)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
using (var trans = conn.BeginTransaction())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = $"UPDATE operation_record SET deleted = 1 WHERE Id = @Id";
|
||||||
|
|
||||||
|
await conn.ExecuteAsync(sql, new { Id = id }, trans);
|
||||||
|
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新增運維作業記錄的檔案
|
/// 新增運維作業記錄的檔案
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -41,7 +41,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
else if (myUser.Role.Layer == 3)
|
else if (myUser.Role.Layer == 3)
|
||||||
{
|
{
|
||||||
sql += @" LEFT JOIN power_station_operation_personnel ps.Id = op.PowerStationId
|
sql += @" LEFT JOIN power_station_operation_personnel op ON ps.Id = op.PowerStationId
|
||||||
WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId ";
|
WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -54,6 +54,8 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> AddOperationRecodeFilesAsync(List<OperationRecodeFile> entity, List<string> properties);
|
Task<int> AddOperationRecodeFilesAsync(List<OperationRecodeFile> entity, List<string> properties);
|
||||||
|
|
||||||
|
Task DeleteOneOperationRecodeAsync(int id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過Id,取得單一運維作業記錄檔案
|
/// 透過Id,取得單一運維作業記錄檔案
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
ViewData["SubNum"] = "2";
|
ViewData["SubNum"] = "2";
|
||||||
ViewData["Title"] = "運維作業記錄";
|
ViewData["Title"] = "運維作業記錄";
|
||||||
}
|
}
|
||||||
|
@using SolarPower.Models.Role
|
||||||
|
@model RoleLayerEnum
|
||||||
|
|
||||||
<ol class="breadcrumb page-breadcrumb">
|
<ol class="breadcrumb page-breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="javascript:void(0);">運維管理</a></li>
|
<li class="breadcrumb-item"><a href="javascript:void(0);">運維管理</a></li>
|
||||||
@ -81,7 +83,10 @@
|
|||||||
<th>本次作業預計</th>
|
<th>本次作業預計</th>
|
||||||
<th>檔案</th>
|
<th>檔案</th>
|
||||||
<th>完成時間</th>
|
<th>完成時間</th>
|
||||||
@*<th>功能</th>*@
|
@if (ViewBag.myUser.Role.Layer != (int)RoleLayerEnum.CompanyUser)
|
||||||
|
{
|
||||||
|
<th>功能</th>
|
||||||
|
}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -384,6 +389,9 @@
|
|||||||
"data": "recodeFiles"
|
"data": "recodeFiles"
|
||||||
}, {
|
}, {
|
||||||
"data": "finishTime"
|
"data": "finishTime"
|
||||||
|
}, {
|
||||||
|
"data": null,
|
||||||
|
"defaultContent": '<button class="btn btn-danger del-btn">刪除</button>'
|
||||||
}],
|
}],
|
||||||
"columnDefs": [{
|
"columnDefs": [{
|
||||||
'targets': 7,
|
'targets': 7,
|
||||||
@ -400,6 +408,9 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
'targets': 9,
|
||||||
|
'visible': @(ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser ? "false" : "true")
|
||||||
}],
|
}],
|
||||||
"language": {
|
"language": {
|
||||||
"emptyTable": "無資料...",
|
"emptyTable": "無資料...",
|
||||||
@ -752,6 +763,44 @@
|
|||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region 刪除公司
|
||||||
|
$('#operation_recode_table').on("click", "button.del-btn", function () {
|
||||||
|
|
||||||
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
|
Swal.fire(
|
||||||
|
{
|
||||||
|
title: "刪除",
|
||||||
|
text: "你確定是否刪除此筆資料?",
|
||||||
|
type: "warning",
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: "是",
|
||||||
|
cancelButtonText: "否"
|
||||||
|
}).then(function (result) {
|
||||||
|
if (result.value) {
|
||||||
|
//刪除單一運維紀錄
|
||||||
|
var url = "/Operation/DeleteOneOperationRecode/";
|
||||||
|
var send_data = {
|
||||||
|
Id: selected_id
|
||||||
|
}
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code == "9999") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (rel.code == "9998") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toast_ok(rel.msg);
|
||||||
|
operationRecodeTable.ajax.reload();
|
||||||
|
}, 'json');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region 取得電站選單資料 (未使用)
|
//#region 取得電站選單資料 (未使用)
|
||||||
function GetPowerStation() {
|
function GetPowerStation() {
|
||||||
var url_power_station_select_option = "/Operation/GetPowerStationSelectOption";
|
var url_power_station_select_option = "/Operation/GetPowerStationSelectOption";
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["MainNum"] = "2";
|
ViewData["MainNum"] = "2";
|
||||||
ViewData["SubNum"] = "1";
|
|
||||||
ViewData["Title"] = "電站管理";
|
ViewData["Title"] = "電站管理";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["MainNum"] = "2";
|
ViewData["MainNum"] = "2";
|
||||||
ViewData["SubNum"] = "1";
|
|
||||||
ViewData["Title"] = "電站管理";
|
ViewData["Title"] = "電站管理";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -131,26 +131,31 @@
|
|||||||
<ul>
|
<ul>
|
||||||
@foreach (var myPowerStationSummary in ViewBag.myPowerStationSummaries)
|
@foreach (var myPowerStationSummary in ViewBag.myPowerStationSummaries)
|
||||||
{
|
{
|
||||||
<li>
|
<li class="@(ViewData["MainNum"].ToString() == "2" &&
|
||||||
|
ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.IndexOf(myPowerStationSummary).ToString() ? "active open" : "")">
|
||||||
<a href="javascript:void(0);" title="Category" data-filter-tags="utilities menu child sublevel item">
|
<a href="javascript:void(0);" title="Category" data-filter-tags="utilities menu child sublevel item">
|
||||||
<span class="nav-link-text" data-i18n="nav.category">@myPowerStationSummary.CityName</span>
|
<span class="nav-link-text" data-i18n="nav.category">@myPowerStationSummary.CityName</span>
|
||||||
<span class="dl-ref bg-primary-500 hidden-nav-function-minify hidden-nav-function-top">@myPowerStationSummary.Amount</span>
|
<span class="dl-ref bg-primary-500 hidden-nav-function-minify hidden-nav-function-top">@myPowerStationSummary.Amount</span>
|
||||||
</a>
|
</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
@foreach (var myPowerStation in myPowerStationSummary.MyPowerStations)
|
@foreach (var myPowerStation in myPowerStationSummary.MyPowerStations)
|
||||||
{
|
{
|
||||||
<li>
|
<li class="@(ViewData["MainNum"].ToString() == "2" &&
|
||||||
|
ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.IndexOf(myPowerStationSummary).ToString() &&
|
||||||
|
ViewData["TagNum"].ToString() == myPowerStationSummary.MyPowerStations.IndexOf(myPowerStation).ToString() ? "active" : "")">
|
||||||
<a asp-controller="PowerStation" asp-action="Edit" asp-route-stationId="@myPowerStation.PowerStationId" title="Sublevel Item" data-filter-tags="utilities menu child sublevel item">
|
<a asp-controller="PowerStation" asp-action="Edit" asp-route-stationId="@myPowerStation.PowerStationId" title="Sublevel Item" data-filter-tags="utilities menu child sublevel item">
|
||||||
<span class="nav-link-text" data-i18n="nav.utilities_menu_child_sublevel_item">@myPowerStation.PowerStationName</span>
|
<span class="nav-link-text" data-i18n="nav.utilities_menu_child_sublevel_item">@myPowerStation.PowerStationName</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
<li class="@(ViewData["MainNum"] == "2" && ViewData["SubNum"] == "1" ? "active" : "")">
|
<li class="@(ViewData["MainNum"] == "2" && ViewData["SubNum"].ToString() == ViewBag.myPowerStationSummaries.Count.ToString() ? "active" : "")">
|
||||||
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
|
<a asp-controller="PowerStation" asp-action="Index" title="電站管理" data-filter-tags="utilities disabled item">
|
||||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理</span>
|
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站管理 + @ViewData["SubNum"]</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["MainNum"] = "7";
|
ViewData["MainNum"] = "7";
|
||||||
ViewData["SubNum"] = "3";
|
ViewData["SubNum"] = "2";
|
||||||
ViewData["Title"] = "帳號管理";
|
ViewData["Title"] = "帳號管理";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user