1公司使用者 角色 bug fix
2. 運維作業記錄 加入 刪除功能
This commit is contained in:
parent
f5d99f5fe5
commit
73b3802123
@ -663,6 +663,37 @@ namespace SolarPower.Controllers
|
||||
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>
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -41,7 +41,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
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 ";
|
||||
}
|
||||
else
|
||||
|
||||
@ -54,6 +54,8 @@ namespace SolarPower.Repository.Interface
|
||||
/// <returns></returns>
|
||||
Task<int> AddOperationRecodeFilesAsync(List<OperationRecodeFile> entity, List<string> properties);
|
||||
|
||||
Task DeleteOneOperationRecodeAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過Id,取得單一運維作業記錄檔案
|
||||
/// </summary>
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
ViewData["SubNum"] = "2";
|
||||
ViewData["Title"] = "運維作業記錄";
|
||||
}
|
||||
@using SolarPower.Models.Role
|
||||
@model RoleLayerEnum
|
||||
|
||||
<ol class="breadcrumb page-breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">運維管理</a></li>
|
||||
@ -81,7 +83,10 @@
|
||||
<th>本次作業預計</th>
|
||||
<th>檔案</th>
|
||||
<th>完成時間</th>
|
||||
@*<th>功能</th>*@
|
||||
@if (ViewBag.myUser.Role.Layer != (int)RoleLayerEnum.CompanyUser)
|
||||
{
|
||||
<th>功能</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -384,6 +389,9 @@
|
||||
"data": "recodeFiles"
|
||||
}, {
|
||||
"data": "finishTime"
|
||||
}, {
|
||||
"data": null,
|
||||
"defaultContent": '<button class="btn btn-danger del-btn">刪除</button>'
|
||||
}],
|
||||
"columnDefs": [{
|
||||
'targets': 7,
|
||||
@ -400,6 +408,9 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
'targets': 9,
|
||||
'visible': @(ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser ? "false" : "true")
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "無資料...",
|
||||
@ -752,6 +763,44 @@
|
||||
}
|
||||
//#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 取得電站選單資料 (未使用)
|
||||
function GetPowerStation() {
|
||||
var url_power_station_select_option = "/Operation/GetPowerStationSelectOption";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user