1. 運維作業紀錄(未完成)
This commit is contained in:
parent
665078f6c6
commit
79853b804b
@ -13,20 +13,23 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
public class OperationController : MyBaseController<OperationController>
|
||||
{
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly IOperationRepository operationRepository;
|
||||
private readonly IRoleRepository roleRepository;
|
||||
public OperationController(
|
||||
IUserRepository userRepository,
|
||||
IOperationRepository operationRepository) : base()
|
||||
{
|
||||
this.userRepository = userRepository;
|
||||
this.operationRepository = operationRepository;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Record()
|
||||
{
|
||||
return View("~/Views/Operation/OperationRecord.cshtml");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得電站Option
|
||||
/// </summary>
|
||||
@ -57,6 +60,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 儲存計畫
|
||||
/// </summary>
|
||||
@ -112,6 +116,7 @@ namespace SolarPower.Controllers
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 定時計畫datatable
|
||||
/// </summary>
|
||||
@ -218,7 +223,7 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await operationRepository.DeleteOneOtherTable(Id, "operation_plan_create");
|
||||
await operationRepository.DeleteOneByIdWithCustomTable(Id, "operation_plan_create");
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
@ -233,5 +238,56 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 運維作業記錄列表
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> OperationRecodeListAsync(PostOperationRecodeFilter post)
|
||||
{
|
||||
ApiResult<List<OperationRecodeDataTable>> apiResult = new ApiResult<List<OperationRecodeDataTable>>();
|
||||
|
||||
int totalRecords = 0; //總資料筆數
|
||||
int recFilter = 0; //過濾後資料筆數
|
||||
|
||||
List<OperationRecodeDataTable> recodes = null;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
//if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
//{ //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料
|
||||
// post.SelectedCompanyId = myUser.CompanyId;
|
||||
//}
|
||||
|
||||
recodes = await operationRepository.GetAllRecodeByFilterAsync(post);
|
||||
|
||||
totalRecords = recodes.Count();
|
||||
recFilter = recodes.Count();
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = recodes;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace SolarPower.Helper
|
||||
var passwordStr = ed.AESDecrypt(dbConfig.Password);
|
||||
|
||||
//var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
||||
var connStr = @"server=127.0.0.1;port=3308;database=solar_power;user=root;password=00000000;charset=utf8;";
|
||||
var connStr = @"server=127.0.0.1;database=solar_power;user=root;password=000000;charset=utf8;";
|
||||
|
||||
this._connectionString = connStr;
|
||||
}
|
||||
|
||||
@ -56,4 +56,92 @@ namespace SolarPower.Models
|
||||
public string StartTimeString { get; set; }
|
||||
public string CreateTimeString { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 運維作業記錄的搜尋條件
|
||||
/// </summary>
|
||||
public class PostOperationRecodeFilter
|
||||
{
|
||||
public List<int> CityIds { get; set; } //縣市編號
|
||||
public List<int> PowerStationIds { get; set; } //電站編號
|
||||
public byte WorkType { get; set; } //工作項目
|
||||
public string Range { get; set; } //取得搜尋範圍
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 運維作業記錄的表單
|
||||
/// </summary>
|
||||
public class OperationRecodeDataTable
|
||||
{
|
||||
private string startTime, endTime, finishTime;
|
||||
public string PowerStationName { get; set; } //電站名稱
|
||||
public string FormId { get; set; } //表單號
|
||||
public byte WorkType { get; set; } //工作項目
|
||||
public string WorkTypeText {
|
||||
get
|
||||
{
|
||||
Dictionary<int, string> pairs = new Dictionary<int, string>()
|
||||
{
|
||||
{ 0, "清洗"},
|
||||
{ 1, "巡檢"},
|
||||
{ 2, "維修"},
|
||||
};
|
||||
|
||||
return pairs[WorkType];
|
||||
}
|
||||
} //工作項目名稱
|
||||
public string FixDo { get; set; } //維修項目
|
||||
public byte Status { get; set; } //狀態
|
||||
public string StatusText {
|
||||
get
|
||||
{
|
||||
Dictionary<int, string> pairs = new Dictionary<int, string>()
|
||||
{
|
||||
{ 0, "未完成"},
|
||||
{ 1, "完成"},
|
||||
{ 2, "未完成-過期"},
|
||||
{ 3, "完成-過期"},
|
||||
};
|
||||
|
||||
return pairs[Status];
|
||||
}
|
||||
} //狀態名稱
|
||||
public string WorkPersonName { get; set; } //處理人員
|
||||
public string StartTime {
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(startTime))
|
||||
{
|
||||
return Convert.ToDateTime(startTime).ToString("yyyy-MM-dd");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set { startTime = value; }
|
||||
} //開始時間
|
||||
public string EndTime {
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrEmpty(endTime))
|
||||
{
|
||||
return Convert.ToDateTime(endTime).ToString("yyyy-MM-dd");
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set { endTime = value; }
|
||||
} // 結束時間
|
||||
public string OperationPredict {
|
||||
get
|
||||
{
|
||||
return StartTime + " ~ " + EndTime;
|
||||
}
|
||||
} //本次作業預計
|
||||
public string FileList { get; set; } //本次作業預計
|
||||
public string FinishTime { get; set; } //本次作業預計
|
||||
}
|
||||
}
|
||||
|
||||
@ -578,19 +578,6 @@ namespace SolarPower.Repository.Implement
|
||||
KEY `IDX_01` (`Deleted`,`IsMainDisplay`,`PowerStationId`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站資料';
|
||||
|
||||
-- 傾印 資料表 power_station_operation_personnel 結構
|
||||
CREATE TABLE IF NOT EXISTS `power_station_operation_personnel` (
|
||||
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Deleted` tinyint(4) NOT NULL DEFAULT 0,
|
||||
`PowerStationId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '電站編號',
|
||||
`UserId` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '人員編號',
|
||||
`CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者',
|
||||
`CreatedAt` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '建立時間',
|
||||
PRIMARY KEY (`Id`),
|
||||
KEY `IDX_01` (`Deleted`),
|
||||
KEY `IDX_02` (`PowerStationId`,`UserId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='電站運維人員';
|
||||
|
||||
-- 傾印 資料表 power_station_single_line_diagram 結構
|
||||
CREATE TABLE IF NOT EXISTS `power_station_single_line_diagram` (
|
||||
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
|
||||
@ -116,5 +116,76 @@ namespace SolarPower.Repository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過搜尋條件,查詢過濾後的運維作業記錄
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<OperationRecodeDataTable>> GetAllRecodeByFilterAsync(PostOperationRecodeFilter filter)
|
||||
{
|
||||
List<OperationRecodeDataTable> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT
|
||||
ps.Name AS PowerStationName,
|
||||
opr.FormId,
|
||||
opr.WorkType,
|
||||
opr.FixDO,
|
||||
opr.Status,
|
||||
u.Name AS WorkPersonName,
|
||||
opr.StartTime,
|
||||
opr.EndTime,
|
||||
opr.FinishTime
|
||||
FROM operation_record opr
|
||||
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
||||
LEFT JOIN user u ON opr.WorkPersonId = u.ID
|
||||
WHERE opr.Deleted = 0
|
||||
AND ps.CityId IN @CityIds
|
||||
AND ps.Id IN @PowerStationIds";
|
||||
|
||||
if (filter.WorkType > 0)
|
||||
{
|
||||
sql += @" AND opr.WorkType = @WorkType";
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Range))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sql += @" AND opr.WorkType IN (0, 1)";
|
||||
sql += @" UNION";
|
||||
sql += @" SELECT
|
||||
ps.Name AS PowerStationName,
|
||||
opr.FormId,
|
||||
opr.WorkType,
|
||||
opr.FixDO,
|
||||
opr.Status,
|
||||
u.Name AS WorkPersonName,
|
||||
opr.StartTime,
|
||||
opr.EndTime,
|
||||
opr.FinishTime
|
||||
FROM operation_record opr
|
||||
LEFT JOIN power_station ps ON opr.PowerStationId = ps.Id
|
||||
LEFT JOIN user u ON opr.WorkPersonId = u.ID
|
||||
WHERE opr.Deleted = 0
|
||||
AND ps.CityId IN @CityIds
|
||||
AND ps.Id IN @PowerStationIds
|
||||
AND opr.WorkType = 2";
|
||||
}
|
||||
|
||||
result = (await conn.QueryAsync<OperationRecodeDataTable>(sql, filter)).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,6 +135,42 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過table_name、Id,軟刪除指定資料表的單一筆資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="table_name"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task DeleteOneByIdWithCustomTable(int id, string table_name)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE {table_name} 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>
|
||||
/// 透過Id、db_name、table_name,刪除指定的資料庫之資料表的一筆資料
|
||||
/// </summary>
|
||||
|
||||
@ -12,6 +12,13 @@ namespace SolarPower.Repository.Interface
|
||||
Task AddOperationPlan(OperationCreatePlan OperationPlan, List<string> properties);
|
||||
Task<List<OperationPlanTable>> OperationPlanTable(List<int> id);
|
||||
Task<OperationCreatePlan> GetOneOperation(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過搜尋條件,查詢過濾後的運維作業記錄
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<OperationRecodeDataTable>> GetAllRecodeByFilterAsync(PostOperationRecodeFilter filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -58,6 +58,14 @@ namespace SolarPower.Repository.Interface
|
||||
/// <returns></returns>
|
||||
Task PurgeOneAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 透過table_name、Id,軟刪除指定資料表的單一筆資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="table_name"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOneByIdWithCustomTable(int id, string table_name);
|
||||
|
||||
/// <summary>
|
||||
/// 透過Id、db_name、table_name,刪除指定的資料庫之資料表的一筆資料
|
||||
/// </summary>
|
||||
|
||||
515
SolarPower/Views/Operation/OperationRecord.cshtml
Normal file
515
SolarPower/Views/Operation/OperationRecord.cshtml
Normal file
@ -0,0 +1,515 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "6";
|
||||
ViewData["SubNum"] = "2";
|
||||
ViewData["Title"] = "運維作業記錄";
|
||||
}
|
||||
|
||||
<ol class="breadcrumb page-breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">運維管理</a></li>
|
||||
<li class="breadcrumb-item active">運維作業記錄</li>
|
||||
<li class="position-absolute pos-top pos-right d-none d-sm-block"><span class="js-get-date"></span></li>
|
||||
</ol>
|
||||
<div class="subheader">
|
||||
<h1 class="subheader-title">
|
||||
<i class="subheader-icon fal fa-globe"></i> 運維作業記錄
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<!-- Your main content goes below here: -->
|
||||
<div id="panel-5" class="panel">
|
||||
<div class="panel-container show">
|
||||
<div class="panel-content">
|
||||
<div class="row mb-5 d-flex justify-content-start">
|
||||
<div class="pr-3">
|
||||
<div class="btn-group btn-group-md">
|
||||
<button type="button" class="btn btn-success waves-effect waves-themed">全部</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">維修</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">巡檢</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">清洗</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pr-3">
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed">近30天</button>
|
||||
</div>
|
||||
<div class="pr-3">
|
||||
<div class="form-group">
|
||||
<input class="form-control" id="example-date" type="date" name="date" value="2023-07-23">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row d-flex justify-content-end px-3">
|
||||
<button type="button" class="btn btn-info waves-effect waves-themed mb-3 mr-2">
|
||||
<span class="fal fa-file-excel mr-1"></span>
|
||||
匯出
|
||||
</button>
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" data-toggle="modal" data-target="#companyrule">
|
||||
<span class="fal fa-plus mr-1"></span>
|
||||
維修單
|
||||
</a>
|
||||
</div>
|
||||
<div class="frame-wrap">
|
||||
<table id="operation_recode_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>
|
||||
<th>完成時間</th>
|
||||
@*<th>功能</th>*@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@*<tr>
|
||||
<th scope="row">新竹巨城站</th>
|
||||
<td>op20210630001</td>
|
||||
<td>維修</td>
|
||||
<td>逆變器異常</td>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="defaultChecked" checked="">
|
||||
<label class="custom-control-label" for="defaultChecked">完成</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>王小明</td>
|
||||
<td></td>
|
||||
<td><img src="img/thumbs/pic-3.png" class="pr-2"><img src="img/thumbs/pic-3.png" class="pr-2"></td>
|
||||
<td>2021-03-5</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">新竹巨城站</th>
|
||||
<td>
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" data-toggle="modal" data-target="#companyrule">
|
||||
填寫表單
|
||||
</a>
|
||||
</td>
|
||||
<td>維修</td>
|
||||
<td>逆變器異常</td>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="defaultChecked" checked="">
|
||||
<label class="custom-control-label" for="defaultChecked">完成</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>王小明</td>
|
||||
<td></td>
|
||||
<td><img src="img/thumbs/pic-3.png" class="pr-2"><img src="img/thumbs/pic-3.png" class="pr-2"></td>
|
||||
<td>2021-03-5</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">新竹巨城站</th>
|
||||
<td>
|
||||
<a href="javascript:;" class="btn btn-success waves-effect waves-themed mb-3 mr-2" data-toggle="modal" data-target="#companyrule">
|
||||
填寫表單
|
||||
</a>
|
||||
</td>
|
||||
<td>維修</td>
|
||||
<td>逆變器異常</td>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="defaultChecked" checked="">
|
||||
<label class="custom-control-label" for="defaultChecked">完成</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>王小明</td>
|
||||
<td></td>
|
||||
<td><img src="img/thumbs/pic-3.png" class="pr-2"><img src="img/thumbs/pic-3.png" class="pr-2"></td>
|
||||
<td>2021-03-5</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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts{
|
||||
<script>
|
||||
var operationRecodeTable;
|
||||
var selected_id = 0;
|
||||
|
||||
$(function () {
|
||||
//#region 運維作業記錄 DataTable
|
||||
operationRecodeTable = $("#operation_recode_table").DataTable({
|
||||
"pageLength": 20,
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": false,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
@*"order": [[5, "desc"]],*@
|
||||
"columns": [{
|
||||
"data": "powerStationName"
|
||||
}, {
|
||||
"data": "formId"
|
||||
}, {
|
||||
"data": "WorkTypeText"
|
||||
}, {
|
||||
"data": "fixDo"
|
||||
}, {
|
||||
"data": "workPersonName"
|
||||
}, {
|
||||
"data": "operationPredict"
|
||||
}, {
|
||||
"data": "fileList"
|
||||
}, {
|
||||
"data": "finishTime"
|
||||
}],
|
||||
"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": "/Operation/OperationRecodeList",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.CityIds = [1];
|
||||
d.PowerStationIds = [15, 16];
|
||||
d.WorkType = $('#company_phone').val();
|
||||
d.Range = $('#company_taxIDNumber').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
|
||||
companyAuthTable = $("#company_auth_table").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": 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 公司權限池全選
|
||||
$("#select-all-company-auth").change(function () {
|
||||
|
||||
var rows = companyAuthTable.rows({ 'search': 'applied' }).nodes();
|
||||
|
||||
if (this.checked) {
|
||||
$('input[type="checkbox"]', rows).prop('checked', this.checked);
|
||||
} else {
|
||||
$('input[type="checkbox"]', rows).prop('checked', this.checked);
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
});
|
||||
|
||||
//#region 搜尋公司列表
|
||||
function SearchCompany() {
|
||||
companyTable.ajax.reload();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 新增公司基本資料
|
||||
function AddCompany() {
|
||||
|
||||
selected_id = 0;
|
||||
$("#company-modal .modal-title").html("公司基本資料 - 新增");
|
||||
$("#company-form").trigger("reset");
|
||||
|
||||
$("#company-modal").modal();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 編輯公司資料
|
||||
$('#company_table').on("click", "button.edit-btn", function () {
|
||||
|
||||
$("#company-modal .modal-title").html("公司基本資料 - 編輯");
|
||||
|
||||
selected_id = $(this).parents('tr').attr('data-id');
|
||||
|
||||
//取得單一公司基本資料
|
||||
var url = "/Company/GetOneCompany/";
|
||||
|
||||
var send_data = {
|
||||
id: selected_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
$("#company_name_modal").val(rel.data.name);
|
||||
$("#company_taxIDNumber_modal").val(rel.data.taxIDNumber);
|
||||
$("#company_phone_modal").val(rel.data.phone);
|
||||
$("#company_address_modal").val(rel.data.address);
|
||||
$("#company_registerUpperLimit_modal").val(rel.data.registerUpperLimit);
|
||||
|
||||
$("#company-modal").modal();
|
||||
}, 'json');
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 公司資料表單驗證
|
||||
$("#company-form").validate({
|
||||
rules: {
|
||||
company_name_modal: {
|
||||
required: true,
|
||||
},
|
||||
company_taxIDNumber_modal: {
|
||||
required: true,
|
||||
maxlength: 8,
|
||||
},
|
||||
},
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 儲存公司資料
|
||||
function SaveComapny() {
|
||||
|
||||
if ($("#company-form").valid()) {
|
||||
var url = "/Company/SaveCompany";
|
||||
|
||||
var formData = new FormData();
|
||||
var logos = $('#company_logo_modal')[0].files;
|
||||
|
||||
formData.append("Id", selected_id);
|
||||
formData.append("Name", $("#company_name_modal").val());
|
||||
formData.append("TaxIDNumber", $("#company_taxIDNumber_modal").val());
|
||||
formData.append("Phone", $("#company_phone_modal").val());
|
||||
formData.append("Address", $("#company_address_modal").val());
|
||||
formData.append("RegisterUpperLimit", $("#company_registerUpperLimit_modal").val());
|
||||
if (logos.length > 0) {
|
||||
formData.append("LogoFile", logos[0])
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
$('#company-modal').modal('hide');
|
||||
|
||||
companyTable.ajax.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 刪除公司
|
||||
$('#company_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 = "/Company/DeleteOneCompany/";
|
||||
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);
|
||||
companyTable.ajax.reload();
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 編輯公司權限池
|
||||
$('#company_table').on("click", "button.company-auth-btn", function () {
|
||||
|
||||
selected_id = $(this).parents('tr').attr('data-id');
|
||||
|
||||
$("#select-all-company-auth").prop("checked", false);
|
||||
|
||||
companyAuthTable.ajax.reload();
|
||||
|
||||
$("#company-auth-modal").modal();
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 儲存公司權限池
|
||||
function SaveComapnyAuth() {
|
||||
|
||||
var rows = companyAuthTable.rows({ 'search': 'applied' }).nodes();
|
||||
//取得被選擇的權限
|
||||
var checkAuths = $("input[name='selectedAuthPage[]']:checked", rows).map(function () {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
|
||||
var url = "/Company/SaveCompanyAuth";
|
||||
|
||||
var send_data = {
|
||||
SelectedCompanyId: selected_id,
|
||||
CheckAuths: checkAuths
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
$("#company-auth-modal").modal('hide');
|
||||
|
||||
companyAuthTable.ajax.reload();
|
||||
}, 'json');
|
||||
}
|
||||
//#endregion
|
||||
</script>
|
||||
}
|
||||
@ -191,7 +191,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="javascript:void(0);" title="運維作業記錄" data-filter-tags="utilities disabled item">
|
||||
<a asp-controller="Operation" asp-action="Record" title="運維作業記錄" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">運維作業記錄</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user